mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-19 02:12:58 +01:00
Compare commits
358 Commits
dev-charge
...
2.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24e4c28355 | ||
|
|
6ec61ecb76 | ||
|
|
55a69006bf | ||
|
|
8a02230fd2 | ||
|
|
2a26b016d9 | ||
|
|
7be5b4ecbd | ||
|
|
565fb35217 | ||
|
|
d2b8c527ad | ||
|
|
2cdb17d64f | ||
|
|
96f06ca812 | ||
|
|
685f6d76a8 | ||
|
|
840cfbe94d | ||
|
|
605535ed60 | ||
|
|
71c72045b9 | ||
|
|
eb930883fa | ||
|
|
30ed18eb95 | ||
|
|
8508f5b8b8 | ||
|
|
dfab223eb2 | ||
|
|
dd82fa0791 | ||
|
|
af8d2dc2c7 | ||
|
|
9f9529debf | ||
|
|
495c4a33e5 | ||
|
|
203d3749ee | ||
|
|
1fcecbd3e7 | ||
|
|
d778616b2c | ||
|
|
4bdd97a302 | ||
|
|
ab2a031ee0 | ||
|
|
5663b71387 | ||
|
|
2a43bce849 | ||
|
|
592c3a2142 | ||
|
|
e9ca341476 | ||
|
|
76617c8a61 | ||
|
|
10ff097232 | ||
|
|
1e043d481a | ||
|
|
7f8c670dc1 | ||
|
|
0e536a2cb3 | ||
|
|
090cf82a39 | ||
|
|
6e60f39f82 | ||
|
|
b8078e4730 | ||
|
|
e08fe64db2 | ||
|
|
2b576568a7 | ||
|
|
e2edbaad34 | ||
|
|
184b98bbdc | ||
|
|
7cc604dbdb | ||
|
|
44ed35825f | ||
|
|
22833eea6c | ||
|
|
64dfc1e3d3 | ||
|
|
6619ca1d22 | ||
|
|
2f2a80e1ce | ||
|
|
fa1bbd2031 | ||
|
|
a39a77f89e | ||
|
|
7800e48f61 | ||
|
|
63378ae4c1 | ||
|
|
fecf83c79c | ||
|
|
f287b6d8a7 | ||
|
|
9082658357 | ||
|
|
4bda175328 | ||
|
|
ee324c77a9 | ||
|
|
210b418e44 | ||
|
|
b73eced36f | ||
|
|
6296a6adde | ||
|
|
99f6192965 | ||
|
|
bff454f397 | ||
|
|
8216dbe355 | ||
|
|
fbe26af2d7 | ||
|
|
0a1559511a | ||
|
|
aee60f2c09 | ||
|
|
9ce850f84f | ||
|
|
cbff8482ce | ||
|
|
0035762a71 | ||
|
|
3d515aab23 | ||
|
|
e77801f3c1 | ||
|
|
c83d011faa | ||
|
|
5aa4949baa | ||
|
|
906ead53dd | ||
|
|
cbcdedc67a | ||
|
|
c87b410823 | ||
|
|
0a447f68c6 | ||
|
|
e98d241452 | ||
|
|
421455224f | ||
|
|
29c55312a5 | ||
|
|
6c474c8838 | ||
|
|
03182ea24c | ||
|
|
2c6543da9e | ||
|
|
20bbdfc4ab | ||
|
|
5b2ebf4aa8 | ||
|
|
2b159adefd | ||
|
|
be2de1d487 | ||
|
|
6876f192de | ||
|
|
875db44afd | ||
|
|
2e120abe3a | ||
|
|
feeb17d6f0 | ||
|
|
6d2003d577 | ||
|
|
40b609ccd8 | ||
|
|
d64399df49 | ||
|
|
d4f2f0e11b | ||
|
|
916d9a7c8a | ||
|
|
6d5ab0edda | ||
|
|
307d483323 | ||
|
|
eb4960f307 | ||
|
|
9df72e61a2 | ||
|
|
fcb6391ba3 | ||
|
|
16a77f281e | ||
|
|
87ebf7023f | ||
|
|
028f87653a | ||
|
|
0e51983819 | ||
|
|
c174f2b829 | ||
|
|
8e9d393eb2 | ||
|
|
f1f02fd005 | ||
|
|
f279a979e3 | ||
|
|
e0bbe9cea4 | ||
|
|
d3cc23f6a0 | ||
|
|
4c3f3ee4e2 | ||
|
|
2d7c5d7fd6 | ||
|
|
8be68aa6df | ||
|
|
a731ad14ec | ||
|
|
05ca96aa7f | ||
|
|
60aa32d003 | ||
|
|
0e7ee41444 | ||
|
|
b5f6b1d97f | ||
|
|
f1ac5739e4 | ||
|
|
8cbb57df97 | ||
|
|
2c8d2998bb | ||
|
|
44684fcfd0 | ||
|
|
7081e03c23 | ||
|
|
246db98519 | ||
|
|
ee245d348f | ||
|
|
f718741044 | ||
|
|
c054ff851a | ||
|
|
755787f9ee | ||
|
|
24f8b2fbd5 | ||
|
|
ee02a19e9a | ||
|
|
cb5d38c11f | ||
|
|
15436b44da | ||
|
|
5c267663a2 | ||
|
|
fda625b235 | ||
|
|
2cbd8789d8 | ||
|
|
95167f44f1 | ||
|
|
789b51fd05 | ||
|
|
0911c86422 | ||
|
|
7d05c9d8e6 | ||
|
|
a43ae4178a | ||
|
|
c9c2c483fa | ||
|
|
133281faaa | ||
|
|
ef8987917d | ||
|
|
d6a00eaf00 | ||
|
|
69151f0855 | ||
|
|
bb27d753b1 | ||
|
|
37ce29a5e8 | ||
|
|
6297e1c79b | ||
|
|
4e2903e65c | ||
|
|
2e7f56eeb5 | ||
|
|
7e46d5ca08 | ||
|
|
a2bcce9ab1 | ||
|
|
2f7b1c38e1 | ||
|
|
789aaec186 | ||
|
|
f3d6c1727b | ||
|
|
c029b51c97 | ||
|
|
6c5fb5f398 | ||
|
|
4b20db47b2 | ||
|
|
e238ec8fc6 | ||
|
|
9689f55e5c | ||
|
|
ec0c7da494 | ||
|
|
5f9f3e8167 | ||
|
|
6388246418 | ||
|
|
86432eb426 | ||
|
|
a51585f5d0 | ||
|
|
9ec75fb470 | ||
|
|
c8a7f6d76f | ||
|
|
01a8a199d2 | ||
|
|
f85c54596a | ||
|
|
b3e1acc563 | ||
|
|
745ff21551 | ||
|
|
31c8cf9766 | ||
|
|
8901db4e18 | ||
|
|
b1b8c4d713 | ||
|
|
b14b37c22d | ||
|
|
e73e628051 | ||
|
|
3bb920f22c | ||
|
|
2bed26f18a | ||
|
|
fb3363661b | ||
|
|
315b713005 | ||
|
|
70de0ba00b | ||
|
|
25cad3afc6 | ||
|
|
11aa126b80 | ||
|
|
d0e8bb3174 | ||
|
|
6b03108052 | ||
|
|
34447ef874 | ||
|
|
dcd79e87e1 | ||
|
|
8822b4edae | ||
|
|
a24d6ff018 | ||
|
|
707195f237 | ||
|
|
321fcd7b84 | ||
|
|
c5970e9246 | ||
|
|
538a0c5d6c | ||
|
|
4c4df60b81 | ||
|
|
d1cf08c6ba | ||
|
|
e091a8eb55 | ||
|
|
d579c9a2af | ||
|
|
a711d3a3e3 | ||
|
|
2c197af9fd | ||
|
|
d58d621f96 | ||
|
|
0203252b63 | ||
|
|
22edd121d3 | ||
|
|
31b83becad | ||
|
|
6cce3098db | ||
|
|
fd3d60d112 | ||
|
|
9094e5feb8 | ||
|
|
60bfabb097 | ||
|
|
2d4cf76825 | ||
|
|
6a7279ea05 | ||
|
|
4cb4a6224b | ||
|
|
a6e445b7ef | ||
|
|
123a139e43 | ||
|
|
4054315c19 | ||
|
|
d942cedb8e | ||
|
|
ec774b590b | ||
|
|
988a11a5da | ||
|
|
1488946fc5 | ||
|
|
1f05967b0b | ||
|
|
4924391ae8 | ||
|
|
f2668d7dbb | ||
|
|
d26779bee9 | ||
|
|
c75715b186 | ||
|
|
a238b7029d | ||
|
|
98511136ee | ||
|
|
6723b3a4c6 | ||
|
|
40c61149cf | ||
|
|
4f9a463b9d | ||
|
|
f3a8208425 | ||
|
|
cbf2f34f93 | ||
|
|
898fad6be4 | ||
|
|
eaa1a8edca | ||
|
|
08db154791 | ||
|
|
e1cf4c0c67 | ||
|
|
529c43b0e6 | ||
|
|
376abdf49e | ||
|
|
11a744a772 | ||
|
|
47f73ba455 | ||
|
|
001b11efc6 | ||
|
|
089f3a0e71 | ||
|
|
af9a3c85c6 | ||
|
|
a534f9aac1 | ||
|
|
a08016647a | ||
|
|
a557fc7d3c | ||
|
|
2d3d11ec2d | ||
|
|
9bc97c6dd3 | ||
|
|
52f1e33052 | ||
|
|
272e99d41f | ||
|
|
77b67d5a79 | ||
|
|
8e1f464209 | ||
|
|
5f960fd80a | ||
|
|
bddca30668 | ||
|
|
28a2b9668d | ||
|
|
f52d9feef8 | ||
|
|
f77ae6ee15 | ||
|
|
88b99a3835 | ||
|
|
8d16af8770 | ||
|
|
fde9ba86a2 | ||
|
|
c9356f9ef5 | ||
|
|
6a0529f02d | ||
|
|
760178c061 | ||
|
|
0bb2642d24 | ||
|
|
635a4f7265 | ||
|
|
0e34202d4d | ||
|
|
3a9c55a9ea | ||
|
|
2dd1775d9a | ||
|
|
a0635eeb08 | ||
|
|
9677653c54 | ||
|
|
6cf7167c09 | ||
|
|
9718123292 | ||
|
|
420559efec | ||
|
|
f4b6d7845e | ||
|
|
b966529487 | ||
|
|
9c7b83a52e | ||
|
|
ac9447d439 | ||
|
|
a5bcc3ce58 | ||
|
|
a020890244 | ||
|
|
616200f20f | ||
|
|
1f9c3759e7 | ||
|
|
9fb72cfea8 | ||
|
|
dd84abe927 | ||
|
|
aaa69adb0c | ||
|
|
982ee13631 | ||
|
|
8927e16b1f | ||
|
|
dd01504111 | ||
|
|
50e727d591 | ||
|
|
f84e98d836 | ||
|
|
7e92905618 | ||
|
|
9b24dd306c | ||
|
|
aa796266a7 | ||
|
|
a783d0dfc8 | ||
|
|
f9879be439 | ||
|
|
5f21efb1cd | ||
|
|
8e2b8f111f | ||
|
|
08766a0ff7 | ||
|
|
5b19e2e9d2 | ||
|
|
bef28583f3 | ||
|
|
eff53d90ab | ||
|
|
2aade8b7ff | ||
|
|
de0ac51b3d | ||
|
|
b161a907a7 | ||
|
|
397ec929aa | ||
|
|
f108de9ba2 | ||
|
|
e3a139f7bd | ||
|
|
90f8132030 | ||
|
|
60d89c15e6 | ||
|
|
58a0287be7 | ||
|
|
ac3b28da8b | ||
|
|
12cb1e4161 | ||
|
|
4e013b44d8 | ||
|
|
9934ab972e | ||
|
|
30adac5e63 | ||
|
|
d3d7c254f4 | ||
|
|
93ad040936 | ||
|
|
bfeac43f12 | ||
|
|
4388430491 | ||
|
|
b4e21a7817 | ||
|
|
4fe41fe416 | ||
|
|
d8184fb298 | ||
|
|
78dec51ad4 | ||
|
|
de38826897 | ||
|
|
f63e793006 | ||
|
|
ecfdd75e36 | ||
|
|
90b31a29f5 | ||
|
|
cfa0daefc5 | ||
|
|
4aeda6e9e8 | ||
|
|
4f1f10333f | ||
|
|
342c37a02c | ||
|
|
e347bc1c9e | ||
|
|
42116f4467 | ||
|
|
7ce72bafb0 | ||
|
|
f76771f0a8 | ||
|
|
6c29da94f3 | ||
|
|
981523789e | ||
|
|
d9aacfa059 | ||
|
|
5efc5289f7 | ||
|
|
1f68f4e654 | ||
|
|
5670e6696a | ||
|
|
ca6dc5195d | ||
|
|
30ebe318e0 | ||
|
|
a1c3f0d651 | ||
|
|
347e03d75e | ||
|
|
8543382bde | ||
|
|
4f1004472c | ||
|
|
7aee829b94 | ||
|
|
98701104d8 | ||
|
|
7a14e61762 | ||
|
|
f42f5c31ed | ||
|
|
342662c944 | ||
|
|
50088fe0bd | ||
|
|
687f87a748 | ||
|
|
6815c66a0e | ||
|
|
385fe1bb05 | ||
|
|
eddadcc179 | ||
|
|
9426f44cdd | ||
|
|
af7ff3df58 | ||
|
|
7c0cc8794f |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,6 +2,7 @@
|
|||||||
/.classpath
|
/.classpath
|
||||||
/.project
|
/.project
|
||||||
/.settings
|
/.settings
|
||||||
|
/dependency-reduced-pom.xml
|
||||||
|
|
||||||
# netbeans
|
# netbeans
|
||||||
/nbproject
|
/nbproject
|
||||||
|
|||||||
@@ -7,13 +7,64 @@ Key:
|
|||||||
! Change
|
! Change
|
||||||
- Removal
|
- Removal
|
||||||
|
|
||||||
Version 1.5.02-dev
|
Version 2.0.00
|
||||||
+ Added new active ability "Charge" to Taming!
|
= Fixed an interaction between Tree Feller and Stripped Wood
|
||||||
|
! Fireworks no longer fire by default for ability activation/deactivation
|
||||||
|
! Website has been changed and the MOTD string relating to it reflects this
|
||||||
|
! Discord link added to mcMMO command
|
||||||
|
! Updated misc strings relating to mcMMO
|
||||||
|
|
||||||
|
|
||||||
|
Version 1.5.05-SNAPSHOT
|
||||||
|
|
||||||
|
Version 1.5.04
|
||||||
|
+ Added option to config.yml to control mcMMO generated sound volume
|
||||||
|
+ Added option to config.yml to truncate existing player skill levels that exceed the skill level cap
|
||||||
|
+ Falling blocks persist mcMMO natural data
|
||||||
|
= Woodcutting double drops correctly identify acacia and dark oak logs
|
||||||
|
= Skill Reset command now correctly identifies arguments
|
||||||
|
= Hylian Treasure config options are now actually used
|
||||||
|
= Child skills now use parent skills configured skill caps properly
|
||||||
|
= Auto Update config now properly works
|
||||||
|
! Item dropped from blocks now drop from the center
|
||||||
|
! Potions Config updated for 1.9
|
||||||
|
! Flux mining now simulates a block break event for other plugins to act upon
|
||||||
|
! Zombie Pigmen spawned from nether portals are now considered spawner mobs
|
||||||
|
! Flux Pickaxe lore now appends to existing lore as opposed to replacing it
|
||||||
|
! Party chat no longer displays colors when logged in server console
|
||||||
|
- Treefeller no longer lowers exp for big trees
|
||||||
|
- No longer supports 1.8 :(
|
||||||
|
- Removed plugin metrics
|
||||||
|
|
||||||
|
Version 1.5.03
|
||||||
|
= Fixed bug where absorption hearts could be attacked by allied players
|
||||||
|
= Fixed bug where new forms of stone would drop the wrong type when mined with Silk Touch
|
||||||
|
= Fixed bug where blocks would not get tracked correctly when using sticky pistons and slime blocks in certain situations
|
||||||
|
= Fixed bug where config value for Daze damage was ignored
|
||||||
|
= Fixed UUID updater to not lose data on errors
|
||||||
|
= Fixed bug where uuid update could result in large amounts of user data being deleted
|
||||||
|
= Fixed bug where custom potions were missed in potion stage calculation
|
||||||
|
= Fixed piston dupe bugs permanently
|
||||||
|
= Fixed bug involving user name changes
|
||||||
|
= Fixed old user purge to properly calculate months
|
||||||
|
= Fixed bug where Repair would incorrectly check items
|
||||||
|
= Fixed bug where apostrophes in locale files would not read correctly
|
||||||
|
= Fixed bug where treasure data was limited to 255 instead of Short.MAX_VALUE
|
||||||
|
! Moved more user loading calculations to async loading thread to reduce lag on login
|
||||||
|
|
||||||
|
Version 1.5.02
|
||||||
+ Added option to config.yml for Chimaera Wings to stop using bed spawn points
|
+ Added option to config.yml for Chimaera Wings to stop using bed spawn points
|
||||||
|
+ Added option to config.yml to let non-tools in hand count as unarmed
|
||||||
|
+ Added option to experience.yml to control XP gained by killing bred animals
|
||||||
|
+ Added support for 1.8 mobs and features
|
||||||
= Fixed bug where no Mining XP was granted when Flux Mining was successful
|
= Fixed bug where no Mining XP was granted when Flux Mining was successful
|
||||||
|
= Fixed bug with UUID conversions in Flatfile
|
||||||
|
= Fixed a couple Dupe bugs that were introduced recently
|
||||||
= Fixed bug where MobHealthbarTypes were not saved between server restarts
|
= Fixed bug where MobHealthbarTypes were not saved between server restarts
|
||||||
! Changed Flux Mining mechanics. In order to use the ability, you need to infuse a pickaxe with furnace powers first.
|
! Changed Flux Mining mechanics. In order to use the ability, you need to infuse a pickaxe with furnace powers first.
|
||||||
! Scoreboard tips are only shown a couple of times to the player, instead of once per login session
|
! Scoreboard tips are only shown a couple of times to the player, instead of once per login session
|
||||||
|
! Changed Archery distance multiplier to be configurable
|
||||||
|
! Archery distance XP bonus cannot exceed indefinitely anymore
|
||||||
|
|
||||||
Version 1.5.01
|
Version 1.5.01
|
||||||
+ Added new child skill; Salvage
|
+ Added new child skill; Salvage
|
||||||
|
|||||||
43
README.md
43
README.md
@@ -2,7 +2,9 @@
|
|||||||
## The RPG lovers mod
|
## The RPG lovers mod
|
||||||
|
|
||||||
### Builds
|
### Builds
|
||||||
Currently, you can obtain our builds via the Spigot resource page: http://www.spigotmc.org/resources/mcmmo.2445/
|
Currently, you can obtain our builds via the Spigot resource page: https://www.spigotmc.org/resources/official-mcmmo.63489/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Brief Description
|
### Brief Description
|
||||||
The goal of mcMMO is to take core Minecraft game mechanics and expand them into add an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds fourteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update.
|
The goal of mcMMO is to take core Minecraft game mechanics and expand them into add an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds fourteen 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.
|
||||||
@@ -11,29 +13,23 @@ The goal of mcMMO is to take core Minecraft game mechanics and expand them into
|
|||||||
|
|
||||||
mcMMO is currently developed by a team of individuals from all over the world.
|
mcMMO is currently developed by a team of individuals from all over the world.
|
||||||
|
|
||||||
|
### Project Lead & Founder
|
||||||
|
[](https://github.com/nossr50)
|
||||||
|
|
||||||
|
### Former Lead
|
||||||
|
[](https://github.com/gmcferrin)
|
||||||
|
|
||||||
### Developers
|
### Developers
|
||||||
[]
|
[](https://github.com/bm01)
|
||||||
(https://github.com/gmcferrin)
|
[](https://github.com/Glitchfinder)
|
||||||
[]
|
[](https://github.com/NuclearW)
|
||||||
(https://github.com/bm01)
|
[](https://github.com/shatteredbeam)
|
||||||
[]
|
[](https://github.com/TfT-02)
|
||||||
(https://github.com/Glitchfinder)
|
[](https://github.com/t00thpick1)
|
||||||
[]
|
[](https://github.com/riking)
|
||||||
(https://github.com/nossr50)
|
|
||||||
[]
|
|
||||||
(https://github.com/NuclearW)
|
|
||||||
[]
|
|
||||||
(https://github.com/shatteredbeam)
|
|
||||||
[]
|
|
||||||
(https://github.com/TfT-02)
|
|
||||||
[]
|
|
||||||
(https://github.com/t00thpick1)
|
|
||||||
[]
|
|
||||||
(https://github.com/riking)
|
|
||||||
|
|
||||||
### Special thanks
|
### Special thanks
|
||||||
[]
|
[](https://github.com/EasyMFnE)
|
||||||
(https://github.com/EasyMFnE)
|
|
||||||
Added the Alchemy skill
|
Added the Alchemy skill
|
||||||
|
|
||||||
## Compiling
|
## Compiling
|
||||||
@@ -43,8 +39,7 @@ mcMMO uses Maven 3 to manage dependencies, packaging, and shading of necessary c
|
|||||||
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:
|
||||||
* JUnit
|
|
||||||
* EMetrics
|
|
||||||
* Bukkit
|
* Bukkit
|
||||||
|
* JUnit
|
||||||
|
|
||||||
http://www.spigotmc.org/resources/mcmmo.2445/ for more up to date information.
|
https://www.spigotmc.org/resources/official-mcmmo.63489/ for more up to date information.
|
||||||
|
|||||||
49
pom.xml
49
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.5.02-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</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>
|
||||||
@@ -38,6 +38,14 @@
|
|||||||
<include>*.yml</include>
|
<include>*.yml</include>
|
||||||
</includes>
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<targetPath>.</targetPath>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<directory>${basedir}</directory>
|
||||||
|
<includes>
|
||||||
|
<include>LICENSE</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@@ -45,8 +53,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>2.3.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.6</source>
|
<source>1.8</source>
|
||||||
<target>1.6</target>
|
<target>1.8</target>
|
||||||
<excludes>
|
<excludes>
|
||||||
</excludes>
|
</excludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -71,21 +79,16 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>1.5</version>
|
<version>3.1.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<artifactSet>
|
<artifactSet>
|
||||||
<includes>
|
<includes>
|
||||||
<include>com.turt2live.metrics:MetricsExtension</include>
|
|
||||||
<include>commons-logging:commons-logging</include>
|
<include>commons-logging:commons-logging</include>
|
||||||
<include>org.apache.tomcat:tomcat-jdbc</include>
|
<include>org.apache.tomcat:tomcat-jdbc</include>
|
||||||
<include>org.apache.tomcat:tomcat-juli</include>
|
<include>org.apache.tomcat:tomcat-juli</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
|
||||||
<pattern>com.turt2live.metrics</pattern>
|
|
||||||
<shadedPattern>com.gmail.nossr50.metrics.mcstats</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>org.apache.commons.logging</pattern>
|
<pattern>org.apache.commons.logging</pattern>
|
||||||
<shadedPattern>com.gmail.nossr50.commons.logging</shadedPattern>
|
<shadedPattern>com.gmail.nossr50.commons.logging</shadedPattern>
|
||||||
@@ -118,22 +121,11 @@
|
|||||||
</extension>
|
</extension>
|
||||||
</extensions>
|
</extensions>
|
||||||
</build>
|
</build>
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>spigot-repo</id>
|
|
||||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>Plugin MetricsExtension</id>
|
|
||||||
<url>http://repo.turt2live.com</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.8-R0.1-SNAPSHOT</version>
|
<version>1.13.1-R0.1-SNAPSHOT</version>
|
||||||
<type>jar</type>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -142,11 +134,6 @@
|
|||||||
<version>4.10</version>
|
<version>4.10</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.turt2live.metrics</groupId>
|
|
||||||
<artifactId>MetricsExtension</artifactId>
|
|
||||||
<version>0.0.5-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.tomcat</groupId>
|
<groupId>org.apache.tomcat</groupId>
|
||||||
<artifactId>tomcat-jdbc</artifactId>
|
<artifactId>tomcat-jdbc</artifactId>
|
||||||
@@ -154,17 +141,7 @@
|
|||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<distributionManagement>
|
|
||||||
<repository>
|
|
||||||
<id>drtshock-releases</id>
|
|
||||||
<url>https://ci.drtshock.net/plugin/repository/everything/com/gmail/nossr50/mcMMO/</url>
|
|
||||||
</repository>
|
|
||||||
</distributionManagement>
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<ciManagement>
|
|
||||||
<system>Jenkins</system>
|
|
||||||
<url>https://ci.drtshock.net/job/mcmmo/</url>
|
|
||||||
</ciManagement>
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
3
src/main/java/META-INF/MANIFEST.MF
Normal file
3
src/main/java/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
Main-Class: com.gmail.nossr50.mcMMO
|
||||||
|
|
||||||
46
src/main/java/com/gmail/nossr50/commands/MHDCommand.java
Normal file
46
src/main/java/com/gmail/nossr50/commands/MHDCommand.java
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package com.gmail.nossr50.commands;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabExecutor;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.database.FlatfileDatabaseManager;
|
||||||
|
import com.gmail.nossr50.database.SQLDatabaseManager;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
public class MHDCommand implements TabExecutor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (mcMMO.getDatabaseManager() instanceof SQLDatabaseManager) {
|
||||||
|
SQLDatabaseManager m = (SQLDatabaseManager) mcMMO.getDatabaseManager();
|
||||||
|
m.resetMobHealthSettings();
|
||||||
|
for (McMMOPlayer player : UserManager.getPlayers()) {
|
||||||
|
player.getProfile().setMobHealthbarType(Config.getInstance().getMobHealthbarDefault());
|
||||||
|
}
|
||||||
|
sender.sendMessage("Mob health reset");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (mcMMO.getDatabaseManager() instanceof FlatfileDatabaseManager) {
|
||||||
|
FlatfileDatabaseManager m = (FlatfileDatabaseManager) mcMMO.getDatabaseManager();
|
||||||
|
m.resetMobHealthSettings();
|
||||||
|
for (McMMOPlayer player : UserManager.getPlayers()) {
|
||||||
|
player.getProfile().setMobHealthbarType(Config.getInstance().getMobHealthbarDefault());
|
||||||
|
}
|
||||||
|
sender.sendMessage("Mob health reset");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
|
return ImmutableList.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,7 +27,7 @@ public class McmmoCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if (Config.getInstance().getDonateMessageEnabled()) {
|
if (Config.getInstance().getDonateMessageEnabled()) {
|
||||||
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
||||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "tft_02@hotmail.com" + ChatColor.GOLD + " Paypal");
|
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "nossr50@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.showversion(sender)) {
|
if (Permissions.showversion(sender)) {
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.gmail.nossr50.commands.experience;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
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;
|
||||||
@@ -16,7 +18,6 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public abstract class ExperienceCommand implements TabExecutor {
|
public abstract class ExperienceCommand implements TabExecutor {
|
||||||
@@ -45,6 +46,12 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
skill = null;
|
skill = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skill != null && skill.isChildSkill())
|
||||||
|
{
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1]));
|
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1]));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -64,6 +71,12 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
skill = null;
|
skill = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skill != null && skill.isChildSkill())
|
||||||
|
{
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int value = Integer.parseInt(args[2]);
|
int value = Integer.parseInt(args[2]);
|
||||||
|
|
||||||
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||||
@@ -71,7 +84,12 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
|
|
||||||
// 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(playerName, false);
|
UUID uuid = null;
|
||||||
|
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
|
||||||
|
if (player != null) {
|
||||||
|
uuid = player.getUniqueId();
|
||||||
|
}
|
||||||
|
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
|
||||||
|
|
||||||
if (CommandUtils.unloadedProfile(sender, profile)) {
|
if (CommandUtils.unloadedProfile(sender, profile)) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.gmail.nossr50.commands.experience;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
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;
|
||||||
@@ -19,7 +21,6 @@ import com.gmail.nossr50.util.EventUtils;
|
|||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,6 +30,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
public class SkillresetCommand implements TabExecutor {
|
public class SkillresetCommand implements TabExecutor {
|
||||||
@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;
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
if (CommandUtils.noConsoleUsage(sender)) {
|
if (CommandUtils.noConsoleUsage(sender)) {
|
||||||
@@ -44,7 +46,14 @@ public class SkillresetCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), SkillType.getSkill(args[0]));
|
if (args[0].equalsIgnoreCase("all")) {
|
||||||
|
skill = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skill = SkillType.getSkill(args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
@@ -57,7 +66,6 @@ public class SkillresetCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkillType skill;
|
|
||||||
if (args[1].equalsIgnoreCase("all")) {
|
if (args[1].equalsIgnoreCase("all")) {
|
||||||
skill = null;
|
skill = null;
|
||||||
}
|
}
|
||||||
@@ -70,7 +78,12 @@ public class SkillresetCommand implements TabExecutor {
|
|||||||
|
|
||||||
// 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(playerName, false);
|
UUID uuid = null;
|
||||||
|
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
|
||||||
|
if (player != null) {
|
||||||
|
uuid = player.getUniqueId();
|
||||||
|
}
|
||||||
|
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
|
||||||
|
|
||||||
if (CommandUtils.unloadedProfile(sender, profile)) {
|
if (CommandUtils.unloadedProfile(sender, profile)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -134,7 +147,7 @@ public class SkillresetCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateArguments(CommandSender sender, String skillName) {
|
private boolean validateArguments(CommandSender sender, String skillName) {
|
||||||
return !(CommandUtils.isInvalidSkill(sender, skillName) && !skillName.equalsIgnoreCase("all"));
|
return skillName.equalsIgnoreCase("all") || !CommandUtils.isInvalidSkill(sender, skillName);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void handleSenderMessage(CommandSender sender, String playerName, SkillType skill) {
|
protected static void handleSenderMessage(CommandSender sender, String playerName, SkillType skill) {
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
package com.gmail.nossr50.commands.player;
|
package com.gmail.nossr50.commands.player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.gmail.nossr50.config.Config;
|
||||||
import java.util.List;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
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;
|
||||||
@@ -10,17 +18,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import java.util.ArrayList;
|
||||||
import com.gmail.nossr50.config.Config;
|
import java.util.List;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
public class MctopCommand implements TabExecutor {
|
public class MctopCommand implements TabExecutor {
|
||||||
@Override
|
@Override
|
||||||
@@ -91,7 +90,12 @@ public class MctopCommand implements TabExecutor {
|
|||||||
long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750);
|
long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750);
|
||||||
|
|
||||||
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
|
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
double seconds = ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis()) / 1000;
|
||||||
|
if (seconds < 1) {
|
||||||
|
seconds = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.formatString(LocaleLoader.getString("Commands.Database.Cooldown"), seconds));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
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.herbalism.Herbalism;
|
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class HerbalismCommand extends SkillCommand {
|
public class HerbalismCommand extends SkillCommand {
|
||||||
private String greenTerraLength;
|
private String greenTerraLength;
|
||||||
@@ -87,8 +86,8 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
protected void permissionsCheck(Player player) {
|
protected void permissionsCheck(Player player) {
|
||||||
hasHylianLuck = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HYLIAN_LUCK);
|
hasHylianLuck = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HYLIAN_LUCK);
|
||||||
canGreenTerra = Permissions.greenTerra(player);
|
canGreenTerra = Permissions.greenTerra(player);
|
||||||
canGreenThumbPlants = Permissions.greenThumbPlant(player, Material.CROPS) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.NETHER_WARTS) || Permissions.greenThumbPlant(player, Material.COCOA);
|
canGreenThumbPlants = Permissions.greenThumbPlant(player, Material.WHEAT) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.BEETROOT) || Permissions.greenThumbPlant(player, Material.NETHER_WART) || Permissions.greenThumbPlant(player, Material.COCOA);
|
||||||
canGreenThumbBlocks = Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLE_WALL) || Permissions.greenThumbBlock(player, Material.SMOOTH_BRICK);
|
canGreenThumbBlocks = Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLESTONE_WALL) || Permissions.greenThumbBlock(player, Material.STONE_BRICKS);
|
||||||
canFarmersDiet = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FARMERS_DIET);
|
canFarmersDiet = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FARMERS_DIET);
|
||||||
canDoubleDrop = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS) && !skill.getDoubleDropsDisabled();
|
canDoubleDrop = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS) && !skill.getDoubleDropsDisabled();
|
||||||
canShroomThumb = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHROOM_THUMB);
|
canShroomThumb = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHROOM_THUMB);
|
||||||
|
|||||||
@@ -1,16 +1,10 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
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.mcMMO;
|
||||||
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.ArcaneForging.Tier;
|
||||||
import com.gmail.nossr50.skills.repair.Repair;
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
@@ -18,6 +12,11 @@ import com.gmail.nossr50.skills.repair.RepairManager;
|
|||||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class RepairCommand extends SkillCommand {
|
public class RepairCommand extends SkillCommand {
|
||||||
private String repairMasteryBonus;
|
private String repairMasteryBonus;
|
||||||
@@ -49,7 +48,7 @@ public class RepairCommand extends SkillCommand {
|
|||||||
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
|
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
|
||||||
// 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);
|
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE);
|
||||||
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE);
|
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLDEN_PICKAXE);
|
||||||
Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE);
|
Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE);
|
||||||
Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE);
|
Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE);
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ public class TamingCommand extends SkillCommand {
|
|||||||
private String goreChance;
|
private String goreChance;
|
||||||
private String goreChanceLucky;
|
private String goreChanceLucky;
|
||||||
|
|
||||||
private boolean canCharge;
|
|
||||||
private boolean canBeastLore;
|
private boolean canBeastLore;
|
||||||
private boolean canGore;
|
private boolean canGore;
|
||||||
private boolean canSharpenedClaws;
|
private boolean canSharpenedClaws;
|
||||||
@@ -44,10 +43,9 @@ public class TamingCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void permissionsCheck(Player player) {
|
protected void permissionsCheck(Player player) {
|
||||||
canCharge = Permissions.charge(player);
|
|
||||||
canBeastLore = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.BEAST_LORE);
|
canBeastLore = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.BEAST_LORE);
|
||||||
canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
|
canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
|
||||||
canEnvironmentallyAware = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ENVIROMENTALLY_AWARE);
|
canEnvironmentallyAware = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ENVIRONMENTALLY_AWARE);
|
||||||
canFastFood = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FAST_FOOD);
|
canFastFood = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FAST_FOOD);
|
||||||
canGore = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.GORE);
|
canGore = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.GORE);
|
||||||
canSharpenedClaws = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHARPENED_CLAWS);
|
canSharpenedClaws = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHARPENED_CLAWS);
|
||||||
@@ -60,10 +58,6 @@ public class TamingCommand extends SkillCommand {
|
|||||||
protected List<String> effectsDisplay() {
|
protected List<String> effectsDisplay() {
|
||||||
List<String> messages = new ArrayList<String>();
|
List<String> messages = new ArrayList<String>();
|
||||||
|
|
||||||
if (canCharge) {
|
|
||||||
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.20"), LocaleLoader.getString("Taming.Effect.21")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canBeastLore) {
|
if (canBeastLore) {
|
||||||
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1")));
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1")));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,13 @@ import java.io.File;
|
|||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import com.gmail.nossr50.metrics.MetricsManager;
|
|
||||||
|
|
||||||
public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
||||||
public AutoUpdateConfigLoader(String relativePath, String fileName) {
|
public AutoUpdateConfigLoader(String relativePath, String fileName) {
|
||||||
super(relativePath, fileName);
|
super(relativePath, fileName);
|
||||||
@@ -26,7 +25,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
|||||||
@Override
|
@Override
|
||||||
protected void loadFile() {
|
protected void loadFile() {
|
||||||
super.loadFile();
|
super.loadFile();
|
||||||
FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(plugin.getResource(fileName));
|
FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(plugin.getResourceAsReader(fileName));
|
||||||
|
|
||||||
Set<String> configKeys = config.getKeys(true);
|
Set<String> configKeys = config.getKeys(true);
|
||||||
Set<String> internalConfigKeys = internalConfig.getKeys(true);
|
Set<String> internalConfigKeys = internalConfig.getKeys(true);
|
||||||
@@ -46,8 +45,8 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (String key : oldKeys) {
|
for (String key : oldKeys) {
|
||||||
plugin.debug("Removing unused key: " + key);
|
plugin.debug("Detected potentially unused key: " + key);
|
||||||
config.set(key, null);
|
//config.set(key, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String key : newKeys) {
|
for (String key : newKeys) {
|
||||||
@@ -71,7 +70,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
|||||||
try {
|
try {
|
||||||
// Read internal
|
// Read internal
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getResource(fileName)));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getResource(fileName)));
|
||||||
HashMap<String, String> comments = new HashMap<String, String>();
|
LinkedHashMap<String, String> comments = new LinkedHashMap<String, String>();
|
||||||
String temp = "";
|
String temp = "";
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
@@ -82,6 +81,15 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
|||||||
else if (line.contains(":")) {
|
else if (line.contains(":")) {
|
||||||
line = line.substring(0, line.indexOf(":") + 1);
|
line = line.substring(0, line.indexOf(":") + 1);
|
||||||
if (!temp.isEmpty()) {
|
if (!temp.isEmpty()) {
|
||||||
|
if(comments.containsKey(line)) {
|
||||||
|
int index = 0;
|
||||||
|
while(comments.containsKey(line + index)) {
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
line = line + index;
|
||||||
|
}
|
||||||
|
|
||||||
comments.put(line, temp);
|
comments.put(line, temp);
|
||||||
temp = "";
|
temp = "";
|
||||||
}
|
}
|
||||||
@@ -89,9 +97,20 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dump to the new one
|
// Dump to the new one
|
||||||
|
HashMap<String, Integer> indexed = new HashMap<String, Integer>();
|
||||||
for (String key : comments.keySet()) {
|
for (String key : comments.keySet()) {
|
||||||
if (output.contains(key)) {
|
String actualkey = key.substring(0, key.indexOf(":") + 1);
|
||||||
output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key));
|
|
||||||
|
int index = 0;
|
||||||
|
if(indexed.containsKey(actualkey)) {
|
||||||
|
index = indexed.get(actualkey);
|
||||||
|
}
|
||||||
|
boolean isAtTop = !output.contains("\n" + actualkey);
|
||||||
|
index = output.indexOf((isAtTop ? "" : "\n") + actualkey, index);
|
||||||
|
|
||||||
|
if (index >= 0) {
|
||||||
|
output = output.substring(0, index) + "\n" + comments.get(key) + output.substring(isAtTop ? index : index + 1);
|
||||||
|
indexed.put(actualkey, index + comments.get(key).length() + actualkey.length() + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,13 +135,5 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
for (String key : configKeys) {
|
|
||||||
if (!config.isConfigurationSection(key) && !config.get(key).equals(internalConfig.get(key))) {
|
|
||||||
MetricsManager.customConfig();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
package com.gmail.nossr50.config;
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.TreeSpecies;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.database.SQLDatabaseManager.PoolIdentifier;
|
import com.gmail.nossr50.database.SQLDatabaseManager.PoolIdentifier;
|
||||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||||
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.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class Config extends AutoUpdateConfigLoader {
|
public class Config extends AutoUpdateConfigLoader {
|
||||||
private static Config instance;
|
private static Config instance;
|
||||||
@@ -178,6 +177,10 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
reason.add("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
|
reason.add("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getFishingLureModifier() < 0) {
|
||||||
|
reason.add("Abilities.Fishing.Lure_Modifier should be at least 0!");
|
||||||
|
}
|
||||||
|
|
||||||
if (getDetonatorItem() == null) {
|
if (getDetonatorItem() == null) {
|
||||||
reason.add("Skills.Mining.Detonator_Item is invalid!");
|
reason.add("Skills.Mining.Detonator_Item is invalid!");
|
||||||
}
|
}
|
||||||
@@ -265,6 +268,8 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getLevelUpSoundsEnabled() { return config.getBoolean("General.LevelUp_Sounds", true); }
|
public boolean getLevelUpSoundsEnabled() { return config.getBoolean("General.LevelUp_Sounds", true); }
|
||||||
public boolean getRefreshChunksEnabled() { return config.getBoolean("General.Refresh_Chunks", false); }
|
public boolean getRefreshChunksEnabled() { return config.getBoolean("General.Refresh_Chunks", false); }
|
||||||
|
|
||||||
|
public boolean getMobHealthbarEnabled() { return config.getBoolean("Mob_Healthbar.Enabled", true); }
|
||||||
|
|
||||||
/* Mob Healthbar */
|
/* Mob Healthbar */
|
||||||
public MobHealthbarType getMobHealthbarDefault() {
|
public MobHealthbarType getMobHealthbarDefault() {
|
||||||
try {
|
try {
|
||||||
@@ -451,6 +456,8 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getDoubleDropsDisabled(SkillType skill) {
|
public boolean getDoubleDropsDisabled(SkillType skill) {
|
||||||
String skillName = StringUtils.getCapitalized(skill.toString());
|
String skillName = StringUtils.getCapitalized(skill.toString());
|
||||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops." + skillName);
|
ConfigurationSection section = config.getConfigurationSection("Double_Drops." + skillName);
|
||||||
|
if (section == null)
|
||||||
|
return false;
|
||||||
Set<String> keys = section.getKeys(false);
|
Set<String> keys = section.getKeys(false);
|
||||||
boolean disabled = true;
|
boolean disabled = true;
|
||||||
|
|
||||||
@@ -477,6 +484,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
|
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
|
||||||
public boolean getFishingOverrideTreasures() { return config.getBoolean("Skills.Fishing.Override_Vanilla_Treasures", true); }
|
public boolean getFishingOverrideTreasures() { return config.getBoolean("Skills.Fishing.Override_Vanilla_Treasures", true); }
|
||||||
public boolean getFishingExtraFish() { return config.getBoolean("Skills.Fishing.Extra_Fish", true); }
|
public boolean getFishingExtraFish() { return config.getBoolean("Skills.Fishing.Extra_Fish", true); }
|
||||||
|
public double getFishingLureModifier() { return config.getDouble("Skills.Fishing.Lure_Modifier", 4.0D); }
|
||||||
|
|
||||||
/* Mining */
|
/* Mining */
|
||||||
public Material getDetonatorItem() { return Material.matchMaterial(config.getString("Skills.Mining.Detonator_Name", "FLINT_AND_STEEL")); }
|
public Material getDetonatorItem() { return Material.matchMaterial(config.getString("Skills.Mining.Detonator_Name", "FLINT_AND_STEEL")); }
|
||||||
@@ -498,6 +506,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
/* Unarmed */
|
/* Unarmed */
|
||||||
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); }
|
||||||
public boolean getUnarmedItemPickupDisabled() { return config.getBoolean("Skills.Unarmed.Item_Pickup_Disabled_Full_Inventory", true); }
|
public boolean getUnarmedItemPickupDisabled() { return config.getBoolean("Skills.Unarmed.Item_Pickup_Disabled_Full_Inventory", true); }
|
||||||
|
public boolean getUnarmedItemsAsUnarmed() { return config.getBoolean("Skills.Unarmed.Items_As_Unarmed", false); }
|
||||||
|
|
||||||
/* Taming */
|
/* Taming */
|
||||||
public Material getTamingCOTWMaterial(EntityType type) { return Material.matchMaterial(config.getString("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Item_Material")); }
|
public Material getTamingCOTWMaterial(EntityType type) { return Material.matchMaterial(config.getString("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Item_Material")); }
|
||||||
@@ -508,7 +517,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40.0D); }
|
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40.0D); }
|
||||||
|
|
||||||
/* Woodcutting */
|
/* Woodcutting */
|
||||||
public boolean getWoodcuttingDoubleDropsEnabled(TreeSpecies species) { return config.getBoolean("Double_Drops.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_")); }
|
public boolean getWoodcuttingDoubleDropsEnabled(BlockData material) { return config.getBoolean("Double_Drops.Woodcutting." + StringUtils.getFriendlyConfigBlockDataString(material)); }
|
||||||
public boolean getTreeFellerSoundsEnabled() { return config.getBoolean("Skills.Woodcutting.Tree_Feller_Sounds", true); }
|
public boolean getTreeFellerSoundsEnabled() { return config.getBoolean("Skills.Woodcutting.Tree_Feller_Sounds", true); }
|
||||||
|
|
||||||
/* AFK Leveling */
|
/* AFK Leveling */
|
||||||
@@ -527,7 +536,11 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
return (cap <= 0) ? Integer.MAX_VALUE : cap;
|
return (cap <= 0) ? Integer.MAX_VALUE : cap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getTruncateSkills() { return config.getBoolean("General.TruncateSkills", false); }
|
||||||
|
|
||||||
/* 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); }
|
||||||
|
|
||||||
|
public float getMasterVolume() { return (float) config.getDouble("Sounds.MasterVolume", 1.0); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.config;
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@@ -29,8 +31,9 @@ public class HiddenConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
if (mcMMO.p.getResource(fileName) != null) {
|
InputStreamReader reader = mcMMO.p.getResourceAsReader(fileName);
|
||||||
config = YamlConfiguration.loadConfiguration(mcMMO.p.getResource(fileName));
|
if (reader != null) {
|
||||||
|
config = YamlConfiguration.loadConfiguration(reader);
|
||||||
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
|
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
|
||||||
conversionRate = config.getInt("Options.ConversionRate", 1);
|
conversionRate = config.getInt("Options.ConversionRate", 1);
|
||||||
useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true);
|
useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true);
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
package com.gmail.nossr50.config.experience;
|
package com.gmail.nossr50.config.experience;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.GrassSpecies;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.TreeSpecies;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.material.LongGrass;
|
|
||||||
import org.bukkit.material.MaterialData;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
|
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
|
||||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ExperienceConfig extends AutoUpdateConfigLoader {
|
public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||||
private static ExperienceConfig instance;
|
private static ExperienceConfig instance;
|
||||||
@@ -72,6 +68,11 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
reason.add("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
|
reason.add("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Bred Mob modifier */
|
||||||
|
if (getBredMobXpMultiplier() < 0) {
|
||||||
|
reason.add("Experience_Formula.Breeding.Multiplier should be at least 0!");
|
||||||
|
}
|
||||||
|
|
||||||
/* Conversion */
|
/* Conversion */
|
||||||
if (getExpModifier() <= 0) {
|
if (getExpModifier() <= 0) {
|
||||||
reason.add("Conversion.Exp_Modifier should be greater than 0!");
|
reason.add("Conversion.Exp_Modifier should be greater than 0!");
|
||||||
@@ -88,15 +89,16 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Archery */
|
||||||
|
if (getArcheryDistanceMultiplier() < 0) {
|
||||||
|
reason.add("Experience.Archery.Distance_Multiplier should be at least 0!");
|
||||||
|
}
|
||||||
|
|
||||||
/* Combat XP Multipliers */
|
/* Combat XP Multipliers */
|
||||||
if (getAnimalsXP() < 0) {
|
if (getAnimalsXP() < 0) {
|
||||||
reason.add("Experience.Combat.Multiplier.Animals should be at least 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) {
|
if (getDodgeXPModifier() < 0) {
|
||||||
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
|
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
|
||||||
}
|
}
|
||||||
@@ -122,31 +124,14 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Taming */
|
/* Taming */
|
||||||
if (getTamingXPWolf() <= 0) {
|
if (getTamingXP(EntityType.WOLF) <= 0) {
|
||||||
reason.add("Experience.Taming.Animal_Taming.Wolf should be greater than 0!");
|
reason.add("Experience.Taming.Animal_Taming.Wolf should be greater than 0!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getTamingXPOcelot() <= 0) {
|
if (getTamingXP(EntityType.OCELOT) <= 0) {
|
||||||
reason.add("Experience.Taming.Animal_Taming.Ocelot should be greater than 0!");
|
reason.add("Experience.Taming.Animal_Taming.Ocelot should be greater than 0!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Woodcutting */
|
|
||||||
for (TreeSpecies species : TreeSpecies.values()) {
|
|
||||||
String key = "Experience.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_");
|
|
||||||
|
|
||||||
if (config.getInt(key) <= 0) {
|
|
||||||
reason.add(key + " 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);
|
return noErrorsInConfig(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,6 +157,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
/* Spawned Mob modifier */
|
/* Spawned Mob modifier */
|
||||||
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); }
|
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); }
|
||||||
|
public double getBredMobXpMultiplier() { return config.getDouble("Experience_Formula.Breeding.Multiplier", 1.0); }
|
||||||
|
|
||||||
/* Skill modifiers */
|
/* Skill modifiers */
|
||||||
public double getFormulaSkillModifier(SkillType skill) { return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
|
public double getFormulaSkillModifier(SkillType skill) { return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
|
||||||
@@ -196,12 +182,67 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
/* Combat XP Multipliers */
|
/* Combat XP Multipliers */
|
||||||
public double getCombatXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
|
public double getCombatXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
|
||||||
|
public double getAnimalsXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"), getAnimalsXP()); }
|
||||||
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
|
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 boolean hasCombatXP(EntityType entity) {return config.contains("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
|
||||||
public double getElderGuardianXP() { return config.getDouble("Experience.Combat.Multiplier.Elder_Guardian", 4.0); }
|
|
||||||
|
|
||||||
/* Materials */
|
/* Materials */
|
||||||
public int getXp(SkillType skill, Material material) { return config.getInt("Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
|
public int getXp(SkillType skill, Material data)
|
||||||
|
{
|
||||||
|
String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||||
|
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
|
||||||
|
if (config.contains(explicitString))
|
||||||
|
return config.getInt(explicitString);
|
||||||
|
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
|
||||||
|
if (config.contains(friendlyString))
|
||||||
|
return config.getInt(friendlyString);
|
||||||
|
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
|
||||||
|
if (config.contains(wildcardString))
|
||||||
|
return config.getInt(wildcardString);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Materials */
|
||||||
|
public int getXp(SkillType skill, BlockData data)
|
||||||
|
{
|
||||||
|
String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||||
|
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
|
||||||
|
if (config.contains(explicitString))
|
||||||
|
return config.getInt(explicitString);
|
||||||
|
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
|
||||||
|
if (config.contains(friendlyString))
|
||||||
|
return config.getInt(friendlyString);
|
||||||
|
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
|
||||||
|
if (config.contains(wildcardString))
|
||||||
|
return config.getInt(wildcardString);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSkillBlock(SkillType skill, Material data)
|
||||||
|
{
|
||||||
|
String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||||
|
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
|
||||||
|
if (config.contains(explicitString))
|
||||||
|
return true;
|
||||||
|
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
|
||||||
|
if (config.contains(friendlyString))
|
||||||
|
return true;
|
||||||
|
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
|
||||||
|
return config.contains(wildcardString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSkillBlock(SkillType skill, BlockData data)
|
||||||
|
{
|
||||||
|
String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||||
|
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
|
||||||
|
if (config.contains(explicitString))
|
||||||
|
return true;
|
||||||
|
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
|
||||||
|
if (config.contains(friendlyString))
|
||||||
|
return true;
|
||||||
|
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
|
||||||
|
return config.contains(wildcardString);
|
||||||
|
}
|
||||||
|
|
||||||
/* Acrobatics */
|
/* Acrobatics */
|
||||||
public int getDodgeXPModifier() { return config.getInt("Experience.Acrobatics.Dodge", 120); }
|
public int getDodgeXPModifier() { return config.getInt("Experience.Acrobatics.Dodge", 120); }
|
||||||
@@ -213,161 +254,18 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
/* Alchemy */
|
/* Alchemy */
|
||||||
public double getPotionXP(PotionStage stage) { return config.getDouble("Experience.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); }
|
public double getPotionXP(PotionStage stage) { return config.getDouble("Experience.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); }
|
||||||
|
|
||||||
/* Excavation */
|
/* Archery */
|
||||||
public int getDirtAndSandXp(MaterialData data) {
|
public double getArcheryDistanceMultiplier() { return config.getDouble("Experience.Archery.Distance_Multiplier", 0.025); }
|
||||||
Material type = data.getItemType();
|
|
||||||
|
|
||||||
if (type == Material.DIRT) {
|
|
||||||
switch (data.getData()) {
|
|
||||||
case 0x0:
|
|
||||||
return config.getInt("Experience.Excavation.Dirt", 40);
|
|
||||||
|
|
||||||
case 0x1:
|
|
||||||
return config.getInt("Experience.Excavation.Coarse_Dirt", 40);
|
|
||||||
|
|
||||||
case 0x2:
|
|
||||||
return config.getInt("Experience.Excavation.Podzol", 40);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (type == Material.SAND) {
|
|
||||||
switch (data.getData()) {
|
|
||||||
case 0x0:
|
|
||||||
return config.getInt("Experience.Excavation.Sand", 40);
|
|
||||||
|
|
||||||
case 0x1:
|
|
||||||
return config.getInt("Experience.Excavation.Red_Sand", 40);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fishing */
|
|
||||||
public int getFishXp(MaterialData data) {
|
|
||||||
switch (data.getData()) {
|
|
||||||
case 0x0:
|
|
||||||
return config.getInt("Experience.Fishing.Raw_Fish", 800);
|
|
||||||
|
|
||||||
case 0x1:
|
|
||||||
return config.getInt("Experience.Fishing.Raw_Salmon", 800);
|
|
||||||
|
|
||||||
case 0x2:
|
|
||||||
return config.getInt("Experience.Fishing.Clownfish", 800);
|
|
||||||
|
|
||||||
case 0x3:
|
|
||||||
return config.getInt("Experience.Fishing.Pufferfish", 800);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFishingShakeXP() { return config.getInt("Experience.Fishing.Shake", 50); }
|
public int getFishingShakeXP() { return config.getInt("Experience.Fishing.Shake", 50); }
|
||||||
|
|
||||||
/* Herbalism */
|
|
||||||
public int getFlowerAndGrassXp(MaterialData data) {
|
|
||||||
Material type = data.getItemType();
|
|
||||||
|
|
||||||
if (type == Material.RED_ROSE) {
|
|
||||||
switch (data.getData()) {
|
|
||||||
case 0x0:
|
|
||||||
return config.getInt("Experience.Herbalism.Poppy", 100);
|
|
||||||
|
|
||||||
case 0x1:
|
|
||||||
return config.getInt("Experience.Herbalism.Blue_Orchid", 150);
|
|
||||||
|
|
||||||
case 0x2:
|
|
||||||
return config.getInt("Experience.Herbalism.Allium", 300);
|
|
||||||
|
|
||||||
case 0x3:
|
|
||||||
return config.getInt("Experience.Herbalism.Azure_Bluet", 150);
|
|
||||||
|
|
||||||
case 0x4:
|
|
||||||
return config.getInt("Experience.Herbalism.Red_Tulip", 150);
|
|
||||||
|
|
||||||
case 0x5:
|
|
||||||
return config.getInt("Experience.Herbalism.Orange_Tulip", 150);
|
|
||||||
|
|
||||||
case 0x6:
|
|
||||||
return config.getInt("Experience.Herbalism.White_Tulip", 150);
|
|
||||||
|
|
||||||
case 0x7:
|
|
||||||
return config.getInt("Experience.Herbalism.Pink_Tulip", 150);
|
|
||||||
|
|
||||||
case 0x8:
|
|
||||||
return config.getInt("Experience.Herbalism.Oxeye_Daisy", 150);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (type == Material.LONG_GRASS) {
|
|
||||||
GrassSpecies species = ((LongGrass) data).getSpecies();
|
|
||||||
if (species == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (species) {
|
|
||||||
case DEAD:
|
|
||||||
return config.getInt("Experience.Herbalism.Dead_Bush", 30);
|
|
||||||
|
|
||||||
case FERN_LIKE:
|
|
||||||
return config.getInt("Experience.Herbalism.Small_Fern", 10);
|
|
||||||
|
|
||||||
case NORMAL:
|
|
||||||
return config.getInt("Experience.Herbalism.Small_Grass", 10);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (type == Material.DOUBLE_PLANT) {
|
|
||||||
switch (data.getData()) {
|
|
||||||
case 0x0:
|
|
||||||
return config.getInt("Experience.Herbalism.Sunflower", 50);
|
|
||||||
|
|
||||||
case 0x1:
|
|
||||||
return config.getInt("Experience.Herbalism.Lilac", 50);
|
|
||||||
|
|
||||||
case 0x2:
|
|
||||||
return config.getInt("Experience.Herbalism.Tall_Grass", 50);
|
|
||||||
|
|
||||||
case 0x3:
|
|
||||||
return config.getInt("Experience.Herbalism.Tall_Fern", 50);
|
|
||||||
|
|
||||||
case 0x4:
|
|
||||||
return config.getInt("Experience.Herbalism.Rose_Bush", 50);
|
|
||||||
|
|
||||||
case 0x5:
|
|
||||||
return config.getInt("Experience.Herbalism.Peony", 50);
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Repair */
|
/* Repair */
|
||||||
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }
|
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }
|
||||||
public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
|
public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
|
||||||
|
|
||||||
/* Taming */
|
/* Taming */
|
||||||
public int getTamingXPHorse() { return config.getInt("Experience.Taming.Animal_Taming.Horse", 1000); }
|
public int getTamingXP(EntityType type)
|
||||||
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
|
{
|
||||||
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
|
return config.getInt("Experience.Taming.Animal_Taming." + StringUtils.getPrettyEntityTypeString(type));
|
||||||
|
}
|
||||||
/* Woodcutting */
|
|
||||||
public int getWoodcuttingTreeXP(TreeSpecies species) { return config.getInt("Experience.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_")); }
|
|
||||||
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,29 +1,27 @@
|
|||||||
package com.gmail.nossr50.config.mods;
|
package com.gmail.nossr50.config.mods;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
|
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
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.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.material.MaterialData;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
|
||||||
|
|
||||||
public class CustomBlockConfig extends ConfigLoader {
|
public class CustomBlockConfig extends ConfigLoader {
|
||||||
private boolean needsUpdate = false;
|
private boolean needsUpdate = false;
|
||||||
|
|
||||||
public List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
|
public List<Material> customExcavationBlocks = new ArrayList<>();
|
||||||
public List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
|
public List<Material> customHerbalismBlocks = new ArrayList<>();
|
||||||
public List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
|
public List<Material> customMiningBlocks = new ArrayList<>();
|
||||||
public List<MaterialData> customOres = new ArrayList<MaterialData>();
|
public List<Material> customOres = new ArrayList<>();
|
||||||
public List<MaterialData> customLogs = new ArrayList<MaterialData>();
|
public List<Material> customLogs = new ArrayList<>();
|
||||||
public List<MaterialData> customLeaves = new ArrayList<MaterialData>();
|
public List<Material> customLeaves = new ArrayList<>();
|
||||||
public List<MaterialData> customAbilityBlocks = new ArrayList<MaterialData>();
|
public List<Material> customAbilityBlocks = new ArrayList<>();
|
||||||
|
|
||||||
public HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
|
public HashMap<Material, CustomBlock> customBlockMap = new HashMap<>();
|
||||||
|
|
||||||
protected CustomBlockConfig(String fileName) {
|
protected CustomBlockConfig(String fileName) {
|
||||||
super("mods", fileName);
|
super("mods", fileName);
|
||||||
@@ -44,7 +42,7 @@ public class CustomBlockConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadBlocks(String skillType, List<MaterialData> blockList) {
|
private void loadBlocks(String skillType, List<Material> blockList) {
|
||||||
if (needsUpdate) {
|
if (needsUpdate) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -58,7 +56,7 @@ 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) {
|
||||||
if (config.contains(skillType + "." + blockName + "." + ".Drop_Item")) {
|
if (config.contains(skillType + "." + blockName + ".Drop_Item")) {
|
||||||
needsUpdate = true;
|
needsUpdate = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -72,11 +70,8 @@ public class CustomBlockConfig extends ConfigLoader {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte blockData = (blockInfo.length == 2) ? Byte.valueOf(blockInfo[1]) : 0;
|
|
||||||
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
|
|
||||||
|
|
||||||
if (blockList != null) {
|
if (blockList != null) {
|
||||||
blockList.add(blockMaterialData);
|
blockList.add(blockMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skillType.equals("Ability_Blocks")) {
|
if (skillType.equals("Ability_Blocks")) {
|
||||||
@@ -87,20 +82,20 @@ public class CustomBlockConfig extends ConfigLoader {
|
|||||||
int smeltingXp = 0;
|
int smeltingXp = 0;
|
||||||
|
|
||||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||||
customOres.add(blockMaterialData);
|
customOres.add(blockMaterial);
|
||||||
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
|
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
|
||||||
}
|
}
|
||||||
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(blockMaterialData);
|
customLogs.add(blockMaterial);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
customLeaves.add(blockMaterialData);
|
customLeaves.add(blockMaterial);
|
||||||
xp = 0; // Leaves don't grant XP
|
xp = 0; // Leaves don't grant XP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
|
customBlockMap.put(blockMaterial, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.gmail.nossr50.config.mods;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
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;
|
||||||
@@ -54,7 +54,7 @@ public class CustomEntityConfig extends ConfigLoader {
|
|||||||
canBeSummoned = false;
|
canBeSummoned = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomEntity entity = new CustomEntity(xpMultiplier, canBeTamed, tamingXp, canBeSummoned, (canBeSummoned ? new MaterialData(callOfTheWildMaterial, callOfTheWildData).toItemStack(1) : null), callOfTheWildAmount);
|
CustomEntity entity = new CustomEntity(xpMultiplier, canBeTamed, tamingXp, canBeSummoned, (canBeSummoned ? new ItemStack(callOfTheWildMaterial) : null), callOfTheWildAmount);
|
||||||
|
|
||||||
customEntityTypeMap.put(entityTypeName, entity);
|
customEntityTypeMap.put(entityTypeName, entity);
|
||||||
customEntityClassMap.put(clazz == null ? null : clazz.getName(), entity);
|
customEntityClassMap.put(clazz == null ? null : clazz.getName(), entity);
|
||||||
|
|||||||
@@ -6,11 +6,15 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.potion.Potion;
|
||||||
|
import org.bukkit.potion.PotionData;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.bukkit.potion.PotionType;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
@@ -28,7 +32,7 @@ public class PotionConfig extends ConfigLoader {
|
|||||||
private List<ItemStack> concoctionsIngredientsTierSeven = new ArrayList<ItemStack>();
|
private List<ItemStack> concoctionsIngredientsTierSeven = new ArrayList<ItemStack>();
|
||||||
private List<ItemStack> concoctionsIngredientsTierEight = new ArrayList<ItemStack>();
|
private List<ItemStack> concoctionsIngredientsTierEight = new ArrayList<ItemStack>();
|
||||||
|
|
||||||
private Map<Short, AlchemyPotion> potionMap = new HashMap<Short, AlchemyPotion>();
|
private Map<String, AlchemyPotion> potionMap = new HashMap<String, AlchemyPotion>();
|
||||||
|
|
||||||
private PotionConfig() {
|
private PotionConfig() {
|
||||||
super("potions.yml");
|
super("potions.yml");
|
||||||
@@ -90,11 +94,11 @@ public class PotionConfig extends ConfigLoader {
|
|||||||
int pass = 0;
|
int pass = 0;
|
||||||
int fail = 0;
|
int fail = 0;
|
||||||
|
|
||||||
for (String dataValue : potionSection.getKeys(false)) {
|
for (String potionName : potionSection.getKeys(false)) {
|
||||||
AlchemyPotion potion = loadPotion(potionSection.getConfigurationSection(dataValue));
|
AlchemyPotion potion = loadPotion(potionSection.getConfigurationSection(potionName));
|
||||||
|
|
||||||
if (potion != null) {
|
if (potion != null) {
|
||||||
potionMap.put(potion.getDataValue(), potion);
|
potionMap.put(potionName, potion);
|
||||||
pass++;
|
pass++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -115,13 +119,29 @@ public class PotionConfig extends ConfigLoader {
|
|||||||
*/
|
*/
|
||||||
private AlchemyPotion loadPotion(ConfigurationSection potion_section) {
|
private AlchemyPotion loadPotion(ConfigurationSection potion_section) {
|
||||||
try {
|
try {
|
||||||
short dataValue = Short.parseShort(potion_section.getName());
|
|
||||||
|
|
||||||
String name = potion_section.getString("Name");
|
String name = potion_section.getString("Name");
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
name = ChatColor.translateAlternateColorCodes('&', name);
|
name = ChatColor.translateAlternateColorCodes('&', name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PotionData data;
|
||||||
|
if (!potion_section.contains("PotionData")) { // Backwards config compatability
|
||||||
|
short dataValue = Short.parseShort(potion_section.getName());
|
||||||
|
Potion potion = Potion.fromDamage(dataValue);
|
||||||
|
data = new PotionData(potion.getType(), potion.hasExtendedDuration(), potion.getLevel() == 2);
|
||||||
|
} else {
|
||||||
|
ConfigurationSection potionData = potion_section.getConfigurationSection("PotionData");
|
||||||
|
data = new PotionData(PotionType.valueOf(potionData.getString("PotionType", "WATER")), potionData.getBoolean("Extended", false), potionData.getBoolean("Upgraded", false));
|
||||||
|
}
|
||||||
|
|
||||||
|
Material material = Material.POTION;
|
||||||
|
String mat = potion_section.getString("Material", null);
|
||||||
|
if (mat != null) {
|
||||||
|
material = Material.valueOf(mat);
|
||||||
|
}
|
||||||
|
|
||||||
List<String> lore = new ArrayList<String>();
|
List<String> lore = new ArrayList<String>();
|
||||||
if (potion_section.contains("Lore")) {
|
if (potion_section.contains("Lore")) {
|
||||||
for (String line : potion_section.getStringList("Lore")) {
|
for (String line : potion_section.getStringList("Lore")) {
|
||||||
@@ -147,12 +167,20 @@ public class PotionConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<ItemStack, Short> children = new HashMap<ItemStack, Short>();
|
Color color = null;
|
||||||
|
if (potion_section.contains("Color")) {
|
||||||
|
color = Color.fromRGB(potion_section.getInt("Color"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
color = this.generateColor(effects);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<ItemStack, String> children = new HashMap<ItemStack, String>();
|
||||||
if (potion_section.contains("Children")) {
|
if (potion_section.contains("Children")) {
|
||||||
for (String child : potion_section.getConfigurationSection("Children").getKeys(false)) {
|
for (String child : potion_section.getConfigurationSection("Children").getKeys(false)) {
|
||||||
ItemStack ingredient = loadIngredient(child);
|
ItemStack ingredient = loadIngredient(child);
|
||||||
if (ingredient != null) {
|
if (ingredient != null) {
|
||||||
children.put(ingredient, Short.parseShort(potion_section.getConfigurationSection("Children").getString(child)));
|
children.put(ingredient, potion_section.getConfigurationSection("Children").getString(child));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mcMMO.p.getLogger().warning("Failed to parse child for potion " + name + ": " + child);
|
mcMMO.p.getLogger().warning("Failed to parse child for potion " + name + ": " + child);
|
||||||
@@ -160,7 +188,7 @@ public class PotionConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new AlchemyPotion(dataValue, name, lore, effects, children);
|
return new AlchemyPotion(material, data, name, lore, effects, color, children);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
mcMMO.p.getLogger().warning("Failed to load Alchemy potion: " + potion_section.getName());
|
mcMMO.p.getLogger().warning("Failed to load Alchemy potion: " + potion_section.getName());
|
||||||
@@ -182,13 +210,10 @@ public class PotionConfig extends ConfigLoader {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] parts = ingredient.split(":");
|
Material material = Material.getMaterial(ingredient);
|
||||||
|
|
||||||
Material material = parts.length > 0 ? Material.getMaterial(parts[0]) : null;
|
|
||||||
short data = parts.length > 1 ? Short.parseShort(parts[1]) : 0;
|
|
||||||
|
|
||||||
if (material != null) {
|
if (material != null) {
|
||||||
return new ItemStack(material, 1, data);
|
return new ItemStack(material, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -217,10 +242,51 @@ public class PotionConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValidPotion(ItemStack item) {
|
public boolean isValidPotion(ItemStack item) {
|
||||||
return potionMap.containsKey(item.getDurability());
|
return getPotion(item) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlchemyPotion getPotion(short durability) {
|
public AlchemyPotion getPotion(String name) {
|
||||||
return potionMap.get(durability);
|
return potionMap.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AlchemyPotion getPotion(ItemStack item) {
|
||||||
|
for (AlchemyPotion potion : potionMap.values()) {
|
||||||
|
if (potion.isSimilar(item)) {
|
||||||
|
return potion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color generateColor(List<PotionEffect> effects) {
|
||||||
|
if (effects != null && !effects.isEmpty()) {
|
||||||
|
List<Color> colors = new ArrayList<Color>();
|
||||||
|
for (PotionEffect effect : effects) {
|
||||||
|
if (effect.getType().getColor() != null) {
|
||||||
|
colors.add(effect.getType().getColor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!colors.isEmpty()) {
|
||||||
|
if (colors.size() > 1) {
|
||||||
|
return calculateAverageColor(colors);
|
||||||
|
}
|
||||||
|
return colors.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color calculateAverageColor(List<Color> colors) {
|
||||||
|
int red = 0;
|
||||||
|
int green = 0;
|
||||||
|
int blue = 0;
|
||||||
|
for (Color color : colors) {
|
||||||
|
red += color.getRed();
|
||||||
|
green += color.getGreen();
|
||||||
|
blue += color.getBlue();
|
||||||
|
}
|
||||||
|
Color color = Color.fromRGB(red/colors.size(), green/colors.size(), blue/colors.size());
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
347
src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java
Normal file → Executable file
347
src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java
Normal file → Executable file
@@ -1,72 +1,36 @@
|
|||||||
package com.gmail.nossr50.config.treasure;
|
package com.gmail.nossr50.config.treasure;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import java.util.HashMap;
|
import com.gmail.nossr50.datatypes.treasure.*;
|
||||||
import java.util.List;
|
import com.gmail.nossr50.util.EnchantmentUtils;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Tag;
|
||||||
|
import org.bukkit.TreeSpecies;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
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.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.material.Dye;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
import org.bukkit.potion.Potion;
|
import org.bukkit.potion.PotionData;
|
||||||
import org.bukkit.potion.PotionType;
|
import org.bukkit.potion.PotionType;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import java.util.ArrayList;
|
||||||
import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure;
|
import java.util.HashMap;
|
||||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
import java.util.List;
|
||||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
|
||||||
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.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 HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<String, List<ExcavationTreasure>>();
|
||||||
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
|
||||||
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
|
|
||||||
public List<ExcavationTreasure> excavationFromGravel = new ArrayList<ExcavationTreasure>();
|
|
||||||
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
|
|
||||||
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
|
||||||
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
|
||||||
public List<ExcavationTreasure> excavationFromSnow = new ArrayList<ExcavationTreasure>();
|
|
||||||
public List<ExcavationTreasure> excavationFromRedSand = new ArrayList<ExcavationTreasure>();
|
|
||||||
public List<ExcavationTreasure> excavationFromPodzol = new ArrayList<ExcavationTreasure>();
|
|
||||||
|
|
||||||
public List<HylianTreasure> hylianFromBushes = new ArrayList<HylianTreasure>();
|
public HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<EntityType, List<ShakeTreasure>>();
|
||||||
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
|
public HashMap<String, List<HylianTreasure>> hylianMap = new HashMap<String, List<HylianTreasure>>();
|
||||||
public List<HylianTreasure> hylianFromPots = new ArrayList<HylianTreasure>();
|
|
||||||
|
|
||||||
public List<ShakeTreasure> shakeFromBlaze = new ArrayList<ShakeTreasure>();
|
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
|
||||||
public List<ShakeTreasure> shakeFromCaveSpider = new ArrayList<ShakeTreasure>();
|
|
||||||
public List<ShakeTreasure> shakeFromSpider = new ArrayList<ShakeTreasure>();
|
|
||||||
public List<ShakeTreasure> shakeFromChicken = new ArrayList<ShakeTreasure>();
|
|
||||||
public List<ShakeTreasure> shakeFromCow = new ArrayList<ShakeTreasure>();
|
|
||||||
public List<ShakeTreasure> shakeFromCreeper = new ArrayList<ShakeTreasure>();
|
|
||||||
public List<ShakeTreasure> shakeFromEnderman = 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> shakeFromMagmaCube = new ArrayList<ShakeTreasure>();
|
|
||||||
public List<ShakeTreasure> shakeFromMushroomCow = new ArrayList<ShakeTreasure>();
|
|
||||||
public List<ShakeTreasure> shakeFromPig = new ArrayList<ShakeTreasure>();
|
|
||||||
public List<ShakeTreasure> shakeFromPigZombie = new ArrayList<ShakeTreasure>();
|
|
||||||
public List<ShakeTreasure> shakeFromPlayer = new ArrayList<ShakeTreasure>();
|
|
||||||
public List<ShakeTreasure> shakeFromSheep = new ArrayList<ShakeTreasure>();
|
|
||||||
public List<ShakeTreasure> shakeFromSkeleton = new ArrayList<ShakeTreasure>();
|
|
||||||
public List<ShakeTreasure> shakeFromSlime = new ArrayList<ShakeTreasure>();
|
|
||||||
public List<ShakeTreasure> shakeFromSnowman = new ArrayList<ShakeTreasure>();
|
|
||||||
public List<ShakeTreasure> shakeFromSquid = new ArrayList<ShakeTreasure>();
|
|
||||||
public List<ShakeTreasure> shakeFromWitch = new ArrayList<ShakeTreasure>();
|
|
||||||
public List<ShakeTreasure> shakeFromZombie = new ArrayList<ShakeTreasure>();
|
|
||||||
|
|
||||||
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
|
|
||||||
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
|
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
|
||||||
|
|
||||||
private TreasureConfig() {
|
private TreasureConfig() {
|
||||||
@@ -87,7 +51,6 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
protected boolean validateKeys() {
|
protected boolean validateKeys() {
|
||||||
// Validate all the settings!
|
// Validate all the settings!
|
||||||
List<String> reason = new ArrayList<String>();
|
List<String> reason = new ArrayList<String>();
|
||||||
|
|
||||||
for (String tier : config.getConfigurationSection("Enchantment_Drop_Rates").getKeys(false)) {
|
for (String tier : config.getConfigurationSection("Enchantment_Drop_Rates").getKeys(false)) {
|
||||||
double totalEnchantDropRate = 0;
|
double totalEnchantDropRate = 0;
|
||||||
double totalItemDropRate = 0;
|
double totalItemDropRate = 0;
|
||||||
@@ -127,19 +90,19 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadTreaures("Fishing");
|
loadTreasures("Fishing");
|
||||||
loadTreaures("Excavation");
|
loadTreasures("Excavation");
|
||||||
loadTreaures("Hylian_Luck");
|
loadTreasures("Hylian_Luck");
|
||||||
loadEnchantments();
|
loadEnchantments();
|
||||||
|
|
||||||
for (EntityType entity : EntityType.values()) {
|
for (EntityType entity : EntityType.values()) {
|
||||||
if (entity.isAlive()) {
|
if (entity.isAlive()) {
|
||||||
loadTreaures("Shake." + entity.toString());
|
loadTreasures("Shake." + entity.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadTreaures(String type) {
|
private void loadTreasures(String type) {
|
||||||
boolean isFishing = type.equals("Fishing");
|
boolean isFishing = type.equals("Fishing");
|
||||||
boolean isShake = type.contains("Shake");
|
boolean isShake = type.contains("Shake");
|
||||||
boolean isExcavation = type.equals("Excavation");
|
boolean isExcavation = type.equals("Excavation");
|
||||||
@@ -170,23 +133,18 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
*/
|
*/
|
||||||
Material material;
|
Material material;
|
||||||
|
|
||||||
if (materialName.contains("POTION")) {
|
if (materialName.contains("INVENTORY")) {
|
||||||
material = Material.POTION;
|
// Use magic material BEDROCK to know that we're grabbing something from the inventory and not a normal treasure
|
||||||
}
|
if (!shakeMap.containsKey(EntityType.PLAYER))
|
||||||
else if (materialName.contains("INK_SACK")) {
|
shakeMap.put(EntityType.PLAYER, new ArrayList<ShakeTreasure>());
|
||||||
material = Material.INK_SACK;
|
shakeMap.get(EntityType.PLAYER).add(new ShakeTreasure(new ItemStack(Material.BEDROCK, 1, (byte) 0), 1, getInventoryStealDropChance(), getInventoryStealDropLevel()));
|
||||||
}
|
|
||||||
else if (materialName.contains("INVENTORY")) {
|
|
||||||
// Use magic material BED_BLOCK to know that we're grabbing something from the inventory and not a normal treasure
|
|
||||||
shakeFromPlayer.add(new ShakeTreasure(new ItemStack(Material.BED_BLOCK, 1, (byte) 0), 1, getInventoryStealDropChance(), getInventoryStealDropLevel()));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
material = Material.matchMaterial(materialName);
|
material = Material.matchMaterial(materialName);
|
||||||
}
|
}
|
||||||
|
|
||||||
int amount = config.getInt(type + "." + treasureName + ".Amount");
|
int amount = config.getInt(type + "." + treasureName + ".Amount");
|
||||||
short data = (treasureInfo.length == 2) ? Byte.valueOf(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data");
|
short data = (treasureInfo.length == 2) ? Short.parseShort(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data");
|
||||||
|
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
reason.add("Invalid material: " + materialName);
|
reason.add("Invalid material: " + materialName);
|
||||||
@@ -239,61 +197,37 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
ItemStack item = null;
|
ItemStack item = null;
|
||||||
|
|
||||||
if (materialName.contains("POTION")) {
|
if (materialName.contains("POTION")) {
|
||||||
String potionType = materialName.substring(7);
|
Material mat = Material.matchMaterial(materialName);
|
||||||
|
if (mat == null) {
|
||||||
|
reason.add("Potion format for Treasures.yml has changed");
|
||||||
|
} else {
|
||||||
|
item = new ItemStack(mat, amount, data);
|
||||||
|
PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
|
||||||
|
|
||||||
try {
|
PotionType potionType = null;
|
||||||
item = new Potion(PotionType.valueOf(potionType.toUpperCase().trim())).toItemStack(amount);
|
try {
|
||||||
|
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
|
||||||
|
}
|
||||||
|
boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
|
||||||
|
boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false);
|
||||||
|
itemMeta.setBasePotionData(new PotionData(potionType, extended, upgraded));
|
||||||
|
|
||||||
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
|
||||||
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
|
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
|
||||||
item.setItemMeta(itemMeta);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.contains(type + "." + treasureName + ".Lore")) {
|
if (config.contains(type + "." + treasureName + ".Lore")) {
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
|
||||||
List<String> lore = new ArrayList<String>();
|
List<String> lore = new ArrayList<String>();
|
||||||
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
|
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
|
||||||
lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
||||||
}
|
}
|
||||||
itemMeta.setLore(lore);
|
itemMeta.setLore(lore);
|
||||||
item.setItemMeta(itemMeta);
|
|
||||||
}
|
}
|
||||||
|
item.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex) {
|
} else if (material != null) {
|
||||||
reason.add("Invalid Potion_Type: " + potionType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (materialName.contains("INK_SACK")) {
|
|
||||||
String color = materialName.substring(9);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Dye dye = new Dye();
|
|
||||||
dye.setColor(DyeColor.valueOf(color.toUpperCase().trim()));
|
|
||||||
|
|
||||||
item = dye.toItemStack(amount);
|
|
||||||
|
|
||||||
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
|
||||||
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
|
|
||||||
item.setItemMeta(itemMeta);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.contains(type + "." + treasureName + ".Lore")) {
|
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
|
||||||
List<String> lore = new ArrayList<String>();
|
|
||||||
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
|
|
||||||
lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
|
||||||
}
|
|
||||||
itemMeta.setLore(lore);
|
|
||||||
item.setItemMeta(itemMeta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex) {
|
|
||||||
reason.add("Invalid Dye_Color: " + color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (material != null) {
|
|
||||||
item = new ItemStack(material, amount, data);
|
item = new ItemStack(material, amount, data);
|
||||||
|
|
||||||
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||||
@@ -316,141 +250,66 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
if (noErrorsInConfig(reason)) {
|
if (noErrorsInConfig(reason)) {
|
||||||
if (isFishing) {
|
if (isFishing) {
|
||||||
fishingRewards.get(rarity).add(new FishingTreasure(item, xp));
|
fishingRewards.get(rarity).add(new FishingTreasure(item, xp));
|
||||||
}
|
} else if (isShake) {
|
||||||
else if (isShake) {
|
|
||||||
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
|
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
|
||||||
|
|
||||||
if (type.equals("Shake.BLAZE")) {
|
EntityType entityType = EntityType.valueOf(type.substring(6));
|
||||||
shakeFromBlaze.add(shakeTreasure);
|
if (!shakeMap.containsKey(entityType))
|
||||||
}
|
shakeMap.put(entityType, new ArrayList<ShakeTreasure>());
|
||||||
else if (type.equals("Shake.CAVE_SPIDER")) {
|
shakeMap.get(entityType).add(shakeTreasure);
|
||||||
shakeFromCaveSpider.add(shakeTreasure);
|
} else if (isExcavation) {
|
||||||
}
|
|
||||||
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.PLAYER")) {
|
|
||||||
shakeFromPlayer.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);
|
ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
||||||
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
|
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
|
||||||
|
|
||||||
if (dropList.contains("Dirt")) {
|
for (String blockType : dropList) {
|
||||||
excavationFromDirt.add(excavationTreasure);
|
if (!excavationMap.containsKey(blockType))
|
||||||
|
excavationMap.put(blockType, new ArrayList<ExcavationTreasure>());
|
||||||
|
excavationMap.get(blockType).add(excavationTreasure);
|
||||||
}
|
}
|
||||||
|
} else if (isHylian) {
|
||||||
if (dropList.contains("Grass")) {
|
|
||||||
excavationFromGrass.add(excavationTreasure);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dropList.contains("Sand")) {
|
|
||||||
excavationFromSand.add(excavationTreasure);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dropList.contains("Gravel")) {
|
|
||||||
excavationFromGravel.add(excavationTreasure);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dropList.contains("Clay")) {
|
|
||||||
excavationFromClay.add(excavationTreasure);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dropList.contains("Mycelium")) {
|
|
||||||
excavationFromMycel.add(excavationTreasure);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dropList.contains("Soul_Sand")) {
|
|
||||||
excavationFromSoulSand.add(excavationTreasure);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dropList.contains("Snow")) {
|
|
||||||
excavationFromSnow.add(excavationTreasure);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dropList.contains("Red_Sand")) {
|
|
||||||
excavationFromRedSand.add(excavationTreasure);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dropList.contains("Podzol")) {
|
|
||||||
excavationFromPodzol.add(excavationTreasure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (isHylian) {
|
|
||||||
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
||||||
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
|
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
|
||||||
|
|
||||||
if (dropList.contains("Bushes")) {
|
for (String dropper : dropList) {
|
||||||
hylianFromBushes.add(hylianTreasure);
|
if (dropper.equals("Bushes")) {
|
||||||
}
|
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.FERN), hylianTreasure);
|
||||||
|
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.TALL_GRASS), hylianTreasure);
|
||||||
|
for (Material species : Tag.SAPLINGS.getValues())
|
||||||
|
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(species), hylianTreasure);
|
||||||
|
|
||||||
if (dropList.contains("Flowers")) {
|
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.DEAD_BUSH), hylianTreasure);
|
||||||
hylianFromFlowers.add(hylianTreasure);
|
continue;
|
||||||
}
|
}
|
||||||
|
if (dropper.equals("Flowers")) {
|
||||||
if (dropList.contains("Pots")) {
|
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.POPPY), hylianTreasure);
|
||||||
hylianFromPots.add(hylianTreasure);
|
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.DANDELION), hylianTreasure);
|
||||||
|
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.BLUE_ORCHID), hylianTreasure);
|
||||||
|
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.ALLIUM), hylianTreasure);
|
||||||
|
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.AZURE_BLUET), hylianTreasure);
|
||||||
|
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.ORANGE_TULIP), hylianTreasure);
|
||||||
|
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.PINK_TULIP), hylianTreasure);
|
||||||
|
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.RED_TULIP), hylianTreasure);
|
||||||
|
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.WHITE_TULIP), hylianTreasure);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (dropper.equals("Pots")) {
|
||||||
|
for (Material species : Tag.FLOWER_POTS.getValues())
|
||||||
|
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(species), hylianTreasure);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
AddHylianTreasure(dropper, hylianTreasure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddHylianTreasure(String dropper, HylianTreasure treasure) {
|
||||||
|
if (!hylianMap.containsKey(dropper))
|
||||||
|
hylianMap.put(dropper, new ArrayList<HylianTreasure>());
|
||||||
|
hylianMap.get(dropper).add(treasure);
|
||||||
|
}
|
||||||
|
|
||||||
private void loadEnchantments() {
|
private void loadEnchantments() {
|
||||||
for (Rarity rarity : Rarity.values()) {
|
for (Rarity rarity : Rarity.values()) {
|
||||||
if (rarity == Rarity.TRAP || rarity == Rarity.RECORD) {
|
if (rarity == Rarity.TRAP || rarity == Rarity.RECORD) {
|
||||||
@@ -481,11 +340,27 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getInventoryStealEnabled() { return config.contains("Shake.PLAYER.INVENTORY"); }
|
public boolean getInventoryStealEnabled() {
|
||||||
public boolean getInventoryStealStacks() { return config.getBoolean("Shake.PLAYER.INVENTORY.Whole_Stacks"); }
|
return config.contains("Shake.PLAYER.INVENTORY");
|
||||||
public double getInventoryStealDropChance() { return config.getDouble("Shake.PLAYER.INVENTORY.Drop_Chance"); }
|
}
|
||||||
public int getInventoryStealDropLevel() { return config.getInt("Shake.PLAYER.INVENTORY.Drop_Level"); }
|
|
||||||
|
|
||||||
public double getItemDropRate(int tier, Rarity rarity) { return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
|
public boolean getInventoryStealStacks() {
|
||||||
public double getEnchantmentDropRate(int tier, Rarity rarity) { return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
|
return config.getBoolean("Shake.PLAYER.INVENTORY.Whole_Stacks");
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getInventoryStealDropChance() {
|
||||||
|
return config.getDouble("Shake.PLAYER.INVENTORY.Drop_Chance");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInventoryStealDropLevel() {
|
||||||
|
return config.getInt("Shake.PLAYER.INVENTORY.Drop_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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
|
||||||
public interface DatabaseManager {
|
public interface DatabaseManager {
|
||||||
// One month in seconds
|
// One month in milliseconds
|
||||||
public final long PURGE_TIME = 2630000L * Config.getInstance().getOldUsersCutoff();
|
public final long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
||||||
// During convertUsers, how often to output a status
|
// During convertUsers, how often to output a status
|
||||||
public final int progressInterval = 200;
|
public final int progressInterval = 200;
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class DatabaseManagerFactory {
|
|||||||
*/
|
*/
|
||||||
public static void setCustomDatabaseManagerClass(Class<? extends DatabaseManager> clazz) {
|
public static void setCustomDatabaseManagerClass(Class<? extends DatabaseManager> clazz) {
|
||||||
try {
|
try {
|
||||||
clazz.getConstructor((Class<?>) null);
|
clazz.getConstructor();
|
||||||
customManager = clazz;
|
customManager = clazz;
|
||||||
}
|
}
|
||||||
catch (Throwable e) {
|
catch (Throwable e) {
|
||||||
@@ -78,10 +78,10 @@ public class DatabaseManagerFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static DatabaseManager createDefaultCustomDatabaseManager() throws Throwable {
|
public static DatabaseManager createDefaultCustomDatabaseManager() throws Throwable {
|
||||||
return customManager.getConstructor((Class<?>) null).newInstance((Object[]) null);
|
return customManager.getConstructor().newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable {
|
public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable {
|
||||||
return clazz.getConstructor((Class<?>) null).newInstance((Object[]) null);
|
return clazz.getConstructor().newInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.io.FileReader;
|
|||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
@@ -138,7 +139,7 @@ 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[USERNAME];
|
||||||
long lastPlayed = 0;
|
long lastPlayed = 0;
|
||||||
boolean rewrite = false;
|
boolean rewrite = false;
|
||||||
try {
|
try {
|
||||||
@@ -213,7 +214,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
// Write out the same file but when we get to the player we want to remove, we skip his line.
|
// Write out the same file but when we get to the player we want to remove, we skip his line.
|
||||||
if (!worked && line.split(":")[0].equalsIgnoreCase(playerName)) {
|
if (!worked && line.split(":")[USERNAME].equalsIgnoreCase(playerName)) {
|
||||||
mcMMO.p.getLogger().info("User found, removing...");
|
mcMMO.p.getLogger().info("User found, removing...");
|
||||||
worked = true;
|
worked = true;
|
||||||
continue; // Skip the player
|
continue; // Skip the player
|
||||||
@@ -272,7 +273,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
// Read the line in and copy it to the output if it's not the player we want to edit
|
// Read the line in and copy it to the output if it's not the player we want to edit
|
||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
if (!character[41].equalsIgnoreCase(uuid.toString()) && !character[0].equalsIgnoreCase(playerName)) {
|
if (!(uuid != null && character[UUID_INDEX].equalsIgnoreCase(uuid.toString())) && !character[USERNAME].equalsIgnoreCase(playerName)) {
|
||||||
writer.append(line).append("\r\n");
|
writer.append(line).append("\r\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -300,7 +301,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
writer.append(profile.getSkillXpLevel(SkillType.SWORDS)).append(":");
|
writer.append(profile.getSkillXpLevel(SkillType.SWORDS)).append(":");
|
||||||
writer.append(profile.getSkillXpLevel(SkillType.AXES)).append(":");
|
writer.append(profile.getSkillXpLevel(SkillType.AXES)).append(":");
|
||||||
writer.append(profile.getSkillXpLevel(SkillType.ACROBATICS)).append(":");
|
writer.append(profile.getSkillXpLevel(SkillType.ACROBATICS)).append(":");
|
||||||
writer.append((int) profile.getAbilityDATS(AbilityType.CHARGE)).append(":");
|
writer.append(":");
|
||||||
writer.append(profile.getSkillLevel(SkillType.TAMING)).append(":");
|
writer.append(profile.getSkillLevel(SkillType.TAMING)).append(":");
|
||||||
writer.append(profile.getSkillXpLevel(SkillType.TAMING)).append(":");
|
writer.append(profile.getSkillXpLevel(SkillType.TAMING)).append(":");
|
||||||
writer.append((int) profile.getAbilityDATS(AbilityType.BERSERK)).append(":");
|
writer.append((int) profile.getAbilityDATS(AbilityType.BERSERK)).append(":");
|
||||||
@@ -319,7 +320,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
writer.append(mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":");
|
writer.append(mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":");
|
||||||
writer.append(profile.getSkillLevel(SkillType.ALCHEMY)).append(":");
|
writer.append(profile.getSkillLevel(SkillType.ALCHEMY)).append(":");
|
||||||
writer.append(profile.getSkillXpLevel(SkillType.ALCHEMY)).append(":");
|
writer.append(profile.getSkillXpLevel(SkillType.ALCHEMY)).append(":");
|
||||||
writer.append(uuid.toString()).append(":");
|
writer.append(uuid != null ? uuid.toString() : "NULL").append(":");
|
||||||
writer.append(profile.getScoreboardTipsShown()).append(":");
|
writer.append(profile.getScoreboardTipsShown()).append(":");
|
||||||
writer.append("\r\n");
|
writer.append("\r\n");
|
||||||
}
|
}
|
||||||
@@ -408,7 +409,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
out.append("0:"); // SwordsXp
|
out.append("0:"); // SwordsXp
|
||||||
out.append("0:"); // AxesXp
|
out.append("0:"); // AxesXp
|
||||||
out.append("0:"); // AcrobaticsXp
|
out.append("0:"); // AcrobaticsXp
|
||||||
out.append("0:"); // DATS
|
out.append(":");
|
||||||
out.append("0:"); // Taming
|
out.append("0:"); // Taming
|
||||||
out.append("0:"); // TamingXp
|
out.append("0:"); // TamingXp
|
||||||
out.append("0:"); // DATS
|
out.append("0:"); // DATS
|
||||||
@@ -473,20 +474,20 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
// Compare names because we don't have a valid uuid for that player even
|
// Compare names because we don't have a valid uuid for that player even
|
||||||
// if input uuid is not null
|
// if input uuid is not null
|
||||||
if (character[41].equalsIgnoreCase("NULL")) {
|
if (character[UUID_INDEX].equalsIgnoreCase("NULL")) {
|
||||||
if (!character[0].equalsIgnoreCase(playerName)) {
|
if (!character[USERNAME].equalsIgnoreCase(playerName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If input uuid is not null then we should compare uuids
|
// If input uuid is not null then we should compare uuids
|
||||||
else if ((uuid != null && !character[41].equalsIgnoreCase(uuid.toString())) || (uuid == null && !character[0].equalsIgnoreCase(playerName))) {
|
else if ((uuid != null && !character[UUID_INDEX].equalsIgnoreCase(uuid.toString())) || (uuid == null && !character[USERNAME].equalsIgnoreCase(playerName))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update playerName in database after name change
|
// Update playerName in database after name change
|
||||||
if (!character[0].equalsIgnoreCase(playerName)) {
|
if (!character[USERNAME].equalsIgnoreCase(playerName)) {
|
||||||
mcMMO.p.debug("Name change detected: " + character[0] + " => " + playerName);
|
mcMMO.p.debug("Name change detected: " + character[USERNAME] + " => " + playerName);
|
||||||
character[0] = playerName;
|
character[USERNAME] = playerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return loadFromLine(character);
|
return loadFromLine(character);
|
||||||
@@ -572,6 +573,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
public boolean saveUserUUID(String userName, UUID uuid) {
|
public boolean saveUserUUID(String userName, UUID uuid) {
|
||||||
boolean worked = false;
|
boolean worked = false;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
FileWriter out = null;
|
FileWriter out = null;
|
||||||
String usersFilePath = mcMMO.getUsersFilePath();
|
String usersFilePath = mcMMO.getUsersFilePath();
|
||||||
@@ -584,17 +586,18 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
if (!worked && character[0].equalsIgnoreCase(userName)) {
|
if (!worked && character[USERNAME].equalsIgnoreCase(userName)) {
|
||||||
if (character.length < 42) {
|
if (character.length < 42) {
|
||||||
mcMMO.p.getLogger().severe("Could not update UUID for " + userName + "!");
|
mcMMO.p.getLogger().severe("Could not update UUID for " + userName + "!");
|
||||||
mcMMO.p.getLogger().severe("Database entry is invalid.");
|
mcMMO.p.getLogger().severe("Database entry is invalid.");
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
line = line.replace(character[41], uuid.toString());
|
line = line.replace(character[UUID_INDEX], uuid.toString());
|
||||||
worked = true;
|
worked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
writer.append(line).append("\r\n");
|
writer.append(line).append("\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -605,6 +608,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
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 + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
mcMMO.p.getLogger().info(i + " entries written while saving UUID for " + userName);
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
try {
|
try {
|
||||||
in.close();
|
in.close();
|
||||||
@@ -631,6 +635,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
FileWriter out = null;
|
FileWriter out = null;
|
||||||
String usersFilePath = mcMMO.getUsersFilePath();
|
String usersFilePath = mcMMO.getUsersFilePath();
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
synchronized (fileWritingLock) {
|
synchronized (fileWritingLock) {
|
||||||
try {
|
try {
|
||||||
@@ -638,19 +643,20 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
StringBuilder writer = new StringBuilder();
|
StringBuilder writer = new StringBuilder();
|
||||||
String line;
|
String line;
|
||||||
|
|
||||||
while (((line = in.readLine()) != null) && !fetchedUUIDs.isEmpty()) {
|
while (((line = in.readLine()) != null)) {
|
||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
if (fetchedUUIDs.containsKey(character[0])) {
|
if (!fetchedUUIDs.isEmpty() && fetchedUUIDs.containsKey(character[USERNAME])) {
|
||||||
if (character.length < 42) {
|
if (character.length < 42) {
|
||||||
mcMMO.p.getLogger().severe("Could not update UUID for " + character[0] + "!");
|
mcMMO.p.getLogger().severe("Could not update UUID for " + character[USERNAME] + "!");
|
||||||
mcMMO.p.getLogger().severe("Database entry is invalid.");
|
mcMMO.p.getLogger().severe("Database entry is invalid.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
character[41] = fetchedUUIDs.remove(character[0]).toString();
|
character[UUID_INDEX] = fetchedUUIDs.remove(character[USERNAME]).toString();
|
||||||
line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString();
|
line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
writer.append(line).append("\r\n");
|
writer.append(line).append("\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -661,6 +667,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
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 + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
mcMMO.p.getLogger().info(i + " entries written while saving UUID batch");
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
try {
|
try {
|
||||||
in.close();
|
in.close();
|
||||||
@@ -696,7 +703,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
users.add(character[0]);
|
users.add(character[USERNAME]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
@@ -754,7 +761,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
String[] data = line.split(":");
|
String[] data = line.split(":");
|
||||||
playerName = data[0];
|
playerName = data[USERNAME];
|
||||||
int powerLevel = 0;
|
int powerLevel = 0;
|
||||||
|
|
||||||
Map<SkillType, Integer> skills = getSkillMapFromLine(data);
|
Map<SkillType, Integer> skills = getSkillMapFromLine(data);
|
||||||
@@ -850,15 +857,20 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
if (line.charAt(line.length() - 1) != ':') {
|
if (line.charAt(line.length() - 1) != ':') {
|
||||||
line = line.concat(":");
|
line = line.concat(":");
|
||||||
}
|
}
|
||||||
|
boolean updated = false;
|
||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
|
|
||||||
// Prevent the same username from being present multiple times
|
// Prevent the same username from being present multiple times
|
||||||
if (!usernames.add(character[0])) {
|
if (!usernames.add(character[USERNAME])) {
|
||||||
continue;
|
character[USERNAME] = "_INVALID_OLD_USERNAME_'";
|
||||||
|
updated = true;
|
||||||
|
if (character.length < UUID_INDEX + 1 || character[UUID_INDEX].equals("NULL")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent the same player from being present multiple times
|
// Prevent the same player from being present multiple times
|
||||||
if (character.length == 42 && (!character[41].isEmpty() && !players.add(character[41]))) {
|
if (character.length >= 42 && (!character[UUID_INDEX].isEmpty() && !character[UUID_INDEX].equals("NULL") && !players.add(character[UUID_INDEX]))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -870,48 +882,54 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
String oldVersion = null;
|
String oldVersion = null;
|
||||||
|
|
||||||
if (character.length <= 33) {
|
if (character.length > 33 && !character[33].isEmpty()) {
|
||||||
// Introduction of HUDType
|
|
||||||
// Version 1.1.06
|
|
||||||
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
|
|
||||||
line = line.concat(" :");
|
|
||||||
character = line.split(":");
|
|
||||||
oldVersion = "1.1.06";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!character[33].isEmpty()) {
|
|
||||||
// Removal of Spout Support
|
// Removal of Spout Support
|
||||||
// Version 1.4.07-dev2
|
// Version 1.4.07-dev2
|
||||||
// commit 7bac0e2ca5143bce84dc160617fed97f0b1cb968
|
// commit 7bac0e2ca5143bce84dc160617fed97f0b1cb968
|
||||||
line = line.replace(character[33], "");
|
character[33] = "";
|
||||||
if (oldVersion == null) {
|
if (oldVersion == null) {
|
||||||
oldVersion = "1.4.07";
|
oldVersion = "1.4.07";
|
||||||
}
|
}
|
||||||
|
updated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (character[23].isEmpty()) {
|
if (Config.getInstance().getTruncateSkills()) {
|
||||||
// Addition of "Charge" Taming ability
|
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||||
// Version 1.5.02
|
int index = getSkillIndex(skill);
|
||||||
line = line.replace(character[23], "0:");
|
if (index >= character.length) {
|
||||||
if (oldVersion == null) {
|
continue;
|
||||||
oldVersion = "1.5.02";
|
}
|
||||||
|
int cap = Config.getInstance().getLevelCap(skill);
|
||||||
|
if (Integer.valueOf(character[index]) > cap) {
|
||||||
|
mcMMO.p.getLogger().warning("Truncating " + skill.getName() + " to configured max level for player " + character[USERNAME]);
|
||||||
|
character[index] = cap + "";
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If they're valid, rewrite them to the file.
|
// If they're valid, rewrite them to the file.
|
||||||
if (character.length == 42) {
|
if (!updated && character.length == 43) {
|
||||||
writer.append(line).append("\r\n");
|
writer.append(line).append("\r\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder newLine = new StringBuilder(line);
|
if (character.length <= 33) {
|
||||||
|
// Introduction of HUDType
|
||||||
|
// Version 1.1.06
|
||||||
|
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
|
||||||
|
character = Arrays.copyOf(character, character.length + 1);
|
||||||
|
character[character.length - 1] = "";
|
||||||
|
oldVersion = "1.1.06";
|
||||||
|
}
|
||||||
|
|
||||||
if (character.length <= 35) {
|
if (character.length <= 35) {
|
||||||
// Introduction of Fishing
|
// Introduction of Fishing
|
||||||
// Version 1.2.00
|
// Version 1.2.00
|
||||||
// commit a814b57311bc7734661109f0e77fc8bab3a0bd29
|
// commit a814b57311bc7734661109f0e77fc8bab3a0bd29
|
||||||
newLine.append(0).append(":");
|
character = Arrays.copyOf(character, character.length + 2);
|
||||||
newLine.append(0).append(":");
|
character[character.length - 1] = "0";
|
||||||
|
character[character.length - 2] = "0";
|
||||||
if (oldVersion == null) {
|
if (oldVersion == null) {
|
||||||
oldVersion = "1.2.00";
|
oldVersion = "1.2.00";
|
||||||
}
|
}
|
||||||
@@ -920,7 +938,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
// Introduction of Blast Mining cooldowns
|
// Introduction of Blast Mining cooldowns
|
||||||
// Version 1.3.00-dev
|
// Version 1.3.00-dev
|
||||||
// commit fadbaf429d6b4764b8f1ad0efaa524a090e82ef5
|
// commit fadbaf429d6b4764b8f1ad0efaa524a090e82ef5
|
||||||
newLine.append(0).append(":");
|
character = Arrays.copyOf(character, character.length + 1);
|
||||||
|
character[character.length - 1] = "0";
|
||||||
if (oldVersion == null) {
|
if (oldVersion == null) {
|
||||||
oldVersion = "1.3.00";
|
oldVersion = "1.3.00";
|
||||||
}
|
}
|
||||||
@@ -930,7 +949,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
// Version 1.4.00-dev
|
// Version 1.4.00-dev
|
||||||
// commmit 3f6c07ba6aaf44e388cc3b882cac3d8f51d0ac28
|
// commmit 3f6c07ba6aaf44e388cc3b882cac3d8f51d0ac28
|
||||||
// XXX Cannot create an OfflinePlayer at startup, use 0 and fix in purge
|
// XXX Cannot create an OfflinePlayer at startup, use 0 and fix in purge
|
||||||
newLine.append("0").append(":");
|
character = Arrays.copyOf(character, character.length + 1);
|
||||||
|
character[character.length - 1] = "0";
|
||||||
if (oldVersion == null) {
|
if (oldVersion == null) {
|
||||||
oldVersion = "1.4.00";
|
oldVersion = "1.4.00";
|
||||||
}
|
}
|
||||||
@@ -939,7 +959,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
// Addition of mob healthbars
|
// Addition of mob healthbars
|
||||||
// Version 1.4.06
|
// Version 1.4.06
|
||||||
// commit da29185b7dc7e0d992754bba555576d48fa08aa6
|
// commit da29185b7dc7e0d992754bba555576d48fa08aa6
|
||||||
newLine.append(Config.getInstance().getMobHealthbarDefault().toString()).append(":");
|
character = Arrays.copyOf(character, character.length + 1);
|
||||||
|
character[character.length - 1] = Config.getInstance().getMobHealthbarDefault().toString();
|
||||||
if (oldVersion == null) {
|
if (oldVersion == null) {
|
||||||
oldVersion = "1.4.06";
|
oldVersion = "1.4.06";
|
||||||
}
|
}
|
||||||
@@ -947,8 +968,9 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
if (character.length <= 39) {
|
if (character.length <= 39) {
|
||||||
// Addition of Alchemy
|
// Addition of Alchemy
|
||||||
// Version 1.4.08
|
// Version 1.4.08
|
||||||
newLine.append("0").append(":");
|
character = Arrays.copyOf(character, character.length + 2);
|
||||||
newLine.append("0").append(":");
|
character[character.length - 1] = "0";
|
||||||
|
character[character.length - 2] = "0";
|
||||||
if (oldVersion == null) {
|
if (oldVersion == null) {
|
||||||
oldVersion = "1.4.08";
|
oldVersion = "1.4.08";
|
||||||
}
|
}
|
||||||
@@ -957,7 +979,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
// Addition of UUIDs
|
// Addition of UUIDs
|
||||||
// Version 1.5.01
|
// Version 1.5.01
|
||||||
// Add a value because otherwise it gets removed
|
// Add a value because otherwise it gets removed
|
||||||
newLine.append("NULL:");
|
character = Arrays.copyOf(character, character.length + 1);
|
||||||
|
character[character.length - 1] = "NULL";
|
||||||
if (oldVersion == null) {
|
if (oldVersion == null) {
|
||||||
oldVersion = "1.5.01";
|
oldVersion = "1.5.01";
|
||||||
}
|
}
|
||||||
@@ -965,61 +988,66 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
if (character.length <= 42) {
|
if (character.length <= 42) {
|
||||||
// Addition of scoreboard tips auto disable
|
// Addition of scoreboard tips auto disable
|
||||||
// Version 1.5.02
|
// Version 1.5.02
|
||||||
newLine.append("0").append(":");
|
character = Arrays.copyOf(character, character.length + 1);
|
||||||
|
character[character.length - 1] = "0";
|
||||||
if (oldVersion == null) {
|
if (oldVersion == null) {
|
||||||
oldVersion = "1.5.02";
|
oldVersion = "1.5.02";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove any blanks that shouldn't be there, and validate the other fields
|
|
||||||
String[] newCharacter = newLine.toString().split(":");
|
|
||||||
boolean corrupted = false;
|
boolean corrupted = false;
|
||||||
|
|
||||||
for (int i = 0; i < newCharacter.length; i++) {
|
for (int i = 0; i < character.length; i++) {
|
||||||
if (newCharacter[i].isEmpty() && !(i == 2 || i == 3 || i == 23 || i == 33 || i == 41)) {
|
if (character[i].isEmpty() && !(i == 2 || i == 3 || i == 23 || i == 33 || i == 41)) {
|
||||||
corrupted = true;
|
corrupted = true;
|
||||||
|
if (i == 37) {
|
||||||
if (newCharacter.length != 42) {
|
character[i] = String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||||
newCharacter = (String[]) ArrayUtils.remove(newCharacter, i);
|
}
|
||||||
|
else if (i == 38) {
|
||||||
|
character[i] = Config.getInstance().getMobHealthbarDefault().toString();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (i == 37) {
|
character[i] = "0";
|
||||||
newCharacter[i] = String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
|
||||||
}
|
|
||||||
else if (i == 38) {
|
|
||||||
newCharacter[i] = Config.getInstance().getMobHealthbarDefault().toString();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
newCharacter[i] = "0";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isInt(newCharacter[i]) && i == 38) {
|
if (StringUtils.isInt(character[i]) && i == 38) {
|
||||||
corrupted = true;
|
corrupted = true;
|
||||||
newCharacter[i] = Config.getInstance().getMobHealthbarDefault().toString();
|
character[i] = Config.getInstance().getMobHealthbarDefault().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!StringUtils.isInt(newCharacter[i]) && !(i == 0 || i == 2 || i == 3 || i == 23 || i == 33 || i == 38 || i == 41)) {
|
if (!StringUtils.isInt(character[i]) && !(i == 0 || i == 2 || i == 3 || i == 23 || i == 33 || i == 38 || i == 41)) {
|
||||||
corrupted = true;
|
corrupted = true;
|
||||||
newCharacter[i] = "0";
|
character[i] = "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (corrupted) {
|
if (corrupted) {
|
||||||
mcMMO.p.debug("Updating corrupted database line for player " + newCharacter[0]);
|
mcMMO.p.debug("Updating corrupted database line for player " + character[USERNAME]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldVersion != null) {
|
if (oldVersion != null) {
|
||||||
mcMMO.p.debug("Updating database line from before version " + oldVersion + " for player " + character[0]);
|
mcMMO.p.debug("Updating database line from before version " + oldVersion + " for player " + character[USERNAME]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (corrupted || oldVersion != null) {
|
updated |= corrupted;
|
||||||
newLine = new StringBuilder(org.apache.commons.lang.StringUtils.join(newCharacter, ":"));
|
updated |= oldVersion != null;
|
||||||
newLine = newLine.append(":");
|
|
||||||
|
if (Config.getInstance().getTruncateSkills()) {
|
||||||
|
Map<SkillType, Integer> skills = getSkillMapFromLine(character);
|
||||||
|
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||||
|
int cap = Config.getInstance().getLevelCap(skill);
|
||||||
|
if (skills.get(skill) > cap) {
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.append(newLine).append("\r\n");
|
if (updated) {
|
||||||
|
line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.append(line).append("\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write the new file
|
// Write the new file
|
||||||
@@ -1109,35 +1137,35 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
// TODO on updates, put new values in a try{} ?
|
// TODO on updates, put new values in a try{} ?
|
||||||
|
|
||||||
skillsXp.put(SkillType.TAMING, (float) Integer.valueOf(character[25]));
|
skillsXp.put(SkillType.TAMING, (float) Integer.valueOf(character[EXP_TAMING]));
|
||||||
skillsXp.put(SkillType.MINING, (float) Integer.valueOf(character[4]));
|
skillsXp.put(SkillType.MINING, (float) Integer.valueOf(character[EXP_MINING]));
|
||||||
skillsXp.put(SkillType.REPAIR, (float) Integer.valueOf(character[15]));
|
skillsXp.put(SkillType.REPAIR, (float) Integer.valueOf(character[EXP_REPAIR]));
|
||||||
skillsXp.put(SkillType.WOODCUTTING, (float) Integer.valueOf(character[6]));
|
skillsXp.put(SkillType.WOODCUTTING, (float) Integer.valueOf(character[EXP_WOODCUTTING]));
|
||||||
skillsXp.put(SkillType.UNARMED, (float) Integer.valueOf(character[16]));
|
skillsXp.put(SkillType.UNARMED, (float) Integer.valueOf(character[EXP_UNARMED]));
|
||||||
skillsXp.put(SkillType.HERBALISM, (float) Integer.valueOf(character[17]));
|
skillsXp.put(SkillType.HERBALISM, (float) Integer.valueOf(character[EXP_HERBALISM]));
|
||||||
skillsXp.put(SkillType.EXCAVATION, (float) Integer.valueOf(character[18]));
|
skillsXp.put(SkillType.EXCAVATION, (float) Integer.valueOf(character[EXP_EXCAVATION]));
|
||||||
skillsXp.put(SkillType.ARCHERY, (float) Integer.valueOf(character[19]));
|
skillsXp.put(SkillType.ARCHERY, (float) Integer.valueOf(character[EXP_ARCHERY]));
|
||||||
skillsXp.put(SkillType.SWORDS, (float) Integer.valueOf(character[20]));
|
skillsXp.put(SkillType.SWORDS, (float) Integer.valueOf(character[EXP_SWORDS]));
|
||||||
skillsXp.put(SkillType.AXES, (float) Integer.valueOf(character[21]));
|
skillsXp.put(SkillType.AXES, (float) Integer.valueOf(character[EXP_AXES]));
|
||||||
skillsXp.put(SkillType.ACROBATICS, (float) Integer.valueOf(character[22]));
|
skillsXp.put(SkillType.ACROBATICS, (float) Integer.valueOf(character[EXP_ACROBATICS]));
|
||||||
skillsXp.put(SkillType.FISHING, (float) Integer.valueOf(character[35]));
|
skillsXp.put(SkillType.FISHING, (float) Integer.valueOf(character[EXP_FISHING]));
|
||||||
skillsXp.put(SkillType.ALCHEMY, (float) Integer.valueOf(character[40]));
|
skillsXp.put(SkillType.ALCHEMY, (float) Integer.valueOf(character[EXP_ALCHEMY]));
|
||||||
|
|
||||||
skillsDATS.put(AbilityType.CHARGE, Integer.valueOf(character[23]));
|
// Taming - Unused
|
||||||
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32]));
|
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[COOLDOWN_SUPER_BREAKER]));
|
||||||
// Repair - Unused
|
// Repair - Unused
|
||||||
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(character[28]));
|
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(character[COOLDOWN_TREE_FELLER]));
|
||||||
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[26]));
|
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[COOLDOWN_BERSERK]));
|
||||||
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(character[29]));
|
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(character[COOLDOWN_GREEN_TERRA]));
|
||||||
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(character[27]));
|
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(character[COOLDOWN_GIGA_DRILL_BREAKER]));
|
||||||
// Archery - Unused
|
// Archery - Unused
|
||||||
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(character[30]));
|
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(character[COOLDOWN_SERRATED_STRIKES]));
|
||||||
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(character[31]));
|
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(character[COOLDOWN_SKULL_SPLITTER]));
|
||||||
// Acrobatics - Unused
|
// Acrobatics - Unused
|
||||||
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36]));
|
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[COOLDOWN_BLAST_MINING]));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mobHealthbarType = MobHealthbarType.valueOf(character[38]);
|
mobHealthbarType = MobHealthbarType.valueOf(character[HEALTHBAR]);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||||
@@ -1145,37 +1173,38 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
try {
|
try {
|
||||||
uuid = UUID.fromString(character[41]);
|
uuid = UUID.fromString(character[UUID_INDEX]);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
uuid = null;
|
uuid = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
scoreboardTipsShown = Integer.valueOf(character[41]);
|
scoreboardTipsShown = Integer.valueOf(character[SCOREBOARD_TIPS]);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
scoreboardTipsShown = 0;
|
scoreboardTipsShown = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PlayerProfile(character[0], uuid, skills, skillsXp, skillsDATS, mobHealthbarType, scoreboardTipsShown);
|
return new PlayerProfile(character[USERNAME], uuid, skills, skillsXp, skillsDATS, mobHealthbarType, scoreboardTipsShown);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<SkillType, Integer> getSkillMapFromLine(String[] character) {
|
private Map<SkillType, Integer> getSkillMapFromLine(String[] character) {
|
||||||
Map<SkillType, Integer> skills = new EnumMap<SkillType, Integer>(SkillType.class); // Skill & Level
|
Map<SkillType, Integer> skills = new EnumMap<SkillType, Integer>(SkillType.class); // Skill & Level
|
||||||
|
|
||||||
skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
|
skills.put(SkillType.TAMING, Integer.valueOf(character[SKILLS_TAMING]));
|
||||||
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
|
skills.put(SkillType.MINING, Integer.valueOf(character[SKILLS_MINING]));
|
||||||
skills.put(SkillType.REPAIR, Integer.valueOf(character[7]));
|
skills.put(SkillType.REPAIR, Integer.valueOf(character[SKILLS_REPAIR]));
|
||||||
skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5]));
|
skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[SKILLS_WOODCUTTING]));
|
||||||
skills.put(SkillType.UNARMED, Integer.valueOf(character[8]));
|
skills.put(SkillType.UNARMED, Integer.valueOf(character[SKILLS_UNARMED]));
|
||||||
skills.put(SkillType.HERBALISM, Integer.valueOf(character[9]));
|
skills.put(SkillType.HERBALISM, Integer.valueOf(character[SKILLS_HERBALISM]));
|
||||||
skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10]));
|
skills.put(SkillType.EXCAVATION, Integer.valueOf(character[SKILLS_EXCAVATION]));
|
||||||
skills.put(SkillType.ARCHERY, Integer.valueOf(character[11]));
|
skills.put(SkillType.ARCHERY, Integer.valueOf(character[SKILLS_ARCHERY]));
|
||||||
skills.put(SkillType.SWORDS, Integer.valueOf(character[12]));
|
skills.put(SkillType.SWORDS, Integer.valueOf(character[SKILLS_SWORDS]));
|
||||||
skills.put(SkillType.AXES, Integer.valueOf(character[13]));
|
skills.put(SkillType.AXES, Integer.valueOf(character[SKILLS_AXES]));
|
||||||
skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14]));
|
skills.put(SkillType.ACROBATICS, Integer.valueOf(character[SKILLS_ACROBATICS]));
|
||||||
skills.put(SkillType.FISHING, Integer.valueOf(character[34]));
|
skills.put(SkillType.FISHING, Integer.valueOf(character[SKILLS_FISHING]));
|
||||||
skills.put(SkillType.ALCHEMY, Integer.valueOf(character[39]));
|
skills.put(SkillType.ALCHEMY, Integer.valueOf(character[SKILLS_ALCHEMY]));
|
||||||
|
|
||||||
return skills;
|
return skills;
|
||||||
}
|
}
|
||||||
@@ -1186,4 +1215,131 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() { }
|
public void onDisable() { }
|
||||||
|
|
||||||
|
private int getSkillIndex(SkillType skill) {
|
||||||
|
switch (skill) {
|
||||||
|
case ACROBATICS:
|
||||||
|
return SKILLS_ACROBATICS;
|
||||||
|
case ALCHEMY:
|
||||||
|
return SKILLS_ALCHEMY;
|
||||||
|
case ARCHERY:
|
||||||
|
return SKILLS_ARCHERY;
|
||||||
|
case AXES:
|
||||||
|
return SKILLS_AXES;
|
||||||
|
case EXCAVATION:
|
||||||
|
return SKILLS_EXCAVATION;
|
||||||
|
case FISHING:
|
||||||
|
return SKILLS_FISHING;
|
||||||
|
case HERBALISM:
|
||||||
|
return SKILLS_HERBALISM;
|
||||||
|
case MINING:
|
||||||
|
return SKILLS_MINING;
|
||||||
|
case REPAIR:
|
||||||
|
return SKILLS_REPAIR;
|
||||||
|
case SWORDS:
|
||||||
|
return SKILLS_SWORDS;
|
||||||
|
case TAMING:
|
||||||
|
return SKILLS_TAMING;
|
||||||
|
case UNARMED:
|
||||||
|
return SKILLS_UNARMED;
|
||||||
|
case WOODCUTTING:
|
||||||
|
return SKILLS_WOODCUTTING;
|
||||||
|
default:
|
||||||
|
throw new RuntimeException("Primary Skills only");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int USERNAME = 0;
|
||||||
|
public static int SKILLS_MINING = 1;
|
||||||
|
public static int EXP_MINING = 4;
|
||||||
|
public static int SKILLS_WOODCUTTING = 5;
|
||||||
|
public static int EXP_WOODCUTTING = 6;
|
||||||
|
public static int SKILLS_REPAIR = 7;
|
||||||
|
public static int SKILLS_UNARMED = 8;
|
||||||
|
public static int SKILLS_HERBALISM = 9;
|
||||||
|
public static int SKILLS_EXCAVATION = 10;
|
||||||
|
public static int SKILLS_ARCHERY = 11;
|
||||||
|
public static int SKILLS_SWORDS = 12;
|
||||||
|
public static int SKILLS_AXES = 13;
|
||||||
|
public static int SKILLS_ACROBATICS = 14;
|
||||||
|
public static int EXP_REPAIR = 15;
|
||||||
|
public static int EXP_UNARMED = 16;
|
||||||
|
public static int EXP_HERBALISM = 17;
|
||||||
|
public static int EXP_EXCAVATION = 18;
|
||||||
|
public static int EXP_ARCHERY = 19;
|
||||||
|
public static int EXP_SWORDS = 20;
|
||||||
|
public static int EXP_AXES = 21;
|
||||||
|
public static int EXP_ACROBATICS = 22;
|
||||||
|
public static int SKILLS_TAMING = 24;
|
||||||
|
public static int EXP_TAMING = 25;
|
||||||
|
public static int COOLDOWN_BERSERK = 26;
|
||||||
|
public static int COOLDOWN_GIGA_DRILL_BREAKER = 27;
|
||||||
|
public static int COOLDOWN_TREE_FELLER = 28;
|
||||||
|
public static int COOLDOWN_GREEN_TERRA = 29;
|
||||||
|
public static int COOLDOWN_SERRATED_STRIKES = 30;
|
||||||
|
public static int COOLDOWN_SKULL_SPLITTER = 31;
|
||||||
|
public static int COOLDOWN_SUPER_BREAKER = 32;
|
||||||
|
public static int SKILLS_FISHING = 34;
|
||||||
|
public static int EXP_FISHING = 35;
|
||||||
|
public static int COOLDOWN_BLAST_MINING = 36;
|
||||||
|
public static int LAST_LOGIN = 37;
|
||||||
|
public static int HEALTHBAR = 38;
|
||||||
|
public static int SKILLS_ALCHEMY = 39;
|
||||||
|
public static int EXP_ALCHEMY = 40;
|
||||||
|
public static int UUID_INDEX = 41;
|
||||||
|
public static int SCOREBOARD_TIPS = 42;
|
||||||
|
|
||||||
|
public void resetMobHealthSettings() {
|
||||||
|
BufferedReader in = null;
|
||||||
|
FileWriter out = null;
|
||||||
|
String usersFilePath = mcMMO.getUsersFilePath();
|
||||||
|
|
||||||
|
synchronized (fileWritingLock) {
|
||||||
|
try {
|
||||||
|
in = new BufferedReader(new FileReader(usersFilePath));
|
||||||
|
StringBuilder writer = new StringBuilder();
|
||||||
|
String line;
|
||||||
|
|
||||||
|
while ((line = in.readLine()) != null) {
|
||||||
|
// Remove empty lines from the file
|
||||||
|
if (line.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String[] character = line.split(":");
|
||||||
|
|
||||||
|
character[HEALTHBAR] = Config.getInstance().getMobHealthbarDefault().toString();
|
||||||
|
|
||||||
|
line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString();
|
||||||
|
|
||||||
|
writer.append(line).append("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write the new file
|
||||||
|
out = new FileWriter(usersFilePath);
|
||||||
|
out.write(writer.toString());
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (in != null) {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (out != null) {
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -10,5 +10,7 @@ public enum UpgradeType {
|
|||||||
ADD_ALCHEMY,
|
ADD_ALCHEMY,
|
||||||
ADD_UUIDS,
|
ADD_UUIDS,
|
||||||
ADD_UUIDS_PARTY,
|
ADD_UUIDS_PARTY,
|
||||||
ADD_SCOREBOARD_TIPS;
|
ADD_SCOREBOARD_TIPS,
|
||||||
|
DROP_NAME_UNIQUENESS,
|
||||||
|
ADD_SKILL_TOTAL,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
package com.gmail.nossr50.datatypes.party;
|
package com.gmail.nossr50.datatypes.party;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@@ -7,20 +20,6 @@ import java.util.List;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
|
|
||||||
public class Party {
|
public class Party {
|
||||||
private final LinkedHashMap<UUID, String> members = new LinkedHashMap<UUID, String>();
|
private final LinkedHashMap<UUID, String> members = new LinkedHashMap<UUID, String>();
|
||||||
private final List<Player> onlineMembers = new ArrayList<Player>();
|
private final List<Player> onlineMembers = new ArrayList<Player>();
|
||||||
@@ -227,7 +226,7 @@ public class Party {
|
|||||||
leader.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, getLevel()));
|
leader.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, getLevel()));
|
||||||
|
|
||||||
if (Config.getInstance().getLevelUpSoundsEnabled()) {
|
if (Config.getInstance().getLevelUpSoundsEnabled()) {
|
||||||
leader.playSound(leader.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
leader.playSound(leader.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -337,7 +336,7 @@ public class Party {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!nearMembers.contains(member) && !playerName.equalsIgnoreCase(memberName)) {
|
if (!nearMembers.contains(member) && !playerName.equalsIgnoreCase(memberName)) {
|
||||||
memberList.append(ChatColor.ITALIC).append("");
|
memberList.append(ChatColor.ITALIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
memberList.append(memberName).append(ChatColor.RESET).append(" ");
|
memberList.append(memberName).append(ChatColor.RESET).append(" ");
|
||||||
|
|||||||
@@ -1,20 +1,5 @@
|
|||||||
package com.gmail.nossr50.datatypes.player;
|
package com.gmail.nossr50.datatypes.player;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
@@ -27,6 +12,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
|
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
|
||||||
@@ -46,7 +32,6 @@ import com.gmail.nossr50.skills.repair.RepairManager;
|
|||||||
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
||||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||||
import com.gmail.nossr50.skills.taming.Taming;
|
|
||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||||
@@ -59,8 +44,18 @@ import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
|||||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class McMMOPlayer {
|
public class McMMOPlayer {
|
||||||
private Player player;
|
private Player player;
|
||||||
@@ -104,12 +99,6 @@ public class McMMOPlayer {
|
|||||||
this.player = player;
|
this.player = player;
|
||||||
playerMetadata = new FixedMetadataValue(mcMMO.p, playerName);
|
playerMetadata = new FixedMetadataValue(mcMMO.p, playerName);
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
party = PartyManager.getPlayerParty(playerName, uuid);
|
|
||||||
ptpRecord = new PartyTeleportRecord();
|
|
||||||
|
|
||||||
if (inParty()) {
|
|
||||||
loginParty();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (profile.getUniqueId() == null) {
|
if (profile.getUniqueId() == null) {
|
||||||
profile.setUniqueId(uuid);
|
profile.setUniqueId(uuid);
|
||||||
@@ -513,7 +502,7 @@ public class McMMOPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getLevelUpSoundsEnabled()) {
|
if (Config.getInstance().getLevelUpSoundsEnabled()) {
|
||||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(skillType.toString()) + ".Skillup", levelsGained, getSkillLevel(skillType)));
|
player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(skillType.toString()) + ".Skillup", levelsGained, getSkillLevel(skillType)));
|
||||||
@@ -535,6 +524,15 @@ public class McMMOPlayer {
|
|||||||
* Party Stuff
|
* Party Stuff
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
public void setupPartyData() {
|
||||||
|
party = PartyManager.getPlayerParty(player.getName(), player.getUniqueId());
|
||||||
|
ptpRecord = new PartyTeleportRecord();
|
||||||
|
|
||||||
|
if (inParty()) {
|
||||||
|
loginParty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setPartyInvite(Party invite) {
|
public void setPartyInvite(Party invite) {
|
||||||
this.invite = invite;
|
this.invite = invite;
|
||||||
}
|
}
|
||||||
@@ -689,7 +687,7 @@ public class McMMOPlayer {
|
|||||||
xp = (float) (xp / skillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
|
xp = (float) (xp / skillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
|
||||||
|
|
||||||
if (Config.getInstance().getToolModsEnabled()) {
|
if (Config.getInstance().getToolModsEnabled()) {
|
||||||
CustomTool tool = mcMMO.getModManager().getTool(player.getItemInHand());
|
CustomTool tool = mcMMO.getModManager().getTool(player.getInventory().getItemInMainHand());
|
||||||
|
|
||||||
if (tool != null) {
|
if (tool != null) {
|
||||||
xp *= tool.getXpMultiplier();
|
xp *= tool.getXpMultiplier();
|
||||||
@@ -742,21 +740,6 @@ public class McMMOPlayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LivingEntity livingEntity = null;
|
|
||||||
|
|
||||||
if (ability == AbilityType.CHARGE) {
|
|
||||||
livingEntity = this.getTamingManager().getTarget(20);
|
|
||||||
|
|
||||||
if (!this.getTamingManager().isEntityTypeNearby(EntityType.WOLF, Taming.wolfCommandRange, true)) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Taming.Skills.Charge.NoneNearby"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (livingEntity == null) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Taming.Skills.Charge.NoTarget"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EventUtils.callPlayerAbilityActivateEvent(player, skill).isCancelled()) {
|
if (EventUtils.callPlayerAbilityActivateEvent(player, skill).isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -780,10 +763,6 @@ public class McMMOPlayer {
|
|||||||
SkillUtils.handleAbilitySpeedIncrease(player);
|
SkillUtils.handleAbilitySpeedIncrease(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ability == AbilityType.CHARGE) {
|
|
||||||
this.getTamingManager().handleCharge(livingEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
new AbilityDisableTask(this, ability).runTaskLater(mcMMO.p, ticks * Misc.TICK_CONVERSION_FACTOR);
|
new AbilityDisableTask(this, ability).runTaskLater(mcMMO.p, ticks * Misc.TICK_CONVERSION_FACTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -792,7 +771,7 @@ public class McMMOPlayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack inHand = player.getItemInHand();
|
ItemStack inHand = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
if (mcMMO.getModManager().isCustomTool(inHand) && !mcMMO.getModManager().getTool(inHand).isAbilityEnabled()) {
|
if (mcMMO.getModManager().isCustomTool(inHand) && !mcMMO.getModManager().getTool(inHand).isAbilityEnabled()) {
|
||||||
return;
|
return;
|
||||||
@@ -825,11 +804,6 @@ public class McMMOPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ability == AbilityType.CHARGE && !this.getTamingManager().isEntityTypeNearby(EntityType.WOLF, Taming.wolfCommandRange, true)) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Taming.Skills.Charge.NoneNearby"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.getInstance().getAbilityMessagesEnabled()) {
|
if (Config.getInstance().getAbilityMessagesEnabled()) {
|
||||||
player.sendMessage(tool.getRaiseTool());
|
player.sendMessage(tool.getRaiseTool());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ public class PlayerProfile {
|
|||||||
int sum = 0;
|
int sum = 0;
|
||||||
|
|
||||||
for (SkillType parent : parents) {
|
for (SkillType parent : parents) {
|
||||||
sum += Math.min(getSkillLevel(parent), 1000);
|
sum += Math.min(getSkillLevel(parent), parent.getMaxLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum / parents.size();
|
return sum / parents.size();
|
||||||
|
|||||||
@@ -60,13 +60,6 @@ public enum AbilityType {
|
|||||||
"Swords.Skills.SS.Refresh",
|
"Swords.Skills.SS.Refresh",
|
||||||
"Swords.Skills.SS.Other.Off"),
|
"Swords.Skills.SS.Other.Off"),
|
||||||
|
|
||||||
CHARGE(
|
|
||||||
"Taming.Skills.Charge.On",
|
|
||||||
"Taming.Skills.Charge.Off",
|
|
||||||
"Taming.Skills.Charge.Other.On",
|
|
||||||
"Taming.Skills.Charge.Refresh",
|
|
||||||
"Taming.Skills.Charge.Other.Off"),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has cooldown - but has to share a skill with Super Breaker, so needs special treatment
|
* Has cooldown - but has to share a skill with Super Breaker, so needs special treatment
|
||||||
*/
|
*/
|
||||||
@@ -159,9 +152,6 @@ public enum AbilityType {
|
|||||||
case BLAST_MINING:
|
case BLAST_MINING:
|
||||||
return Permissions.remoteDetonation(player);
|
return Permissions.remoteDetonation(player);
|
||||||
|
|
||||||
case CHARGE:
|
|
||||||
return Permissions.charge(player);
|
|
||||||
|
|
||||||
case GIGA_DRILL_BREAKER:
|
case GIGA_DRILL_BREAKER:
|
||||||
return Permissions.gigaDrillBreaker(player);
|
return Permissions.gigaDrillBreaker(player);
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public enum MaterialType {
|
|||||||
return Material.LEATHER;
|
return Material.LEATHER;
|
||||||
|
|
||||||
case WOOD:
|
case WOOD:
|
||||||
return Material.WOOD;
|
return Material.OAK_PLANKS;
|
||||||
|
|
||||||
case STONE:
|
case STONE:
|
||||||
return Material.COBBLESTONE;
|
return Material.COBBLESTONE;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public enum SecondaryAbility {
|
|||||||
/* Taming */
|
/* Taming */
|
||||||
BEAST_LORE,
|
BEAST_LORE,
|
||||||
CALL_OF_THE_WILD,
|
CALL_OF_THE_WILD,
|
||||||
ENVIROMENTALLY_AWARE,
|
ENVIRONMENTALLY_AWARE,
|
||||||
FAST_FOOD,
|
FAST_FOOD,
|
||||||
GORE,
|
GORE,
|
||||||
HOLY_HOUND,
|
HOLY_HOUND,
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public enum SkillType {
|
|||||||
SALVAGE(SalvageManager.class, Color.ORANGE, ImmutableList.of(SecondaryAbility.ADVANCED_SALVAGE, SecondaryAbility.ARCANE_SALVAGE)),
|
SALVAGE(SalvageManager.class, Color.ORANGE, ImmutableList.of(SecondaryAbility.ADVANCED_SALVAGE, SecondaryAbility.ARCANE_SALVAGE)),
|
||||||
SMELTING(SmeltingManager.class, Color.YELLOW, ImmutableList.of(SecondaryAbility.FLUX_MINING, SecondaryAbility.FUEL_EFFICIENCY, SecondaryAbility.SECOND_SMELT)),
|
SMELTING(SmeltingManager.class, Color.YELLOW, ImmutableList.of(SecondaryAbility.FLUX_MINING, SecondaryAbility.FUEL_EFFICIENCY, SecondaryAbility.SECOND_SMELT)),
|
||||||
SWORDS(SwordsManager.class, Color.fromRGB(178, 34, 34), AbilityType.SERRATED_STRIKES, ToolType.SWORD, ImmutableList.of(SecondaryAbility.BLEED, SecondaryAbility.COUNTER)),
|
SWORDS(SwordsManager.class, Color.fromRGB(178, 34, 34), AbilityType.SERRATED_STRIKES, ToolType.SWORD, ImmutableList.of(SecondaryAbility.BLEED, SecondaryAbility.COUNTER)),
|
||||||
TAMING(TamingManager.class, Color.PURPLE, AbilityType.CHARGE, ToolType.BONE, ImmutableList.of(SecondaryAbility.BEAST_LORE, SecondaryAbility.CALL_OF_THE_WILD, SecondaryAbility.ENVIROMENTALLY_AWARE, SecondaryAbility.FAST_FOOD, SecondaryAbility.GORE, SecondaryAbility.HOLY_HOUND, SecondaryAbility.SHARPENED_CLAWS, SecondaryAbility.SHOCK_PROOF, SecondaryAbility.THICK_FUR, SecondaryAbility.PUMMEL)),
|
TAMING(TamingManager.class, Color.PURPLE, ImmutableList.of(SecondaryAbility.BEAST_LORE, SecondaryAbility.CALL_OF_THE_WILD, SecondaryAbility.ENVIRONMENTALLY_AWARE, SecondaryAbility.FAST_FOOD, SecondaryAbility.GORE, SecondaryAbility.HOLY_HOUND, SecondaryAbility.SHARPENED_CLAWS, SecondaryAbility.SHOCK_PROOF, SecondaryAbility.THICK_FUR, SecondaryAbility.PUMMEL)),
|
||||||
UNARMED(UnarmedManager.class, Color.BLACK, AbilityType.BERSERK, ToolType.FISTS, ImmutableList.of(SecondaryAbility.BLOCK_CRACKER, SecondaryAbility.DEFLECT, SecondaryAbility.DISARM, SecondaryAbility.IRON_ARM, SecondaryAbility.IRON_GRIP)),
|
UNARMED(UnarmedManager.class, Color.BLACK, AbilityType.BERSERK, ToolType.FISTS, ImmutableList.of(SecondaryAbility.BLOCK_CRACKER, SecondaryAbility.DEFLECT, SecondaryAbility.DISARM, SecondaryAbility.IRON_ARM, SecondaryAbility.IRON_GRIP)),
|
||||||
WOODCUTTING(WoodcuttingManager.class, Color.OLIVE, AbilityType.TREE_FELLER, ToolType.AXE, ImmutableList.of(SecondaryAbility.LEAF_BLOWER, SecondaryAbility.WOODCUTTING_DOUBLE_DROPS));
|
WOODCUTTING(WoodcuttingManager.class, Color.OLIVE, AbilityType.TREE_FELLER, ToolType.AXE, ImmutableList.of(SecondaryAbility.LEAF_BLOWER, SecondaryAbility.WOODCUTTING_DOUBLE_DROPS));
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import com.gmail.nossr50.util.ItemUtils;
|
|||||||
|
|
||||||
public enum ToolType {
|
public enum ToolType {
|
||||||
AXE(LocaleLoader.getString("Axes.Ability.Lower"), LocaleLoader.getString("Axes.Ability.Ready")),
|
AXE(LocaleLoader.getString("Axes.Ability.Lower"), LocaleLoader.getString("Axes.Ability.Ready")),
|
||||||
BONE(LocaleLoader.getString("Taming.Ability.Lower"), LocaleLoader.getString("Taming.Ability.Ready")),
|
|
||||||
FISTS(LocaleLoader.getString("Unarmed.Ability.Lower"), LocaleLoader.getString("Unarmed.Ability.Ready")),
|
FISTS(LocaleLoader.getString("Unarmed.Ability.Lower"), LocaleLoader.getString("Unarmed.Ability.Ready")),
|
||||||
HOE(LocaleLoader.getString("Herbalism.Ability.Lower"), LocaleLoader.getString("Herbalism.Ability.Ready")),
|
HOE(LocaleLoader.getString("Herbalism.Ability.Lower"), LocaleLoader.getString("Herbalism.Ability.Ready")),
|
||||||
PICKAXE(LocaleLoader.getString("Mining.Ability.Lower"), LocaleLoader.getString("Mining.Ability.Ready")),
|
PICKAXE(LocaleLoader.getString("Mining.Ability.Lower"), LocaleLoader.getString("Mining.Ability.Ready")),
|
||||||
@@ -42,9 +41,6 @@ public enum ToolType {
|
|||||||
case AXE:
|
case AXE:
|
||||||
return ItemUtils.isAxe(itemStack);
|
return ItemUtils.isAxe(itemStack);
|
||||||
|
|
||||||
case BONE:
|
|
||||||
return itemStack.getType() == Material.BONE;
|
|
||||||
|
|
||||||
case FISTS:
|
case FISTS:
|
||||||
return itemStack.getType() == Material.AIR;
|
return itemStack.getType() == Material.AIR;
|
||||||
|
|
||||||
|
|||||||
@@ -4,35 +4,44 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
import org.bukkit.potion.Potion;
|
import org.bukkit.potion.Potion;
|
||||||
|
import org.bukkit.potion.PotionData;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
|
||||||
|
|
||||||
public class AlchemyPotion {
|
public class AlchemyPotion {
|
||||||
private short dataValue;
|
private Material material;
|
||||||
|
private PotionData data;
|
||||||
private String name;
|
private String name;
|
||||||
private List<String> lore;
|
private List<String> lore;
|
||||||
private List<PotionEffect> effects;
|
private List<PotionEffect> effects;
|
||||||
private Map<ItemStack, Short> children;
|
private Color color;
|
||||||
|
private Map<ItemStack, String> children;
|
||||||
|
|
||||||
public AlchemyPotion(short dataValue, String name, List<String> lore, List<PotionEffect> effects, Map<ItemStack, Short> children) {
|
public AlchemyPotion(Material material, PotionData data, String name, List<String> lore, List<PotionEffect> effects, Color color, Map<ItemStack, String> children) {
|
||||||
this.dataValue = dataValue;
|
this.material = material;
|
||||||
|
this.data = data;
|
||||||
this.lore = lore;
|
this.lore = lore;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.effects = effects;
|
this.effects = effects;
|
||||||
this.children = children;
|
this.children = children;
|
||||||
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "AlchemyPotion{" + dataValue + ", " + name + ", Effects[" + effects.size() + "], Children[" + children.size() + "]}";
|
return "AlchemyPotion{" + data + ", " + name + ", Effects[" + effects.size() + "], Children[" + children.size() + "]}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack toItemStack(int amount) {
|
public ItemStack toItemStack(int amount) {
|
||||||
ItemStack potion = new ItemStack(Material.POTION, amount, this.getDataValue());
|
ItemStack potion = new ItemStack(material, amount);
|
||||||
PotionMeta meta = (PotionMeta) potion.getItemMeta();
|
PotionMeta meta = (PotionMeta) potion.getItemMeta();
|
||||||
|
|
||||||
|
meta.setBasePotionData(data);
|
||||||
if (this.getName() != null) {
|
if (this.getName() != null) {
|
||||||
meta.setDisplayName(this.getName());
|
meta.setDisplayName(this.getName());
|
||||||
}
|
}
|
||||||
@@ -47,20 +56,28 @@ public class AlchemyPotion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.getColor() != null) {
|
||||||
|
meta.setColor(this.getColor());
|
||||||
|
}
|
||||||
|
|
||||||
potion.setItemMeta(meta);
|
potion.setItemMeta(meta);
|
||||||
return potion;
|
return potion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Material getMaterial() {
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
public Potion toPotion(int amount) {
|
public Potion toPotion(int amount) {
|
||||||
return Potion.fromItemStack(this.toItemStack(amount));
|
return Potion.fromItemStack(this.toItemStack(amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
public short getDataValue() {
|
public PotionData getData() {
|
||||||
return dataValue;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataValue(short data_value) {
|
public void setData(PotionData data) {
|
||||||
this.dataValue = data_value;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -87,22 +104,65 @@ public class AlchemyPotion {
|
|||||||
this.effects = effects;
|
this.effects = effects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<ItemStack, Short> getChildren() {
|
public Color getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(Color color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<ItemStack, String> getChildren() {
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChildren(Map<ItemStack, Short> children) {
|
public void setChildren(Map<ItemStack, String> children) {
|
||||||
this.children = children;
|
this.children = children;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Short getChildDataValue(ItemStack ingredient) {
|
public AlchemyPotion getChild(ItemStack ingredient) {
|
||||||
if (!children.isEmpty()) {
|
if (!children.isEmpty()) {
|
||||||
for (Entry<ItemStack, Short> child : children.entrySet()) {
|
for (Entry<ItemStack, String> child : children.entrySet()) {
|
||||||
if (ingredient.isSimilar(child.getKey())) {
|
if (ingredient.isSimilar(child.getKey())) {
|
||||||
return child.getValue();
|
return PotionConfig.getInstance().getPotion(child.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSimilar(ItemStack item) {
|
||||||
|
if (item.getType() != material) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!item.hasItemMeta()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
PotionMeta meta = (PotionMeta) item.getItemMeta();
|
||||||
|
PotionData that = meta.getBasePotionData();
|
||||||
|
if (data.getType() != that.getType()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (data.isExtended() != that.isExtended()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (data.isUpgraded() != that.isUpgraded()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (PotionEffect effect : effects) {
|
||||||
|
if (!meta.hasCustomEffect(effect.getType())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!meta.hasLore() && !lore.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!(lore.isEmpty() && !meta.hasLore()) && !meta.getLore().equals(lore)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!meta.hasDisplayName() && name != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (name == null && !meta.hasDisplayName()) || meta.getDisplayName().equals(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
package com.gmail.nossr50.datatypes.skills.alchemy;
|
package com.gmail.nossr50.datatypes.skills.alchemy;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.potion.Potion;
|
import org.bukkit.potion.Potion;
|
||||||
|
import org.bukkit.potion.PotionData;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionType;
|
||||||
|
|
||||||
public enum PotionStage {
|
public enum PotionStage {
|
||||||
FIVE(5),
|
FIVE(5),
|
||||||
@@ -39,31 +45,40 @@ public enum PotionStage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isWaterBottle(AlchemyPotion input) {
|
private static boolean isWaterBottle(AlchemyPotion input) {
|
||||||
return input.getDataValue() == 0;
|
return input.getData().getType() == PotionType.WATER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PotionStage getPotionStage(AlchemyPotion alchemyPotion) {
|
public static PotionStage getPotionStage(AlchemyPotion alchemyPotion) {
|
||||||
Potion potion = alchemyPotion.toPotion(1);
|
PotionData data = alchemyPotion.getData();
|
||||||
|
List<PotionEffect> effects = alchemyPotion.getEffects();
|
||||||
|
|
||||||
int stage = 1;
|
int stage = 1;
|
||||||
|
|
||||||
// Check if potion isn't awkward or mundane
|
// Check if potion has an effect of any sort
|
||||||
if (potion.getType() != null) {
|
if (data.getType().getEffectType() != null || !effects.isEmpty()) {
|
||||||
stage++;
|
stage++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if potion has a glowstone dust amplifier
|
// Check if potion has a glowstone dust amplifier
|
||||||
if (potion.getLevel() > 1) {
|
// Else check if the potion has a custom effect with an amplifier added by mcMMO
|
||||||
|
if (data.isUpgraded()) {
|
||||||
stage++;
|
stage++;
|
||||||
|
} else if(!effects.isEmpty()) {
|
||||||
|
for (PotionEffect effect : effects){
|
||||||
|
if(effect.getAmplifier() > 0){
|
||||||
|
stage++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if potion has a redstone dust amplifier
|
// Check if potion has a redstone dust amplifier
|
||||||
if (potion.hasExtendedDuration()) {
|
if (data.isExtended()) {
|
||||||
stage++;
|
stage++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if potion has a gunpowder amplifier
|
// Check if potion has a gunpowder amplifier
|
||||||
if (potion.isSplash()) {
|
if (alchemyPotion.getMaterial() == Material.SPLASH_POTION || alchemyPotion.getMaterial() == Material.LINGERING_POTION) {
|
||||||
stage++;
|
stage++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
|
|||||||
this.cancelled = cancelled;
|
this.cancelled = cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Rest of file is required boilerplate for custom events **/
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.events.experience;
|
package com.gmail.nossr50.events.experience;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
@@ -46,4 +47,15 @@ public class McMMOPlayerLevelDownEvent extends McMMOPlayerLevelChangeEvent {
|
|||||||
public int getLevelsLost() {
|
public int getLevelsLost() {
|
||||||
return levelsLost;
|
return levelsLost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.events.experience;
|
package com.gmail.nossr50.events.experience;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
@@ -46,4 +47,15 @@ public class McMMOPlayerLevelUpEvent extends McMMOPlayerLevelChangeEvent {
|
|||||||
public int getLevelsGained() {
|
public int getLevelsGained() {
|
||||||
return levelsGained;
|
return levelsGained;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.events.experience;
|
package com.gmail.nossr50.events.experience;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
@@ -51,4 +52,15 @@ public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
|
|||||||
public void setXpGained(int xpGained) {
|
public void setXpGained(int xpGained) {
|
||||||
this.xpGained = xpGained;
|
this.xpGained = xpGained;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import org.bukkit.event.inventory.BrewEvent;
|
|||||||
import org.bukkit.inventory.BrewerInventory;
|
import org.bukkit.inventory.BrewerInventory;
|
||||||
|
|
||||||
public class FakeBrewEvent extends BrewEvent {
|
public class FakeBrewEvent extends BrewEvent {
|
||||||
public FakeBrewEvent(Block brewer, BrewerInventory contents) {
|
public FakeBrewEvent(Block brewer, BrewerInventory contents, int fuelLevel) {
|
||||||
super(brewer, contents);
|
super(brewer, contents, fuelLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.gmail.nossr50.events.fake;
|
package com.gmail.nossr50.events.fake;
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Fish;
|
import org.bukkit.entity.FishHook;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerFishEvent;
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
|
|
||||||
public class FakePlayerFishEvent extends PlayerFishEvent {
|
public class FakePlayerFishEvent extends PlayerFishEvent {
|
||||||
public FakePlayerFishEvent(Player player, Entity entity, Fish hookEntity, State state) {
|
public FakePlayerFishEvent(Player player, Entity entity, FishHook hookEntity, State state) {
|
||||||
super(player, entity, hookEntity, state);
|
super(player, entity, hookEntity, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package com.gmail.nossr50.events.skills.salvage;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called just before a player salvages an item with mcMMO.
|
||||||
|
*/
|
||||||
|
public class McMMOPlayerSalvageCheckEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||||
|
private ItemStack salvageItem;
|
||||||
|
private ItemStack salvageResults;
|
||||||
|
private ItemStack enchantedBook;
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
public McMMOPlayerSalvageCheckEvent(Player player, ItemStack salvageItem, ItemStack salvageResults, ItemStack enchantedBook) {
|
||||||
|
super(player, SkillType.SALVAGE);
|
||||||
|
this.salvageItem = salvageItem;
|
||||||
|
this.salvageResults = salvageResults;
|
||||||
|
this.enchantedBook = enchantedBook;
|
||||||
|
this.cancelled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The item that should get salvaged.
|
||||||
|
*/
|
||||||
|
public ItemStack getSalvageItem() {
|
||||||
|
return salvageItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The results that should be dropped after salvaging.
|
||||||
|
*/
|
||||||
|
public ItemStack getSalvageResults() {
|
||||||
|
return salvageResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The enchanted book that should drop after salvaging or null if no book should be dropped.
|
||||||
|
*/
|
||||||
|
public ItemStack getEnchantedBook() {
|
||||||
|
return enchantedBook;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Following are required for Cancellable **/
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancelled = cancel;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,28 +1,5 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.block.BrewingStand;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
|
||||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.HiddenConfig;
|
import com.gmail.nossr50.config.HiddenConfig;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
@@ -31,8 +8,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||||
import com.gmail.nossr50.runnables.PistonTrackerTask;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
|
|
||||||
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
import com.gmail.nossr50.skills.alchemy.Alchemy;
|
||||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||||
@@ -42,13 +18,27 @@ import com.gmail.nossr50.skills.repair.Repair;
|
|||||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.*;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.block.BrewingStand;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.*;
|
||||||
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
import org.bukkit.metadata.MetadataValue;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class BlockListener implements Listener {
|
public class BlockListener implements Listener {
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
@@ -64,27 +54,16 @@ public class BlockListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||||
if (!EventUtils.shouldProcessEvent(event.getBlock(), true)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockFace direction = event.getDirection();
|
BlockFace direction = event.getDirection();
|
||||||
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
|
Block movedBlock = event.getBlock();
|
||||||
|
movedBlock = movedBlock.getRelative(direction, 2);
|
||||||
|
|
||||||
if (futureEmptyBlock.getType() == Material.AIR) {
|
for (Block b : event.getBlocks()) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Block> blocks = event.getBlocks();
|
|
||||||
|
|
||||||
for (Block b : blocks) {
|
|
||||||
if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) {
|
if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) {
|
||||||
b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
|
movedBlock = b.getRelative(direction);
|
||||||
|
mcMMO.getPlaceStore().setTrue(movedBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed because blocks sometimes don't move when two pistons push towards each other
|
|
||||||
new PistonTrackerTask(blocks, direction, futureEmptyBlock).runTaskLater(plugin, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,18 +73,43 @@ public class BlockListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||||
if (!EventUtils.shouldProcessEvent(event.getBlock(), false)) {
|
// Get opposite direction so we get correct block
|
||||||
return;
|
BlockFace direction = event.getDirection();
|
||||||
|
Block movedBlock = event.getBlock().getRelative(direction);
|
||||||
|
mcMMO.getPlaceStore().setTrue(movedBlock);
|
||||||
|
|
||||||
|
for (Block block : event.getBlocks()) {
|
||||||
|
movedBlock = block.getRelative(direction);
|
||||||
|
mcMMO.getPlaceStore().setTrue(movedBlock);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!event.isSticky()) {
|
/**
|
||||||
return;
|
* Monitor falling blocks.
|
||||||
|
*
|
||||||
|
* @param event The event to watch
|
||||||
|
*/
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onFallingBlock(EntityChangeBlockEvent event) {
|
||||||
|
|
||||||
|
if (BlockUtils.shouldBeWatched(event.getBlock().getState()) && event.getEntityType().equals(EntityType.FALLING_BLOCK)) {
|
||||||
|
if (event.getTo().equals(Material.AIR) && mcMMO.getPlaceStore().isTrue(event.getBlock())) {
|
||||||
|
event.getEntity().setMetadata("mcMMOBlockFall", new FixedMetadataValue( plugin, event.getBlock().getLocation()));
|
||||||
|
} else {
|
||||||
|
List<MetadataValue> values = event.getEntity().getMetadata( "mcMMOBlockFall" );
|
||||||
|
|
||||||
|
if (!values.isEmpty()) {
|
||||||
|
|
||||||
|
if (values.get(0).value() == null) return;
|
||||||
|
Block spawn = ((org.bukkit.Location) values.get(0).value()).getBlock();
|
||||||
|
|
||||||
|
|
||||||
|
mcMMO.getPlaceStore().setTrue( event.getBlock() );
|
||||||
|
mcMMO.getPlaceStore().setFalse( spawn );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Block movedBlock = event.getRetractLocation().getBlock();
|
|
||||||
|
|
||||||
// Needed only because under some circumstances Minecraft doesn't move the block
|
|
||||||
new StickyPistonTrackerTask(event.getDirection(), event.getBlock(), movedBlock).runTaskLater(plugin, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -124,8 +128,10 @@ public class BlockListener implements Listener {
|
|||||||
BlockState blockState = event.getBlock().getState();
|
BlockState blockState = event.getBlock().getState();
|
||||||
|
|
||||||
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
||||||
if (BlockUtils.shouldBeWatched(blockState)) {
|
if (BlockUtils.shouldBeWatched(blockState) && blockState.getType() != Material.CHORUS_FLOWER) {
|
||||||
mcMMO.getPlaceStore().setTrue(blockState);
|
// Don't count de-barking wood
|
||||||
|
if (!Tag.LOGS.isTagged(event.getBlockReplacedState().getType()) || !Tag.LOGS.isTagged(event.getBlockPlaced().getType()))
|
||||||
|
mcMMO.getPlaceStore().setTrue(blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
@@ -138,6 +144,18 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onBlockGrow(BlockGrowEvent event)
|
||||||
|
{
|
||||||
|
BlockState blockState = event.getBlock().getState();
|
||||||
|
|
||||||
|
if (!BlockUtils.shouldBeWatched(blockState)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMO.getPlaceStore().setFalse(blockState);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor BlockBreak events.
|
* Monitor BlockBreak events.
|
||||||
*
|
*
|
||||||
@@ -168,7 +186,7 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
/* HERBALISM */
|
/* HERBALISM */
|
||||||
if (BlockUtils.affectedByGreenTerra(blockState)) {
|
if (BlockUtils.affectedByGreenTerra(blockState)) {
|
||||||
@@ -197,7 +215,6 @@ public class BlockListener implements Listener {
|
|||||||
/* WOOD CUTTING */
|
/* WOOD CUTTING */
|
||||||
else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && SkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && SkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||||
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
|
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
|
||||||
|
|
||||||
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
|
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
|
||||||
woodcuttingManager.processTreeFeller(blockState);
|
woodcuttingManager.processTreeFeller(blockState);
|
||||||
}
|
}
|
||||||
@@ -238,7 +255,7 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BlockState blockState = event.getBlock().getState();
|
BlockState blockState = event.getBlock().getState();
|
||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
if (Herbalism.isRecentlyRegrown(blockState)) {
|
if (Herbalism.isRecentlyRegrown(blockState)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@@ -298,7 +315,7 @@ public class BlockListener implements Listener {
|
|||||||
* We check permissions here before processing activation.
|
* We check permissions here before processing activation.
|
||||||
*/
|
*/
|
||||||
if (BlockUtils.canActivateAbilities(blockState)) {
|
if (BlockUtils.canActivateAbilities(blockState)) {
|
||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
|
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
|
||||||
if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER))) {
|
if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER))) {
|
||||||
@@ -334,7 +351,7 @@ public class BlockListener implements Listener {
|
|||||||
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
||||||
*/
|
*/
|
||||||
if (mcMMOPlayer.getAbilityMode(AbilityType.TREE_FELLER) && BlockUtils.isLog(blockState) && Config.getInstance().getTreeFellerSoundsEnabled()) {
|
if (mcMMOPlayer.getAbilityMode(AbilityType.TREE_FELLER) && BlockUtils.isLog(blockState) && Config.getInstance().getTreeFellerSoundsEnabled()) {
|
||||||
player.playSound(blockState.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.getFizzPitch());
|
player.playSound(blockState.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, Misc.FIZZ_VOLUME, Misc.getFizzPitch());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,7 +373,7 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
BlockState blockState = block.getState();
|
BlockState blockState = block.getState();
|
||||||
|
|
||||||
@@ -373,7 +390,7 @@ public class BlockListener implements Listener {
|
|||||||
else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
|
else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
|
||||||
if (AbilityType.BERSERK.blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true)) {
|
if (AbilityType.BERSERK.blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true)) {
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
player.playSound(block.getLocation(), Sound.ENTITY_ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
||||||
}
|
}
|
||||||
else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
|
else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
|
||||||
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
|
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
|
||||||
@@ -383,7 +400,7 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isLeaves(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
|
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isLeaves(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
player.playSound(blockState.getLocation(), Sound.ENTITY_ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +1,5 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.AnimalTamer;
|
|
||||||
import org.bukkit.entity.Arrow;
|
|
||||||
import org.bukkit.entity.Enderman;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.FallingBlock;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.Projectile;
|
|
||||||
import org.bukkit.entity.TNTPrimed;
|
|
||||||
import org.bukkit.entity.Tameable;
|
|
||||||
import org.bukkit.entity.Wolf;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
|
||||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
|
||||||
import org.bukkit.event.entity.EntityTameEvent;
|
|
||||||
import org.bukkit.event.entity.EntityTargetEvent;
|
|
||||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
|
||||||
import org.bukkit.event.entity.PotionSplashEvent;
|
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
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;
|
||||||
@@ -47,6 +7,7 @@ import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
|||||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||||
@@ -63,6 +24,23 @@ import com.gmail.nossr50.util.Permissions;
|
|||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.*;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.*;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
public class EntityListener implements Listener {
|
public class EntityListener implements Listener {
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
@@ -104,13 +82,15 @@ public class EntityListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Monitor EntityChangeBlock events.
|
* Monitor EntityChangeBlock events.
|
||||||
*
|
*
|
||||||
* @param event The event to watch
|
* @param event
|
||||||
|
* The event to watch
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
|
|
||||||
// When the event is fired for the falling block that changes back to a normal block
|
// When the event is fired for the falling block that changes back to a
|
||||||
|
// normal block
|
||||||
// event.getBlock().getType() returns AIR
|
// event.getBlock().getType() returns AIR
|
||||||
if (!BlockUtils.shouldBeWatched(block.getState()) && block.getType() != Material.AIR) {
|
if (!BlockUtils.shouldBeWatched(block.getState()) && block.getType() != Material.AIR) {
|
||||||
return;
|
return;
|
||||||
@@ -128,8 +108,7 @@ public class EntityListener implements Listener {
|
|||||||
else if (isTracked) {
|
else if (isTracked) {
|
||||||
mcMMO.getPlaceStore().setTrue(block);
|
mcMMO.getPlaceStore().setTrue(block);
|
||||||
}
|
}
|
||||||
}
|
} else if ((block.getType() == Material.REDSTONE_ORE)) {
|
||||||
else if ((block.getType() == Material.REDSTONE_ORE || block.getType() == Material.GLOWING_REDSTONE_ORE) && (event.getTo() == Material.REDSTONE_ORE || event.getTo() == Material.GLOWING_REDSTONE_ORE)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -142,7 +121,8 @@ public class EntityListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Handle EntityDamageByEntity events that involve modifying the event.
|
* Handle EntityDamageByEntity events that involve modifying the event.
|
||||||
*
|
*
|
||||||
* @param event The event to watch
|
* @param event
|
||||||
|
* The event to watch
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||||
@@ -150,13 +130,35 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double damage = event.getFinalDamage();
|
if (event.getEntity() instanceof ArmorStand) {
|
||||||
|
|
||||||
if (damage <= 0) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.getDamager().hasMetadata(mcMMO.funfettiMetadataKey))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
double damage = event.getFinalDamage();
|
||||||
Entity defender = event.getEntity();
|
Entity defender = event.getEntity();
|
||||||
|
Entity attacker = event.getDamager();
|
||||||
|
|
||||||
|
if (damage <= 0) {
|
||||||
|
if (defender instanceof Player && attacker instanceof Player) {
|
||||||
|
Player defendingPlayer = (Player) defender;
|
||||||
|
Player attackingPlayer = (Player) attacker;
|
||||||
|
if (event.getDamage(DamageModifier.ABSORPTION) > 0) {
|
||||||
|
if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (defender.hasMetadata(mcMMO.customDamageKey)) {
|
if (defender.hasMetadata(mcMMO.customDamageKey)) {
|
||||||
defender.removeMetadata(mcMMO.customDamageKey, plugin);
|
defender.removeMetadata(mcMMO.customDamageKey, plugin);
|
||||||
@@ -173,7 +175,7 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity attacker = event.getDamager();
|
|
||||||
|
|
||||||
if (Misc.isNPCEntity(attacker)) {
|
if (Misc.isNPCEntity(attacker)) {
|
||||||
return;
|
return;
|
||||||
@@ -207,7 +209,8 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want to make sure we're not gaining XP or applying abilities when we hit ourselves
|
// We want to make sure we're not gaining XP or applying abilities
|
||||||
|
// when we hit ourselves
|
||||||
if (defendingPlayer.equals(attackingPlayer)) {
|
if (defendingPlayer.equals(attackingPlayer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -225,7 +228,8 @@ public class EntityListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Handle EntityDamage events that involve modifying the event.
|
* Handle EntityDamage events that involve modifying the event.
|
||||||
*
|
*
|
||||||
* @param event The event to modify
|
* @param event
|
||||||
|
* The event to modify
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onEntityDamage(EntityDamageEvent event) {
|
public void onEntityDamage(EntityDamageEvent event) {
|
||||||
@@ -371,7 +375,8 @@ public class EntityListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Monitor EntityDeath events.
|
* Monitor EntityDeath events.
|
||||||
*
|
*
|
||||||
* @param event The event to watch
|
* @param event
|
||||||
|
* The event to watch
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onEntityDeathLowest(EntityDeathEvent event) {
|
public void onEntityDeathLowest(EntityDeathEvent event) {
|
||||||
@@ -390,12 +395,17 @@ public class EntityListener implements Listener {
|
|||||||
entity.setCustomNameVisible(entity.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean());
|
entity.setCustomNameVisible(entity.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean());
|
||||||
entity.removeMetadata(mcMMO.customVisibleKey, plugin);
|
entity.removeMetadata(mcMMO.customVisibleKey, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entity.hasMetadata(mcMMO.entityMetadataKey)) {
|
||||||
|
entity.removeMetadata(mcMMO.entityMetadataKey, plugin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor EntityDeath events.
|
* Monitor EntityDeath events.
|
||||||
*
|
*
|
||||||
* @param event The event to watch
|
* @param event
|
||||||
|
* The event to watch
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
@@ -412,23 +422,30 @@ public class EntityListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Monitor CreatureSpawn events.
|
* Monitor CreatureSpawn events.
|
||||||
*
|
*
|
||||||
* @param event The event to watch
|
* @param event
|
||||||
|
* The event to watch
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||||
|
LivingEntity entity = event.getEntity();
|
||||||
|
|
||||||
switch (event.getSpawnReason()) {
|
switch (event.getSpawnReason()) {
|
||||||
|
case NETHER_PORTAL:
|
||||||
case SPAWNER:
|
case SPAWNER:
|
||||||
case SPAWNER_EGG:
|
case SPAWNER_EGG:
|
||||||
LivingEntity entity = event.getEntity();
|
|
||||||
Entity passenger = entity.getPassenger();
|
|
||||||
|
|
||||||
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||||
|
|
||||||
|
Entity passenger = entity.getPassenger();
|
||||||
|
|
||||||
if (passenger != null) {
|
if (passenger != null) {
|
||||||
passenger.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
passenger.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case BREEDING:
|
||||||
|
entity.setMetadata(mcMMO.bredMetadataKey, mcMMO.metadataValue);
|
||||||
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -437,7 +454,8 @@ public class EntityListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Handle ExplosionPrime events that involve modifying the event.
|
* Handle ExplosionPrime events that involve modifying the event.
|
||||||
*
|
*
|
||||||
* @param event The event to modify
|
* @param event
|
||||||
|
* The event to modify
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
||||||
@@ -447,7 +465,8 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
// We can make this assumption because we (should) be the only ones
|
||||||
|
// using this exact metadata
|
||||||
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||||
|
|
||||||
if (!UserManager.hasPlayerDataKey(player)) {
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
@@ -464,7 +483,8 @@ public class EntityListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Handle EntityExplode events that involve modifying the event.
|
* Handle EntityExplode events that involve modifying the event.
|
||||||
*
|
*
|
||||||
* @param event The event to modify
|
* @param event
|
||||||
|
* The event to modify
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onEnitityExplode(EntityExplodeEvent event) {
|
public void onEnitityExplode(EntityExplodeEvent event) {
|
||||||
@@ -474,7 +494,8 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
// We can make this assumption because we (should) be the only ones
|
||||||
|
// using this exact metadata
|
||||||
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||||
|
|
||||||
if (!UserManager.hasPlayerDataKey(player)) {
|
if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
@@ -492,7 +513,8 @@ public class EntityListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Handle EntityExplode events that involve modifying the event.
|
* Handle EntityExplode events that involve modifying the event.
|
||||||
*
|
*
|
||||||
* @param event The event to modify
|
* @param event
|
||||||
|
* The event to modify
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onEntityExplodeMonitor(EntityExplodeEvent event) {
|
public void onEntityExplodeMonitor(EntityExplodeEvent event) {
|
||||||
@@ -508,7 +530,8 @@ public class EntityListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Handle FoodLevelChange events that involve modifying the event.
|
* Handle FoodLevelChange events that involve modifying the event.
|
||||||
*
|
*
|
||||||
* @param event The event to modify
|
* @param event
|
||||||
|
* The event to modify
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||||
@@ -533,39 +556,60 @@ public class EntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some foods have 3 ranks
|
* Some foods have 3 ranks Some foods have 5 ranks The number of ranks
|
||||||
* Some foods have 5 ranks
|
* is based on how 'common' the item is We can adjust this quite easily
|
||||||
* The number of ranks is based on how 'common' the item is
|
* if we find something is giving too much of a bonus
|
||||||
* We can adjust this quite easily if we find something is giving too much of a bonus
|
|
||||||
*/
|
*/
|
||||||
switch (player.getItemInHand().getType()) {
|
switch (player.getInventory().getItemInMainHand().getType()) {
|
||||||
case BAKED_POTATO: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
case BAKED_POTATO: /*
|
||||||
case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
|
||||||
case CARROT_ITEM: /* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */
|
* 1000
|
||||||
case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
*/
|
||||||
case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
case BEETROOT:
|
||||||
case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||||
|
case CARROT: /*
|
||||||
|
* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @
|
||||||
|
* 1000
|
||||||
|
*/
|
||||||
|
case GOLDEN_CARROT: /*
|
||||||
|
* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
|
||||||
|
* 1000
|
||||||
|
*/
|
||||||
|
case MUSHROOM_STEW: /*
|
||||||
|
* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @
|
||||||
|
* 1000
|
||||||
|
*/
|
||||||
|
case PUMPKIN_PIE: /*
|
||||||
|
* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @
|
||||||
|
* 1000
|
||||||
|
*/
|
||||||
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FARMERS_DIET)) {
|
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FARMERS_DIET)) {
|
||||||
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel));
|
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||||
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
case MELON_SLICE: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||||
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
case POISONOUS_POTATO: /*
|
||||||
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER
|
||||||
|
* @ 1000
|
||||||
|
*/
|
||||||
|
case POTATO: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||||
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FARMERS_DIET)) {
|
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FARMERS_DIET)) {
|
||||||
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
|
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
case COOKED_SALMON: /*
|
||||||
|
* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @
|
||||||
|
* 1000
|
||||||
|
*/
|
||||||
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHERMANS_DIET)) {
|
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHERMANS_DIET)) {
|
||||||
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
|
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
case SALMON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||||
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHERMANS_DIET)) {
|
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHERMANS_DIET)) {
|
||||||
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel));
|
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel));
|
||||||
}
|
}
|
||||||
@@ -579,7 +623,8 @@ public class EntityListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Monitor EntityTame events.
|
* Monitor EntityTame events.
|
||||||
*
|
*
|
||||||
* @param event The event to watch
|
* @param event
|
||||||
|
* The event to watch
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onEntityTame(EntityTameEvent event) {
|
public void onEntityTame(EntityTameEvent event) {
|
||||||
@@ -601,7 +646,8 @@ public class EntityListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Handle EntityTarget events.
|
* Handle EntityTarget events.
|
||||||
*
|
*
|
||||||
* @param event The event to process
|
* @param event
|
||||||
|
* The event to process
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onEntityTarget(EntityTargetEvent event) {
|
public void onEntityTarget(EntityTargetEvent event) {
|
||||||
@@ -619,7 +665,8 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party
|
// isFriendlyPet ensures that the Tameable is: Tamed, owned by a player,
|
||||||
|
// and the owner is in the same party
|
||||||
// So we can make some assumptions here, about our casting and our check
|
// So we can make some assumptions here, about our casting and our check
|
||||||
if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire((Player) tameable.getOwner()))) {
|
if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire((Player) tameable.getOwner()))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@@ -627,9 +674,11 @@ public class EntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle PotionSplash events in order to fix broken Splash Potion of Saturation.
|
* Handle PotionSplash events in order to fix broken Splash Potion of
|
||||||
|
* Saturation.
|
||||||
*
|
*
|
||||||
* @param event The event to process
|
* @param event
|
||||||
|
* The event to process
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPotionSplash(PotionSplashEvent event) {
|
public void onPotionSplash(PotionSplashEvent event) {
|
||||||
@@ -644,4 +693,11 @@ public class EntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onPigZapEvent(PigZapEvent event) {
|
||||||
|
if (event.getEntity().hasMetadata(mcMMO.entityMetadataKey)) {
|
||||||
|
event.getPigZombie().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package com.gmail.nossr50.listeners;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.events.fake.FakeBrewEvent;
|
||||||
|
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
@@ -12,17 +15,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.*;
|
||||||
import org.bukkit.event.inventory.CraftItemEvent;
|
|
||||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
|
||||||
import org.bukkit.event.inventory.FurnaceExtractEvent;
|
|
||||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
|
||||||
import org.bukkit.inventory.BrewerInventory;
|
import org.bukkit.inventory.BrewerInventory;
|
||||||
import org.bukkit.inventory.FurnaceInventory;
|
import org.bukkit.inventory.FurnaceInventory;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
@@ -123,10 +116,8 @@ public class InventoryListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
|
public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
|
||||||
Block furnaceBlock = event.getBlock();
|
Block furnaceBlock = event.getBlock();
|
||||||
BlockState furnaceState = furnaceBlock.getState();
|
|
||||||
ItemStack result = furnaceState instanceof Furnace ? ((Furnace) furnaceState).getInventory().getResult() : null;
|
|
||||||
|
|
||||||
if (!ItemUtils.isSmelted(result)) {
|
if (!ItemUtils.isSmelted(new ItemStack(event.getItemType(), event.getItemAmount()))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +127,8 @@ public class InventoryListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setExpToDrop(UserManager.getPlayer(player).getSmeltingManager().vanillaXPBoost(event.getExpToDrop()));
|
int exp = UserManager.getPlayer(player).getSmeltingManager().vanillaXPBoost(event.getExpToDrop());
|
||||||
|
event.setExpToDrop(exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
@@ -164,7 +156,7 @@ public class InventoryListener implements Listener {
|
|||||||
ItemStack clicked = event.getCurrentItem();
|
ItemStack clicked = event.getCurrentItem();
|
||||||
ItemStack cursor = event.getCursor();
|
ItemStack cursor = event.getCursor();
|
||||||
|
|
||||||
if ((clicked != null && clicked.getType() == Material.POTION) || (cursor != null && cursor.getType() == Material.POTION)) {
|
if ((clicked != null && (clicked.getType() == Material.POTION || clicked.getType() == Material.SPLASH_POTION || clicked.getType() == Material.LINGERING_POTION)) || (cursor != null && (cursor.getType() == Material.POTION || cursor.getType() == Material.SPLASH_POTION || cursor.getType() == Material.LINGERING_POTION))) {
|
||||||
AlchemyPotionBrewer.scheduleCheck(player, stand);
|
AlchemyPotionBrewer.scheduleCheck(player, stand);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -279,6 +271,19 @@ public class InventoryListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apparently sometimes vanilla brewing beats our task listener to the actual brew. We handle this by cancelling the vanilla event and finishing our brew ourselves.
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
|
public void onBrew(BrewEvent event)
|
||||||
|
{
|
||||||
|
if (event instanceof FakeBrewEvent)
|
||||||
|
return;
|
||||||
|
Location location = event.getBlock().getLocation();
|
||||||
|
if (Alchemy.brewingStandMap.containsKey(location)) {
|
||||||
|
Alchemy.brewingStandMap.get(location).finishImmediately();
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
|
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
|
||||||
Inventory inventory = event.getDestination();
|
Inventory inventory = event.getDestination();
|
||||||
@@ -295,12 +300,12 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
ItemStack item = event.getItem();
|
ItemStack item = event.getItem();
|
||||||
|
|
||||||
if (Config.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION) {
|
if (Config.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION && item.getType() != Material.SPLASH_POTION && item.getType() != Material.LINGERING_POTION) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getPreventHopperTransferBottles() && item.getType() == Material.POTION) {
|
if (Config.getInstance().getPreventHopperTransferBottles() && (item.getType() == Material.POTION || item.getType() == Material.SPLASH_POTION || item.getType() == Material.LINGERING_POTION)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -313,6 +318,14 @@ public class InventoryListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onInventoryClickEvent(InventoryClickEvent event) {
|
public void onInventoryClickEvent(InventoryClickEvent event) {
|
||||||
SkillUtils.removeAbilityBuff(event.getCurrentItem());
|
SkillUtils.removeAbilityBuff(event.getCurrentItem());
|
||||||
|
if (event.getAction() == InventoryAction.HOTBAR_SWAP) {
|
||||||
|
SkillUtils.removeAbilityBuff(event.getWhoClicked().getInventory().getItem(event.getHotbarButton()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onInventoryOpenEvent(InventoryOpenEvent event) {
|
||||||
|
SkillUtils.removeAbilityBuff(event.getPlayer().getInventory().getItemInMainHand());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
|||||||
@@ -1,34 +1,5 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Item;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|
||||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
|
||||||
import org.bukkit.event.player.PlayerFishEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
|
||||||
import org.bukkit.event.player.PlayerStatisticIncrementEvent;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.chat.ChatManager;
|
import com.gmail.nossr50.chat.ChatManager;
|
||||||
import com.gmail.nossr50.chat.ChatManagerFactory;
|
import com.gmail.nossr50.chat.ChatManagerFactory;
|
||||||
import com.gmail.nossr50.chat.PartyChatManager;
|
import com.gmail.nossr50.chat.PartyChatManager;
|
||||||
@@ -39,8 +10,8 @@ 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.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.skills.ToolType;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
|
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
|
||||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||||
@@ -52,17 +23,22 @@ import com.gmail.nossr50.skills.salvage.Salvage;
|
|||||||
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
import com.gmail.nossr50.skills.unarmed.Unarmed;
|
import com.gmail.nossr50.skills.unarmed.Unarmed;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.*;
|
||||||
import com.gmail.nossr50.util.ChimaeraWing;
|
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
|
||||||
import com.gmail.nossr50.util.HardcoreManager;
|
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.MobHealthbarUtils;
|
|
||||||
import com.gmail.nossr50.util.Motd;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.entity.*;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.bukkit.event.player.*;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class PlayerListener implements Listener {
|
public class PlayerListener implements Listener {
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
@@ -222,13 +198,16 @@ public class PlayerListener implements Listener {
|
|||||||
event.setCancelled(fishingManager.exploitPrevention());
|
event.setCancelled(fishingManager.exploitPrevention());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case CAUGHT_FISH:
|
case CAUGHT_FISH:
|
||||||
//TODO Update to new API once available! Waiting for case CAUGHT_TREASURE:
|
//TODO Update to new API once available! Waiting for case CAUGHT_TREASURE:
|
||||||
Item fishingCatch = (Item) event.getCaught();
|
Item fishingCatch = (Item) event.getCaught();
|
||||||
|
|
||||||
if (Config.getInstance().getFishingOverrideTreasures() && fishingCatch.getItemStack().getType() != Material.RAW_FISH) {
|
if (Config.getInstance().getFishingOverrideTreasures() &&
|
||||||
fishingCatch.setItemStack(new ItemStack(Material.RAW_FISH, 1));
|
fishingCatch.getItemStack().getType() != Material.SALMON &&
|
||||||
|
fishingCatch.getItemStack().getType() != Material.COD &&
|
||||||
|
fishingCatch.getItemStack().getType() != Material.TROPICAL_FISH &&
|
||||||
|
fishingCatch.getItemStack().getType() != Material.PUFFERFISH) {
|
||||||
|
fishingCatch.setItemStack(new ItemStack(Material.SALMON, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.vanillaXpBoost(player, SkillType.FISHING)) {
|
if (Permissions.vanillaXpBoost(player, SkillType.FISHING)) {
|
||||||
@@ -324,18 +303,18 @@ public class PlayerListener implements Listener {
|
|||||||
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
|
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
player.playSound(player.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mcMMOPlayer.isUsingUnarmed() && ItemUtils.isSharable(dropStack)) || mcMMOPlayer.getAbilityMode(AbilityType.BERSERK)) {
|
if ((mcMMOPlayer.isUsingUnarmed() && ItemUtils.isSharable(dropStack) && !Config.getInstance().getUnarmedItemsAsUnarmed()) || mcMMOPlayer.getAbilityMode(AbilityType.BERSERK)) {
|
||||||
boolean pickupSuccess = Unarmed.handleItemPickup(player.getInventory(), drop);
|
boolean pickupSuccess = Unarmed.handleItemPickup(player.getInventory(), drop);
|
||||||
boolean cancel = Config.getInstance().getUnarmedItemPickupDisabled() || pickupSuccess;
|
boolean cancel = Config.getInstance().getUnarmedItemPickupDisabled() || pickupSuccess;
|
||||||
event.setCancelled(cancel);
|
event.setCancelled(cancel);
|
||||||
|
|
||||||
if (pickupSuccess) {
|
if (pickupSuccess) {
|
||||||
player.playSound(player.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -389,11 +368,6 @@ public class PlayerListener implements Listener {
|
|||||||
if (plugin.isXPEventEnabled()) {
|
if (plugin.isXPEventEnabled()) {
|
||||||
player.sendMessage(LocaleLoader.getString("XPRate.Event", ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
|
player.sendMessage(LocaleLoader.getString("XPRate.Event", ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.updateNotifications(player) && plugin.isUpdateAvailable()) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("UpdateChecker.Outdated"));
|
|
||||||
player.sendMessage(LocaleLoader.getString("UpdateChecker.NewAvailable"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -425,14 +399,14 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerInteractLowest(PlayerInteractEvent event) {
|
public void onPlayerInteractLowest(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
|
if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case RIGHT_CLICK_BLOCK:
|
case RIGHT_CLICK_BLOCK:
|
||||||
@@ -478,7 +452,7 @@ public class PlayerListener implements Listener {
|
|||||||
case LEFT_CLICK_BLOCK:
|
case LEFT_CLICK_BLOCK:
|
||||||
type = block.getType();
|
type = block.getType();
|
||||||
|
|
||||||
if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) {
|
if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
|
||||||
/* REPAIR CHECKS */
|
/* REPAIR CHECKS */
|
||||||
if (type == Repair.anvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
if (type == Repair.anvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
@@ -517,16 +491,20 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerInteractMonitor(PlayerInteractEvent event) {
|
public void onPlayerInteractMonitor(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
|
if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||||
Block block = event.getClickedBlock();
|
|
||||||
|
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case RIGHT_CLICK_BLOCK:
|
case RIGHT_CLICK_BLOCK:
|
||||||
|
if(player.getInventory().getItemInOffHand().getType() != Material.AIR && !player.isInsideVehicle() && !player.isSneaking()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Block block = event.getClickedBlock();
|
||||||
BlockState blockState = block.getState();
|
BlockState blockState = block.getState();
|
||||||
|
|
||||||
/* ACTIVATION & ITEM CHECKS */
|
/* ACTIVATION & ITEM CHECKS */
|
||||||
@@ -550,8 +528,20 @@ public class PlayerListener implements Listener {
|
|||||||
/* GREEN THUMB CHECK */
|
/* GREEN THUMB CHECK */
|
||||||
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
||||||
|
|
||||||
|
if (heldItem.getType() == Material.BONE_MEAL) {
|
||||||
|
switch (blockState.getType()) {
|
||||||
|
case BEETROOTS:
|
||||||
|
case CARROT:
|
||||||
|
case COCOA:
|
||||||
|
case WHEAT:
|
||||||
|
case NETHER_WART_BLOCK:
|
||||||
|
case POTATO:
|
||||||
|
mcMMO.getPlaceStore().setFalse(blockState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (herbalismManager.canGreenThumbBlock(blockState)) {
|
if (herbalismManager.canGreenThumbBlock(blockState)) {
|
||||||
player.setItemInHand(new ItemStack(Material.SEEDS, heldItem.getAmount() - 1));
|
player.getInventory().setItemInMainHand(new ItemStack(Material.WHEAT_SEEDS, heldItem.getAmount() - 1));
|
||||||
|
|
||||||
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
||||||
blockState.update(true);
|
blockState.update(true);
|
||||||
@@ -560,6 +550,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/* SHROOM THUMB CHECK */
|
/* SHROOM THUMB CHECK */
|
||||||
else if (herbalismManager.canUseShroomThumb(blockState)) {
|
else if (herbalismManager.canUseShroomThumb(blockState)) {
|
||||||
|
event.setCancelled(true);
|
||||||
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
|
||||||
blockState.update(true);
|
blockState.update(true);
|
||||||
}
|
}
|
||||||
@@ -567,6 +558,9 @@ public class PlayerListener implements Listener {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RIGHT_CLICK_AIR:
|
case RIGHT_CLICK_AIR:
|
||||||
|
if(player.getInventory().getItemInOffHand().getType() != Material.AIR && !player.isInsideVehicle() && !player.isSneaking()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* ACTIVATION CHECKS */
|
/* ACTIVATION CHECKS */
|
||||||
if (Config.getInstance().getAbilitiesEnabled()) {
|
if (Config.getInstance().getAbilitiesEnabled()) {
|
||||||
@@ -577,7 +571,6 @@ public class PlayerListener implements Listener {
|
|||||||
mcMMOPlayer.processAbilityActivation(SkillType.SWORDS);
|
mcMMOPlayer.processAbilityActivation(SkillType.SWORDS);
|
||||||
mcMMOPlayer.processAbilityActivation(SkillType.UNARMED);
|
mcMMOPlayer.processAbilityActivation(SkillType.UNARMED);
|
||||||
mcMMOPlayer.processAbilityActivation(SkillType.WOODCUTTING);
|
mcMMOPlayer.processAbilityActivation(SkillType.WOODCUTTING);
|
||||||
mcMMOPlayer.processAbilityActivation(SkillType.TAMING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ITEM CHECKS */
|
/* ITEM CHECKS */
|
||||||
@@ -592,12 +585,6 @@ public class PlayerListener implements Listener {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LEFT_CLICK_AIR:
|
case LEFT_CLICK_AIR:
|
||||||
if (mcMMOPlayer.getToolPreparationMode(ToolType.BONE) && ToolType.BONE.inHand(heldItem)) {
|
|
||||||
mcMMOPlayer.checkAbilityActivation(SkillType.TAMING);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallthrough
|
|
||||||
|
|
||||||
case LEFT_CLICK_BLOCK:
|
case LEFT_CLICK_BLOCK:
|
||||||
|
|
||||||
if (!player.isSneaking()) {
|
if (!player.isSneaking()) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@@ -44,9 +45,10 @@ public class SelfListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
|
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
|
||||||
|
if (event.getXpGainReason() == XPGainReason.COMMAND)
|
||||||
|
return;
|
||||||
SkillType skillType = event.getSkill();
|
SkillType skillType = event.getSkill();
|
||||||
int threshold = ExperienceConfig.getInstance().getDiminishedReturnsThreshold(skillType);
|
int threshold = ExperienceConfig.getInstance().getDiminishedReturnsThreshold(skillType);
|
||||||
|
|
||||||
if (threshold <= 0 || !ExperienceConfig.getInstance().getDiminishedReturnsEnabled()) {
|
if (threshold <= 0 || !ExperienceConfig.getInstance().getDiminishedReturnsEnabled()) {
|
||||||
// Diminished returns is turned off
|
// Diminished returns is turned off
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public final class LocaleLoader {
|
|||||||
public static String formatString(String string, Object... messageArguments) {
|
public static String formatString(String string, Object... messageArguments) {
|
||||||
if (messageArguments != null) {
|
if (messageArguments != null) {
|
||||||
MessageFormat formatter = new MessageFormat("");
|
MessageFormat formatter = new MessageFormat("");
|
||||||
formatter.applyPattern(string);
|
formatter.applyPattern(string.replace("'", "''"));
|
||||||
string = formatter.format(messageArguments);
|
string = formatter.format(messageArguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,5 @@
|
|||||||
package com.gmail.nossr50;
|
package com.gmail.nossr50;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
|
||||||
import org.bukkit.plugin.PluginManager;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.HiddenConfig;
|
import com.gmail.nossr50.config.HiddenConfig;
|
||||||
@@ -26,17 +14,10 @@ import com.gmail.nossr50.config.skills.salvage.SalvageConfigManager;
|
|||||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||||
import com.gmail.nossr50.database.DatabaseManager;
|
import com.gmail.nossr50.database.DatabaseManager;
|
||||||
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||||
import com.gmail.nossr50.listeners.BlockListener;
|
import com.gmail.nossr50.listeners.*;
|
||||||
import com.gmail.nossr50.listeners.EntityListener;
|
|
||||||
import com.gmail.nossr50.listeners.InventoryListener;
|
|
||||||
import com.gmail.nossr50.listeners.PlayerListener;
|
|
||||||
import com.gmail.nossr50.listeners.SelfListener;
|
|
||||||
import com.gmail.nossr50.listeners.WorldListener;
|
|
||||||
import com.gmail.nossr50.metrics.MetricsManager;
|
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.runnables.CheckDateTask;
|
import com.gmail.nossr50.runnables.CheckDateTask;
|
||||||
import com.gmail.nossr50.runnables.SaveTimerTask;
|
import com.gmail.nossr50.runnables.SaveTimerTask;
|
||||||
import com.gmail.nossr50.runnables.UpdaterResultAsyncTask;
|
|
||||||
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
|
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
|
||||||
import com.gmail.nossr50.runnables.database.UserPurgeTask;
|
import com.gmail.nossr50.runnables.database.UserPurgeTask;
|
||||||
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
|
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
|
||||||
@@ -53,12 +34,7 @@ import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
|||||||
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableManager;
|
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableManager;
|
||||||
import com.gmail.nossr50.skills.salvage.salvageables.SimpleSalvageableManager;
|
import com.gmail.nossr50.skills.salvage.salvageables.SimpleSalvageableManager;
|
||||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||||
import com.gmail.nossr50.util.ChimaeraWing;
|
import com.gmail.nossr50.util.*;
|
||||||
import com.gmail.nossr50.util.HolidayManager;
|
|
||||||
import com.gmail.nossr50.util.LogFilter;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.ModManager;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
|
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
|
||||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
||||||
import com.gmail.nossr50.util.commands.CommandRegistrationManager;
|
import com.gmail.nossr50.util.commands.CommandRegistrationManager;
|
||||||
@@ -66,8 +42,22 @@ import com.gmail.nossr50.util.experience.FormulaManager;
|
|||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
import com.gmail.nossr50.util.upgrade.UpgradeManager;
|
import com.gmail.nossr50.util.upgrade.UpgradeManager;
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class mcMMO extends JavaPlugin {
|
public class mcMMO extends JavaPlugin {
|
||||||
/* Managers */
|
/* Managers */
|
||||||
@@ -91,9 +81,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
// Jar Stuff
|
// Jar Stuff
|
||||||
public static File mcmmo;
|
public static File mcmmo;
|
||||||
|
|
||||||
// Update Check
|
|
||||||
private boolean updateAvailable;
|
|
||||||
|
|
||||||
/* Plugin Checks */
|
/* Plugin Checks */
|
||||||
private static boolean healthBarPluginEnabled;
|
private static boolean healthBarPluginEnabled;
|
||||||
|
|
||||||
@@ -108,6 +95,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
public final static String blockMetadataKey = "mcMMO: Piston Tracking";
|
public final static String blockMetadataKey = "mcMMO: Piston Tracking";
|
||||||
public final static String furnaceMetadataKey = "mcMMO: Tracked Furnace";
|
public final static String furnaceMetadataKey = "mcMMO: Tracked Furnace";
|
||||||
public final static String tntMetadataKey = "mcMMO: Tracked TNT";
|
public final static String tntMetadataKey = "mcMMO: Tracked TNT";
|
||||||
|
public final static String funfettiMetadataKey = "mcMMO: Funfetti";
|
||||||
public final static String tntsafeMetadataKey = "mcMMO: Safe TNT";
|
public final static String tntsafeMetadataKey = "mcMMO: Safe TNT";
|
||||||
public final static String customNameKey = "mcMMO: Custom Name";
|
public final static String customNameKey = "mcMMO: Custom Name";
|
||||||
public final static String customVisibleKey = "mcMMO: Name Visibility";
|
public final static String customVisibleKey = "mcMMO: Name Visibility";
|
||||||
@@ -119,8 +107,8 @@ public class mcMMO extends JavaPlugin {
|
|||||||
public final static String disarmedItemKey = "mcMMO: Disarmed Item";
|
public final static String disarmedItemKey = "mcMMO: Disarmed Item";
|
||||||
public final static String playerDataKey = "mcMMO: Player Data";
|
public final static String playerDataKey = "mcMMO: Player Data";
|
||||||
public final static String greenThumbDataKey = "mcMMO: Green Thumb";
|
public final static String greenThumbDataKey = "mcMMO: Green Thumb";
|
||||||
public final static String pistonDataKey = "mcMMO: Piston State";
|
|
||||||
public final static String databaseCommandKey = "mcMMO: Processing Database Command";
|
public final static String databaseCommandKey = "mcMMO: Processing Database Command";
|
||||||
|
public final static String bredMetadataKey = "mcMMO: Bred Animal";
|
||||||
|
|
||||||
public static FixedMetadataValue metadataValue;
|
public static FixedMetadataValue metadataValue;
|
||||||
|
|
||||||
@@ -181,12 +169,8 @@ public class mcMMO extends JavaPlugin {
|
|||||||
scheduleTasks();
|
scheduleTasks();
|
||||||
CommandRegistrationManager.registerCommands();
|
CommandRegistrationManager.registerCommands();
|
||||||
|
|
||||||
MetricsManager.setup();
|
|
||||||
|
|
||||||
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
|
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
|
||||||
|
|
||||||
checkForUpdates();
|
|
||||||
|
|
||||||
if (Config.getInstance().getPTPCommandWorldPermissions()) {
|
if (Config.getInstance().getPTPCommandWorldPermissions()) {
|
||||||
Permissions.generateWorldTeleportPermissions();
|
Permissions.generateWorldTeleportPermissions();
|
||||||
}
|
}
|
||||||
@@ -267,14 +251,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
return modDirectory;
|
return modDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUpdateAvailable() {
|
|
||||||
return updateAvailable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpdateAvailable(boolean available) {
|
|
||||||
this.updateAvailable = available;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isXPEventEnabled() {
|
public boolean isXPEventEnabled() {
|
||||||
return xpEventEnabled;
|
return xpEventEnabled;
|
||||||
}
|
}
|
||||||
@@ -393,14 +369,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
currentFlatfilePath.mkdirs();
|
currentFlatfilePath.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForUpdates() {
|
|
||||||
if (!Config.getInstance().getUpdateCheckEnabled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
new UpdaterResultAsyncTask(this).runTaskAsynchronously(mcMMO.p);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadConfigFiles() {
|
private void loadConfigFiles() {
|
||||||
// Force the loading of config files
|
// Force the loading of config files
|
||||||
TreasureConfig.getInstance();
|
TreasureConfig.getInstance();
|
||||||
@@ -454,17 +422,19 @@ public class mcMMO extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void registerCustomRecipes() {
|
private void registerCustomRecipes() {
|
||||||
if (Config.getInstance().getChimaeraEnabled()) {
|
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
|
||||||
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
|
if (Config.getInstance().getChimaeraEnabled()) {
|
||||||
}
|
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
|
||||||
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getFluxPickaxeEnabled()) {
|
if (Config.getInstance().getFluxPickaxeEnabled()) {
|
||||||
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.DIAMOND_PICKAXE));
|
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.DIAMOND_PICKAXE));
|
||||||
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.GOLD_PICKAXE));
|
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.GOLDEN_PICKAXE));
|
||||||
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.IRON_PICKAXE));
|
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.IRON_PICKAXE));
|
||||||
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.STONE_PICKAXE));
|
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.STONE_PICKAXE));
|
||||||
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.WOOD_PICKAXE));
|
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.WOODEN_PICKAXE));
|
||||||
}
|
}
|
||||||
|
}, 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scheduleTasks() {
|
private void scheduleTasks() {
|
||||||
@@ -532,4 +502,9 @@ public class mcMMO extends JavaPlugin {
|
|||||||
getLogger().info("To enable, set Mods.Entity_Mods_Enabled to TRUE in config.yml.");
|
getLogger().info("To enable, set Mods.Entity_Mods_Enabled to TRUE in config.yml.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public InputStreamReader getResourceAsReader(String fileName) {
|
||||||
|
InputStream in = getResource(fileName);
|
||||||
|
return in == null ? null : new InputStreamReader(in, Charsets.UTF_8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,353 +0,0 @@
|
|||||||
package com.gmail.nossr50.metrics;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.config.HiddenConfig;
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
|
|
||||||
import com.turt2live.metrics.EMetrics;
|
|
||||||
import com.turt2live.metrics.Metrics;
|
|
||||||
import com.turt2live.metrics.Metrics.Graph;
|
|
||||||
import com.turt2live.metrics.data.DataEvent;
|
|
||||||
import com.turt2live.metrics.data.DataTracker;
|
|
||||||
import com.turt2live.metrics.tracker.Tracker;
|
|
||||||
|
|
||||||
public class MetricsManager {
|
|
||||||
private static boolean setup = false;
|
|
||||||
|
|
||||||
private static Tracker chimeraUseTracker;
|
|
||||||
private static Tracker chimeraServerUseTracker;
|
|
||||||
|
|
||||||
private static boolean customConfig = false;
|
|
||||||
|
|
||||||
private static DataTracker tracker;
|
|
||||||
private static EMetrics emetrics;
|
|
||||||
|
|
||||||
public static void setup() {
|
|
||||||
if (setup) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.getInstance().getStatsTrackingEnabled()) {
|
|
||||||
try {
|
|
||||||
emetrics = new EMetrics(mcMMO.p);
|
|
||||||
Metrics metrics = emetrics.getMetrics();
|
|
||||||
|
|
||||||
// Timings Graph
|
|
||||||
Graph timingsGraph = metrics.createGraph("Percentage of servers using timings");
|
|
||||||
|
|
||||||
if (mcMMO.p.getServer().getPluginManager().useTimings()) {
|
|
||||||
timingsGraph.addPlotter(new Metrics.Plotter("Enabled") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
timingsGraph.addPlotter(new Metrics.Plotter("Disabled") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Donut Version Graph
|
|
||||||
Graph versionDonutGraph = metrics.createGraph("Donut Version");
|
|
||||||
|
|
||||||
boolean haveVersionInformation = false;
|
|
||||||
boolean isOfficialBuild = false;
|
|
||||||
String officialKey = "e14cfacdd442a953343ebd8529138680";
|
|
||||||
|
|
||||||
String version = mcMMO.p.getDescription().getVersion();
|
|
||||||
|
|
||||||
InputStreamReader isr = new InputStreamReader(mcMMO.p.getResource(".jenkins"));
|
|
||||||
BufferedReader br = new BufferedReader(isr);
|
|
||||||
char[] key = new char[32];
|
|
||||||
br.read(key);
|
|
||||||
if (officialKey.equals(String.valueOf(key))) {
|
|
||||||
isOfficialBuild = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version.contains("-")) {
|
|
||||||
String majorVersion = version.substring(0, version.indexOf("-"));
|
|
||||||
String subVersion;
|
|
||||||
|
|
||||||
if (isOfficialBuild) {
|
|
||||||
int startIndex = version.indexOf("-");
|
|
||||||
if (version.substring(startIndex + 1).contains("-")) {
|
|
||||||
subVersion = version.substring(startIndex, version.indexOf("-", startIndex + 1));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
subVersion = "-release";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
subVersion = "-custom";
|
|
||||||
}
|
|
||||||
|
|
||||||
version = majorVersion + "~=~" + subVersion;
|
|
||||||
haveVersionInformation = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (haveVersionInformation) {
|
|
||||||
versionDonutGraph.addPlotter(new Metrics.Plotter(version) {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Official v Custom build Graph
|
|
||||||
Graph officialGraph = metrics.createGraph("Built by official ci");
|
|
||||||
|
|
||||||
if (isOfficialBuild) {
|
|
||||||
officialGraph.addPlotter(new Metrics.Plotter("Yes") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
officialGraph.addPlotter(new Metrics.Plotter("No") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Chunkmeta enabled Graph
|
|
||||||
Graph chunkmetaGraph = metrics.createGraph("Uses Chunkmeta");
|
|
||||||
|
|
||||||
if (HiddenConfig.getInstance().getChunkletsEnabled()) {
|
|
||||||
chunkmetaGraph.addPlotter(new Metrics.Plotter("Yes") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
chunkmetaGraph.addPlotter(new Metrics.Plotter("No") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Storage method Graph
|
|
||||||
Graph storageGraph = metrics.createGraph("Storage method");
|
|
||||||
|
|
||||||
if (Config.getInstance().getUseMySQL()) {
|
|
||||||
storageGraph.addPlotter(new Metrics.Plotter("SQL") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
storageGraph.addPlotter(new Metrics.Plotter("Flatfile") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Locale Graph
|
|
||||||
Graph localeGraph = metrics.createGraph("Locale");
|
|
||||||
|
|
||||||
localeGraph.addPlotter(new Metrics.Plotter(LocaleLoader.getCurrentLocale().getDisplayLanguage(Locale.US)) {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// ExperienceFormulaShape Graph
|
|
||||||
Graph experienceFormulaShapeGraph = metrics.createGraph("Experience Formula Shape Graph");
|
|
||||||
|
|
||||||
experienceFormulaShapeGraph.addPlotter(new Metrics.Plotter(ExperienceConfig.getInstance().getFormulaType().toString()) {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// GlobalMultiplier Graph
|
|
||||||
Graph globalMultiplierGraph = metrics.createGraph("Global Multiplier Graph");
|
|
||||||
|
|
||||||
globalMultiplierGraph.addPlotter(new Metrics.Plotter(ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier() + "") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// GlobalCurveModifier Graph
|
|
||||||
Graph globalCurveModifierGraph = metrics.createGraph("Global Curve Modifier Graph");
|
|
||||||
|
|
||||||
globalCurveModifierGraph.addPlotter(new Metrics.Plotter(ExperienceConfig.getInstance().getMultiplier(FormulaType.LINEAR) + "") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// GlobalMultiplierGraph Fuzzy Logic Numbers
|
|
||||||
Graph globalMultiplierGraphFuzzy = metrics.createGraph("Global Multiplier Fuzz");
|
|
||||||
|
|
||||||
if (ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier() > 1.0) {
|
|
||||||
globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Higher") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier() < 1.0) {
|
|
||||||
globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Lower") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Default") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// GlobalCurveModifier Fuzzy Logic Numbers
|
|
||||||
Graph globalCurveMultiplierGraphFuzzy = metrics.createGraph("Global Curve Multiplier Fuzz");
|
|
||||||
|
|
||||||
if (ExperienceConfig.getInstance().getMultiplier(FormulaType.LINEAR) > 20.0) {
|
|
||||||
globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Higher") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (ExperienceConfig.getInstance().getMultiplier(FormulaType.LINEAR) < 20.0) {
|
|
||||||
globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Lower") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Default") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Chimera Wing Usage Trackers
|
|
||||||
final String chimeraGraphName = "Chimera Wing Usage";
|
|
||||||
|
|
||||||
chimeraUseTracker = EMetrics.createBasicTracker(chimeraGraphName, "Player use");
|
|
||||||
chimeraServerUseTracker = EMetrics.createEnabledTracker(chimeraGraphName, "Server use");
|
|
||||||
|
|
||||||
emetrics.addTracker(chimeraUseTracker);
|
|
||||||
emetrics.addTracker(chimeraServerUseTracker);
|
|
||||||
|
|
||||||
// Chimera Wing Enabled Graph
|
|
||||||
Graph chimeraGraph = metrics.createGraph("Chimera Wing");
|
|
||||||
|
|
||||||
if (Config.getInstance().getChimaeraEnabled()) {
|
|
||||||
chimeraGraph.addPlotter(new Metrics.Plotter("Enabled") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
chimeraGraph.addPlotter(new Metrics.Plotter("Disabled") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Vanilla v Modified config graph
|
|
||||||
Graph customConfigGraph = metrics.createGraph("Modified Configs");
|
|
||||||
|
|
||||||
if (customConfig) {
|
|
||||||
customConfigGraph.addPlotter(new Metrics.Plotter("Edited") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
customConfigGraph.addPlotter(new Metrics.Plotter("Vanilla") {
|
|
||||||
@Override
|
|
||||||
public int getValue() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Debug stuff
|
|
||||||
* tracker = emetrics.getDataTracker();
|
|
||||||
* tracker.enable();
|
|
||||||
* tracker.setFilter(new DataEvent.DataType [] { DataEvent.DataType.SEND_DATA });
|
|
||||||
*/
|
|
||||||
|
|
||||||
emetrics.startMetrics();
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
mcMMO.p.getLogger().warning("Failed to submit stats.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void chimeraWingUsed() {
|
|
||||||
chimeraUseTracker.increment();
|
|
||||||
chimeraServerUseTracker.increment();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void customConfig() {
|
|
||||||
customConfig = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private static void debug() {
|
|
||||||
emetrics.getMetrics().flush();
|
|
||||||
|
|
||||||
for (DataEvent event : tracker.getEvents()) {
|
|
||||||
String graphName = event.getGraphName();
|
|
||||||
String colName = event.getTrackerName();
|
|
||||||
int value = event.getValueSent();
|
|
||||||
|
|
||||||
System.out.println("Graph: " + graphName + ", Column: " + colName + ", Value: " + value);
|
|
||||||
}
|
|
||||||
|
|
||||||
tracker.resetEvents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +1,5 @@
|
|||||||
package com.gmail.nossr50.party;
|
package com.gmail.nossr50.party;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
||||||
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
import com.gmail.nossr50.datatypes.database.UpgradeType;
|
||||||
@@ -26,8 +13,20 @@ import com.gmail.nossr50.events.party.McMMOPartyAllianceChangeEvent;
|
|||||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
|
||||||
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.mcMMO;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public final class PartyManager {
|
public final class PartyManager {
|
||||||
private static String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
|
private static String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
|
||||||
@@ -71,9 +70,7 @@ public final class PartyManager {
|
|||||||
|
|
||||||
removeFromParty(mcMMOPlayer);
|
removeFromParty(mcMMOPlayer);
|
||||||
}
|
}
|
||||||
else if (!handlePartyChangeEvent(player, null, newPartyName, EventReason.JOINED_PARTY)) {
|
else return handlePartyChangeEvent(player, null, newPartyName, EventReason.JOINED_PARTY);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -729,7 +726,7 @@ public final class PartyManager {
|
|||||||
member.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, level));
|
member.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, level));
|
||||||
|
|
||||||
if (levelUpSoundsEnabled) {
|
if (levelUpSoundsEnabled) {
|
||||||
member.playSound(member.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
member.playSound(member.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ public final class ShareHandler {
|
|||||||
|
|
||||||
private static void awardDrop(Player winningPlayer, ItemStack drop) {
|
private static void awardDrop(Player winningPlayer, ItemStack drop) {
|
||||||
if (winningPlayer.getInventory().addItem(drop).size() != 0) {
|
if (winningPlayer.getInventory().addItem(drop).size() != 0) {
|
||||||
winningPlayer.getWorld().dropItemNaturally(winningPlayer.getLocation(), drop);
|
winningPlayer.getWorld().dropItem(winningPlayer.getLocation(), drop);
|
||||||
}
|
}
|
||||||
|
|
||||||
winningPlayer.updateInventory();
|
winningPlayer.updateInventory();
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class StickyPistonTrackerTask extends BukkitRunnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!mcMMO.getPlaceStore().isTrue(movedBlock)) {
|
if (!mcMMO.getPlaceStore().isTrue(movedBlock.getRelative(direction))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ public class StickyPistonTrackerTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The sticky piston actually pulled the block so move the PlaceStore data
|
// The sticky piston actually pulled the block so move the PlaceStore data
|
||||||
mcMMO.getPlaceStore().setFalse(movedBlock);
|
mcMMO.getPlaceStore().setFalse(movedBlock.getRelative(direction));
|
||||||
mcMMO.getPlaceStore().setTrue(block.getRelative(direction));
|
mcMMO.getPlaceStore().setTrue(movedBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
package com.gmail.nossr50.runnables;
|
|
||||||
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
|
|
||||||
import net.gravitydevelopment.updater.mcmmo.Updater;
|
|
||||||
|
|
||||||
public class UpdaterResultAsyncTask extends BukkitRunnable {
|
|
||||||
private mcMMO plugin;
|
|
||||||
|
|
||||||
public UpdaterResultAsyncTask(mcMMO plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Updater updater = new Updater(plugin, 31030, plugin.mcmmo, Updater.UpdateType.NO_DOWNLOAD, false);
|
|
||||||
|
|
||||||
if (updater.getResult() != Updater.UpdateResult.UPDATE_AVAILABLE) {
|
|
||||||
plugin.setUpdateAvailable(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updater.getLatestType().equals("beta") && !Config.getInstance().getPreferBeta()) {
|
|
||||||
plugin.setUpdateAvailable(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.setUpdateAvailable(true);
|
|
||||||
plugin.getLogger().info(LocaleLoader.getString("UpdateChecker.Outdated"));
|
|
||||||
plugin.getLogger().info(LocaleLoader.getString("UpdateChecker.NewAvailable"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,16 @@
|
|||||||
package com.gmail.nossr50.runnables.commands;
|
package com.gmail.nossr50.runnables.commands;
|
||||||
|
|
||||||
import java.util.List;
|
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import java.util.List;
|
||||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the results of {@link MctopCommandAsyncTask} to the sender.
|
* Display the results of {@link MctopCommandAsyncTask} to the sender.
|
||||||
@@ -45,15 +44,27 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
|
|||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
((Player) sender).removeMetadata(mcMMO.databaseCommandKey, mcMMO.p);
|
((Player) sender).removeMetadata(mcMMO.databaseCommandKey, mcMMO.p);
|
||||||
}
|
}
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
if(sender instanceof Player)
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayChat() {
|
private void displayChat() {
|
||||||
|
|
||||||
if (skill == null) {
|
if (skill == null) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
if(sender instanceof Player) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(ChatColor.stripColor(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName()));
|
if(sender instanceof Player) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(ChatColor.stripColor(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int place = (page * 10) - 9;
|
int place = (page * 10) - 9;
|
||||||
@@ -62,7 +73,13 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
|
|||||||
// Format:
|
// Format:
|
||||||
// 01. Playername - skill value
|
// 01. Playername - skill value
|
||||||
// 12. Playername - skill value
|
// 12. Playername - skill value
|
||||||
sender.sendMessage(String.format("%2d. %s%s - %s%s", place, ChatColor.GREEN, stat.name, ChatColor.WHITE, stat.statVal));
|
if(sender instanceof Player) {
|
||||||
|
sender.sendMessage(String.format("%2d. %s%s - %s%s", place, ChatColor.GREEN, stat.name, ChatColor.WHITE, stat.statVal));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(String.format("%2d. %s - %s", place, stat.name, stat.statVal));
|
||||||
|
}
|
||||||
|
|
||||||
place++;
|
place++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable {
|
|||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
// Handle 429
|
// Handle 429
|
||||||
if (e.getMessage().contains("429")) {
|
if (e.getMessage().contains("429")) {
|
||||||
|
size += userNamesSection.size();
|
||||||
try {
|
try {
|
||||||
Thread.sleep(LIMIT_PERIOD);
|
Thread.sleep(LIMIT_PERIOD);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
|
|||||||
@@ -31,10 +31,11 @@ public class ChimaeraWingWarmup extends BukkitRunnable {
|
|||||||
|
|
||||||
if (player.getLocation().distanceSquared(previousLocation) > 1.0 || !player.getInventory().containsAtLeast(ChimaeraWing.getChimaeraWing(0), 1)) {
|
if (player.getLocation().distanceSquared(previousLocation) > 1.0 || !player.getInventory().containsAtLeast(ChimaeraWing.getChimaeraWing(0), 1)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Teleport.Cancelled"));
|
player.sendMessage(LocaleLoader.getString("Teleport.Cancelled"));
|
||||||
|
mcMMOPlayer.setTeleportCommenceLocation(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack inHand = player.getItemInHand();
|
ItemStack inHand = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
if (!ItemUtils.isChimaeraWing(inHand) || inHand.getAmount() < Config.getInstance().getChimaeraUseCost()) {
|
if (!ItemUtils.isChimaeraWing(inHand) || inHand.getAmount() < Config.getInstance().getChimaeraUseCost()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name")));
|
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name")));
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
package com.gmail.nossr50.runnables.party;
|
package com.gmail.nossr50.runnables.party;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
import com.gmail.nossr50.config.Config;
|
||||||
import java.util.regex.Pattern;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import java.util.regex.Matcher;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import java.util.regex.Pattern;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
|
|
||||||
public class PartyChatTask extends BukkitRunnable {
|
public class PartyChatTask extends BukkitRunnable {
|
||||||
private Plugin plugin;
|
private Plugin plugin;
|
||||||
@@ -46,6 +45,6 @@ public class PartyChatTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getServer().getConsoleSender().sendMessage("[mcMMO] [P]<" + party.getName() + ">" + message);
|
plugin.getServer().getConsoleSender().sendMessage(ChatColor.stripColor("[mcMMO] [P]<" + party.getName() + ">" + message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
|
|||||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true);
|
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true);
|
||||||
// If successful, schedule the apply
|
// If successful, schedule the apply
|
||||||
if (profile.isLoaded()) {
|
if (profile.isLoaded()) {
|
||||||
new ApplySuccessfulProfile(profile).runTask(mcMMO.p);
|
new ApplySuccessfulProfile(new McMMOPlayer(player, profile)).runTask(mcMMO.p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,10 +59,10 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class ApplySuccessfulProfile extends BukkitRunnable {
|
private class ApplySuccessfulProfile extends BukkitRunnable {
|
||||||
private final PlayerProfile profile;
|
private final McMMOPlayer mcMMOPlayer;
|
||||||
|
|
||||||
private ApplySuccessfulProfile(PlayerProfile profile) {
|
private ApplySuccessfulProfile(McMMOPlayer mcMMOPlayer) {
|
||||||
this.profile = profile;
|
this.mcMMOPlayer = mcMMOPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synchronized task
|
// Synchronized task
|
||||||
@@ -74,7 +74,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = new McMMOPlayer(player, profile);
|
mcMMOPlayer.setupPartyData();
|
||||||
UserManager.track(mcMMOPlayer);
|
UserManager.track(mcMMOPlayer);
|
||||||
mcMMOPlayer.actualizeRespawnATS();
|
mcMMOPlayer.actualizeRespawnATS();
|
||||||
ScoreboardManager.setupPlayer(player);
|
ScoreboardManager.setupPlayer(player);
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ public class AbilityDisableTask extends BukkitRunnable {
|
|||||||
int chunkX = chunk.getX();
|
int chunkX = chunk.getX();
|
||||||
int chunkZ = chunk.getZ();
|
int chunkZ = chunk.getZ();
|
||||||
|
|
||||||
for (int x = chunkX - radius; x < chunkX + radius; x++) {
|
for (int x = chunkX - radius; x <= chunkX + radius; x++) {
|
||||||
for (int z = chunkZ - radius; z < chunkZ + radius; z++) {
|
for (int z = chunkZ - radius; z <= chunkZ + radius; z++) {
|
||||||
world.refreshChunk(x, z);
|
world.refreshChunk(x, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class AlchemyBrewCheckTask extends BukkitRunnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
Location location = brewingStand.getLocation();
|
Location location = brewingStand.getLocation();
|
||||||
ItemStack[] newInventory = Arrays.copyOfRange(brewingStand.getInventory().getContents(), 0, 4);
|
ItemStack[] newInventory = Arrays.copyOfRange(brewingStand.getInventory().getContents(), 0, 4);
|
||||||
boolean validBrew = AlchemyPotionBrewer.isValidBrew(player, newInventory);
|
boolean validBrew = brewingStand.getFuelLevel() > 0 && AlchemyPotionBrewer.isValidBrew(player, newInventory);
|
||||||
|
|
||||||
if (Alchemy.brewingStandMap.containsKey(location)) {
|
if (Alchemy.brewingStandMap.containsKey(location)) {
|
||||||
if (oldInventory[Alchemy.INGREDIENT_SLOT] == null || newInventory[Alchemy.INGREDIENT_SLOT] == null || !oldInventory[Alchemy.INGREDIENT_SLOT].isSimilar(newInventory[Alchemy.INGREDIENT_SLOT]) || !validBrew) {
|
if (oldInventory[Alchemy.INGREDIENT_SLOT] == null || newInventory[Alchemy.INGREDIENT_SLOT] == null || !oldInventory[Alchemy.INGREDIENT_SLOT].isSimilar(newInventory[Alchemy.INGREDIENT_SLOT]) || !validBrew) {
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ public class AlchemyBrewTask extends BukkitRunnable {
|
|||||||
private double brewSpeed;
|
private double brewSpeed;
|
||||||
private double brewTimer;
|
private double brewTimer;
|
||||||
private Player player;
|
private Player player;
|
||||||
|
private int fuel;
|
||||||
|
private boolean firstRun = true;
|
||||||
|
|
||||||
public AlchemyBrewTask(BlockState brewingStand, Player player) {
|
public AlchemyBrewTask(BlockState brewingStand, Player player) {
|
||||||
this.brewingStand = brewingStand;
|
this.brewingStand = brewingStand;
|
||||||
@@ -51,13 +53,18 @@ public class AlchemyBrewTask extends BukkitRunnable {
|
|||||||
Alchemy.brewingStandMap.get(location).cancel();
|
Alchemy.brewingStandMap.get(location).cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fuel = ((BrewingStand) brewingStand).getFuelLevel();
|
||||||
|
|
||||||
|
if (((BrewingStand) brewingStand).getBrewingTime() == -1) // Only decrement on our end if it isn't a vanilla ingredient.
|
||||||
|
fuel--;
|
||||||
|
|
||||||
Alchemy.brewingStandMap.put(location, this);
|
Alchemy.brewingStandMap.put(location, this);
|
||||||
this.runTaskTimer(mcMMO.p, 1, 1);
|
this.runTaskTimer(mcMMO.p, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (player == null || !player.isValid() || brewingStand == null || brewingStand.getType() != Material.BREWING_STAND) {
|
if (player == null || !player.isValid() || brewingStand == null || brewingStand.getType() != Material.BREWING_STAND || !AlchemyPotionBrewer.isValidIngredient(player, ((BrewingStand) brewingStand).getInventory().getContents()[Alchemy.INGREDIENT_SLOT])) {
|
||||||
if (Alchemy.brewingStandMap.containsKey(location)) {
|
if (Alchemy.brewingStandMap.containsKey(location)) {
|
||||||
Alchemy.brewingStandMap.remove(location);
|
Alchemy.brewingStandMap.remove(location);
|
||||||
}
|
}
|
||||||
@@ -67,6 +74,11 @@ public class AlchemyBrewTask extends BukkitRunnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (firstRun) {
|
||||||
|
firstRun = false;
|
||||||
|
((BrewingStand) brewingStand).setFuelLevel(fuel);
|
||||||
|
}
|
||||||
|
|
||||||
brewTimer -= brewSpeed;
|
brewTimer -= brewSpeed;
|
||||||
|
|
||||||
// Vanilla potion brewing completes when BrewingTime == 1
|
// Vanilla potion brewing completes when BrewingTime == 1
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
package com.gmail.nossr50.runnables.skills;
|
package com.gmail.nossr50.runnables.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.HolidayManager;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.util.HolidayManager;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
|
|
||||||
public class AprilTask extends BukkitRunnable {
|
public class AprilTask extends BukkitRunnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -23,7 +22,7 @@ public class AprilTask extends BukkitRunnable {
|
|||||||
int random = Misc.getRandom().nextInt(40) + 11;
|
int random = Misc.getRandom().nextInt(40) + 11;
|
||||||
int betterRandom = Misc.getRandom().nextInt(2000);
|
int betterRandom = Misc.getRandom().nextInt(2000);
|
||||||
if (betterRandom == 0) {
|
if (betterRandom == 0) {
|
||||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
||||||
player.sendMessage(unknown("superskill") + " skill increased by 1. Total (" + unknown("12") + ")");
|
player.sendMessage(unknown("superskill") + " skill increased by 1. Total (" + unknown("12") + ")");
|
||||||
fireworksShow(player);
|
fireworksShow(player);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.runnables.skills;
|
package com.gmail.nossr50.runnables.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@@ -7,9 +9,6 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
|
|
||||||
public class KrakenAttackTask extends BukkitRunnable {
|
public class KrakenAttackTask extends BukkitRunnable {
|
||||||
private LivingEntity kraken;
|
private LivingEntity kraken;
|
||||||
private Player player;
|
private Player player;
|
||||||
@@ -86,11 +85,11 @@ public class KrakenAttackTask extends BukkitRunnable {
|
|||||||
player.damage(AdvancedConfig.getInstance().getKrakenAttackDamage(), kraken);
|
player.damage(AdvancedConfig.getInstance().getKrakenAttackDamage(), kraken);
|
||||||
|
|
||||||
if (GLOBAL_EFFECTS) {
|
if (GLOBAL_EFFECTS) {
|
||||||
world.playSound(playerLocation, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
world.playSound(playerLocation, Sound.ENTITY_GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
||||||
world.strikeLightningEffect(playerLocation);
|
world.strikeLightningEffect(playerLocation);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.playSound(playerLocation, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
player.playSound(playerLocation, Sound.ENTITY_GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
||||||
world.createExplosion(playerLocation.getX(), playerLocation.getY(), playerLocation.getZ(), 0F, false, false);
|
world.createExplosion(playerLocation.getX(), playerLocation.getY(), playerLocation.getZ(), 0F, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
|
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
|
||||||
if (player.getItemInHand().getType() == Material.ENDER_PEARL || player.isInsideVehicle()) {
|
if (player.getInventory().getItemInMainHand().getType() == Material.ENDER_PEARL || player.isInsideVehicle()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,16 +38,7 @@ public class AlchemyManager extends SkillManager {
|
|||||||
StringBuilder list = new StringBuilder();
|
StringBuilder list = new StringBuilder();
|
||||||
|
|
||||||
for (ItemStack ingredient : getIngredients()) {
|
for (ItemStack ingredient : getIngredients()) {
|
||||||
short durability = ingredient.getDurability();
|
String string = StringUtils.getPrettyItemString(ingredient.getType());
|
||||||
|
|
||||||
String string = StringUtils.getPrettyItemString(ingredient.getType()) + (durability != 0 ? ":" + durability : "");
|
|
||||||
|
|
||||||
if (string.equals("Long Grass:2")) {
|
|
||||||
string = "Fern";
|
|
||||||
}
|
|
||||||
else if (string.equals("Raw Fish:3")) {
|
|
||||||
string = "Pufferfish";
|
|
||||||
}
|
|
||||||
|
|
||||||
list.append(", ").append(string);
|
list.append(", ").append(string);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ public final class AlchemyPotionBrewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (contents[i] == null || contents[i].getType() != Material.POTION) {
|
if (contents[i] == null || contents[i].getType() != Material.POTION && contents[i].getType() != Material.SPLASH_POTION && contents[i].getType() != Material.LINGERING_POTION) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getChildPotion(PotionConfig.getInstance().getPotion(contents[i].getDurability()), contents[Alchemy.INGREDIENT_SLOT]) != null) {
|
if (getChildPotion(PotionConfig.getInstance().getPotion(contents[i]), contents[Alchemy.INGREDIENT_SLOT]) != null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,8 +45,8 @@ public final class AlchemyPotionBrewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static AlchemyPotion getChildPotion(AlchemyPotion potion, ItemStack ingredient) {
|
private static AlchemyPotion getChildPotion(AlchemyPotion potion, ItemStack ingredient) {
|
||||||
if (potion != null && potion.getChildDataValue(ingredient) != -1) {
|
if (potion != null) {
|
||||||
return PotionConfig.getInstance().getPotion(potion.getChildDataValue(ingredient));
|
return potion.getChild(ingredient);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -56,23 +56,29 @@ public final class AlchemyPotionBrewer {
|
|||||||
return item == null || item.getType() == Material.AIR || item.getAmount() == 0;
|
return item == null || item.getType() == Material.AIR || item.getAmount() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean removeIngredient(BrewerInventory inventory, Player player) {
|
private static void removeIngredient(BrewerInventory inventory, Player player) {
|
||||||
ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
|
ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
|
||||||
|
|
||||||
if (isEmpty(ingredient) || !isValidIngredient(player, ingredient)) {
|
if (isEmpty(ingredient) || !isValidIngredient(player, ingredient)) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
else if (ingredient.getAmount() <= 1) {
|
else if (ingredient.getAmount() <= 1) {
|
||||||
inventory.setIngredient(null);
|
inventory.setIngredient(null);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ingredient.setAmount(ingredient.getAmount() - 1);
|
ingredient.setAmount(ingredient.getAmount() - 1);
|
||||||
inventory.setIngredient(ingredient);
|
inventory.setIngredient(ingredient);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean hasIngredient(BrewerInventory inventory, Player player) {
|
||||||
|
ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
|
||||||
|
|
||||||
|
return !isEmpty(ingredient) && isValidIngredient(player, ingredient);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isValidIngredient(Player player, ItemStack item) {
|
public static boolean isValidIngredient(Player player, ItemStack item) {
|
||||||
if (isEmpty(item)) {
|
if (isEmpty(item)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -99,7 +105,7 @@ public final class AlchemyPotionBrewer {
|
|||||||
BrewerInventory inventory = ((BrewingStand) brewingStand).getInventory();
|
BrewerInventory inventory = ((BrewingStand) brewingStand).getInventory();
|
||||||
ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
|
ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
|
||||||
|
|
||||||
if (!removeIngredient(inventory, player)) {
|
if (!hasIngredient(inventory, player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,8 +118,8 @@ public final class AlchemyPotionBrewer {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
AlchemyPotion input = PotionConfig.getInstance().getPotion(item.getDurability());
|
AlchemyPotion input = PotionConfig.getInstance().getPotion(item);
|
||||||
AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient));
|
AlchemyPotion output = input.getChild(ingredient);
|
||||||
|
|
||||||
inputList.add(input);
|
inputList.add(input);
|
||||||
|
|
||||||
@@ -122,15 +128,17 @@ public final class AlchemyPotionBrewer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FakeBrewEvent event = new FakeBrewEvent(brewingStand.getBlock(), inventory);
|
FakeBrewEvent event = new FakeBrewEvent(brewingStand.getBlock(), inventory, ((BrewingStand) brewingStand).getFuelLevel());
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled() || inputList.isEmpty()) {
|
if (event.isCancelled() || inputList.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeIngredient(inventory, player);
|
||||||
|
|
||||||
for (AlchemyPotion input : inputList) {
|
for (AlchemyPotion input : inputList) {
|
||||||
AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient));
|
AlchemyPotion output = input.getChild(ingredient);
|
||||||
|
|
||||||
if (output != null && player != null) {
|
if (output != null && player != null) {
|
||||||
PotionStage potionStage = PotionStage.getPotionStage(input, output);
|
PotionStage potionStage = PotionStage.getPotionStage(input, output);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
public class Archery {
|
public class Archery {
|
||||||
@@ -21,7 +22,7 @@ public class Archery {
|
|||||||
|
|
||||||
public static double dazeBonusDamage = AdvancedConfig.getInstance().getDazeBonusDamage();
|
public static double dazeBonusDamage = AdvancedConfig.getInstance().getDazeBonusDamage();
|
||||||
|
|
||||||
public static final double DISTANCE_XP_MULTIPLIER = 0.025;
|
public static final double DISTANCE_XP_MULTIPLIER = ExperienceConfig.getInstance().getArcheryDistanceMultiplier();
|
||||||
|
|
||||||
protected static void incrementTrackerValue(LivingEntity livingEntity) {
|
protected static void incrementTrackerValue(LivingEntity livingEntity) {
|
||||||
for (TrackedEntity trackedEntity : trackedEntities) {
|
for (TrackedEntity trackedEntity : trackedEntities) {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class ArcheryManager extends SkillManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
applyXpGain((int) (firedLocation.distanceSquared(targetLocation) * Archery.DISTANCE_XP_MULTIPLIER), getXPGainReason(target, damager));
|
applyXpGain((int) (Math.min(firedLocation.distanceSquared(targetLocation), 2500) * Archery.DISTANCE_XP_MULTIPLIER), getXPGainReason(target, damager));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class Axes {
|
|||||||
|
|
||||||
protected static boolean hasArmor(LivingEntity target) {
|
protected static boolean hasArmor(LivingEntity target) {
|
||||||
for (ItemStack itemStack : target.getEquipment().getArmorContents()) {
|
for (ItemStack itemStack : target.getEquipment().getArmorContents()) {
|
||||||
if (ItemUtils.isArmor(itemStack)) {
|
if (itemStack != null && ItemUtils.isArmor(itemStack)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,10 +74,16 @@ public class AxesManager extends SkillManager {
|
|||||||
|
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
|
if (mcMMOPlayer.useChatNotifications()) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
|
||||||
|
}
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player) {
|
||||||
((Player) target).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
|
Player defender = (Player) target;
|
||||||
|
|
||||||
|
if (UserManager.getPlayer(defender).useChatNotifications()) {
|
||||||
|
defender.sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
|
||||||
|
}
|
||||||
|
|
||||||
damage = (damage * Axes.criticalHitPVPModifier) - damage;
|
damage = (damage * Axes.criticalHitPVPModifier) - damage;
|
||||||
}
|
}
|
||||||
@@ -97,7 +103,7 @@ public class AxesManager extends SkillManager {
|
|||||||
int durabilityDamage = 1 + (getSkillLevel() / Axes.impactIncreaseLevel);
|
int durabilityDamage = 1 + (getSkillLevel() / Axes.impactIncreaseLevel);
|
||||||
|
|
||||||
for (ItemStack armor : target.getEquipment().getArmorContents()) {
|
for (ItemStack armor : target.getEquipment().getArmorContents()) {
|
||||||
if (ItemUtils.isArmor(armor)) {
|
if (armor != null && ItemUtils.isArmor(armor)) {
|
||||||
if (SkillUtils.activationSuccessful(SecondaryAbility.ARMOR_IMPACT, getPlayer(), Axes.impactChance, activationChance)) {
|
if (SkillUtils.activationSuccessful(SecondaryAbility.ARMOR_IMPACT, getPlayer(), Axes.impactChance, activationChance)) {
|
||||||
SkillUtils.handleDurabilityChange(armor, durabilityDamage, Axes.impactMaxDurabilityModifier);
|
SkillUtils.handleDurabilityChange(armor, durabilityDamage, Axes.impactMaxDurabilityModifier);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class ChildConfig extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResource("child.yml")));
|
config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResourceAsReader("child.yml")));
|
||||||
|
|
||||||
FamilyTree.clearRegistrations(); // when reloading, need to clear statics
|
FamilyTree.clearRegistrations(); // when reloading, need to clear statics
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
package com.gmail.nossr50.skills.excavation;
|
package com.gmail.nossr50.skills.excavation;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
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.ExcavationTreasure;
|
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Excavation {
|
public class Excavation {
|
||||||
/**
|
/**
|
||||||
@@ -20,46 +19,14 @@ public class Excavation {
|
|||||||
* @return the list of treasures that could be found
|
* @return the list of treasures that could be found
|
||||||
*/
|
*/
|
||||||
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
|
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData());
|
||||||
case DIRT:
|
if (TreasureConfig.getInstance().excavationMap.containsKey(friendly))
|
||||||
return blockState.getRawData() == 0x2 ? TreasureConfig.getInstance().excavationFromPodzol : TreasureConfig.getInstance().excavationFromDirt;
|
return TreasureConfig.getInstance().excavationMap.get(friendly);
|
||||||
|
return new ArrayList<ExcavationTreasure>();
|
||||||
case GRASS:
|
|
||||||
return TreasureConfig.getInstance().excavationFromGrass;
|
|
||||||
|
|
||||||
case SAND:
|
|
||||||
return blockState.getRawData() == 0x1 ? TreasureConfig.getInstance().excavationFromRedSand : TreasureConfig.getInstance().excavationFromSand;
|
|
||||||
|
|
||||||
case GRAVEL:
|
|
||||||
return TreasureConfig.getInstance().excavationFromGravel;
|
|
||||||
|
|
||||||
case CLAY:
|
|
||||||
return TreasureConfig.getInstance().excavationFromClay;
|
|
||||||
|
|
||||||
case MYCEL:
|
|
||||||
return TreasureConfig.getInstance().excavationFromMycel;
|
|
||||||
|
|
||||||
case SOUL_SAND:
|
|
||||||
return TreasureConfig.getInstance().excavationFromSoulSand;
|
|
||||||
|
|
||||||
case SNOW:
|
|
||||||
return TreasureConfig.getInstance().excavationFromSnow;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return new ArrayList<ExcavationTreasure>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static int getBlockXP(BlockState blockState) {
|
protected static int getBlockXP(BlockState blockState) {
|
||||||
Material material = blockState.getType();
|
int xp = ExperienceConfig.getInstance().getXp(SkillType.EXCAVATION, blockState.getType());
|
||||||
int xp;
|
|
||||||
|
|
||||||
if (material == Material.DIRT || material == Material.SAND) {
|
|
||||||
xp = ExperienceConfig.getInstance().getDirtAndSandXp(blockState.getData());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
xp = ExperienceConfig.getInstance().getXp(SkillType.EXCAVATION, material);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xp == 0 && mcMMO.getModManager().isCustomExcavationBlock(blockState)) {
|
if (xp == 0 && mcMMO.getModManager().isCustomExcavationBlock(blockState)) {
|
||||||
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
|
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class ExcavationManager extends SkillManager {
|
|||||||
|
|
||||||
if (!treasures.isEmpty()) {
|
if (!treasures.isEmpty()) {
|
||||||
int skillLevel = getSkillLevel();
|
int skillLevel = getSkillLevel();
|
||||||
Location location = blockState.getLocation();
|
Location location = Misc.getBlockCenter(blockState);
|
||||||
|
|
||||||
for (ExcavationTreasure treasure : treasures) {
|
for (ExcavationTreasure treasure : treasures) {
|
||||||
if (skillLevel >= treasure.getDropLevel() && SkillUtils.treasureDropSuccessful(getPlayer(), treasure.getDropChance(), activationChance)) {
|
if (skillLevel >= treasure.getDropLevel() && SkillUtils.treasureDropSuccessful(getPlayer(), treasure.getDropChance(), activationChance)) {
|
||||||
@@ -57,6 +57,6 @@ public class ExcavationManager extends SkillManager {
|
|||||||
excavationBlockCheck(blockState);
|
excavationBlockCheck(blockState);
|
||||||
excavationBlockCheck(blockState);
|
excavationBlockCheck(blockState);
|
||||||
|
|
||||||
SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage());
|
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.fishing;
|
package com.gmail.nossr50.skills.fishing;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -8,6 +7,7 @@ import java.util.Set;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Guardian;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@@ -15,18 +15,13 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
|||||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||||
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.adapter.BiomeAdapter;
|
||||||
|
|
||||||
public final class Fishing {
|
public final class Fishing {
|
||||||
|
|
||||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||||
public enum Tier {
|
public enum Tier {
|
||||||
EIGHT(8),
|
EIGHT(8), SEVEN(7), SIX(6), FIVE(5), FOUR(4), THREE(3), TWO(2), ONE(1);
|
||||||
SEVEN(7),
|
|
||||||
SIX(6),
|
|
||||||
FIVE(5),
|
|
||||||
FOUR(4),
|
|
||||||
THREE(3),
|
|
||||||
TWO(2),
|
|
||||||
ONE(1);
|
|
||||||
|
|
||||||
int numerical;
|
int numerical;
|
||||||
|
|
||||||
@@ -57,95 +52,30 @@ public final class Fishing {
|
|||||||
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
|
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
|
||||||
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;
|
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;
|
||||||
|
|
||||||
public static Set<Biome> masterAnglerBiomes = EnumSet.of(Biome.RIVER, Biome.OCEAN, Biome.DEEP_OCEAN);
|
public static Set<Biome> masterAnglerBiomes = BiomeAdapter.WATER_BIOMES;
|
||||||
public static Set<Biome> iceFishingBiomes = EnumSet.of(
|
public static Set<Biome> iceFishingBiomes = BiomeAdapter.ICE_BIOMES;
|
||||||
Biome.FROZEN_OCEAN, Biome.FROZEN_RIVER,
|
|
||||||
Biome.TAIGA, Biome.TAIGA_HILLS, Biome.TAIGA_MOUNTAINS,
|
|
||||||
Biome.ICE_PLAINS, Biome.ICE_MOUNTAINS, Biome.ICE_PLAINS_SPIKES,
|
|
||||||
Biome.COLD_TAIGA, Biome.COLD_TAIGA_HILLS, Biome.COLD_TAIGA_MOUNTAINS);
|
|
||||||
|
|
||||||
private Fishing() {}
|
private Fishing() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the possible drops of an entity
|
* Finds the possible drops of an entity
|
||||||
*
|
*
|
||||||
* @param target Targeted entity
|
* @param target
|
||||||
|
* Targeted entity
|
||||||
* @return possibleDrops List of ItemStack that can be dropped
|
* @return possibleDrops List of ItemStack that can be dropped
|
||||||
*/
|
*/
|
||||||
protected static List<ShakeTreasure> findPossibleDrops(LivingEntity target) {
|
protected static List<ShakeTreasure> findPossibleDrops(LivingEntity target) {
|
||||||
switch (target.getType()) {
|
if (TreasureConfig.getInstance().shakeMap.containsKey(target.getType()))
|
||||||
case BLAZE:
|
return TreasureConfig.getInstance().shakeMap.get(target.getType());
|
||||||
return TreasureConfig.getInstance().shakeFromBlaze;
|
|
||||||
|
|
||||||
case CAVE_SPIDER:
|
return null;
|
||||||
return TreasureConfig.getInstance().shakeFromCaveSpider;
|
|
||||||
|
|
||||||
case CHICKEN:
|
|
||||||
return TreasureConfig.getInstance().shakeFromChicken;
|
|
||||||
|
|
||||||
case COW:
|
|
||||||
return TreasureConfig.getInstance().shakeFromCow;
|
|
||||||
|
|
||||||
case CREEPER:
|
|
||||||
return TreasureConfig.getInstance().shakeFromCreeper;
|
|
||||||
|
|
||||||
case ENDERMAN:
|
|
||||||
return TreasureConfig.getInstance().shakeFromEnderman;
|
|
||||||
|
|
||||||
case GHAST:
|
|
||||||
return TreasureConfig.getInstance().shakeFromGhast;
|
|
||||||
|
|
||||||
case IRON_GOLEM:
|
|
||||||
return TreasureConfig.getInstance().shakeFromIronGolem;
|
|
||||||
|
|
||||||
case MAGMA_CUBE:
|
|
||||||
return TreasureConfig.getInstance().shakeFromMagmaCube;
|
|
||||||
|
|
||||||
case MUSHROOM_COW:
|
|
||||||
return TreasureConfig.getInstance().shakeFromMushroomCow;
|
|
||||||
|
|
||||||
case PIG:
|
|
||||||
return TreasureConfig.getInstance().shakeFromPig;
|
|
||||||
|
|
||||||
case PIG_ZOMBIE:
|
|
||||||
return TreasureConfig.getInstance().shakeFromPigZombie;
|
|
||||||
|
|
||||||
case PLAYER:
|
|
||||||
return TreasureConfig.getInstance().shakeFromPlayer;
|
|
||||||
|
|
||||||
case SHEEP:
|
|
||||||
return TreasureConfig.getInstance().shakeFromSheep;
|
|
||||||
|
|
||||||
case SKELETON:
|
|
||||||
return TreasureConfig.getInstance().shakeFromSkeleton;
|
|
||||||
|
|
||||||
case SLIME:
|
|
||||||
return TreasureConfig.getInstance().shakeFromSlime;
|
|
||||||
|
|
||||||
case SNOWMAN:
|
|
||||||
return TreasureConfig.getInstance().shakeFromSnowman;
|
|
||||||
|
|
||||||
case SPIDER:
|
|
||||||
return TreasureConfig.getInstance().shakeFromSpider;
|
|
||||||
|
|
||||||
case SQUID:
|
|
||||||
return TreasureConfig.getInstance().shakeFromSquid;
|
|
||||||
|
|
||||||
case WITCH:
|
|
||||||
return TreasureConfig.getInstance().shakeFromWitch;
|
|
||||||
|
|
||||||
case ZOMBIE:
|
|
||||||
return TreasureConfig.getInstance().shakeFromZombie;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Randomly chooses a drop among the list
|
* Randomly chooses a drop among the list
|
||||||
*
|
*
|
||||||
* @param possibleDrops List of ItemStack that can be dropped
|
* @param possibleDrops
|
||||||
|
* List of ItemStack that can be dropped
|
||||||
* @return Chosen ItemStack
|
* @return Chosen ItemStack
|
||||||
*/
|
*/
|
||||||
protected static ItemStack chooseDrop(List<ShakeTreasure> possibleDrops) {
|
protected static ItemStack chooseDrop(List<ShakeTreasure> possibleDrops) {
|
||||||
|
|||||||
@@ -1,41 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.fishing;
|
package com.gmail.nossr50.skills.fishing;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.WeatherType;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Fish;
|
|
||||||
import org.bukkit.entity.Item;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.Sheep;
|
|
||||||
import org.bukkit.entity.Skeleton;
|
|
||||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
|
||||||
import org.bukkit.entity.TNTPrimed;
|
|
||||||
import org.bukkit.entity.ThrownPotion;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
import org.bukkit.material.Wool;
|
|
||||||
import org.bukkit.potion.Potion;
|
|
||||||
import org.bukkit.potion.PotionType;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
@@ -52,16 +16,27 @@ import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
|
|||||||
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent;
|
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent;
|
||||||
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
|
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.runnables.skills.KrakenAttackTask;
|
import com.gmail.nossr50.runnables.skills.KrakenAttackTask;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.*;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.*;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
import org.bukkit.potion.Potion;
|
||||||
|
import org.bukkit.potion.PotionType;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class FishingManager extends SkillManager {
|
public class FishingManager extends SkillManager {
|
||||||
private final long FISHING_COOLDOWN_SECONDS = 1000L;
|
private final long FISHING_COOLDOWN_SECONDS = 1000L;
|
||||||
@@ -121,7 +96,7 @@ public class FishingManager extends SkillManager {
|
|||||||
world.strikeLightningEffect(location);
|
world.strikeLightningEffect(location);
|
||||||
world.strikeLightningEffect(location);
|
world.strikeLightningEffect(location);
|
||||||
|
|
||||||
world.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
world.playSound(location, Sound.ENTITY_GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
||||||
mcMMO.p.getServer().broadcastMessage(ChatColor.RED + AdvancedConfig.getInstance().getServerUnleashMessage().replace("(PLAYER)", player.getDisplayName()));
|
mcMMO.p.getServer().broadcastMessage(ChatColor.RED + AdvancedConfig.getInstance().getServerUnleashMessage().replace("(PLAYER)", player.getDisplayName()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -129,11 +104,14 @@ public class FishingManager extends SkillManager {
|
|||||||
world.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
|
world.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
|
||||||
world.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
|
world.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
|
||||||
|
|
||||||
player.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
player.playSound(location, Sound.ENTITY_GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getItemInHand().getType() == Material.FISHING_ROD) {
|
if (player.getInventory().getItemInMainHand().getType() == Material.FISHING_ROD) {
|
||||||
player.setItemInHand(null);
|
player.getInventory().setItemInMainHand(null);
|
||||||
|
}
|
||||||
|
else if (player.getInventory().getItemInOffHand().getType() == Material.FISHING_ROD) {
|
||||||
|
player.getInventory().setItemInOffHand(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
LivingEntity kraken = (LivingEntity) world.spawnEntity(player.getEyeLocation(), (Misc.getRandom().nextInt(100) == 0 ? EntityType.CHICKEN : EntityType.SQUID));
|
LivingEntity kraken = (LivingEntity) world.spawnEntity(player.getEyeLocation(), (Misc.getRandom().nextInt(100) == 0 ? EntityType.CHICKEN : EntityType.SQUID));
|
||||||
@@ -199,7 +177,7 @@ public class FishingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure this is a body of water, not just a block of ice.
|
// Make sure this is a body of water, not just a block of ice.
|
||||||
if (!Fishing.iceFishingBiomes.contains(block.getBiome()) && (block.getRelative(BlockFace.DOWN, 3).getType() != Material.STATIONARY_WATER)) {
|
if (!Fishing.iceFishingBiomes.contains(block.getBiome()) && (block.getRelative(BlockFace.DOWN, 3).getType() != Material.WATER)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,16 +236,16 @@ public class FishingManager extends SkillManager {
|
|||||||
return SkillUtils.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Fishing.fishermansDietRankLevel1, Fishing.fishermansDietMaxLevel, rankChange);
|
return SkillUtils.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Fishing.fishermansDietRankLevel1, Fishing.fishermansDietMaxLevel, rankChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void iceFishing(Fish hook, Block block) {
|
public void iceFishing(FishHook hook, Block block) {
|
||||||
// Make a hole
|
// Make a hole
|
||||||
block.setType(Material.STATIONARY_WATER);
|
block.setType(Material.WATER);
|
||||||
|
|
||||||
for (int x = -1; x <= 1; x++) {
|
for (int x = -1; x <= 1; x++) {
|
||||||
for (int z = -1; z <= 1; z++) {
|
for (int z = -1; z <= 1; z++) {
|
||||||
Block relative = block.getRelative(x, 0, z);
|
Block relative = block.getRelative(x, 0, z);
|
||||||
|
|
||||||
if (relative.getType() == Material.ICE) {
|
if (relative.getType() == Material.ICE) {
|
||||||
relative.setType(Material.STATIONARY_WATER);
|
relative.setType(Material.WATER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,7 +254,7 @@ public class FishingManager extends SkillManager {
|
|||||||
EventUtils.callFakeFishEvent(getPlayer(), hook);
|
EventUtils.callFakeFishEvent(getPlayer(), hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void masterAngler(Fish hook) {
|
public void masterAngler(FishHook hook) {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
Location location = hook.getLocation();
|
Location location = hook.getLocation();
|
||||||
double biteChance = hook.getBiteChance();
|
double biteChance = hook.getBiteChance();
|
||||||
@@ -301,7 +279,7 @@ public class FishingManager extends SkillManager {
|
|||||||
*/
|
*/
|
||||||
public void handleFishing(Item fishingCatch) {
|
public void handleFishing(Item fishingCatch) {
|
||||||
this.fishingCatch = fishingCatch;
|
this.fishingCatch = fishingCatch;
|
||||||
int fishXp = ExperienceConfig.getInstance().getFishXp(fishingCatch.getItemStack().getData());
|
int fishXp = ExperienceConfig.getInstance().getXp(SkillType.FISHING, fishingCatch.getItemStack().getType());
|
||||||
int treasureXp = 0;
|
int treasureXp = 0;
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
FishingTreasure treasure = null;
|
FishingTreasure treasure = null;
|
||||||
@@ -399,14 +377,14 @@ public class FishingManager extends SkillManager {
|
|||||||
Player targetPlayer = (Player) target;
|
Player targetPlayer = (Player) target;
|
||||||
|
|
||||||
switch (drop.getType()) {
|
switch (drop.getType()) {
|
||||||
case SKULL_ITEM:
|
case PLAYER_HEAD:
|
||||||
drop.setDurability((short) 3);
|
drop.setDurability((short) 3);
|
||||||
SkullMeta skullMeta = (SkullMeta) drop.getItemMeta();
|
SkullMeta skullMeta = (SkullMeta) drop.getItemMeta();
|
||||||
skullMeta.setOwner(targetPlayer.getName());
|
skullMeta.setOwningPlayer(targetPlayer);
|
||||||
drop.setItemMeta(skullMeta);
|
drop.setItemMeta(skullMeta);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BED_BLOCK:
|
case BEDROCK:
|
||||||
if (TreasureConfig.getInstance().getInventoryStealEnabled()) {
|
if (TreasureConfig.getInstance().getInventoryStealEnabled()) {
|
||||||
PlayerInventory inventory = targetPlayer.getInventory();
|
PlayerInventory inventory = targetPlayer.getInventory();
|
||||||
int length = inventory.getContents().length;
|
int length = inventory.getContents().length;
|
||||||
@@ -437,35 +415,15 @@ public class FishingManager extends SkillManager {
|
|||||||
case SHEEP:
|
case SHEEP:
|
||||||
Sheep sheep = (Sheep) target;
|
Sheep sheep = (Sheep) target;
|
||||||
|
|
||||||
if (drop.getType() == Material.WOOL) {
|
if (drop.getType().name().endsWith("WOOL")) {
|
||||||
if (sheep.isSheared()) {
|
if (sheep.isSheared()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
drop = new Wool(sheep.getColor()).toItemStack(drop.getAmount());
|
|
||||||
sheep.setSheared(true);
|
sheep.setSheared(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SKELETON:
|
|
||||||
if (((Skeleton) target).getSkeletonType() == SkeletonType.WITHER) {
|
|
||||||
switch (drop.getType()) {
|
|
||||||
case SKULL_ITEM:
|
|
||||||
drop.setDurability((short) 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ARROW:
|
|
||||||
drop.setType(Material.COAL);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayerShakeEvent shakeEvent = new McMMOPlayerShakeEvent(getPlayer(), drop);
|
McMMOPlayerShakeEvent shakeEvent = new McMMOPlayerShakeEvent(getPlayer(), drop);
|
||||||
@@ -489,7 +447,18 @@ public class FishingManager extends SkillManager {
|
|||||||
*/
|
*/
|
||||||
private FishingTreasure getFishingTreasure() {
|
private FishingTreasure getFishingTreasure() {
|
||||||
double diceRoll = Misc.getRandom().nextDouble() * 100;
|
double diceRoll = Misc.getRandom().nextDouble() * 100;
|
||||||
diceRoll -= getPlayer().getItemInHand().getEnchantmentLevel(Enchantment.LUCK);
|
int luck;
|
||||||
|
|
||||||
|
if (getPlayer().getInventory().getItemInMainHand().getType() == Material.FISHING_ROD) {
|
||||||
|
luck = getPlayer().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// We know something was caught, so if the rod wasn't in the main hand it must be in the offhand
|
||||||
|
luck = getPlayer().getInventory().getItemInOffHand().getEnchantmentLevel(Enchantment.LUCK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rather than subtracting luck (and causing a minimum 3% chance for every drop), scale by luck.
|
||||||
|
diceRoll *= (1.0 - luck * Config.getInstance().getFishingLureModifier() / 100);
|
||||||
|
|
||||||
FishingTreasure treasure = null;
|
FishingTreasure treasure = null;
|
||||||
|
|
||||||
@@ -586,6 +555,11 @@ public class FishingManager extends SkillManager {
|
|||||||
double dropRate = TreasureConfig.getInstance().getEnchantmentDropRate(getLootTier(), rarity);
|
double dropRate = TreasureConfig.getInstance().getEnchantmentDropRate(getLootTier(), rarity);
|
||||||
|
|
||||||
if (diceRoll <= dropRate) {
|
if (diceRoll <= dropRate) {
|
||||||
|
// Make sure enchanted books always get some kind of enchantment. --hoorigan
|
||||||
|
if (treasureDrop.getType() == Material.ENCHANTED_BOOK) {
|
||||||
|
diceRoll = dropRate + 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
fishingEnchantments = TreasureConfig.getInstance().fishingEnchantments.get(rarity);
|
fishingEnchantments = TreasureConfig.getInstance().fishingEnchantments.get(rarity);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -663,6 +637,6 @@ public class FishingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
package com.gmail.nossr50.skills.herbalism;
|
package com.gmail.nossr50.skills.herbalism;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.material.SmoothBrick;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import java.util.HashSet;
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
||||||
|
|
||||||
public class Herbalism {
|
public class Herbalism {
|
||||||
|
|
||||||
public static int farmersDietRankLevel1 = AdvancedConfig.getInstance().getFarmerDietRankChange();
|
public static int farmersDietRankLevel1 = AdvancedConfig.getInstance().getFarmerDietRankChange();
|
||||||
public static int farmersDietRankLevel2 = farmersDietRankLevel1 * 2;
|
public static int farmersDietRankLevel2 = farmersDietRankLevel1 * 2;
|
||||||
public static int farmersDietMaxLevel = farmersDietRankLevel1 * 5;
|
public static int farmersDietMaxLevel = farmersDietRankLevel1 * 5;
|
||||||
@@ -21,56 +22,129 @@ public class Herbalism {
|
|||||||
/**
|
/**
|
||||||
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState
|
||||||
|
* The {@link BlockState} to check ability activation for
|
||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
protected static boolean convertGreenTerraBlocks(BlockState blockState) {
|
protected static boolean convertGreenTerraBlocks(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case COBBLE_WALL:
|
case COBBLESTONE_WALL:
|
||||||
blockState.setRawData((byte) 0x1);
|
blockState.setType(Material.MOSSY_COBBLESTONE_WALL);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case SMOOTH_BRICK:
|
case STONE_BRICKS:
|
||||||
((SmoothBrick) blockState.getData()).setMaterial(Material.MOSSY_COBBLESTONE);
|
blockState.setType(Material.MOSSY_STONE_BRICKS);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case DIRT:
|
case DIRT :
|
||||||
blockState.setType(Material.GRASS);
|
case GRASS_PATH :
|
||||||
|
blockState.setType(Material.GRASS_BLOCK);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case COBBLESTONE:
|
case COBBLESTONE :
|
||||||
blockState.setType(Material.MOSSY_COBBLESTONE);
|
blockState.setType(Material.MOSSY_COBBLESTONE);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default :
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HashSet<Block> findChorusPlant(Block target) {
|
||||||
|
return findChorusPlant(target, new HashSet<Block>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HashSet<Block> findChorusPlant(Block target, HashSet<Block> traversed) {
|
||||||
|
if (target.getType() != Material.CHORUS_PLANT) {
|
||||||
|
return traversed;
|
||||||
|
}
|
||||||
|
// Prevent any infinite loops, who needs more than 64 chorus anyways
|
||||||
|
if (traversed.size() > 64)
|
||||||
|
{
|
||||||
|
return traversed;
|
||||||
|
}
|
||||||
|
|
||||||
|
traversed.add(target);
|
||||||
|
|
||||||
|
Block relative = target.getRelative(BlockFace.UP, 1);
|
||||||
|
if (!traversed.contains(relative)) {
|
||||||
|
if (relative.getType() == Material.CHORUS_PLANT) {
|
||||||
|
traversed.addAll(findChorusPlant(relative, traversed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
relative = target.getRelative(BlockFace.NORTH, 1);
|
||||||
|
if (!traversed.contains(relative)) {
|
||||||
|
if (relative.getType() == Material.CHORUS_PLANT) {
|
||||||
|
traversed.addAll(findChorusPlant(relative, traversed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
relative = target.getRelative(BlockFace.SOUTH, 1);
|
||||||
|
if (!traversed.contains(relative)) {
|
||||||
|
if (relative.getType() == Material.CHORUS_PLANT) {
|
||||||
|
traversed.addAll(findChorusPlant(relative, traversed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
relative = target.getRelative(BlockFace.EAST, 1);
|
||||||
|
if (!traversed.contains(relative)) {
|
||||||
|
if (relative.getType() == Material.CHORUS_PLANT) {
|
||||||
|
traversed.addAll(findChorusPlant(relative, traversed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
relative = target.getRelative(BlockFace.WEST, 1);
|
||||||
|
if (!traversed.contains(relative)) {
|
||||||
|
if (relative.getType() == Material.CHORUS_PLANT) {
|
||||||
|
traversed.addAll(findChorusPlant(relative, traversed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return traversed;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the drop amounts for cacti & sugar cane based on the blocks above them.
|
* Calculate the drop amounts for multi block plants based on the blocks
|
||||||
|
* relative to them.
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the bottom block of the plant
|
* @param blockState
|
||||||
|
* The {@link BlockState} of the bottom block of the plant
|
||||||
* @return the number of bonus drops to award from the blocks in this plant
|
* @return the number of bonus drops to award from the blocks in this plant
|
||||||
*/
|
*/
|
||||||
protected static int calculateCatciAndSugarDrops(BlockState blockState) {
|
protected static int calculateMultiBlockPlantDrops(BlockState blockState) {
|
||||||
Block block = blockState.getBlock();
|
Block block = blockState.getBlock();
|
||||||
Material blockType = blockState.getType();
|
Material blockType = blockState.getType();
|
||||||
int dropAmount = mcMMO.getPlaceStore().isTrue(block) ? 0 : 1;
|
int dropAmount = mcMMO.getPlaceStore().isTrue(block) ? 0 : 1;
|
||||||
|
|
||||||
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally
|
if (blockType == Material.CHORUS_PLANT) {
|
||||||
for (int y = 1; y < 3; y++) {
|
dropAmount = 1;
|
||||||
Block relativeBlock = block.getRelative(BlockFace.UP, y);
|
|
||||||
|
|
||||||
if (relativeBlock.getType() != blockType) {
|
if (block.getRelative(BlockFace.DOWN, 1).getType() == Material.END_STONE) {
|
||||||
break;
|
HashSet<Block> blocks = findChorusPlant(block);
|
||||||
}
|
|
||||||
|
|
||||||
if (mcMMO.getPlaceStore().isTrue(relativeBlock)) {
|
dropAmount = blocks.size();
|
||||||
mcMMO.getPlaceStore().setFalse(relativeBlock);
|
|
||||||
|
/*
|
||||||
|
* for(Block b : blocks) {
|
||||||
|
* b.breakNaturally();
|
||||||
|
* }
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
dropAmount++;
|
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally
|
||||||
|
for (int y = 1; y < 3; y++) {
|
||||||
|
Block relativeBlock = block.getRelative(BlockFace.UP, y);
|
||||||
|
|
||||||
|
if (relativeBlock.getType() != blockType) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mcMMO.getPlaceStore().isTrue(relativeBlock)) {
|
||||||
|
mcMMO.getPlaceStore().setFalse(relativeBlock);
|
||||||
|
} else {
|
||||||
|
dropAmount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,17 +154,19 @@ public class Herbalism {
|
|||||||
/**
|
/**
|
||||||
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
* Convert blocks affected by the Green Thumb & Green Terra abilities.
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState
|
||||||
|
* The {@link BlockState} to check ability activation for
|
||||||
* @return true if the ability was successful, false otherwise
|
* @return true if the ability was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
protected static boolean convertShroomThumb(BlockState blockState) {
|
protected static boolean convertShroomThumb(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case DIRT:
|
case DIRT :
|
||||||
case GRASS:
|
case GRASS_BLOCK:
|
||||||
blockState.setType(Material.MYCEL);
|
case GRASS_PATH :
|
||||||
|
blockState.setType(Material.MYCELIUM);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default :
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,7 +174,8 @@ public class Herbalism {
|
|||||||
/**
|
/**
|
||||||
* Check if the block has a recently grown crop from Green Thumb
|
* Check if the block has a recently grown crop from Green Thumb
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} to check green thumb regrown for
|
* @param blockState
|
||||||
|
* The {@link BlockState} to check green thumb regrown for
|
||||||
* @return true if the block is recently regrown, false otherwise
|
* @return true if the block is recently regrown, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isRecentlyRegrown(BlockState blockState) {
|
public static boolean isRecentlyRegrown(BlockState blockState) {
|
||||||
|
|||||||
@@ -1,42 +1,29 @@
|
|||||||
package com.gmail.nossr50.skills.herbalism;
|
package com.gmail.nossr50.skills.herbalism;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.CropState;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.NetherWartsState;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
|
||||||
import org.bukkit.material.CocoaPlant;
|
|
||||||
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
|
|
||||||
import org.bukkit.material.Crops;
|
|
||||||
import org.bukkit.material.NetherWarts;
|
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.*;
|
||||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
|
||||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask;
|
import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.*;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.block.data.Ageable;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class HerbalismManager extends SkillManager {
|
public class HerbalismManager extends SkillManager {
|
||||||
public HerbalismManager(McMMOPlayer mcMMOPlayer) {
|
public HerbalismManager(McMMOPlayer mcMMOPlayer) {
|
||||||
@@ -49,15 +36,17 @@ public class HerbalismManager extends SkillManager {
|
|||||||
|
|
||||||
public boolean canGreenThumbBlock(BlockState blockState) {
|
public boolean canGreenThumbBlock(BlockState blockState) {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
ItemStack item = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
return player.getItemInHand().getType() == Material.SEEDS && BlockUtils.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType());
|
return item.getAmount() > 0 && item.getType() == Material.WHEAT_SEEDS && BlockUtils.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseShroomThumb(BlockState blockState) {
|
public boolean canUseShroomThumb(BlockState blockState) {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
Material itemType = player.getItemInHand().getType();
|
PlayerInventory inventory = player.getInventory();
|
||||||
|
Material itemType = inventory.getItemInMainHand().getType();
|
||||||
|
|
||||||
return (itemType == Material.RED_MUSHROOM || itemType == Material.BROWN_MUSHROOM) && BlockUtils.canMakeShroomy(blockState) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHROOM_THUMB);
|
return (itemType == Material.BROWN_MUSHROOM || itemType == Material.RED_MUSHROOM) && inventory.contains(Material.BROWN_MUSHROOM, 1) && inventory.contains(Material.RED_MUSHROOM, 1) && BlockUtils.canMakeShroomy(blockState) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHROOM_THUMB);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseHylianLuck() {
|
public boolean canUseHylianLuck() {
|
||||||
@@ -101,7 +90,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlayerInventory playerInventory = player.getInventory();
|
PlayerInventory playerInventory = player.getInventory();
|
||||||
ItemStack seed = new ItemStack(Material.SEEDS);
|
ItemStack seed = new ItemStack(Material.WHEAT_SEEDS);
|
||||||
|
|
||||||
if (!playerInventory.containsAtLeast(seed, 1)) {
|
if (!playerInventory.containsAtLeast(seed, 1)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.NeedMore"));
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.NeedMore"));
|
||||||
@@ -120,8 +109,9 @@ public class HerbalismManager extends SkillManager {
|
|||||||
public void herbalismBlockCheck(BlockState blockState) {
|
public void herbalismBlockCheck(BlockState blockState) {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
Material material = blockState.getType();
|
Material material = blockState.getType();
|
||||||
boolean oneBlockPlant = !(material == Material.CACTUS || material == Material.SUGAR_CANE_BLOCK);
|
boolean oneBlockPlant = !(material == Material.CACTUS || material == Material.CHORUS_PLANT || material == Material.SUGAR_CANE);
|
||||||
|
|
||||||
|
// Prevents placing and immediately breaking blocks for exp
|
||||||
if (oneBlockPlant && mcMMO.getPlaceStore().isTrue(blockState)) {
|
if (oneBlockPlant && mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -144,25 +134,20 @@ public class HerbalismManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (Permissions.greenThumbPlant(player, material)) {
|
xp = ExperienceConfig.getInstance().getXp(skill, blockState.getBlockData());
|
||||||
processGreenThumbPlants(blockState, greenTerra);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (material == Material.DOUBLE_PLANT || material == Material.RED_ROSE || material == Material.LONG_GRASS) {
|
|
||||||
xp = ExperienceConfig.getInstance().getFlowerAndGrassXp(blockState.getData());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
xp = ExperienceConfig.getInstance().getXp(skill, material);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.getInstance().getDoubleDropsEnabled(skill, material) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS)) {
|
if (Config.getInstance().getDoubleDropsEnabled(skill, material) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS)) {
|
||||||
drops = blockState.getBlock().getDrops();
|
drops = blockState.getBlock().getDrops();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!oneBlockPlant) {
|
if (!oneBlockPlant) {
|
||||||
amount = Herbalism.calculateCatciAndSugarDrops(blockState);
|
amount = Herbalism.calculateMultiBlockPlantDrops(blockState);
|
||||||
xp *= amount;
|
xp *= amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Permissions.greenThumbPlant(player, material)) {
|
||||||
|
processGreenThumbPlants(blockState, greenTerra);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applyXpGain(xp, XPGainReason.PVE);
|
applyXpGain(xp, XPGainReason.PVE);
|
||||||
@@ -174,7 +159,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
for (int i = greenTerra ? 2 : 1; i != 0; i--) {
|
for (int i = greenTerra ? 2 : 1; i != 0; i--) {
|
||||||
if (SkillUtils.activationSuccessful(SecondaryAbility.HERBALISM_DOUBLE_DROPS, getPlayer(), getSkillLevel(), activationChance)) {
|
if (SkillUtils.activationSuccessful(SecondaryAbility.HERBALISM_DOUBLE_DROPS, getPlayer(), getSkillLevel(), activationChance)) {
|
||||||
for (ItemStack item : drops) {
|
for (ItemStack item : drops) {
|
||||||
Misc.dropItems(blockState.getLocation(), item, amount);
|
Misc.dropItems(Misc.getBlockCenter(blockState), item, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,44 +191,31 @@ public class HerbalismManager extends SkillManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<HylianTreasure> treasures;
|
String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData());
|
||||||
|
if (!TreasureConfig.getInstance().hylianMap.containsKey(friendly))
|
||||||
switch (blockState.getType()) {
|
return false;
|
||||||
case DEAD_BUSH:
|
List<HylianTreasure> treasures = TreasureConfig.getInstance().hylianMap.get(friendly);
|
||||||
case LONG_GRASS:
|
|
||||||
case SAPLING:
|
|
||||||
treasures = TreasureConfig.getInstance().hylianFromBushes;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RED_ROSE:
|
|
||||||
case YELLOW_FLOWER:
|
|
||||||
if (mcMMO.getPlaceStore().isTrue(blockState)) {
|
|
||||||
mcMMO.getPlaceStore().setFalse(blockState);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
treasures = TreasureConfig.getInstance().hylianFromFlowers;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FLOWER_POT:
|
|
||||||
treasures = TreasureConfig.getInstance().hylianFromPots;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
|
||||||
if (treasures.isEmpty() || !EventUtils.simulateBlockBreak(blockState.getBlock(), player, false)) {
|
if (treasures.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
int skillLevel = getSkillLevel();
|
||||||
|
Location location = Misc.getBlockCenter(blockState);
|
||||||
|
|
||||||
blockState.setType(Material.AIR);
|
for (HylianTreasure treasure : treasures) {
|
||||||
|
if (skillLevel >= treasure.getDropLevel() && SkillUtils.treasureDropSuccessful(getPlayer(), treasure.getDropChance(), activationChance)) {
|
||||||
Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop());
|
if (!EventUtils.simulateBlockBreak(blockState.getBlock(), player, false)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
|
return false;
|
||||||
return true;
|
}
|
||||||
|
blockState.setType(Material.AIR);
|
||||||
|
Misc.dropItem(location, treasure.getDrop());
|
||||||
|
player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -256,12 +228,12 @@ public class HerbalismManager extends SkillManager {
|
|||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
PlayerInventory playerInventory = player.getInventory();
|
PlayerInventory playerInventory = player.getInventory();
|
||||||
|
|
||||||
if (!playerInventory.contains(Material.BROWN_MUSHROOM)) {
|
if (!playerInventory.contains(Material.BROWN_MUSHROOM, 1)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM)));
|
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!playerInventory.contains(Material.RED_MUSHROOM)) {
|
if (!playerInventory.contains(Material.RED_MUSHROOM, 1)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM)));
|
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -285,32 +257,45 @@ public class HerbalismManager extends SkillManager {
|
|||||||
* @param greenTerra boolean to determine if greenTerra is active or not
|
* @param greenTerra boolean to determine if greenTerra is active or not
|
||||||
*/
|
*/
|
||||||
private void processGreenThumbPlants(BlockState blockState, boolean greenTerra) {
|
private void processGreenThumbPlants(BlockState blockState, boolean greenTerra) {
|
||||||
|
if (!BlockUtils.isFullyGrown(blockState))
|
||||||
|
return;
|
||||||
|
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
PlayerInventory playerInventory = player.getInventory();
|
PlayerInventory playerInventory = player.getInventory();
|
||||||
ItemStack seed = null;
|
Material seed = null;
|
||||||
|
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case CARROT:
|
case CARROTS:
|
||||||
seed = new ItemStack(Material.CARROT_ITEM);
|
seed = Material.CARROT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CROPS:
|
case WHEAT:
|
||||||
seed = new ItemStack(Material.SEEDS);
|
seed = Material.WHEAT_SEEDS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NETHER_WARTS:
|
case NETHER_WART:
|
||||||
seed = new ItemStack(Material.NETHER_STALK);
|
seed = Material.NETHER_WART;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case POTATO:
|
case POTATOES:
|
||||||
seed = new ItemStack(Material.POTATO_ITEM);
|
seed = Material.POTATO;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BEETROOTS:
|
||||||
|
seed = Material.BEETROOT_SEEDS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COCOA:
|
||||||
|
seed = Material.COCOA_BEANS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!playerInventory.containsAtLeast(seed, 1)) {
|
ItemStack seedStack = new ItemStack(seed);
|
||||||
|
|
||||||
|
if (!playerInventory.containsAtLeast(seedStack, 1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +307,7 @@ public class HerbalismManager extends SkillManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerInventory.removeItem(seed);
|
playerInventory.removeItem(seedStack);
|
||||||
player.updateInventory(); // Needed until replacement available
|
player.updateInventory(); // Needed until replacement available
|
||||||
new HerbalismBlockUpdaterTask(blockState).runTaskLater(mcMMO.p, 0);
|
new HerbalismBlockUpdaterTask(blockState).runTaskLater(mcMMO.p, 0);
|
||||||
}
|
}
|
||||||
@@ -331,74 +316,51 @@ public class HerbalismManager extends SkillManager {
|
|||||||
byte greenThumbStage = getGreenThumbStage();
|
byte greenThumbStage = getGreenThumbStage();
|
||||||
|
|
||||||
blockState.setMetadata(mcMMO.greenThumbDataKey, new FixedMetadataValue(mcMMO.p, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
|
blockState.setMetadata(mcMMO.greenThumbDataKey, new FixedMetadataValue(mcMMO.p, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
|
||||||
|
Ageable crops = (Ageable) blockState.getBlockData();
|
||||||
|
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case CROPS:
|
|
||||||
Crops crops = (Crops) blockState.getData();
|
case POTATOES:
|
||||||
|
case CARROTS:
|
||||||
|
case WHEAT:
|
||||||
|
|
||||||
if (greenTerra) {
|
if (greenTerra) {
|
||||||
crops.setState(CropState.MEDIUM);
|
crops.setAge(3);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
switch (greenThumbStage) {
|
crops.setAge(greenThumbStage);
|
||||||
case 4:
|
|
||||||
crops.setState(CropState.SMALL);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
crops.setState(CropState.VERY_SMALL);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
crops.setState(CropState.GERMINATED);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
crops.setState(CropState.SEEDED);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
return true;
|
case BEETROOTS:
|
||||||
|
case NETHER_WART:
|
||||||
case CARROT:
|
|
||||||
case POTATO:
|
|
||||||
if (greenTerra) {
|
|
||||||
blockState.setRawData(CropState.MEDIUM.getData());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
blockState.setRawData(greenThumbStage);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case NETHER_WARTS:
|
|
||||||
NetherWarts warts = (NetherWarts) blockState.getData();
|
|
||||||
|
|
||||||
if (greenTerra || greenThumbStage > 2) {
|
if (greenTerra || greenThumbStage > 2) {
|
||||||
warts.setState(NetherWartsState.STAGE_TWO);
|
crops.setAge(2);
|
||||||
}
|
}
|
||||||
else if (greenThumbStage == 2) {
|
else if (greenThumbStage == 2) {
|
||||||
warts.setState(NetherWartsState.STAGE_ONE);
|
crops.setAge(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
warts.setState(NetherWartsState.SEEDED);
|
crops.setAge(0);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
return true;
|
|
||||||
|
|
||||||
case COCOA:
|
case COCOA:
|
||||||
CocoaPlant plant = (CocoaPlant) blockState.getData();
|
|
||||||
|
|
||||||
if (greenTerra || getGreenThumbStage() > 1) {
|
if (greenTerra || getGreenThumbStage() > 1) {
|
||||||
plant.setSize(CocoaPlantSize.MEDIUM);
|
crops.setAge(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plant.setSize(CocoaPlantSize.SMALL);
|
crops.setAge(0);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
blockState.setBlockData(crops);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte getGreenThumbStage() {
|
private byte getGreenThumbStage() {
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
package com.gmail.nossr50.skills.mining;
|
package com.gmail.nossr50.skills.mining;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
|
|
||||||
public class Mining {
|
public class Mining {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,8 +16,7 @@ public class Mining {
|
|||||||
* @param blockState The {@link BlockState} to check ability activation for
|
* @param blockState The {@link BlockState} to check ability activation for
|
||||||
*/
|
*/
|
||||||
public static int getBlockXp(BlockState blockState) {
|
public static int getBlockXp(BlockState blockState) {
|
||||||
Material blockType = blockState.getType();
|
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockState.getType());
|
||||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockType != Material.GLOWING_REDSTONE_ORE ? blockType : Material.REDSTONE_ORE);
|
|
||||||
|
|
||||||
if (xp == 0 && mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
if (xp == 0 && mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
||||||
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
|
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||||
@@ -37,39 +34,65 @@ public class Mining {
|
|||||||
Material blockType = blockState.getType();
|
Material blockType = blockState.getType();
|
||||||
|
|
||||||
switch (blockType) {
|
switch (blockType) {
|
||||||
case ENDER_STONE:
|
case END_STONE:
|
||||||
case GOLD_ORE:
|
case TERRACOTTA:
|
||||||
case HARD_CLAY:
|
case CLAY:
|
||||||
case IRON_ORE:
|
case IRON_ORE:
|
||||||
case MOSSY_COBBLESTONE:
|
case MOSSY_COBBLESTONE:
|
||||||
case NETHERRACK:
|
case NETHERRACK:
|
||||||
case OBSIDIAN:
|
case OBSIDIAN:
|
||||||
case SANDSTONE:
|
case SANDSTONE:
|
||||||
case STAINED_CLAY:
|
case BLACK_GLAZED_TERRACOTTA:
|
||||||
|
case BLACK_TERRACOTTA:
|
||||||
|
case BLUE_GLAZED_TERRACOTTA:
|
||||||
|
case BLUE_TERRACOTTA:
|
||||||
|
case BROWN_GLAZED_TERRACOTTA:
|
||||||
|
case BROWN_TERRACOTTA:
|
||||||
|
case CYAN_GLAZED_TERRACOTTA:
|
||||||
|
case CYAN_TERRACOTTA:
|
||||||
|
case GRAY_GLAZED_TERRACOTTA:
|
||||||
|
case GRAY_TERRACOTTA:
|
||||||
|
case GREEN_GLAZED_TERRACOTTA:
|
||||||
|
case GREEN_TERRACOTTA:
|
||||||
|
case LIGHT_BLUE_GLAZED_TERRACOTTA:
|
||||||
|
case LIGHT_BLUE_TERRACOTTA:
|
||||||
|
case LIGHT_GRAY_GLAZED_TERRACOTTA:
|
||||||
|
case LIGHT_GRAY_TERRACOTTA:
|
||||||
|
case LIME_GLAZED_TERRACOTTA:
|
||||||
|
case LIME_TERRACOTTA:
|
||||||
|
case MAGENTA_GLAZED_TERRACOTTA:
|
||||||
|
case MAGENTA_TERRACOTTA:
|
||||||
|
case ORANGE_GLAZED_TERRACOTTA:
|
||||||
|
case ORANGE_TERRACOTTA:
|
||||||
|
case PINK_GLAZED_TERRACOTTA:
|
||||||
|
case PINK_TERRACOTTA:
|
||||||
|
case PURPLE_GLAZED_TERRACOTTA:
|
||||||
|
case PURPLE_TERRACOTTA:
|
||||||
|
case RED_GLAZED_TERRACOTTA:
|
||||||
|
case RED_TERRACOTTA:
|
||||||
|
case WHITE_GLAZED_TERRACOTTA:
|
||||||
|
case WHITE_TERRACOTTA:
|
||||||
|
case YELLOW_GLAZED_TERRACOTTA:
|
||||||
|
case YELLOW_TERRACOTTA:
|
||||||
handleMiningDrops(blockState);
|
handleMiningDrops(blockState);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case GLOWING_REDSTONE_ORE:
|
|
||||||
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
|
|
||||||
Misc.dropItem(blockState.getLocation(), new ItemStack(Material.REDSTONE_ORE));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case COAL_ORE:
|
case COAL_ORE:
|
||||||
case DIAMOND_ORE:
|
case DIAMOND_ORE:
|
||||||
case EMERALD_ORE:
|
case EMERALD_ORE:
|
||||||
case GLOWSTONE:
|
case GLOWSTONE:
|
||||||
case LAPIS_ORE:
|
case LAPIS_ORE:
|
||||||
case PACKED_ICE:
|
case PACKED_ICE:
|
||||||
case QUARTZ_ORE:
|
case NETHER_QUARTZ_ORE:
|
||||||
case REDSTONE_ORE:
|
case REDSTONE_ORE:
|
||||||
case STONE:
|
case STONE:
|
||||||
Misc.dropItem(blockState.getLocation(), new ItemStack(blockType));
|
case PRISMARINE:
|
||||||
|
Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
if (mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
||||||
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1));
|
Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -85,10 +108,10 @@ public class Mining {
|
|||||||
case COAL_ORE:
|
case COAL_ORE:
|
||||||
case DIAMOND_ORE:
|
case DIAMOND_ORE:
|
||||||
case EMERALD_ORE:
|
case EMERALD_ORE:
|
||||||
case ENDER_STONE:
|
case END_STONE:
|
||||||
case GLOWSTONE:
|
case GLOWSTONE:
|
||||||
case GOLD_ORE:
|
case GOLD_ORE:
|
||||||
case HARD_CLAY:
|
case TERRACOTTA:
|
||||||
case IRON_ORE:
|
case IRON_ORE:
|
||||||
case LAPIS_ORE:
|
case LAPIS_ORE:
|
||||||
case MOSSY_COBBLESTONE:
|
case MOSSY_COBBLESTONE:
|
||||||
@@ -97,21 +120,46 @@ public class Mining {
|
|||||||
case PACKED_ICE:
|
case PACKED_ICE:
|
||||||
case REDSTONE_ORE:
|
case REDSTONE_ORE:
|
||||||
case SANDSTONE:
|
case SANDSTONE:
|
||||||
case STAINED_CLAY:
|
case BLACK_GLAZED_TERRACOTTA:
|
||||||
|
case BLACK_TERRACOTTA:
|
||||||
|
case BLUE_GLAZED_TERRACOTTA:
|
||||||
|
case BLUE_TERRACOTTA:
|
||||||
|
case BROWN_GLAZED_TERRACOTTA:
|
||||||
|
case BROWN_TERRACOTTA:
|
||||||
|
case CYAN_GLAZED_TERRACOTTA:
|
||||||
|
case CYAN_TERRACOTTA:
|
||||||
|
case GRAY_GLAZED_TERRACOTTA:
|
||||||
|
case GRAY_TERRACOTTA:
|
||||||
|
case GREEN_GLAZED_TERRACOTTA:
|
||||||
|
case GREEN_TERRACOTTA:
|
||||||
|
case LIGHT_BLUE_GLAZED_TERRACOTTA:
|
||||||
|
case LIGHT_BLUE_TERRACOTTA:
|
||||||
|
case LIGHT_GRAY_GLAZED_TERRACOTTA:
|
||||||
|
case LIGHT_GRAY_TERRACOTTA:
|
||||||
|
case LIME_GLAZED_TERRACOTTA:
|
||||||
|
case LIME_TERRACOTTA:
|
||||||
|
case MAGENTA_GLAZED_TERRACOTTA:
|
||||||
|
case MAGENTA_TERRACOTTA:
|
||||||
|
case ORANGE_GLAZED_TERRACOTTA:
|
||||||
|
case ORANGE_TERRACOTTA:
|
||||||
|
case PINK_GLAZED_TERRACOTTA:
|
||||||
|
case PINK_TERRACOTTA:
|
||||||
|
case PURPLE_GLAZED_TERRACOTTA:
|
||||||
|
case PURPLE_TERRACOTTA:
|
||||||
|
case RED_GLAZED_TERRACOTTA:
|
||||||
|
case RED_TERRACOTTA:
|
||||||
|
case WHITE_GLAZED_TERRACOTTA:
|
||||||
|
case WHITE_TERRACOTTA:
|
||||||
|
case YELLOW_GLAZED_TERRACOTTA:
|
||||||
|
case YELLOW_TERRACOTTA:
|
||||||
case STONE:
|
case STONE:
|
||||||
case QUARTZ_ORE:
|
case NETHER_QUARTZ_ORE:
|
||||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops());
|
||||||
return;
|
|
||||||
|
|
||||||
case GLOWING_REDSTONE_ORE:
|
|
||||||
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
|
|
||||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
if (mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
||||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.mining;
|
package com.gmail.nossr50.skills.mining;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.TNTPrimed;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
@@ -18,6 +7,7 @@ import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
|
import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
|
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
|
||||||
@@ -26,6 +16,16 @@ 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.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.TNTPrimed;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MiningManager extends SkillManager {
|
public class MiningManager extends SkillManager {
|
||||||
public MiningManager(McMMOPlayer mcMMOPlayer) {
|
public MiningManager(McMMOPlayer mcMMOPlayer) {
|
||||||
@@ -39,7 +39,7 @@ public class MiningManager extends SkillManager {
|
|||||||
public boolean canDetonate() {
|
public boolean canDetonate() {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
|
||||||
return canUseBlastMining() && player.isSneaking() && player.getItemInHand().getType() == BlastMining.detonator && Permissions.remoteDetonation(player);
|
return canUseBlastMining() && player.isSneaking() && player.getInventory().getItemInMainHand().getType() == BlastMining.detonator && Permissions.remoteDetonation(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseBlastMining() {
|
public boolean canUseBlastMining() {
|
||||||
@@ -67,14 +67,14 @@ public class MiningManager extends SkillManager {
|
|||||||
Material material = blockState.getType();
|
Material material = blockState.getType();
|
||||||
|
|
||||||
if (mcMMOPlayer.getAbilityMode(skill.getAbility())) {
|
if (mcMMOPlayer.getAbilityMode(skill.getAbility())) {
|
||||||
SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage());
|
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mcMMO.getModManager().isCustomMiningBlock(blockState) && !mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) || material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) {
|
if ((mcMMO.getModManager().isCustomMiningBlock(blockState) && !mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) || !Config.getInstance().getDoubleDropsEnabled(skill, material)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean silkTouch = player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH);
|
boolean silkTouch = player.getInventory().getItemInMainHand().containsEnchantment(Enchantment.SILK_TOUCH);
|
||||||
|
|
||||||
for (int i = mcMMOPlayer.getAbilityMode(skill.getAbility()) ? 2 : 1; i != 0; i--) {
|
for (int i = mcMMOPlayer.getAbilityMode(skill.getAbility()) ? 2 : 1; i != 0; i--) {
|
||||||
if (SkillUtils.activationSuccessful(SecondaryAbility.MINING_DOUBLE_DROPS, getPlayer(), getSkillLevel(), activationChance)) {
|
if (SkillUtils.activationSuccessful(SecondaryAbility.MINING_DOUBLE_DROPS, getPlayer(), getSkillLevel(), activationChance)) {
|
||||||
@@ -147,7 +147,7 @@ public class MiningManager extends SkillManager {
|
|||||||
xp += Mining.getBlockXp(blockState);
|
xp += Mining.getBlockXp(blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1)); // Initial block that would have been dropped
|
Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType())); // Initial block that would have been dropped
|
||||||
|
|
||||||
if (!mcMMO.getPlaceStore().isTrue(blockState)) {
|
if (!mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||||
for (int i = 1; i < dropMultiplier; i++) {
|
for (int i = 1; i < dropMultiplier; i++) {
|
||||||
@@ -160,7 +160,7 @@ public class MiningManager extends SkillManager {
|
|||||||
if (debrisYield > 0) {
|
if (debrisYield > 0) {
|
||||||
for (BlockState blockState : debris) {
|
for (BlockState blockState : debris) {
|
||||||
if (Misc.getRandom().nextFloat() < debrisYield) {
|
if (Misc.getRandom().nextFloat() < debrisYield) {
|
||||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.repair;
|
package com.gmail.nossr50.skills.repair;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
|
||||||
import org.bukkit.material.MaterialData;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
@@ -19,6 +7,7 @@ import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.skills.repair.ArcaneForging.Tier;
|
import com.gmail.nossr50.skills.repair.ArcaneForging.Tier;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||||
@@ -27,6 +16,16 @@ 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.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
public class RepairManager extends SkillManager {
|
public class RepairManager extends SkillManager {
|
||||||
private boolean placedAnvil;
|
private boolean placedAnvil;
|
||||||
@@ -51,7 +50,7 @@ public class RepairManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getRepairAnvilPlaceSoundsEnabled()) {
|
if (Config.getInstance().getRepairAnvilPlaceSoundsEnabled()) {
|
||||||
player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
togglePlacedAnvil();
|
togglePlacedAnvil();
|
||||||
@@ -61,13 +60,18 @@ public class RepairManager extends SkillManager {
|
|||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
Repairable repairable = mcMMO.getRepairableManager().getRepairable(item.getType());
|
Repairable repairable = mcMMO.getRepairableManager().getRepairable(item.getType());
|
||||||
|
|
||||||
|
if (item.getItemMeta().isUnbreakable()) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Anvil.Unbreakable"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Permissions checks on material and item types
|
// Permissions checks on material and item types
|
||||||
if (!Permissions.repairMaterialType(player, repairable.getRepairMaterialType())) {
|
if (!Permissions.repairMaterialType(player, repairable.getRepairMaterialType())) {
|
||||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Permissions.repairMaterialType(player, repairable.getRepairMaterialType())) {
|
if (!Permissions.repairItemType(player, repairable.getRepairItemType())) {
|
||||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -85,7 +89,7 @@ public class RepairManager extends SkillManager {
|
|||||||
|
|
||||||
Material repairMaterial = repairable.getRepairMaterial();
|
Material repairMaterial = repairable.getRepairMaterial();
|
||||||
byte repairMaterialMetadata = repairable.getRepairMaterialMetadata();
|
byte repairMaterialMetadata = repairable.getRepairMaterialMetadata();
|
||||||
ItemStack toRemove = new MaterialData(repairMaterial, repairMaterialMetadata).toItemStack(1);
|
ItemStack toRemove = new ItemStack(repairMaterial);
|
||||||
|
|
||||||
short startDurability = item.getDurability();
|
short startDurability = item.getDurability();
|
||||||
|
|
||||||
@@ -145,7 +149,7 @@ public class RepairManager extends SkillManager {
|
|||||||
|
|
||||||
// BWONG BWONG BWONG
|
// BWONG BWONG BWONG
|
||||||
if (Config.getInstance().getRepairAnvilUseSoundsEnabled()) {
|
if (Config.getInstance().getRepairAnvilUseSoundsEnabled()) {
|
||||||
player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Repair the item!
|
// Repair the item!
|
||||||
|
|||||||
@@ -1,8 +1,18 @@
|
|||||||
package com.gmail.nossr50.skills.salvage;
|
package com.gmail.nossr50.skills.salvage;
|
||||||
|
|
||||||
import java.util.Map;
|
import com.gmail.nossr50.config.Config;
|
||||||
import java.util.Map.Entry;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
|
import com.gmail.nossr50.skills.salvage.Salvage.Tier;
|
||||||
|
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||||
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@@ -10,20 +20,10 @@ import org.bukkit.enchantments.Enchantment;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import java.util.Map;
|
||||||
import com.gmail.nossr50.config.Config;
|
import java.util.Map.Entry;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
|
||||||
import com.gmail.nossr50.skills.salvage.Salvage.Tier;
|
|
||||||
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
||||||
|
|
||||||
public class SalvageManager extends SkillManager {
|
public class SalvageManager extends SkillManager {
|
||||||
private boolean placedAnvil;
|
private boolean placedAnvil;
|
||||||
@@ -48,7 +48,7 @@ public class SalvageManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getSalvageAnvilPlaceSoundsEnabled()) {
|
if (Config.getInstance().getSalvageAnvilPlaceSoundsEnabled()) {
|
||||||
player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
togglePlacedAnvil();
|
togglePlacedAnvil();
|
||||||
@@ -59,6 +59,11 @@ public class SalvageManager extends SkillManager {
|
|||||||
|
|
||||||
Salvageable salvageable = mcMMO.getSalvageableManager().getSalvageable(item.getType());
|
Salvageable salvageable = mcMMO.getSalvageableManager().getSalvageable(item.getType());
|
||||||
|
|
||||||
|
if (item.getItemMeta().isUnbreakable()) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Anvil.Unbreakable"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Permissions checks on material and item types
|
// Permissions checks on material and item types
|
||||||
if (!Permissions.salvageItemType(player, salvageable.getSalvageItemType())) {
|
if (!Permissions.salvageItemType(player, salvageable.getSalvageItemType())) {
|
||||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||||
@@ -93,27 +98,33 @@ public class SalvageManager extends SkillManager {
|
|||||||
|
|
||||||
salvageableAmount = Math.max((int) (salvageableAmount * getMaxSalvagePercentage()), 1); // Always get at least something back, if you're capable of salvaging it.
|
salvageableAmount = Math.max((int) (salvageableAmount * getMaxSalvagePercentage()), 1); // Always get at least something back, if you're capable of salvaging it.
|
||||||
|
|
||||||
player.setItemInHand(new ItemStack(Material.AIR));
|
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||||
location.add(0, 1, 0);
|
location.add(0.5, 1, 0.5);
|
||||||
|
|
||||||
Map<Enchantment, Integer> enchants = item.getEnchantments();
|
Map<Enchantment, Integer> enchants = item.getEnchantments();
|
||||||
|
|
||||||
|
ItemStack enchantBook = null;
|
||||||
if (!enchants.isEmpty()) {
|
if (!enchants.isEmpty()) {
|
||||||
ItemStack enchantBook = arcaneSalvageCheck(enchants);
|
enchantBook = arcaneSalvageCheck(enchants);
|
||||||
|
|
||||||
if (enchantBook != null) {
|
|
||||||
Misc.dropItem(location, enchantBook);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
byte salvageMaterialMetadata = (salvageable.getSalvageMaterialMetadata() != (byte) -1) ? salvageable.getSalvageMaterialMetadata() : 0;
|
ItemStack salvageResults = new ItemStack(salvageable.getSalvageMaterial(), salvageableAmount);
|
||||||
|
|
||||||
Misc.dropItems(location, new MaterialData(salvageable.getSalvageMaterial(), salvageMaterialMetadata).toItemStack(salvageableAmount), 1);
|
//Call event
|
||||||
|
if (EventUtils.callSalvageCheckEvent(player, item, salvageResults, enchantBook).isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enchantBook != null) {
|
||||||
|
Misc.dropItem(location, enchantBook);
|
||||||
|
}
|
||||||
|
|
||||||
|
Misc.dropItems(location, salvageResults, 1);
|
||||||
|
|
||||||
// BWONG BWONG BWONG - CLUNK!
|
// BWONG BWONG BWONG - CLUNK!
|
||||||
if (Config.getInstance().getSalvageAnvilUseSoundsEnabled()) {
|
if (Config.getInstance().getSalvageAnvilUseSoundsEnabled()) {
|
||||||
player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
|
||||||
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1.0F, 1.0F);
|
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Salvage.Skills.Success"));
|
player.sendMessage(LocaleLoader.getString("Salvage.Skills.Success"));
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
package com.gmail.nossr50.skills.smelting;
|
package com.gmail.nossr50.skills.smelting;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.material.MaterialData;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class Smelting {
|
public class Smelting {
|
||||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||||
@@ -23,7 +20,7 @@ public class Smelting {
|
|||||||
|
|
||||||
int numerical;
|
int numerical;
|
||||||
|
|
||||||
private Tier(int numerical) {
|
Tier(int numerical) {
|
||||||
this.numerical = numerical;
|
this.numerical = numerical;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,9 +44,6 @@ public class Smelting {
|
|||||||
public static double fluxMiningChance = AdvancedConfig.getInstance().getFluxMiningChance();
|
public static double fluxMiningChance = AdvancedConfig.getInstance().getFluxMiningChance();
|
||||||
|
|
||||||
protected static int getResourceXp(ItemStack smelting) {
|
protected static int getResourceXp(ItemStack smelting) {
|
||||||
MaterialData data = smelting.getData();
|
return mcMMO.getModManager().isCustomOre(smelting.getType()) ? mcMMO.getModManager().getBlock(smelting.getType()).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(SkillType.SMELTING, smelting.getType());
|
||||||
Material resourceType = smelting.getType();
|
|
||||||
|
|
||||||
return mcMMO.getModManager().isCustomOre(data) ? mcMMO.getModManager().getBlock(data).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(SkillType.SMELTING, resourceType != Material.GLOWING_REDSTONE_ORE ? resourceType : Material.REDSTONE_ORE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,22 @@
|
|||||||
package com.gmail.nossr50.skills.smelting;
|
package com.gmail.nossr50.skills.smelting;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.gmail.nossr50.config.Config;
|
||||||
import java.util.List;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
|
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
|
import com.gmail.nossr50.skills.mining.Mining;
|
||||||
|
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
|
||||||
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@@ -13,22 +27,8 @@ import org.bukkit.inventory.FurnaceRecipe;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import java.util.ArrayList;
|
||||||
import com.gmail.nossr50.config.Config;
|
import java.util.List;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
|
||||||
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
|
||||||
import com.gmail.nossr50.skills.mining.Mining;
|
|
||||||
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
|
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
||||||
|
|
||||||
public class SmeltingManager extends SkillManager {
|
public class SmeltingManager extends SkillManager {
|
||||||
public SmeltingManager(McMMOPlayer mcMMOPlayer) {
|
public SmeltingManager(McMMOPlayer mcMMOPlayer) {
|
||||||
@@ -74,17 +74,21 @@ public class SmeltingManager extends SkillManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!EventUtils.simulateBlockBreak(blockState.getBlock(), player, true)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// We need to distribute Mining XP here, because the block break event gets cancelled
|
// We need to distribute Mining XP here, because the block break event gets cancelled
|
||||||
applyXpGain(Mining.getBlockXp(blockState), XPGainReason.PVE);
|
applyXpGain(Mining.getBlockXp(blockState), XPGainReason.PVE);
|
||||||
|
|
||||||
SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage());
|
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage());
|
||||||
|
|
||||||
Misc.dropItems(blockState.getLocation(), item, isSecondSmeltSuccessful() ? 2 : 1);
|
Misc.dropItems(Misc.getBlockCenter(blockState), item, isSecondSmeltSuccessful() ? 2 : 1);
|
||||||
|
|
||||||
blockState.setType(Material.AIR);
|
blockState.setType(Material.AIR);
|
||||||
|
|
||||||
if (Config.getInstance().getFluxPickaxeSoundEnabled()) {
|
if (Config.getInstance().getFluxPickaxeSoundEnabled()) {
|
||||||
player.playSound(blockState.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.getFizzPitch());
|
player.playSound(blockState.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, Misc.FIZZ_VOLUME, Misc.getFizzPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleEffectUtils.playFluxEffect(blockState.getLocation());
|
ParticleEffectUtils.playFluxEffect(blockState.getLocation());
|
||||||
@@ -100,7 +104,7 @@ public class SmeltingManager extends SkillManager {
|
|||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
itemMeta.setDisplayName(ChatColor.GOLD + LocaleLoader.getString("Item.FluxPickaxe.Name"));
|
itemMeta.setDisplayName(ChatColor.GOLD + LocaleLoader.getString("Item.FluxPickaxe.Name"));
|
||||||
|
|
||||||
List<String> itemLore = new ArrayList<String>();
|
List<String> itemLore = itemMeta.hasLore() ? itemMeta.getLore() : new ArrayList<String>();
|
||||||
itemLore.add("mcMMO Item");
|
itemLore.add("mcMMO Item");
|
||||||
itemLore.add(LocaleLoader.getString("Item.FluxPickaxe.Lore.1"));
|
itemLore.add(LocaleLoader.getString("Item.FluxPickaxe.Lore.1"));
|
||||||
itemLore.add(LocaleLoader.getString("Item.FluxPickaxe.Lore.2", Smelting.fluxMiningUnlockLevel));
|
itemLore.add(LocaleLoader.getString("Item.FluxPickaxe.Lore.2", Smelting.fluxMiningUnlockLevel));
|
||||||
|
|||||||
@@ -30,12 +30,6 @@ public class Taming {
|
|||||||
public static int thickFurUnlockLevel = AdvancedConfig.getInstance().getThickFurUnlock();
|
public static int thickFurUnlockLevel = AdvancedConfig.getInstance().getThickFurUnlock();
|
||||||
public static double thickFurModifier = AdvancedConfig.getInstance().getThickFurModifier();
|
public static double thickFurModifier = AdvancedConfig.getInstance().getThickFurModifier();
|
||||||
|
|
||||||
public static double wolfCommandRange = 10.0;
|
|
||||||
|
|
||||||
public static int wolfXp = ExperienceConfig.getInstance().getTamingXPWolf();
|
|
||||||
public static int ocelotXp = ExperienceConfig.getInstance().getTamingXPOcelot();
|
|
||||||
public static int horseXp = ExperienceConfig.getInstance().getTamingXPHorse();
|
|
||||||
|
|
||||||
public static boolean canPreventDamage(Tameable pet, AnimalTamer owner) {
|
public static boolean canPreventDamage(Tameable pet, AnimalTamer owner) {
|
||||||
return pet.isTamed() && owner instanceof Player && pet instanceof Wolf;
|
return pet.isTamed() && owner instanceof Player && pet instanceof Wolf;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,8 @@
|
|||||||
package com.gmail.nossr50.skills.taming;
|
package com.gmail.nossr50.skills.taming;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Horse;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Ocelot;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.Tameable;
|
|
||||||
import org.bukkit.entity.Wolf;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
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.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
@@ -28,6 +10,7 @@ import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
|||||||
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
|
||||||
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
|
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
@@ -36,6 +19,14 @@ import com.gmail.nossr50.util.StringUtils;
|
|||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.*;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TamingManager extends SkillManager {
|
public class TamingManager extends SkillManager {
|
||||||
public TamingManager(McMMOPlayer mcMMOPlayer) {
|
public TamingManager(McMMOPlayer mcMMOPlayer) {
|
||||||
@@ -49,7 +40,7 @@ public class TamingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseEnvironmentallyAware() {
|
public boolean canUseEnvironmentallyAware() {
|
||||||
return getSkillLevel() >= Taming.environmentallyAwareUnlockLevel && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.ENVIROMENTALLY_AWARE);
|
return getSkillLevel() >= Taming.environmentallyAwareUnlockLevel && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.ENVIRONMENTALLY_AWARE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseShockProof() {
|
public boolean canUseShockProof() {
|
||||||
@@ -82,22 +73,7 @@ public class TamingManager extends SkillManager {
|
|||||||
* @param entity The LivingEntity to award XP for
|
* @param entity The LivingEntity to award XP for
|
||||||
*/
|
*/
|
||||||
public void awardTamingXP(LivingEntity entity) {
|
public void awardTamingXP(LivingEntity entity) {
|
||||||
switch (entity.getType()) {
|
applyXpGain(ExperienceConfig.getInstance().getTamingXP(entity.getType()), XPGainReason.PVE);
|
||||||
case HORSE:
|
|
||||||
applyXpGain(Taming.horseXp, XPGainReason.PVE);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case WOLF:
|
|
||||||
applyXpGain(Taming.wolfXp, XPGainReason.PVE);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case OCELOT:
|
|
||||||
applyXpGain(Taming.ocelotXp, XPGainReason.PVE);
|
|
||||||
return;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +110,7 @@ public class TamingManager extends SkillManager {
|
|||||||
BleedTimerTask.add(target, Taming.goreBleedTicks);
|
BleedTimerTask.add(target, Taming.goreBleedTicks);
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player) {
|
||||||
((Player) target).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
|
target.sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
|
||||||
}
|
}
|
||||||
|
|
||||||
getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));
|
getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));
|
||||||
@@ -210,81 +186,6 @@ public class TamingManager extends SkillManager {
|
|||||||
owner.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf"));
|
owner.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleCharge(LivingEntity livingEntity) {
|
|
||||||
attackTarget(livingEntity, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LivingEntity getTarget(double range) {
|
|
||||||
Player player = getPlayer();
|
|
||||||
LivingEntity target = null;
|
|
||||||
|
|
||||||
for (Entity entity : player.getNearbyEntities(range, range, range)) {
|
|
||||||
if (!(entity instanceof LivingEntity) || entity.getType() == EntityType.WOLF || entity.getType() == EntityType.CREEPER || entity.equals(player)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!player.hasLineOfSight(entity)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
target = (LivingEntity) entity;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Make nearby wolves owned by the player attack the target
|
|
||||||
*
|
|
||||||
* @param target The LivingEntity to attack
|
|
||||||
*
|
|
||||||
* @return true if the attack was successful, false otherwise
|
|
||||||
*/
|
|
||||||
public boolean attackTarget(LivingEntity target, boolean charge) {
|
|
||||||
boolean success = false;
|
|
||||||
|
|
||||||
for (Entity entity : getNearbyEntities(EntityType.WOLF, Taming.wolfCommandRange, true)) {
|
|
||||||
Wolf wolf = (Wolf) entity;
|
|
||||||
|
|
||||||
if (charge) {
|
|
||||||
charge(wolf);
|
|
||||||
}
|
|
||||||
|
|
||||||
wolf.setTarget(target);
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean attackTarget(LivingEntity target) {
|
|
||||||
return attackTarget(target, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void charge(Wolf wolf) {
|
|
||||||
int duration = 0;
|
|
||||||
int amplifier = 0;
|
|
||||||
|
|
||||||
if (wolf.hasPotionEffect(PotionEffectType.SPEED)) {
|
|
||||||
for (PotionEffect effect : wolf.getActivePotionEffects()) {
|
|
||||||
if (effect.getType() != PotionEffectType.SPEED) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
duration = effect.getDuration();
|
|
||||||
amplifier = effect.getAmplifier();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int ticks = 20 * 5;
|
|
||||||
|
|
||||||
PotionEffect abilityBuff = new PotionEffect(PotionEffectType.SPEED, duration + ticks, amplifier + 3);
|
|
||||||
wolf.addPotionEffect(abilityBuff, true);
|
|
||||||
ParticleEffectUtils.playSmokeEffect(wolf);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void pummel(LivingEntity target, Wolf wolf) {
|
public void pummel(LivingEntity target, Wolf wolf) {
|
||||||
double chance = 10 / activationChance;
|
double chance = 10 / activationChance;
|
||||||
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(getPlayer(), SecondaryAbility.PUMMEL, chance);
|
SecondaryAbilityWeightedActivationCheckEvent event = new SecondaryAbilityWeightedActivationCheckEvent(getPlayer(), SecondaryAbility.PUMMEL, chance);
|
||||||
@@ -305,6 +206,25 @@ public class TamingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void attackTarget(LivingEntity target) {
|
||||||
|
double range = 5;
|
||||||
|
Player player = getPlayer();
|
||||||
|
|
||||||
|
for (Entity entity : player.getNearbyEntities(range, range, range)) {
|
||||||
|
if (entity.getType() != EntityType.WOLF) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Wolf wolf = (Wolf) entity;
|
||||||
|
|
||||||
|
if (!wolf.isTamed() || (wolf.getOwner() != player) || wolf.isSitting()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
wolf.setTarget(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the Call of the Wild ability.
|
* Handle the Call of the Wild ability.
|
||||||
*
|
*
|
||||||
@@ -314,7 +234,7 @@ public class TamingManager extends SkillManager {
|
|||||||
private void callOfTheWild(EntityType type, int summonAmount) {
|
private void callOfTheWild(EntityType type, int summonAmount) {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
|
||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||||
int heldItemAmount = heldItem.getAmount();
|
int heldItemAmount = heldItem.getAmount();
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
|
|
||||||
@@ -323,8 +243,7 @@ public class TamingManager extends SkillManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEntityTypeNearby(type)) {
|
if (!rangeCheck(type)) {
|
||||||
player.sendMessage(Taming.getCallOfTheWildFailureMessage(type));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,7 +303,9 @@ public class TamingManager extends SkillManager {
|
|||||||
ParticleEffectUtils.playCallOfTheWildEffect(entity);
|
ParticleEffectUtils.playCallOfTheWildEffect(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setItemInHand(heldItemAmount == summonAmount ? null : new ItemStack(heldItem.getType(), heldItemAmount - summonAmount));
|
ItemStack leftovers = new ItemStack(heldItem);
|
||||||
|
leftovers.setAmount(heldItemAmount - summonAmount);
|
||||||
|
player.getInventory().setItemInMainHand(heldItemAmount == summonAmount ? null : leftovers);
|
||||||
|
|
||||||
String lifeSpan = "";
|
String lifeSpan = "";
|
||||||
if (tamingCOTWLength > 0) {
|
if (tamingCOTWLength > 0) {
|
||||||
@@ -392,44 +313,25 @@ public class TamingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete") + lifeSpan);
|
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete") + lifeSpan);
|
||||||
player.playSound(location, Sound.FIREWORK_LARGE_BLAST2, 1F, 0.5F);
|
player.playSound(location, Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR, 1F, 0.5F);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Entity> getNearbyEntities(EntityType type, double range, boolean wolfReady) {
|
private boolean rangeCheck(EntityType type) {
|
||||||
List<Entity> nearbyEntities = new ArrayList<Entity>();
|
double range = Config.getInstance().getTamingCOTWRange();
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
|
||||||
if (range == 0) {
|
if (range == 0) {
|
||||||
return nearbyEntities;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Entity entity : player.getNearbyEntities(range, range, range)) {
|
for (Entity entity : player.getNearbyEntities(range, range, range)) {
|
||||||
EntityType entityType = entity.getType();
|
if (entity.getType() == type) {
|
||||||
|
player.sendMessage(Taming.getCallOfTheWildFailureMessage(type));
|
||||||
if (entityType != type) {
|
return false;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entityType == EntityType.WOLF && wolfReady) {
|
|
||||||
Wolf wolf = (Wolf) entity;
|
|
||||||
|
|
||||||
if (!wolf.isTamed() || (wolf.getOwner() != player) || wolf.isSitting()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nearbyEntities.add(entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nearbyEntities;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEntityTypeNearby(EntityType type) {
|
|
||||||
return isEntityTypeNearby(type, Config.getInstance().getTamingCOTWRange(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEntityTypeNearby(EntityType type, double range, boolean wolfReady) {
|
|
||||||
return !getNearbyEntities(type, range, wolfReady).isEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean summonAmountCheck(EntityType entityType) {
|
private boolean summonAmountCheck(EntityType entityType) {
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
package com.gmail.nossr50.skills.taming;
|
package com.gmail.nossr50.skills.taming;
|
||||||
|
|
||||||
import java.util.UUID;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
|
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import java.util.UUID;
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
|
||||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
|
||||||
|
|
||||||
public class TrackedTamingEntity extends BukkitRunnable {
|
public class TrackedTamingEntity extends BukkitRunnable {
|
||||||
private LivingEntity livingEntity;
|
private LivingEntity livingEntity;
|
||||||
@@ -35,7 +34,7 @@ public class TrackedTamingEntity extends BukkitRunnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (livingEntity.isValid()) {
|
if (livingEntity.isValid()) {
|
||||||
Location location = livingEntity.getLocation();
|
Location location = livingEntity.getLocation();
|
||||||
location.getWorld().playSound(location, Sound.FIZZ, 0.8F, 0.8F);
|
location.getWorld().playSound(location, Sound.BLOCK_FIRE_EXTINGUISH, 0.8F, 0.8F);
|
||||||
ParticleEffectUtils.playCallOfTheWildEffect(livingEntity);
|
ParticleEffectUtils.playCallOfTheWildEffect(livingEntity);
|
||||||
CombatUtils.dealDamage(livingEntity, livingEntity.getMaxHealth(), DamageCause.SUICIDE, livingEntity);
|
CombatUtils.dealDamage(livingEntity, livingEntity.getMaxHealth(), DamageCause.SUICIDE, livingEntity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ public class Unarmed {
|
|||||||
if (inventory.containsAtLeast(dropStack, 1)) {
|
if (inventory.containsAtLeast(dropStack, 1)) {
|
||||||
int nextSlot = 0;
|
int nextSlot = 0;
|
||||||
|
|
||||||
for (ItemStack itemstack : inventory) {
|
ItemStack[] items = inventory.getStorageContents();
|
||||||
|
for (ItemStack itemstack : items) {
|
||||||
if (dropStack.isSimilar(itemstack)) {
|
if (dropStack.isSimilar(itemstack)) {
|
||||||
int itemAmount = itemstack.getAmount();
|
int itemAmount = itemstack.getAmount();
|
||||||
int itemMax = itemstack.getMaxStackSize();
|
int itemMax = itemstack.getMaxStackSize();
|
||||||
@@ -36,13 +37,15 @@ public class Unarmed {
|
|||||||
if (dropAmount + itemAmount <= itemMax) {
|
if (dropAmount + itemAmount <= itemMax) {
|
||||||
drop.remove();
|
drop.remove();
|
||||||
addStack.setAmount(dropAmount + itemAmount);
|
addStack.setAmount(dropAmount + itemAmount);
|
||||||
inventory.setItem(nextSlot, addStack);
|
items[nextSlot] = addStack;
|
||||||
|
inventory.setStorageContents(items);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
addStack.setAmount(itemMax);
|
addStack.setAmount(itemMax);
|
||||||
dropAmount = dropAmount + itemAmount - itemMax;
|
dropAmount = dropAmount + itemAmount - itemMax;
|
||||||
inventory.setItem(nextSlot, addStack);
|
items[nextSlot] = addStack;
|
||||||
|
inventory.setStorageContents(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dropAmount == 0) {
|
if (dropAmount == 0) {
|
||||||
@@ -57,13 +60,15 @@ public class Unarmed {
|
|||||||
if (firstEmpty == inventory.getHeldItemSlot()) {
|
if (firstEmpty == inventory.getHeldItemSlot()) {
|
||||||
int nextSlot = firstEmpty + 1;
|
int nextSlot = firstEmpty + 1;
|
||||||
|
|
||||||
for (Iterator<ItemStack> iterator = inventory.iterator(nextSlot); iterator.hasNext(); ) {
|
ItemStack[] items = inventory.getStorageContents();
|
||||||
ItemStack itemstack = iterator.next();
|
for (; nextSlot < items.length; nextSlot++) {
|
||||||
|
ItemStack itemstack = items[nextSlot];
|
||||||
|
|
||||||
if (itemstack == null) {
|
if (itemstack == null) {
|
||||||
drop.remove();
|
drop.remove();
|
||||||
dropStack.setAmount(dropAmount);
|
dropStack.setAmount(dropAmount);
|
||||||
inventory.setItem(nextSlot, dropStack);
|
items[nextSlot] = dropStack;
|
||||||
|
inventory.setStorageContents(items);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +76,14 @@ public class Unarmed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inventory is full - cancel the item pickup
|
// Inventory is full - cancel the item pickup
|
||||||
return false;
|
if (dropStack.getAmount() == dropAmount) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
drop.remove();
|
||||||
|
dropStack.setAmount(dropAmount);
|
||||||
|
((Item) drop.getWorld().dropItem(drop.getLocation(), dropStack)).setPickupDelay(0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (firstEmpty != -1) {
|
else if (firstEmpty != -1) {
|
||||||
drop.remove();
|
drop.remove();
|
||||||
|
|||||||
@@ -1,15 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.unarmed;
|
package com.gmail.nossr50.skills.unarmed;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.entity.Item;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.material.MaterialData;
|
|
||||||
import org.bukkit.material.SmoothBrick;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
@@ -17,12 +7,21 @@ import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
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.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.entity.Item;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
public class UnarmedManager extends SkillManager {
|
public class UnarmedManager extends SkillManager {
|
||||||
public UnarmedManager(McMMOPlayer mcMMOPlayer) {
|
public UnarmedManager(McMMOPlayer mcMMOPlayer) {
|
||||||
@@ -42,13 +41,13 @@ public class UnarmedManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDisarm(LivingEntity target) {
|
public boolean canDisarm(LivingEntity target) {
|
||||||
return target instanceof Player && ((Player) target).getItemInHand().getType() != Material.AIR && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DISARM);
|
return target instanceof Player && ((Player) target).getInventory().getItemInMainHand().getType() != Material.AIR && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DISARM);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDeflect() {
|
public boolean canDeflect() {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
|
||||||
return player.getItemInHand().getType() == Material.AIR && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DEFLECT);
|
return ItemUtils.isUnarmed(player.getInventory().getItemInMainHand()) && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DEFLECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUseBlockCracker() {
|
public boolean canUseBlockCracker() {
|
||||||
@@ -60,22 +59,15 @@ public class UnarmedManager extends SkillManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialData data = blockState.getData();
|
BlockData data = blockState.getBlockData();
|
||||||
|
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case SMOOTH_BRICK:
|
case STONE_BRICKS:
|
||||||
if (!Unarmed.blockCrackerSmoothBrick) {
|
if (!Unarmed.blockCrackerSmoothBrick) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Yes, this is awkward, but it's the *right* way to do it.
|
blockState.setType(Material.CRACKED_STONE_BRICKS);
|
||||||
SmoothBrick smoothBrick = (SmoothBrick) data;
|
|
||||||
|
|
||||||
if (smoothBrick.getMaterial() != Material.STONE) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
smoothBrick.setMaterial(Material.COBBLESTONE);
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -94,13 +86,13 @@ public class UnarmedManager extends SkillManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item item = Misc.dropItem(defender.getLocation(), defender.getItemInHand());
|
Item item = Misc.dropItem(defender.getLocation(), defender.getInventory().getItemInMainHand());
|
||||||
|
|
||||||
if (item != null && AdvancedConfig.getInstance().getDisarmProtected()) {
|
if (item != null && AdvancedConfig.getInstance().getDisarmProtected()) {
|
||||||
item.setMetadata(mcMMO.disarmedItemKey, UserManager.getPlayer(defender).getPlayerMetadata());
|
item.setMetadata(mcMMO.disarmedItemKey, UserManager.getPlayer(defender).getPlayerMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
defender.setItemInHand(new ItemStack(Material.AIR));
|
defender.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||||
defender.sendMessage(LocaleLoader.getString("Skills.Disarmed"));
|
defender.sendMessage(LocaleLoader.getString("Skills.Disarmed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,22 @@
|
|||||||
package com.gmail.nossr50.skills.woodcutting;
|
package com.gmail.nossr50.skills.woodcutting;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.TreeSpecies;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.material.Tree;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
||||||
|
|
||||||
public final class Woodcutting {
|
public final class Woodcutting {
|
||||||
public static int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
|
public static int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
|
||||||
public static int treeFellerThreshold = Config.getInstance().getTreeFellerThreshold();
|
public static int treeFellerThreshold = Config.getInstance().getTreeFellerThreshold();
|
||||||
@@ -28,7 +26,7 @@ public final class Woodcutting {
|
|||||||
protected enum ExperienceGainMethod {
|
protected enum ExperienceGainMethod {
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
TREE_FELLER,
|
TREE_FELLER,
|
||||||
};
|
}
|
||||||
|
|
||||||
private Woodcutting() {}
|
private Woodcutting() {}
|
||||||
|
|
||||||
@@ -40,35 +38,11 @@ public final class Woodcutting {
|
|||||||
* @return Amount of experience
|
* @return Amount of experience
|
||||||
*/
|
*/
|
||||||
protected static int getExperienceFromLog(BlockState blockState, ExperienceGainMethod experienceGainMethod) {
|
protected static int getExperienceFromLog(BlockState blockState, ExperienceGainMethod experienceGainMethod) {
|
||||||
// Mushrooms aren't trees so we could never get species data from them
|
|
||||||
switch (blockState.getType()) {
|
|
||||||
case HUGE_MUSHROOM_1:
|
|
||||||
return ExperienceConfig.getInstance().getWoodcuttingXPHugeBrownMushroom();
|
|
||||||
|
|
||||||
case HUGE_MUSHROOM_2:
|
|
||||||
return ExperienceConfig.getInstance().getWoodcuttingXPHugeRedMushroom();
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mcMMO.getModManager().isCustomLog(blockState)) {
|
if (mcMMO.getModManager().isCustomLog(blockState)) {
|
||||||
return mcMMO.getModManager().getBlock(blockState).getXpGain();
|
return mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Remove this workaround when casting to Tree works again
|
return ExperienceConfig.getInstance().getXp(SkillType.WOODCUTTING, blockState.getType());
|
||||||
TreeSpecies species = TreeSpecies.GENERIC;
|
|
||||||
if (blockState.getData() instanceof Tree) {
|
|
||||||
species = ((Tree) blockState.getData()).getSpecies();
|
|
||||||
}
|
|
||||||
|
|
||||||
int xp = ExperienceConfig.getInstance().getWoodcuttingTreeXP(species);
|
|
||||||
|
|
||||||
if (species == TreeSpecies.JUNGLE && experienceGainMethod == ExperienceGainMethod.TREE_FELLER) {
|
|
||||||
xp *= 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
return xp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,17 +52,11 @@ public final class Woodcutting {
|
|||||||
*/
|
*/
|
||||||
protected static void checkForDoubleDrop(BlockState blockState) {
|
protected static void checkForDoubleDrop(BlockState blockState) {
|
||||||
if (mcMMO.getModManager().isCustomLog(blockState) && mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) {
|
if (mcMMO.getModManager().isCustomLog(blockState) && mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) {
|
||||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//TODO Remove this workaround when casting to Tree works again
|
if (Config.getInstance().getWoodcuttingDoubleDropsEnabled(blockState.getBlockData())) {
|
||||||
TreeSpecies species = TreeSpecies.GENERIC;
|
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops());
|
||||||
if (blockState.getData() instanceof Tree) {
|
|
||||||
species = ((Tree) blockState.getData()).getSpecies();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.getInstance().getWoodcuttingDoubleDropsEnabled(species)) {
|
|
||||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.woodcutting;
|
package com.gmail.nossr50.skills.woodcutting;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.material.Tree;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
@@ -19,14 +7,20 @@ import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod;
|
import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.*;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class WoodcuttingManager extends SkillManager {
|
public class WoodcuttingManager extends SkillManager {
|
||||||
public WoodcuttingManager(McMMOPlayer mcMMOPlayer) {
|
public WoodcuttingManager(McMMOPlayer mcMMOPlayer) {
|
||||||
@@ -54,8 +48,8 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
int xp = Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT);
|
int xp = Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT);
|
||||||
|
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case HUGE_MUSHROOM_1:
|
case BROWN_MUSHROOM_BLOCK:
|
||||||
case HUGE_MUSHROOM_2:
|
case RED_MUSHROOM_BLOCK:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -89,7 +83,7 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the tool can't sustain the durability loss
|
// If the tool can't sustain the durability loss
|
||||||
if (!Woodcutting.handleDurabilityLoss(treeFellerBlocks, player.getItemInHand())) {
|
if (!Woodcutting.handleDurabilityLoss(treeFellerBlocks, player.getInventory().getItemInMainHand())) {
|
||||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter"));
|
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter"));
|
||||||
|
|
||||||
double health = player.getHealth();
|
double health = player.getHealth();
|
||||||
@@ -123,9 +117,9 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
|
|
||||||
Material material = blockState.getType();
|
Material material = blockState.getType();
|
||||||
|
|
||||||
if (material == Material.HUGE_MUSHROOM_1 || material == Material.HUGE_MUSHROOM_2) {
|
if (material == Material.BROWN_MUSHROOM_BLOCK || material == Material.RED_MUSHROOM_BLOCK) {
|
||||||
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
||||||
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
|
||||||
}
|
}
|
||||||
else if (mcMMO.getModManager().isCustomLog(blockState)) {
|
else if (mcMMO.getModManager().isCustomLog(blockState)) {
|
||||||
if (canGetDoubleDrops()) {
|
if (canGetDoubleDrops()) {
|
||||||
@@ -135,35 +129,22 @@ public class WoodcuttingManager extends SkillManager {
|
|||||||
CustomBlock customBlock = mcMMO.getModManager().getBlock(blockState);
|
CustomBlock customBlock = mcMMO.getModManager().getBlock(blockState);
|
||||||
xp = customBlock.getXpGain();
|
xp = customBlock.getXpGain();
|
||||||
|
|
||||||
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
|
||||||
}
|
}
|
||||||
else if (mcMMO.getModManager().isCustomLeaf(blockState)) {
|
else if (mcMMO.getModManager().isCustomLeaf(blockState)) {
|
||||||
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//TODO Remove this workaround when casting to Tree works again
|
|
||||||
if (blockState.getData() instanceof Tree) {
|
if (BlockUtils.isLog(blockState)) {
|
||||||
Tree tree = (Tree) blockState.getData();
|
if (canGetDoubleDrops()) {
|
||||||
tree.setDirection(BlockFace.UP);
|
Woodcutting.checkForDoubleDrop(blockState);
|
||||||
|
}
|
||||||
|
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
||||||
|
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
|
||||||
}
|
}
|
||||||
|
if (BlockUtils.isLeaves(blockState)) {
|
||||||
switch (material) {
|
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
|
||||||
case LOG:
|
|
||||||
case LOG_2:
|
|
||||||
if (canGetDoubleDrops()) {
|
|
||||||
Woodcutting.checkForDoubleDrop(blockState);
|
|
||||||
}
|
|
||||||
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
|
||||||
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LEAVES:
|
|
||||||
case LEAVES_2:
|
|
||||||
Misc.dropItems(blockState.getLocation(), block.getDrops());
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +1,26 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import org.bukkit.CropState;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.NetherWartsState;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.material.CocoaPlant;
|
|
||||||
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
|
|
||||||
import org.bukkit.material.Crops;
|
|
||||||
import org.bukkit.material.NetherWarts;
|
|
||||||
import org.bukkit.material.SmoothBrick;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.repair.Repair;
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||||
import com.gmail.nossr50.util.temp.DualSupport;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.block.data.Ageable;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
public final class BlockUtils {
|
public final class BlockUtils {
|
||||||
|
|
||||||
private BlockUtils() {}
|
private BlockUtils() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if a given block awards XP.
|
* Checks to see if a given block awards XP.
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState
|
||||||
|
* The {@link BlockState} of the block to check
|
||||||
* @return true if the block awards XP, false otherwise
|
* @return true if the block awards XP, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean shouldBeWatched(BlockState blockState) {
|
public static boolean shouldBeWatched(BlockState blockState) {
|
||||||
@@ -33,74 +30,136 @@ public final class BlockUtils {
|
|||||||
/**
|
/**
|
||||||
* Check if a given block should allow for the activation of abilities
|
* Check if a given block should allow for the activation of abilities
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState
|
||||||
* @return true if the block should allow ability activation, false otherwise
|
* The {@link BlockState} of the block to check
|
||||||
|
* @return true if the block should allow ability activation, false
|
||||||
|
* otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean canActivateAbilities(BlockState blockState) {
|
public static boolean canActivateAbilities(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case BED_BLOCK:
|
case BLACK_BED:
|
||||||
case BREWING_STAND:
|
case BLUE_BED:
|
||||||
case BOOKSHELF:
|
case BROWN_BED:
|
||||||
case BURNING_FURNACE:
|
case CYAN_BED:
|
||||||
case CAKE_BLOCK:
|
case GRAY_BED:
|
||||||
case CHEST:
|
case GREEN_BED:
|
||||||
case DISPENSER:
|
case LIGHT_BLUE_BED:
|
||||||
case ENCHANTMENT_TABLE:
|
case LIGHT_GRAY_BED:
|
||||||
case ENDER_CHEST:
|
case LIME_BED:
|
||||||
case FENCE_GATE:
|
case MAGENTA_BED:
|
||||||
case FURNACE:
|
case ORANGE_BED:
|
||||||
case IRON_DOOR_BLOCK:
|
case PINK_BED:
|
||||||
case JUKEBOX:
|
case PURPLE_BED:
|
||||||
case LEVER:
|
case RED_BED:
|
||||||
case NOTE_BLOCK:
|
case WHITE_BED:
|
||||||
case STONE_BUTTON:
|
case YELLOW_BED:
|
||||||
case WOOD_BUTTON:
|
case BREWING_STAND :
|
||||||
case TRAP_DOOR:
|
case BOOKSHELF :
|
||||||
case WALL_SIGN:
|
case CAKE:
|
||||||
case WOODEN_DOOR:
|
case CHEST :
|
||||||
case WORKBENCH:
|
case DISPENSER :
|
||||||
case BEACON:
|
case ENCHANTING_TABLE:
|
||||||
case ANVIL:
|
case ENDER_CHEST :
|
||||||
case DROPPER:
|
case OAK_FENCE_GATE:
|
||||||
case HOPPER:
|
case ACACIA_FENCE_GATE :
|
||||||
case TRAPPED_CHEST:
|
case DARK_OAK_FENCE_GATE :
|
||||||
case IRON_DOOR:
|
case SPRUCE_FENCE_GATE :
|
||||||
|
case BIRCH_FENCE_GATE :
|
||||||
|
case JUNGLE_FENCE_GATE :
|
||||||
|
case FURNACE :
|
||||||
|
case JUKEBOX :
|
||||||
|
case LEVER :
|
||||||
|
case NOTE_BLOCK :
|
||||||
|
case STONE_BUTTON :
|
||||||
|
case OAK_BUTTON:
|
||||||
|
case BIRCH_BUTTON:
|
||||||
|
case ACACIA_BUTTON:
|
||||||
|
case DARK_OAK_BUTTON:
|
||||||
|
case JUNGLE_BUTTON:
|
||||||
|
case SPRUCE_BUTTON:
|
||||||
|
case ACACIA_TRAPDOOR:
|
||||||
|
case BIRCH_TRAPDOOR:
|
||||||
|
case DARK_OAK_TRAPDOOR:
|
||||||
|
case JUNGLE_TRAPDOOR:
|
||||||
|
case OAK_TRAPDOOR:
|
||||||
|
case SPRUCE_TRAPDOOR:
|
||||||
|
case WALL_SIGN :
|
||||||
|
case CRAFTING_TABLE:
|
||||||
|
case BEACON :
|
||||||
|
case ANVIL :
|
||||||
|
case DROPPER :
|
||||||
|
case HOPPER :
|
||||||
|
case TRAPPED_CHEST :
|
||||||
|
case IRON_DOOR :
|
||||||
|
case IRON_TRAPDOOR :
|
||||||
|
case OAK_DOOR:
|
||||||
|
case ACACIA_DOOR :
|
||||||
|
case SPRUCE_DOOR :
|
||||||
|
case BIRCH_DOOR :
|
||||||
|
case JUNGLE_DOOR :
|
||||||
|
case DARK_OAK_DOOR :
|
||||||
|
case OAK_FENCE:
|
||||||
|
case ACACIA_FENCE :
|
||||||
|
case DARK_OAK_FENCE :
|
||||||
|
case BIRCH_FENCE :
|
||||||
|
case JUNGLE_FENCE :
|
||||||
|
case SPRUCE_FENCE :
|
||||||
|
case ARMOR_STAND :
|
||||||
|
case BLACK_SHULKER_BOX :
|
||||||
|
case BLUE_SHULKER_BOX :
|
||||||
|
case BROWN_SHULKER_BOX :
|
||||||
|
case CYAN_SHULKER_BOX :
|
||||||
|
case GRAY_SHULKER_BOX :
|
||||||
|
case GREEN_SHULKER_BOX :
|
||||||
|
case LIGHT_BLUE_SHULKER_BOX :
|
||||||
|
case LIME_SHULKER_BOX :
|
||||||
|
case MAGENTA_SHULKER_BOX :
|
||||||
|
case ORANGE_SHULKER_BOX :
|
||||||
|
case PINK_SHULKER_BOX :
|
||||||
|
case PURPLE_SHULKER_BOX :
|
||||||
|
case RED_SHULKER_BOX :
|
||||||
|
case LIGHT_GRAY_SHULKER_BOX:
|
||||||
|
case WHITE_SHULKER_BOX :
|
||||||
|
case YELLOW_SHULKER_BOX :
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
default:
|
default :
|
||||||
return DualSupport.canActivateAbilities(blockState) && !isMcMMOAnvil(blockState) && !mcMMO.getModManager().isCustomAbilityBlock(blockState);
|
return !isMcMMOAnvil(blockState) && !mcMMO.getModManager().isCustomAbilityBlock(blockState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a given block is an ore
|
* Check if a given block is an ore
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState
|
||||||
|
* The {@link BlockState} of the block to check
|
||||||
* @return true if the block is an ore, false otherwise
|
* @return true if the block is an ore, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isOre(BlockState blockState) {
|
public static boolean isOre(BlockState blockState) {
|
||||||
return MaterialUtils.isOre(blockState.getData());
|
return MaterialUtils.isOre(blockState.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if a given block can be made mossy
|
* Determine if a given block can be made mossy
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState
|
||||||
|
* The {@link BlockState} of the block to check
|
||||||
* @return true if the block can be made mossy, false otherwise
|
* @return true if the block can be made mossy, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean canMakeMossy(BlockState blockState) {
|
public static boolean canMakeMossy(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case COBBLESTONE:
|
case COBBLESTONE :
|
||||||
case DIRT:
|
case DIRT :
|
||||||
|
case GRASS_PATH :
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case SMOOTH_BRICK:
|
case STONE_BRICKS:
|
||||||
return ((SmoothBrick) blockState.getData()).getMaterial() == Material.STONE;
|
return true;
|
||||||
|
|
||||||
case COBBLE_WALL:
|
case COBBLESTONE_WALL:
|
||||||
return blockState.getRawData() == (byte) 0x0;
|
return true;
|
||||||
|
|
||||||
default:
|
default :
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,124 +167,78 @@ public final class BlockUtils {
|
|||||||
/**
|
/**
|
||||||
* Determine if a given block should be affected by Green Terra
|
* Determine if a given block should be affected by Green Terra
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState
|
||||||
|
* The {@link BlockState} of the block to check
|
||||||
* @return true if the block should affected by Green Terra, false otherwise
|
* @return true if the block should affected by Green Terra, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean affectedByGreenTerra(BlockState blockState) {
|
public static boolean affectedByGreenTerra(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.HERBALISM, blockState.getBlockData())) {
|
||||||
case BROWN_MUSHROOM:
|
return true;
|
||||||
case CACTUS:
|
|
||||||
case DOUBLE_PLANT:
|
|
||||||
case MELON_BLOCK:
|
|
||||||
case LONG_GRASS:
|
|
||||||
case PUMPKIN:
|
|
||||||
case RED_MUSHROOM:
|
|
||||||
case RED_ROSE:
|
|
||||||
case SUGAR_CANE_BLOCK:
|
|
||||||
case VINE:
|
|
||||||
case WATER_LILY:
|
|
||||||
case YELLOW_FLOWER:
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case CARROT:
|
|
||||||
case POTATO:
|
|
||||||
return blockState.getRawData() == CropState.RIPE.getData();
|
|
||||||
|
|
||||||
case CROPS:
|
|
||||||
return ((Crops) blockState.getData()).getState() == CropState.RIPE;
|
|
||||||
|
|
||||||
case NETHER_WARTS:
|
|
||||||
return ((NetherWarts) blockState.getData()).getState() == NetherWartsState.RIPE;
|
|
||||||
|
|
||||||
case COCOA:
|
|
||||||
return ((CocoaPlant) blockState.getData()).getSize() == CocoaPlantSize.LARGE;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return mcMMO.getModManager().isCustomHerbalismBlock(blockState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return mcMMO.getModManager().isCustomHerbalismBlock(blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if a given block should be affected by Super Breaker
|
* Determine if a given block should be affected by Super Breaker
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState
|
||||||
* @return true if the block should affected by Super Breaker, false otherwise
|
* The {@link BlockState} of the block to check
|
||||||
|
* @return true if the block should affected by Super Breaker, false
|
||||||
|
* otherwise
|
||||||
*/
|
*/
|
||||||
public static Boolean affectedBySuperBreaker(BlockState blockState) {
|
public static Boolean affectedBySuperBreaker(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.MINING, blockState.getBlockData()))
|
||||||
case ENDER_STONE:
|
return true;
|
||||||
case GLOWSTONE:
|
|
||||||
case HARD_CLAY:
|
|
||||||
case MOSSY_COBBLESTONE:
|
|
||||||
case NETHERRACK:
|
|
||||||
case OBSIDIAN:
|
|
||||||
case PACKED_ICE:
|
|
||||||
case SANDSTONE:
|
|
||||||
case STAINED_CLAY:
|
|
||||||
case STONE:
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
return isOre(blockState) || mcMMO.getModManager().isCustomMiningBlock(blockState);
|
||||||
return DualSupport.affectedBySuperBreaker(blockState) || isOre(blockState) || mcMMO.getModManager().isCustomMiningBlock(blockState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if a given block should be affected by Giga Drill Breaker
|
* Determine if a given block should be affected by Giga Drill Breaker
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState
|
||||||
* @return true if the block should affected by Giga Drill Breaker, false otherwise
|
* The {@link BlockState} of the block to check
|
||||||
|
* @return true if the block should affected by Giga Drill Breaker, false
|
||||||
|
* otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean affectedByGigaDrillBreaker(BlockState blockState) {
|
public static boolean affectedByGigaDrillBreaker(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.EXCAVATION, blockState.getBlockData()))
|
||||||
case CLAY:
|
return true;
|
||||||
case DIRT:
|
return mcMMO.getModManager().isCustomExcavationBlock(blockState);
|
||||||
case GRASS:
|
|
||||||
case GRAVEL:
|
|
||||||
case MYCEL:
|
|
||||||
case SAND:
|
|
||||||
case SNOW:
|
|
||||||
case SNOW_BLOCK:
|
|
||||||
case SOUL_SAND:
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return mcMMO.getModManager().isCustomExcavationBlock(blockState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a given block is a log
|
* Check if a given block is a log
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState
|
||||||
|
* The {@link BlockState} of the block to check
|
||||||
* @return true if the block is a log, false otherwise
|
* @return true if the block is a log, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isLog(BlockState blockState) {
|
public static boolean isLog(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.WOODCUTTING, blockState.getBlockData()))
|
||||||
case LOG:
|
return true;
|
||||||
case LOG_2:
|
return mcMMO.getModManager().isCustomLog(blockState);
|
||||||
case HUGE_MUSHROOM_1:
|
|
||||||
case HUGE_MUSHROOM_2:
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return mcMMO.getModManager().isCustomLog(blockState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a given block is a leaf
|
* Check if a given block is a leaf
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState
|
||||||
|
* The {@link BlockState} of the block to check
|
||||||
* @return true if the block is a leaf, false otherwise
|
* @return true if the block is a leaf, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isLeaves(BlockState blockState) {
|
public static boolean isLeaves(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case LEAVES:
|
case OAK_LEAVES:
|
||||||
case LEAVES_2:
|
case ACACIA_LEAVES:
|
||||||
|
case BIRCH_LEAVES:
|
||||||
|
case DARK_OAK_LEAVES:
|
||||||
|
case JUNGLE_LEAVES:
|
||||||
|
case SPRUCE_LEAVES:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default :
|
||||||
return mcMMO.getModManager().isCustomLeaf(blockState);
|
return mcMMO.getModManager().isCustomLeaf(blockState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -233,16 +246,17 @@ public final class BlockUtils {
|
|||||||
/**
|
/**
|
||||||
* Determine if a given block should be affected by Flux Mining
|
* Determine if a given block should be affected by Flux Mining
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState
|
||||||
|
* The {@link BlockState} of the block to check
|
||||||
* @return true if the block should affected by Flux Mining, false otherwise
|
* @return true if the block should affected by Flux Mining, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean affectedByFluxMining(BlockState blockState) {
|
public static boolean affectedByFluxMining(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case IRON_ORE:
|
case IRON_ORE :
|
||||||
case GOLD_ORE:
|
case GOLD_ORE :
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default :
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -250,17 +264,20 @@ public final class BlockUtils {
|
|||||||
/**
|
/**
|
||||||
* Determine if a given block can activate Herbalism abilities
|
* Determine if a given block can activate Herbalism abilities
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState
|
||||||
* @return true if the block can be activate Herbalism abilities, false otherwise
|
* The {@link BlockState} of the block to check
|
||||||
|
* @return true if the block can be activate Herbalism abilities, false
|
||||||
|
* otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean canActivateHerbalism(BlockState blockState) {
|
public static boolean canActivateHerbalism(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case DIRT:
|
case DIRT :
|
||||||
case GRASS:
|
case GRASS :
|
||||||
case SOIL:
|
case GRASS_PATH :
|
||||||
|
case FARMLAND:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
default:
|
default :
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,15 +285,17 @@ public final class BlockUtils {
|
|||||||
/**
|
/**
|
||||||
* Determine if a given block should be affected by Block Cracker
|
* Determine if a given block should be affected by Block Cracker
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState
|
||||||
* @return true if the block should affected by Block Cracker, false otherwise
|
* The {@link BlockState} of the block to check
|
||||||
|
* @return true if the block should affected by Block Cracker, false
|
||||||
|
* otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean affectedByBlockCracker(BlockState blockState) {
|
public static boolean affectedByBlockCracker(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case SMOOTH_BRICK:
|
case STONE_BRICKS:
|
||||||
return ((SmoothBrick) blockState.getData()).getMaterial() == Material.STONE;
|
return true;
|
||||||
|
|
||||||
default:
|
default :
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,16 +303,18 @@ public final class BlockUtils {
|
|||||||
/**
|
/**
|
||||||
* Determine if a given block can be made into Mycelium
|
* Determine if a given block can be made into Mycelium
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState
|
||||||
|
* The {@link BlockState} of the block to check
|
||||||
* @return true if the block can be made into Mycelium, false otherwise
|
* @return true if the block can be made into Mycelium, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean canMakeShroomy(BlockState blockState) {
|
public static boolean canMakeShroomy(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case DIRT:
|
case DIRT :
|
||||||
case GRASS:
|
case GRASS :
|
||||||
|
case GRASS_PATH :
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default :
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -301,7 +322,8 @@ public final class BlockUtils {
|
|||||||
/**
|
/**
|
||||||
* Determine if a given block is an mcMMO anvil
|
* Determine if a given block is an mcMMO anvil
|
||||||
*
|
*
|
||||||
* @param blockState The {@link BlockState} of the block to check
|
* @param blockState
|
||||||
|
* The {@link BlockState} of the block to check
|
||||||
* @return true if the block is an mcMMO anvil, false otherwise
|
* @return true if the block is an mcMMO anvil, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isMcMMOAnvil(BlockState blockState) {
|
public static boolean isMcMMOAnvil(BlockState blockState) {
|
||||||
@@ -313,7 +335,7 @@ public final class BlockUtils {
|
|||||||
public static boolean isPistonPiece(BlockState blockState) {
|
public static boolean isPistonPiece(BlockState blockState) {
|
||||||
Material type = blockState.getType();
|
Material type = blockState.getType();
|
||||||
|
|
||||||
return type == Material.PISTON_MOVING_PIECE || type == Material.AIR;
|
return type == Material.MOVING_PISTON || type == Material.AIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -321,15 +343,27 @@ public final class BlockUtils {
|
|||||||
*
|
*
|
||||||
* @return HashSet with the IDs of every transparent block
|
* @return HashSet with the IDs of every transparent block
|
||||||
*/
|
*/
|
||||||
public static HashSet<Byte> getTransparentBlocks() {
|
public static HashSet<Material> getTransparentBlocks() {
|
||||||
HashSet<Byte> transparentBlocks = new HashSet<Byte>();
|
HashSet<Material> transparentBlocks = new HashSet<Material>();
|
||||||
|
|
||||||
for (Material material : Material.values()) {
|
for (Material material : Material.values()) {
|
||||||
if (material.isTransparent()) {
|
if (material.isTransparent()) {
|
||||||
transparentBlocks.add((byte) material.getId());
|
transparentBlocks.add(material);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return transparentBlocks;
|
return transparentBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isFullyGrown(BlockState blockState) {
|
||||||
|
BlockData data = blockState.getBlockData();
|
||||||
|
if (data.getMaterial() == Material.CACTUS || data.getMaterial() == Material.SUGAR_CANE)
|
||||||
|
return true;
|
||||||
|
if (data instanceof Ageable)
|
||||||
|
{
|
||||||
|
Ageable ageable = (Ageable) data;
|
||||||
|
return ageable.getAge() == ageable.getMaximumAge();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,22 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.gmail.nossr50.config.Config;
|
||||||
import java.util.List;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import org.bukkit.ChatColor;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import org.bukkit.Location;
|
import com.gmail.nossr50.runnables.items.ChimaeraWingWarmup;
|
||||||
import org.bukkit.Material;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import org.bukkit.Sound;
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.ShapelessRecipe;
|
import org.bukkit.inventory.ShapelessRecipe;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import java.util.ArrayList;
|
||||||
import com.gmail.nossr50.config.Config;
|
import java.util.List;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.metrics.MetricsManager;
|
|
||||||
import com.gmail.nossr50.runnables.items.ChimaeraWingWarmup;
|
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
||||||
|
|
||||||
public final class ChimaeraWing {
|
public final class ChimaeraWing {
|
||||||
private static McMMOPlayer mcMMOPlayer;
|
private static McMMOPlayer mcMMOPlayer;
|
||||||
@@ -39,7 +34,7 @@ public final class ChimaeraWing {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack inHand = player.getItemInHand();
|
ItemStack inHand = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
if (!ItemUtils.isChimaeraWing(inHand)) {
|
if (!ItemUtils.isChimaeraWing(inHand)) {
|
||||||
return;
|
return;
|
||||||
@@ -91,7 +86,7 @@ public final class ChimaeraWing {
|
|||||||
|
|
||||||
if (Config.getInstance().getChimaeraPreventUseUnderground()) {
|
if (Config.getInstance().getChimaeraPreventUseUnderground()) {
|
||||||
if (location.getY() < player.getWorld().getHighestBlockYAt(location)) {
|
if (location.getY() < player.getWorld().getHighestBlockYAt(location)) {
|
||||||
player.setItemInHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost())));
|
player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost())));
|
||||||
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail"));
|
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail"));
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
player.setVelocity(new Vector(0, 0.5D, 0));
|
player.setVelocity(new Vector(0, 0.5D, 0));
|
||||||
@@ -130,17 +125,13 @@ public final class ChimaeraWing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setItemInHand(new ItemStack(getChimaeraWing(player.getItemInHand().getAmount() - Config.getInstance().getChimaeraUseCost())));
|
player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(player.getInventory().getItemInMainHand().getAmount() - Config.getInstance().getChimaeraUseCost())));
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
mcMMOPlayer.actualizeChimeraWingLastUse();
|
mcMMOPlayer.actualizeChimeraWingLastUse();
|
||||||
mcMMOPlayer.setTeleportCommenceLocation(null);
|
mcMMOPlayer.setTeleportCommenceLocation(null);
|
||||||
|
|
||||||
if (Config.getInstance().getStatsTrackingEnabled()) {
|
|
||||||
MetricsManager.chimeraWingUsed();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.getInstance().getChimaeraSoundEnabled()) {
|
if (Config.getInstance().getChimaeraSoundEnabled()) {
|
||||||
player.playSound(location, Sound.BAT_TAKEOFF, Misc.BAT_VOLUME, Misc.BAT_PITCH);
|
player.playSound(location, Sound.ENTITY_BAT_TAKEOFF, Misc.BAT_VOLUME, Misc.BAT_PITCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass"));
|
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass"));
|
||||||
@@ -165,7 +156,7 @@ public final class ChimaeraWing {
|
|||||||
Material ingredient = Config.getInstance().getChimaeraItem();
|
Material ingredient = Config.getInstance().getChimaeraItem();
|
||||||
int amount = Config.getInstance().getChimaeraRecipeCost();
|
int amount = Config.getInstance().getChimaeraRecipeCost();
|
||||||
|
|
||||||
ShapelessRecipe chimeraWing = new ShapelessRecipe(getChimaeraWing(1));
|
ShapelessRecipe chimeraWing = new ShapelessRecipe(new NamespacedKey(mcMMO.p, "Chimera"), getChimaeraWing(1));
|
||||||
chimeraWing.addIngredient(amount, ingredient);
|
chimeraWing.addIngredient(amount, ingredient);
|
||||||
return chimeraWing;
|
return chimeraWing;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ public class EnchantmentUtils {
|
|||||||
enchants.put("FLAME", Enchantment.ARROW_FIRE);
|
enchants.put("FLAME", Enchantment.ARROW_FIRE);
|
||||||
enchants.put("KNOCKBACK", Enchantment.KNOCKBACK);
|
enchants.put("KNOCKBACK", Enchantment.KNOCKBACK);
|
||||||
enchants.put("THORNS", Enchantment.THORNS);
|
enchants.put("THORNS", Enchantment.THORNS);
|
||||||
|
enchants.put("MENDING", Enchantment.MENDING);
|
||||||
|
enchants.put("DEPTH_STRIDER", Enchantment.DEPTH_STRIDER);
|
||||||
|
enchants.put("FROST_WALKER", Enchantment.FROST_WALKER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,6 +48,6 @@ public class EnchantmentUtils {
|
|||||||
return enchants.get(enchantmentName);
|
return enchants.get(enchantmentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return Enchantment.getByName(enchantmentName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,5 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Fish;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.player.PlayerFishEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
|
||||||
import org.bukkit.plugin.PluginManager;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
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.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
@@ -41,8 +28,20 @@ import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent;
|
|||||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||||
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityEvent;
|
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityEvent;
|
||||||
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent;
|
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent;
|
||||||
|
import com.gmail.nossr50.events.skills.salvage.McMMOPlayerSalvageCheckEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.FishHook;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class EventUtils {
|
public class EventUtils {
|
||||||
public static McMMOPlayerAbilityActivateEvent callPlayerAbilityActivateEvent(Player player, SkillType skill) {
|
public static McMMOPlayerAbilityActivateEvent callPlayerAbilityActivateEvent(Player player, SkillType skill) {
|
||||||
@@ -98,7 +97,7 @@ public class EventUtils {
|
|||||||
callFakeArmSwingEvent(player);
|
callFakeArmSwingEvent(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
FakeBlockDamageEvent damageEvent = new FakeBlockDamageEvent(player, block, player.getItemInHand(), true);
|
FakeBlockDamageEvent damageEvent = new FakeBlockDamageEvent(player, block, player.getInventory().getItemInMainHand(), true);
|
||||||
pluginManager.callEvent(damageEvent);
|
pluginManager.callEvent(damageEvent);
|
||||||
|
|
||||||
FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player);
|
FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player);
|
||||||
@@ -253,7 +252,7 @@ public class EventUtils {
|
|||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FakePlayerFishEvent callFakeFishEvent(Player player, Fish hook) {
|
public static FakePlayerFishEvent callFakeFishEvent(Player player, FishHook hook) {
|
||||||
FakePlayerFishEvent event = new FakePlayerFishEvent(player, null, hook, PlayerFishEvent.State.FISHING);
|
FakePlayerFishEvent event = new FakePlayerFishEvent(player, null, hook, PlayerFishEvent.State.FISHING);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
@@ -281,25 +280,10 @@ public class EventUtils {
|
|||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static McMMOPlayerSalvageCheckEvent callSalvageCheckEvent(Player player, ItemStack salvageMaterial, ItemStack salvageResults, ItemStack enchantedBook) {
|
||||||
* There is a bug in CraftBukkit that causes piston events to
|
McMMOPlayerSalvageCheckEvent event = new McMMOPlayerSalvageCheckEvent(player, salvageMaterial, salvageResults, enchantedBook);
|
||||||
* fire multiple times. Check this method to see if the piston event
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
* should be processed.
|
|
||||||
*
|
|
||||||
* @param block Block object of the piston block
|
|
||||||
* @param isExtendEvent should be true when called from BlockPistonExtendEvent
|
|
||||||
*
|
|
||||||
* @return true if the PistonEvent should be processed, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean shouldProcessEvent(Block block, boolean isExtendEvent) {
|
|
||||||
String pistonAction = isExtendEvent ? "EXTEND" : "RETRACT";
|
|
||||||
String lastAction = block.hasMetadata(mcMMO.pistonDataKey) ? block.getMetadata(mcMMO.pistonDataKey).get(0).asString() : "";
|
|
||||||
|
|
||||||
if (!lastAction.equals(pistonAction)) {
|
return event;
|
||||||
block.setMetadata(mcMMO.pistonDataKey, new FixedMetadataValue(mcMMO.p, pistonAction));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,13 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import com.gmail.nossr50.commands.skills.AprilCommand;
|
||||||
import java.io.BufferedWriter;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import java.io.File;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import java.io.FileReader;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import java.io.FileWriter;
|
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||||
import java.io.IOException;
|
import com.google.common.collect.ImmutableList;
|
||||||
import java.util.ArrayList;
|
import org.bukkit.*;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Color;
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.FireworkEffect;
|
|
||||||
import org.bukkit.FireworkEffect.Type;
|
import org.bukkit.FireworkEffect.Type;
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.Statistic;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@@ -31,13 +16,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.player.PlayerStatisticIncrementEvent;
|
import org.bukkit.event.player.PlayerStatisticIncrementEvent;
|
||||||
import org.bukkit.inventory.meta.FireworkMeta;
|
import org.bukkit.inventory.meta.FireworkMeta;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import java.io.*;
|
||||||
import com.gmail.nossr50.commands.skills.AprilCommand;
|
import java.util.*;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import java.util.regex.Pattern;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
|
||||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
public final class HolidayManager {
|
public final class HolidayManager {
|
||||||
private ArrayList<String> hasCelebrated;
|
private ArrayList<String> hasCelebrated;
|
||||||
@@ -95,7 +76,7 @@ public final class HolidayManager {
|
|||||||
return FakeSkillType.CLIMBING;
|
return FakeSkillType.CLIMBING;
|
||||||
case FLY_ONE_CM:
|
case FLY_ONE_CM:
|
||||||
return FakeSkillType.FLYING;
|
return FakeSkillType.FLYING;
|
||||||
case DIVE_ONE_CM:
|
case WALK_UNDER_WATER_ONE_CM:
|
||||||
return FakeSkillType.DIVING;
|
return FakeSkillType.DIVING;
|
||||||
case PIG_ONE_CM:
|
case PIG_ONE_CM:
|
||||||
return FakeSkillType.PIGGY;
|
return FakeSkillType.PIGGY;
|
||||||
@@ -107,7 +88,7 @@ public final class HolidayManager {
|
|||||||
|
|
||||||
public final Set<Statistic> movementStatistics = EnumSet.of(
|
public final Set<Statistic> movementStatistics = EnumSet.of(
|
||||||
Statistic.WALK_ONE_CM, Statistic.SWIM_ONE_CM, Statistic.FALL_ONE_CM,
|
Statistic.WALK_ONE_CM, Statistic.SWIM_ONE_CM, Statistic.FALL_ONE_CM,
|
||||||
Statistic.CLIMB_ONE_CM, Statistic.FLY_ONE_CM, Statistic.DIVE_ONE_CM,
|
Statistic.CLIMB_ONE_CM, Statistic.FLY_ONE_CM, Statistic.WALK_UNDER_WATER_ONE_CM,
|
||||||
Statistic.PIG_ONE_CM);
|
Statistic.PIG_ONE_CM);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -376,7 +357,7 @@ public final class HolidayManager {
|
|||||||
|
|
||||||
public void levelUpApril(Player player, FakeSkillType fakeSkillType) {
|
public void levelUpApril(Player player, FakeSkillType fakeSkillType) {
|
||||||
int levelTotal = Misc.getRandom().nextInt(1 + UserManager.getPlayer(player).getSkillLevel(SkillType.MINING)) + 1;
|
int levelTotal = Misc.getRandom().nextInt(1 + UserManager.getPlayer(player).getSkillLevel(SkillType.MINING)) + 1;
|
||||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
|
||||||
player.sendMessage(ChatColor.YELLOW + StringUtils.getCapitalized(fakeSkillType.toString()) + " skill increased by 1. Total (" + levelTotal + ")");
|
player.sendMessage(ChatColor.YELLOW + StringUtils.getCapitalized(fakeSkillType.toString()) + " skill increased by 1. Total (" + levelTotal + ")");
|
||||||
ParticleEffectUtils.fireworkParticleShower(player, ALL_COLORS.get(Misc.getRandom().nextInt(ALL_COLORS.size())));
|
ParticleEffectUtils.fireworkParticleShower(player, ALL_COLORS.get(Misc.getRandom().nextInt(ALL_COLORS.size())));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,15 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.CoalType;
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.FurnaceRecipe;
|
import org.bukkit.inventory.FurnaceRecipe;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.Recipe;
|
import org.bukkit.inventory.Recipe;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.material.Coal;
|
|
||||||
import org.bukkit.material.Dye;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
|
|
||||||
public final class ItemUtils {
|
public final class ItemUtils {
|
||||||
private ItemUtils() {}
|
private ItemUtils() {}
|
||||||
@@ -47,10 +43,10 @@ public final class ItemUtils {
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DIAMOND_SWORD:
|
case DIAMOND_SWORD:
|
||||||
case GOLD_SWORD:
|
case GOLDEN_SWORD:
|
||||||
case IRON_SWORD:
|
case IRON_SWORD:
|
||||||
case STONE_SWORD:
|
case STONE_SWORD:
|
||||||
case WOOD_SWORD:
|
case WOODEN_SWORD:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -69,10 +65,10 @@ public final class ItemUtils {
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DIAMOND_HOE:
|
case DIAMOND_HOE:
|
||||||
case GOLD_HOE:
|
case GOLDEN_HOE:
|
||||||
case IRON_HOE:
|
case IRON_HOE:
|
||||||
case STONE_HOE:
|
case STONE_HOE:
|
||||||
case WOOD_HOE:
|
case WOODEN_HOE:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -90,11 +86,11 @@ public final class ItemUtils {
|
|||||||
Material type = item.getType();
|
Material type = item.getType();
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DIAMOND_SPADE:
|
case DIAMOND_SHOVEL:
|
||||||
case GOLD_SPADE:
|
case GOLDEN_SHOVEL:
|
||||||
case IRON_SPADE:
|
case IRON_SHOVEL:
|
||||||
case STONE_SPADE:
|
case STONE_SHOVEL:
|
||||||
case WOOD_SPADE:
|
case WOODEN_SHOVEL:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -113,10 +109,10 @@ public final class ItemUtils {
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DIAMOND_AXE:
|
case DIAMOND_AXE:
|
||||||
case GOLD_AXE:
|
case GOLDEN_AXE:
|
||||||
case IRON_AXE:
|
case IRON_AXE:
|
||||||
case STONE_AXE:
|
case STONE_AXE:
|
||||||
case WOOD_AXE:
|
case WOODEN_AXE:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -135,10 +131,10 @@ public final class ItemUtils {
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DIAMOND_PICKAXE:
|
case DIAMOND_PICKAXE:
|
||||||
case GOLD_PICKAXE:
|
case GOLDEN_PICKAXE:
|
||||||
case IRON_PICKAXE:
|
case IRON_PICKAXE:
|
||||||
case STONE_PICKAXE:
|
case STONE_PICKAXE:
|
||||||
case WOOD_PICKAXE:
|
case WOODEN_PICKAXE:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -146,6 +142,20 @@ public final class ItemUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the item counts as unarmed.
|
||||||
|
*
|
||||||
|
* @param item Item to check
|
||||||
|
* @return true if the item counts as unarmed, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean isUnarmed(ItemStack item) {
|
||||||
|
if (Config.getInstance().getUnarmedItemsAsUnarmed()) {
|
||||||
|
return !isMinecraftTool(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return item.getType() == Material.AIR;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the item is a helmet.
|
* Checks if the item is a helmet.
|
||||||
*
|
*
|
||||||
@@ -157,7 +167,7 @@ public final class ItemUtils {
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DIAMOND_HELMET:
|
case DIAMOND_HELMET:
|
||||||
case GOLD_HELMET:
|
case GOLDEN_HELMET:
|
||||||
case IRON_HELMET:
|
case IRON_HELMET:
|
||||||
case CHAINMAIL_HELMET:
|
case CHAINMAIL_HELMET:
|
||||||
case LEATHER_HELMET:
|
case LEATHER_HELMET:
|
||||||
@@ -179,7 +189,7 @@ public final class ItemUtils {
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DIAMOND_CHESTPLATE:
|
case DIAMOND_CHESTPLATE:
|
||||||
case GOLD_CHESTPLATE:
|
case GOLDEN_CHESTPLATE:
|
||||||
case IRON_CHESTPLATE:
|
case IRON_CHESTPLATE:
|
||||||
case CHAINMAIL_CHESTPLATE:
|
case CHAINMAIL_CHESTPLATE:
|
||||||
case LEATHER_CHESTPLATE:
|
case LEATHER_CHESTPLATE:
|
||||||
@@ -201,7 +211,7 @@ public final class ItemUtils {
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DIAMOND_LEGGINGS:
|
case DIAMOND_LEGGINGS:
|
||||||
case GOLD_LEGGINGS:
|
case GOLDEN_LEGGINGS:
|
||||||
case IRON_LEGGINGS:
|
case IRON_LEGGINGS:
|
||||||
case CHAINMAIL_LEGGINGS:
|
case CHAINMAIL_LEGGINGS:
|
||||||
case LEATHER_LEGGINGS:
|
case LEATHER_LEGGINGS:
|
||||||
@@ -223,7 +233,7 @@ public final class ItemUtils {
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DIAMOND_BOOTS:
|
case DIAMOND_BOOTS:
|
||||||
case GOLD_BOOTS:
|
case GOLDEN_BOOTS:
|
||||||
case IRON_BOOTS:
|
case IRON_BOOTS:
|
||||||
case CHAINMAIL_BOOTS:
|
case CHAINMAIL_BOOTS:
|
||||||
case LEATHER_BOOTS:
|
case LEATHER_BOOTS:
|
||||||
@@ -281,10 +291,10 @@ public final class ItemUtils {
|
|||||||
*/
|
*/
|
||||||
public static boolean isGoldArmor(ItemStack item) {
|
public static boolean isGoldArmor(ItemStack item) {
|
||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
case GOLD_BOOTS:
|
case GOLDEN_BOOTS:
|
||||||
case GOLD_CHESTPLATE:
|
case GOLDEN_CHESTPLATE:
|
||||||
case GOLD_HELMET:
|
case GOLDEN_HELMET:
|
||||||
case GOLD_LEGGINGS:
|
case GOLDEN_LEGGINGS:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -370,7 +380,7 @@ public final class ItemUtils {
|
|||||||
case STONE_AXE:
|
case STONE_AXE:
|
||||||
case STONE_HOE:
|
case STONE_HOE:
|
||||||
case STONE_PICKAXE:
|
case STONE_PICKAXE:
|
||||||
case STONE_SPADE:
|
case STONE_SHOVEL:
|
||||||
case STONE_SWORD:
|
case STONE_SWORD:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -387,11 +397,11 @@ public final class ItemUtils {
|
|||||||
*/
|
*/
|
||||||
public static boolean isWoodTool(ItemStack item) {
|
public static boolean isWoodTool(ItemStack item) {
|
||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
case WOOD_AXE:
|
case WOODEN_AXE:
|
||||||
case WOOD_HOE:
|
case WOODEN_HOE:
|
||||||
case WOOD_PICKAXE:
|
case WOODEN_PICKAXE:
|
||||||
case WOOD_SPADE:
|
case WOODEN_SHOVEL:
|
||||||
case WOOD_SWORD:
|
case WOODEN_SWORD:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -408,7 +418,7 @@ public final class ItemUtils {
|
|||||||
public static boolean isStringTool(ItemStack item) {
|
public static boolean isStringTool(ItemStack item) {
|
||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
case BOW:
|
case BOW:
|
||||||
case CARROT_STICK:
|
case CARROT_ON_A_STICK:
|
||||||
case FISHING_ROD:
|
case FISHING_ROD:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -425,11 +435,11 @@ public final class ItemUtils {
|
|||||||
*/
|
*/
|
||||||
public static boolean isGoldTool(ItemStack item) {
|
public static boolean isGoldTool(ItemStack item) {
|
||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
case GOLD_AXE:
|
case GOLDEN_AXE:
|
||||||
case GOLD_HOE:
|
case GOLDEN_HOE:
|
||||||
case GOLD_PICKAXE:
|
case GOLDEN_PICKAXE:
|
||||||
case GOLD_SPADE:
|
case GOLDEN_SHOVEL:
|
||||||
case GOLD_SWORD:
|
case GOLDEN_SWORD:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -450,7 +460,7 @@ public final class ItemUtils {
|
|||||||
case IRON_AXE:
|
case IRON_AXE:
|
||||||
case IRON_HOE:
|
case IRON_HOE:
|
||||||
case IRON_PICKAXE:
|
case IRON_PICKAXE:
|
||||||
case IRON_SPADE:
|
case IRON_SHOVEL:
|
||||||
case IRON_SWORD:
|
case IRON_SWORD:
|
||||||
case SHEARS:
|
case SHEARS:
|
||||||
return true;
|
return true;
|
||||||
@@ -471,7 +481,7 @@ public final class ItemUtils {
|
|||||||
case DIAMOND_AXE:
|
case DIAMOND_AXE:
|
||||||
case DIAMOND_HOE:
|
case DIAMOND_HOE:
|
||||||
case DIAMOND_PICKAXE:
|
case DIAMOND_PICKAXE:
|
||||||
case DIAMOND_SPADE:
|
case DIAMOND_SHOVEL:
|
||||||
case DIAMOND_SWORD:
|
case DIAMOND_SWORD:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -488,10 +498,12 @@ public final class ItemUtils {
|
|||||||
*/
|
*/
|
||||||
public static boolean isEnchantable(ItemStack item) {
|
public static boolean isEnchantable(ItemStack item) {
|
||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
|
case ENCHANTED_BOOK:
|
||||||
case SHEARS:
|
case SHEARS:
|
||||||
case FISHING_ROD:
|
case FISHING_ROD:
|
||||||
case CARROT_STICK:
|
case CARROT_ON_A_STICK:
|
||||||
case FLINT_AND_STEEL:
|
case FLINT_AND_STEEL:
|
||||||
|
case TRIDENT:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -500,7 +512,7 @@ public final class ItemUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSmeltable(ItemStack item) {
|
public static boolean isSmeltable(ItemStack item) {
|
||||||
return item != null && MaterialUtils.isOre(item.getData());
|
return item != null && item.getType().isBlock() && MaterialUtils.isOre(item.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSmelted(ItemStack item) {
|
public static boolean isSmelted(ItemStack item) {
|
||||||
@@ -509,8 +521,8 @@ public final class ItemUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Recipe recipe : mcMMO.p.getServer().getRecipesFor(item)) {
|
for (Recipe recipe : mcMMO.p.getServer().getRecipesFor(item)) {
|
||||||
if (recipe instanceof FurnaceRecipe) {
|
if (recipe instanceof FurnaceRecipe && ((FurnaceRecipe) recipe).getInput().getType().isBlock() && MaterialUtils.isOre(((FurnaceRecipe) recipe).getInput().getType())) {
|
||||||
return MaterialUtils.isOre(((FurnaceRecipe) recipe).getInput().getData());
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,12 +564,10 @@ public final class ItemUtils {
|
|||||||
case REDSTONE:
|
case REDSTONE:
|
||||||
case GLOWSTONE_DUST: // Should we also have Glowstone here?
|
case GLOWSTONE_DUST: // Should we also have Glowstone here?
|
||||||
case QUARTZ:
|
case QUARTZ:
|
||||||
case QUARTZ_ORE:
|
case NETHER_QUARTZ_ORE:
|
||||||
|
case LAPIS_LAZULI:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case INK_SACK:
|
|
||||||
return ((Dye) item.getData()).getColor() == DyeColor.BLUE;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -572,29 +582,30 @@ public final class ItemUtils {
|
|||||||
public static boolean isHerbalismDrop(ItemStack item) {
|
public static boolean isHerbalismDrop(ItemStack item) {
|
||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
case WHEAT:
|
case WHEAT:
|
||||||
case SEEDS:
|
case WHEAT_SEEDS:
|
||||||
case CARROT_ITEM:
|
case CARROT:
|
||||||
case POTATO_ITEM:
|
case CHORUS_FRUIT:
|
||||||
case NETHER_WARTS:
|
case CHORUS_FLOWER:
|
||||||
|
case POTATO:
|
||||||
|
case BEETROOT:
|
||||||
|
case BEETROOT_SEEDS:
|
||||||
|
case NETHER_WART:
|
||||||
case BROWN_MUSHROOM:
|
case BROWN_MUSHROOM:
|
||||||
case RED_MUSHROOM:
|
case RED_MUSHROOM:
|
||||||
case RED_ROSE:
|
case ROSE_RED:
|
||||||
case YELLOW_FLOWER:
|
case DANDELION_YELLOW:
|
||||||
case CACTUS:
|
case CACTUS:
|
||||||
case SUGAR_CANE:
|
case SUGAR_CANE:
|
||||||
case MELON:
|
case MELON:
|
||||||
case MELON_SEEDS:
|
case MELON_SEEDS:
|
||||||
case PUMPKIN:
|
case PUMPKIN:
|
||||||
case PUMPKIN_SEEDS:
|
case PUMPKIN_SEEDS:
|
||||||
case WATER_LILY:
|
case LILY_PAD:
|
||||||
case VINE:
|
case VINE:
|
||||||
case LONG_GRASS:
|
case TALL_GRASS:
|
||||||
case DOUBLE_PLANT:
|
case COCOA_BEANS:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case INK_SACK:
|
|
||||||
return ((Dye) item.getData()).getColor() == DyeColor.BROWN;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -610,19 +621,34 @@ public final class ItemUtils {
|
|||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
case STRING:
|
case STRING:
|
||||||
case FEATHER:
|
case FEATHER:
|
||||||
case RAW_CHICKEN:
|
case CHICKEN:
|
||||||
case COOKED_CHICKEN:
|
case COOKED_CHICKEN:
|
||||||
case LEATHER:
|
case LEATHER:
|
||||||
case RAW_BEEF:
|
case BEEF:
|
||||||
case COOKED_BEEF:
|
case COOKED_BEEF:
|
||||||
case PORK:
|
case PORKCHOP:
|
||||||
case GRILLED_PORK:
|
case COOKED_PORKCHOP:
|
||||||
case WOOL:
|
case WHITE_WOOL:
|
||||||
|
case BLACK_WOOL:
|
||||||
|
case BLUE_WOOL:
|
||||||
|
case BROWN_WOOL:
|
||||||
|
case CYAN_WOOL:
|
||||||
|
case GRAY_WOOL:
|
||||||
|
case GREEN_WOOL:
|
||||||
|
case LIGHT_BLUE_WOOL:
|
||||||
|
case LIGHT_GRAY_WOOL:
|
||||||
|
case LIME_WOOL:
|
||||||
|
case MAGENTA_WOOL:
|
||||||
|
case ORANGE_WOOL:
|
||||||
|
case PINK_WOOL:
|
||||||
|
case PURPLE_WOOL:
|
||||||
|
case RED_WOOL:
|
||||||
|
case YELLOW_WOOL:
|
||||||
case IRON_INGOT:
|
case IRON_INGOT:
|
||||||
case SNOW_BALL:
|
case SNOWBALL:
|
||||||
case BLAZE_ROD:
|
case BLAZE_ROD:
|
||||||
case SPIDER_EYE:
|
case SPIDER_EYE:
|
||||||
case SULPHUR:
|
case GUNPOWDER:
|
||||||
case ENDER_PEARL:
|
case ENDER_PEARL:
|
||||||
case GHAST_TEAR:
|
case GHAST_TEAR:
|
||||||
case MAGMA_CREAM:
|
case MAGMA_CREAM:
|
||||||
@@ -633,14 +659,10 @@ public final class ItemUtils {
|
|||||||
case ROTTEN_FLESH:
|
case ROTTEN_FLESH:
|
||||||
case GOLD_NUGGET:
|
case GOLD_NUGGET:
|
||||||
case EGG:
|
case EGG:
|
||||||
|
case ROSE_RED:
|
||||||
|
case COAL:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case COAL: // Not sure we should include this, as it will also trigger when mining
|
|
||||||
return (((Coal) item.getData()).getType() == CoalType.COAL);
|
|
||||||
|
|
||||||
case RED_ROSE: // Not sure we should include this, as it will also trigger from herbalism
|
|
||||||
return (item.getData().getData() == 0x0);
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -654,11 +676,30 @@ public final class ItemUtils {
|
|||||||
*/
|
*/
|
||||||
public static boolean isWoodcuttingDrop(ItemStack item) {
|
public static boolean isWoodcuttingDrop(ItemStack item) {
|
||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
case LOG:
|
case ACACIA_LOG:
|
||||||
case LOG_2:
|
case BIRCH_LOG:
|
||||||
case LEAVES:
|
case DARK_OAK_LOG:
|
||||||
case LEAVES_2:
|
case JUNGLE_LOG:
|
||||||
case SAPLING:
|
case OAK_LOG:
|
||||||
|
case SPRUCE_LOG:
|
||||||
|
case STRIPPED_ACACIA_LOG:
|
||||||
|
case STRIPPED_BIRCH_LOG:
|
||||||
|
case STRIPPED_DARK_OAK_LOG:
|
||||||
|
case STRIPPED_JUNGLE_LOG:
|
||||||
|
case STRIPPED_OAK_LOG:
|
||||||
|
case STRIPPED_SPRUCE_LOG:
|
||||||
|
case ACACIA_SAPLING:
|
||||||
|
case SPRUCE_SAPLING:
|
||||||
|
case BIRCH_SAPLING:
|
||||||
|
case DARK_OAK_SAPLING:
|
||||||
|
case JUNGLE_SAPLING:
|
||||||
|
case OAK_SAPLING:
|
||||||
|
case ACACIA_LEAVES:
|
||||||
|
case BIRCH_LEAVES:
|
||||||
|
case DARK_OAK_LEAVES:
|
||||||
|
case JUNGLE_LEAVES:
|
||||||
|
case OAK_LEAVES:
|
||||||
|
case SPRUCE_LEAVES:
|
||||||
case APPLE:
|
case APPLE:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
import org.bukkit.material.MaterialData;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
public final class MaterialUtils {
|
public final class MaterialUtils {
|
||||||
private MaterialUtils() {}
|
private MaterialUtils() {}
|
||||||
|
|
||||||
protected static boolean isOre(MaterialData data) {
|
protected static boolean isOre(Material data) {
|
||||||
switch (data.getItemType()) {
|
switch (data) {
|
||||||
case COAL_ORE:
|
case COAL_ORE:
|
||||||
case DIAMOND_ORE:
|
case DIAMOND_ORE:
|
||||||
case GLOWING_REDSTONE_ORE:
|
case NETHER_QUARTZ_ORE:
|
||||||
case GOLD_ORE:
|
case GOLD_ORE:
|
||||||
case IRON_ORE:
|
case IRON_ORE:
|
||||||
case LAPIS_ORE:
|
case LAPIS_ORE:
|
||||||
case QUARTZ_ORE:
|
|
||||||
case REDSTONE_ORE:
|
case REDSTONE_ORE:
|
||||||
case EMERALD_ORE:
|
case EMERALD_ORE:
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.NPC;
|
import org.bukkit.entity.NPC;
|
||||||
@@ -13,6 +14,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
|
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
|
||||||
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
|
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@@ -30,14 +32,14 @@ public final class Misc {
|
|||||||
|
|
||||||
// Sound Pitches & Volumes from CB
|
// Sound Pitches & Volumes from CB
|
||||||
public static final float ANVIL_USE_PITCH = 0.3F; // Not in CB directly, I went off the place sound values
|
public static final float ANVIL_USE_PITCH = 0.3F; // Not in CB directly, I went off the place sound values
|
||||||
public static final float ANVIL_USE_VOLUME = 1.0F; // Not in CB directly, I went off the place sound values
|
public static final float ANVIL_USE_VOLUME = 1.0F * Config.getInstance().getMasterVolume(); // Not in CB directly, I went off the place sound values
|
||||||
public static final float FIZZ_VOLUME = 0.5F;
|
public static final float FIZZ_VOLUME = 0.5F * Config.getInstance().getMasterVolume();
|
||||||
public static final float POP_VOLUME = 0.2F;
|
public static final float POP_VOLUME = 0.2F * Config.getInstance().getMasterVolume();
|
||||||
public static final float BAT_VOLUME = 1.0F;
|
public static final float BAT_VOLUME = 1.0F * Config.getInstance().getMasterVolume();
|
||||||
public static final float BAT_PITCH = 0.6F;
|
public static final float BAT_PITCH = 0.6F;
|
||||||
public static final float GHAST_VOLUME = 1.0F;
|
public static final float GHAST_VOLUME = 1.0F * Config.getInstance().getMasterVolume();
|
||||||
public static final float LEVELUP_PITCH = 0.5F; // Reduced to differentiate between vanilla level-up
|
public static final float LEVELUP_PITCH = 0.5F; // Reduced to differentiate between vanilla level-up
|
||||||
public static final float LEVELUP_VOLUME = 0.75F; // Use max volume always
|
public static final float LEVELUP_VOLUME = 0.75F * Config.getInstance().getMasterVolume(); // Use max volume always
|
||||||
|
|
||||||
public static final Set<String> modNames = ImmutableSet.of("LOTR", "BUILDCRAFT", "ENDERIO", "ENHANCEDBIOMES", "IC2", "METALLURGY", "FORESTRY", "GALACTICRAFT", "RAILCRAFT", "TWILIGHTFOREST", "THAUMCRAFT", "GRAVESTONEMOD", "GROWTHCRAFT", "ARCTICMOBS", "DEMONMOBS", "INFERNOMOBS", "SWAMPMOBS", "MARICULTURE", "MINESTRAPPOLATION");
|
public static final Set<String> modNames = ImmutableSet.of("LOTR", "BUILDCRAFT", "ENDERIO", "ENHANCEDBIOMES", "IC2", "METALLURGY", "FORESTRY", "GALACTICRAFT", "RAILCRAFT", "TWILIGHTFOREST", "THAUMCRAFT", "GRAVESTONEMOD", "GROWTHCRAFT", "ARCTICMOBS", "DEMONMOBS", "INFERNOMOBS", "SWAMPMOBS", "MARICULTURE", "MINESTRAPPOLATION");
|
||||||
|
|
||||||
@@ -71,6 +73,16 @@ public final class Misc {
|
|||||||
return (first.getWorld() == second.getWorld()) && (first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0);
|
return (first.getWorld() == second.getWorld()) && (first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the center of the given block.
|
||||||
|
*
|
||||||
|
* @param blockState The {@link BlockState} of the block
|
||||||
|
* @return A {@link Location} lying at the center of the block
|
||||||
|
*/
|
||||||
|
public static Location getBlockCenter(BlockState blockState) {
|
||||||
|
return blockState.getLocation().add(0.5, 0.5, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
public static void dropItems(Location location, Collection<ItemStack> drops) {
|
public static void dropItems(Location location, Collection<ItemStack> drops) {
|
||||||
for (ItemStack drop : drops) {
|
for (ItemStack drop : drops) {
|
||||||
dropItem(location, drop);
|
dropItem(location, drop);
|
||||||
@@ -110,7 +122,7 @@ public final class Misc {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return location.getWorld().dropItemNaturally(location, itemStack);
|
return location.getWorld().dropItem(location, itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void profileCleanup(String playerName) {
|
public static void profileCleanup(String playerName) {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user