mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 09:43:00 +01:00
Compare commits
425 Commits
1.4.00-bet
...
1.4.06-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c87ce06eb | ||
|
|
875091a1ce | ||
|
|
5ad7716137 | ||
|
|
8c97399cec | ||
|
|
27e0a9d3b6 | ||
|
|
07f9b287e7 | ||
|
|
fbee4f1b37 | ||
|
|
26542f3d6e | ||
|
|
14630fe956 | ||
|
|
30f5c761d9 | ||
|
|
365abaaa8f | ||
|
|
f4681a282c | ||
|
|
8a14d9ac26 | ||
|
|
0ab1986202 | ||
|
|
e11dc680de | ||
|
|
71249334c3 | ||
|
|
fa41dbce16 | ||
|
|
4246e6c900 | ||
|
|
1b421a24b0 | ||
|
|
9cc9eead52 | ||
|
|
8b21aea9c7 | ||
|
|
4f87cb6446 | ||
|
|
7525de1a72 | ||
|
|
78d2fa7520 | ||
|
|
7fe8122499 | ||
|
|
532c2e7450 | ||
|
|
b391a53c6b | ||
|
|
f3c6346b95 | ||
|
|
dd8984314f | ||
|
|
b82c3f41d3 | ||
|
|
7d6eb65776 | ||
|
|
dc0800e7e1 | ||
|
|
c151366952 | ||
|
|
212137ec3e | ||
|
|
31f36935d3 | ||
|
|
a14fc3e3c9 | ||
|
|
158b3c43f8 | ||
|
|
e31c1e33d9 | ||
|
|
25dfa6d34d | ||
|
|
431429a29c | ||
|
|
d4c8cc28a1 | ||
|
|
ce08405c00 | ||
|
|
da29185b7d | ||
|
|
87feb8c250 | ||
|
|
12797893df | ||
|
|
6d47e43ba9 | ||
|
|
f6b1643378 | ||
|
|
f1c16df63b | ||
|
|
c16e5231f4 | ||
|
|
2365c253dd | ||
|
|
c4e7f2597e | ||
|
|
13fd522bd4 | ||
|
|
b74f6e92dc | ||
|
|
630c3e81e6 | ||
|
|
0f77cf8066 | ||
|
|
52746fca76 | ||
|
|
dae25c2f2d | ||
|
|
a272316301 | ||
|
|
6772f4f169 | ||
|
|
9463e210b8 | ||
|
|
4c44b72f78 | ||
|
|
c849f751bb | ||
|
|
1cde45599e | ||
|
|
f1a22f5f6b | ||
|
|
90d6fbde48 | ||
|
|
802ad84613 | ||
|
|
c4aa9396fd | ||
|
|
f0c937ad47 | ||
|
|
fcc36ee5d7 | ||
|
|
0f023f627c | ||
|
|
fa645b5e00 | ||
|
|
1fb28eeee0 | ||
|
|
d7f67d43b3 | ||
|
|
5a1ec745ce | ||
|
|
6fd599bd31 | ||
|
|
afd706bed8 | ||
|
|
6c3820c747 | ||
|
|
0ebc555136 | ||
|
|
4992c50098 | ||
|
|
4e9322485a | ||
|
|
fc8ad40b00 | ||
|
|
f62e053a84 | ||
|
|
0af3c7ab7d | ||
|
|
7f4efe1775 | ||
|
|
80a5c2f9c4 | ||
|
|
90e13c9562 | ||
|
|
fe89c19969 | ||
|
|
0b6dfad7e5 | ||
|
|
f2b1758439 | ||
|
|
86eaa3b091 | ||
|
|
24153c2fb1 | ||
|
|
5e36683ff2 | ||
|
|
c53563e7d1 | ||
|
|
d778293531 | ||
|
|
7d8888d47d | ||
|
|
6fbfec48b0 | ||
|
|
1f25b0b00b | ||
|
|
0118346aaf | ||
|
|
287842c675 | ||
|
|
61dc77559b | ||
|
|
ca51b2f70f | ||
|
|
3cf01cb6f3 | ||
|
|
16a4b78580 | ||
|
|
94b560ba01 | ||
|
|
3ae9956df9 | ||
|
|
78109eb499 | ||
|
|
da5238878d | ||
|
|
f9a823e4b0 | ||
|
|
eb20da021d | ||
|
|
596f2fa78a | ||
|
|
fa99ebb391 | ||
|
|
9b685be84e | ||
|
|
96f9d2a030 | ||
|
|
2b7178fb00 | ||
|
|
c47bf84493 | ||
|
|
8cf16d4a1c | ||
|
|
5b5b73cde0 | ||
|
|
9f55c25775 | ||
|
|
92c6a7bfcf | ||
|
|
145a47c890 | ||
|
|
70160468c0 | ||
|
|
9730cdb880 | ||
|
|
399bf8e3b9 | ||
|
|
c3a69c8c55 | ||
|
|
db2bf9ee51 | ||
|
|
255dece550 | ||
|
|
d004361836 | ||
|
|
5453b0511d | ||
|
|
42bc5065df | ||
|
|
b0d609e9a3 | ||
|
|
814ffbe800 | ||
|
|
e7ee23b871 | ||
|
|
c14ceab24d | ||
|
|
70e8e534fe | ||
|
|
c4504de1da | ||
|
|
685f901e09 | ||
|
|
d196710a87 | ||
|
|
050f97e088 | ||
|
|
c2fea660e7 | ||
|
|
b2cdf21de5 | ||
|
|
ed09d1b390 | ||
|
|
171026ba23 | ||
|
|
dafa690a09 | ||
|
|
4cd4223ee0 | ||
|
|
3ac5ac385d | ||
|
|
0ae5421d10 | ||
|
|
3f56c8e690 | ||
|
|
c14f3777c0 | ||
|
|
2838a52e0c | ||
|
|
dcfdfa0e62 | ||
|
|
23719ace47 | ||
|
|
33882983e9 | ||
|
|
5aecedc074 | ||
|
|
69bf17a619 | ||
|
|
0292d3eefb | ||
|
|
0cd3e4ed84 | ||
|
|
3a26194a71 | ||
|
|
1313e3fe4b | ||
|
|
b2f400f61a | ||
|
|
9aa676cee1 | ||
|
|
eabf0f7f82 | ||
|
|
d0171809ec | ||
|
|
410c946faf | ||
|
|
3a7d88db4f | ||
|
|
9eba2c683b | ||
|
|
8059636b62 | ||
|
|
d78a1efbf6 | ||
|
|
c0b4a33346 | ||
|
|
2cef6700c7 | ||
|
|
df67bd6720 | ||
|
|
655dcb1c9b | ||
|
|
ce32792668 | ||
|
|
4b384abc51 | ||
|
|
82bccd357b | ||
|
|
12709bcd7f | ||
|
|
0b53f8266a | ||
|
|
a07f14e326 | ||
|
|
3349e9cb05 | ||
|
|
0e2746622d | ||
|
|
d9bd0ace9a | ||
|
|
e31b7d5c48 | ||
|
|
4bddbbf56e | ||
|
|
0654f27599 | ||
|
|
3f71dab0b1 | ||
|
|
bd45fff1b4 | ||
|
|
9618e45a11 | ||
|
|
3839373f5a | ||
|
|
1633617006 | ||
|
|
57e33bbf39 | ||
|
|
cddcf36016 | ||
|
|
dff03109a3 | ||
|
|
c0986a1f89 | ||
|
|
cd4c328320 | ||
|
|
03d0ecd450 | ||
|
|
3a809dab32 | ||
|
|
ade9e20cdd | ||
|
|
29520dc95c | ||
|
|
d40d89f29a | ||
|
|
9377de930f | ||
|
|
3219674678 | ||
|
|
a9438ed52b | ||
|
|
09169bd019 | ||
|
|
c30fdef615 | ||
|
|
109e9725a9 | ||
|
|
44ede5c3f8 | ||
|
|
c1161da6de | ||
|
|
80927417f2 | ||
|
|
91d8cd5da8 | ||
|
|
869d731b81 | ||
|
|
f6a18ef777 | ||
|
|
3e084b3b5d | ||
|
|
2c7f931c4d | ||
|
|
6b18cec7fb | ||
|
|
08960a2dbc | ||
|
|
5f4e269efa | ||
|
|
e5f6da01ec | ||
|
|
ae741a1b99 | ||
|
|
78a3ea4765 | ||
|
|
1a66ff7659 | ||
|
|
df53e2fd4f | ||
|
|
4210920c5f | ||
|
|
3440833af8 | ||
|
|
1e738263bc | ||
|
|
9cf322ca0b | ||
|
|
0c027ca697 | ||
|
|
27ed5f7c38 | ||
|
|
2f83e559a4 | ||
|
|
8b55744447 | ||
|
|
2f491b24e2 | ||
|
|
d2cb55befa | ||
|
|
e3e4cf9884 | ||
|
|
1b461ac96a | ||
|
|
1fc3c8fab2 | ||
|
|
7c28be5e62 | ||
|
|
cbe9cae4ea | ||
|
|
c0b7f8a323 | ||
|
|
f8b4412049 | ||
|
|
10e227a5ac | ||
|
|
077431630a | ||
|
|
37395a70e6 | ||
|
|
b779258d69 | ||
|
|
d3ec976f44 | ||
|
|
79a5732c4d | ||
|
|
12c6bfc2e8 | ||
|
|
31fff0623d | ||
|
|
0d2b87834c | ||
|
|
2feba8f64c | ||
|
|
cf82ae4c66 | ||
|
|
0d7c402c01 | ||
|
|
ae8b70be0f | ||
|
|
a87336b7ee | ||
|
|
7814fa8d46 | ||
|
|
a542d6cf3e | ||
|
|
13111a8d1b | ||
|
|
bbbba12e95 | ||
|
|
fbd016f86d | ||
|
|
10e7fe5560 | ||
|
|
d5bcb4346e | ||
|
|
213b4763e7 | ||
|
|
886515400d | ||
|
|
c900edb261 | ||
|
|
8fb8c67148 | ||
|
|
499411f6a2 | ||
|
|
c3eaec513b | ||
|
|
a7f858ab03 | ||
|
|
5ba4dc7b77 | ||
|
|
bbcc8f918e | ||
|
|
356c97cd67 | ||
|
|
0bdd5b219f | ||
|
|
90368d4ece | ||
|
|
ec12303834 | ||
|
|
294393bd1c | ||
|
|
4aaaf01ab5 | ||
|
|
cbbe436a69 | ||
|
|
18510ba851 | ||
|
|
0201ed332f | ||
|
|
e46ed07b94 | ||
|
|
3db6762531 | ||
|
|
f388948f04 | ||
|
|
4392e6b9ab | ||
|
|
38c3891533 | ||
|
|
a28d673eb7 | ||
|
|
55138f1599 | ||
|
|
0cd07cf2fd | ||
|
|
ae1eda915b | ||
|
|
38cd395171 | ||
|
|
3aec0e5ef4 | ||
|
|
56bd782625 | ||
|
|
d8904827ec | ||
|
|
f767edba93 | ||
|
|
07a0f43825 | ||
|
|
ec8581a835 | ||
|
|
f5290c3256 | ||
|
|
070189a7fd | ||
|
|
d409610a55 | ||
|
|
d46b134dbb | ||
|
|
5026bdcbd4 | ||
|
|
3607d0b9a1 | ||
|
|
21b8626366 | ||
|
|
4c10fdf34a | ||
|
|
8001a928ea | ||
|
|
26c2134484 | ||
|
|
2373ca82ba | ||
|
|
3bd9a30055 | ||
|
|
52467075b4 | ||
|
|
9888fe6e09 | ||
|
|
19068dee03 | ||
|
|
ca8204d8f4 | ||
|
|
35139815a6 | ||
|
|
da1e03cbfc | ||
|
|
219667965f | ||
|
|
ec8221610a | ||
|
|
afe28d54c6 | ||
|
|
1eb225cae1 | ||
|
|
e716e38386 | ||
|
|
1fe471b005 | ||
|
|
5cd542002e | ||
|
|
a485308fca | ||
|
|
9659ef65b9 | ||
|
|
214079a3cd | ||
|
|
e9dcb31002 | ||
|
|
3b05bb96e3 | ||
|
|
54ca6e78f5 | ||
|
|
9759224690 | ||
|
|
20970e430c | ||
|
|
38155e3af4 | ||
|
|
3036d4fa90 | ||
|
|
aba662e3d0 | ||
|
|
301914d94b | ||
|
|
8d16c06739 | ||
|
|
7e1eeb66d6 | ||
|
|
920bdde135 | ||
|
|
1db9a554dc | ||
|
|
62aaad8707 | ||
|
|
2fee9df625 | ||
|
|
6c6ab4c96e | ||
|
|
1d316f9420 | ||
|
|
d2035f1816 | ||
|
|
fd821139bd | ||
|
|
7e6550d147 | ||
|
|
e556b707c9 | ||
|
|
9282b7bd15 | ||
|
|
0d473d232e | ||
|
|
f9ad8ffe93 | ||
|
|
e85a0f6cfc | ||
|
|
63974f3968 | ||
|
|
3b07d4055a | ||
|
|
d052d7a3ce | ||
|
|
513a9212e4 | ||
|
|
84dce845a5 | ||
|
|
0a68b82078 | ||
|
|
3dc1afde7e | ||
|
|
e50eb1963f | ||
|
|
fdd6c0a0d8 | ||
|
|
c589c5556b | ||
|
|
17a85c94c6 | ||
|
|
4284fe1029 | ||
|
|
dec3c10ec1 | ||
|
|
c805a48a87 | ||
|
|
918d81198f | ||
|
|
1d87de0a3e | ||
|
|
fdeadde7f0 | ||
|
|
760432fb41 | ||
|
|
240589e9ea | ||
|
|
400c93fb7d | ||
|
|
1bcf43db63 | ||
|
|
79bcd76aa0 | ||
|
|
8833ceb3b5 | ||
|
|
ccc265edf9 | ||
|
|
b18a4da0d9 | ||
|
|
e956988c60 | ||
|
|
1b6d66d4b0 | ||
|
|
fd47d77800 | ||
|
|
5c76ef312f | ||
|
|
f189907ff8 | ||
|
|
6e32843fb4 | ||
|
|
a99d6eb9f8 | ||
|
|
bb37a5982e | ||
|
|
a43a5a0861 | ||
|
|
4ff1e79cc0 | ||
|
|
d28794a587 | ||
|
|
19292c8007 | ||
|
|
a67dd1d9d7 | ||
|
|
9c0f763949 | ||
|
|
6571864b16 | ||
|
|
701822c69f | ||
|
|
2eab93292e | ||
|
|
29fb8b83c2 | ||
|
|
ad68f50b14 | ||
|
|
519485f155 | ||
|
|
45fbb47ccf | ||
|
|
cf0f075acb | ||
|
|
d9aad67ca5 | ||
|
|
083a89c1a3 | ||
|
|
671be42472 | ||
|
|
add4bc24df | ||
|
|
1da1bb7218 | ||
|
|
d0d9527d39 | ||
|
|
c39827ed59 | ||
|
|
5d6a35d4ef | ||
|
|
0d62688343 | ||
|
|
80b7cc717f | ||
|
|
05a9c8b7e5 | ||
|
|
e78cbcfcc8 | ||
|
|
f7b1aea7e0 | ||
|
|
2744fb122c | ||
|
|
77638bf56a | ||
|
|
57e6e5400b | ||
|
|
f2b03896e2 | ||
|
|
8a795e6091 | ||
|
|
946513cb66 | ||
|
|
1fe182babe | ||
|
|
f61aed9f6c | ||
|
|
08882e58b6 | ||
|
|
4c6f2da78a | ||
|
|
3550310e5c | ||
|
|
cedd8da9ba | ||
|
|
3cb269de4b | ||
|
|
91010f2958 | ||
|
|
f3e823997b | ||
|
|
4ae276d1d7 | ||
|
|
f6b38ab32a | ||
|
|
6f96a5026b | ||
|
|
4071f259ad | ||
|
|
a9ed1a1850 |
4
.gitattributes
vendored
Normal file
4
.gitattributes
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
* text=auto
|
||||
|
||||
*.png binary
|
||||
*.wav binary
|
||||
82
.gitignore
vendored
82
.gitignore
vendored
@@ -1,42 +1,42 @@
|
||||
# Eclipse stuff
|
||||
/.classpath
|
||||
/.project
|
||||
/.settings
|
||||
|
||||
# netbeans
|
||||
/nbproject
|
||||
|
||||
# we use maven!
|
||||
/build.xml
|
||||
|
||||
# maven
|
||||
/target
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# various other potential build files
|
||||
/build
|
||||
/bin
|
||||
/dist
|
||||
/manifest.mf
|
||||
|
||||
/world
|
||||
|
||||
# Mac filesystem dust
|
||||
*.DS_Store
|
||||
|
||||
# intellij
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Project Stuff
|
||||
/src/main/resources/mcMMO
|
||||
|
||||
# Other Libraries
|
||||
*.jar
|
||||
|
||||
# Atlassian Stuff
|
||||
# Eclipse stuff
|
||||
/.classpath
|
||||
/.project
|
||||
/.settings
|
||||
|
||||
# netbeans
|
||||
/nbproject
|
||||
|
||||
# we use maven!
|
||||
/build.xml
|
||||
|
||||
# maven
|
||||
/target
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# various other potential build files
|
||||
/build
|
||||
/bin
|
||||
/dist
|
||||
/manifest.mf
|
||||
|
||||
/world
|
||||
|
||||
# Mac filesystem dust
|
||||
*.DS_Store
|
||||
|
||||
# intellij
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
|
||||
# Project Stuff
|
||||
/src/main/resources/mcMMO
|
||||
|
||||
# Other Libraries
|
||||
*.jar
|
||||
|
||||
# Atlassian Stuff
|
||||
/atlassian-ide-plugin.xml
|
||||
|
||||
3402
Changelog.txt
3402
Changelog.txt
File diff suppressed because it is too large
Load Diff
@@ -1,28 +0,0 @@
|
||||
== mcMMO
|
||||
**The RPG lovers mod**
|
||||
|
||||
=== Dev builds
|
||||
http://ci.mcmmo.info Download the latest dev build of mcMMO here.
|
||||
|
||||
=== Brief Description
|
||||
mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience.
|
||||
|
||||
If you want an original RPG experience like no other mod out there, mcMMO is for you.
|
||||
|
||||
=== About the Developer
|
||||
I've always wanted to make games and in the last year I decided to take a swing at developing Minecraft mods as a platform to teach myself programming, the biggest project I have made to date is mcMMO. I went from knowing nothing about Java to what I know now purely from modding Minecraft, and I plan to move onto game development in the not so distant future.
|
||||
|
||||
I take design very seriously, I am not the kind of person who can be satisfied giving a project anything less than my all. As you will see reflected in the quality of the mods I make, I take great care in my work.
|
||||
|
||||
Hearing that people enjoy mcMMO and seeing the daily youtube videos about my mod has become a joy, I really can't believe how popular my mod has gotten!
|
||||
|
||||
=== Compiling
|
||||
|
||||
Required Libraries:
|
||||
* Spout API
|
||||
* JUnit
|
||||
|
||||
Required to Run:
|
||||
* Bukkit
|
||||
|
||||
http://dev.bukkit.org/server-mods/mcmmo for more up to date information.
|
||||
47
README.md
Normal file
47
README.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# mcMMO
|
||||
## The RPG lovers mod
|
||||
|
||||
### Dev builds
|
||||
Our latest development builds are available [here](http://ci.mcmmo.info).
|
||||
|
||||
### Brief Description
|
||||
mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience.
|
||||
|
||||
If you want an original RPG experience like no other mod out there, mcMMO is for you.
|
||||
|
||||
## About the Team
|
||||
|
||||
mcMMO is currently developed by a team of individuals from all over the world.
|
||||
### Glorious Leader
|
||||
[]
|
||||
(https://github.com/gmcferrin)
|
||||
|
||||
### Developers
|
||||
[]
|
||||
(https://github.com/bm01)
|
||||
[]
|
||||
(https://github.com/Glitchfinder)
|
||||
[]
|
||||
(https://github.com/nossr50)
|
||||
[]
|
||||
(https://github.com/NuclearW)
|
||||
[]
|
||||
(https://github.com/shatteredbeam)
|
||||
[]
|
||||
(https://github.com/TfT-02)
|
||||
[]
|
||||
(https://github.com/t00thpick1)
|
||||
|
||||
## Compiling
|
||||
|
||||
mcMMO uses Maven 3 to manage dependancies, packaging, and shading of necessary classes; Maven 3 is required to compile mcMMO.
|
||||
|
||||
The typical command used to build mcMMO is: mvn clean package install
|
||||
|
||||
Required Libraries:
|
||||
* Spout API
|
||||
* JUnit
|
||||
* Metrics
|
||||
* Bukkit
|
||||
|
||||
http://dev.bukkit.org/server-mods/mcmmo for more up to date information.
|
||||
381
pom.xml
381
pom.xml
@@ -1,197 +1,184 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.4.00-beta3</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO/issues</url>
|
||||
<system>GitHub</system>
|
||||
</issueManagement>
|
||||
<build>
|
||||
<finalName>mcMMO</finalName>
|
||||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>.</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/</directory>
|
||||
<includes>
|
||||
<include>*.yml</include>
|
||||
<include>.jenkins</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>resources</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/xpbar/</directory>
|
||||
<includes>
|
||||
<include>xpbar*.png</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>resources</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/healthbar/</directory>
|
||||
<includes>
|
||||
<include>health*.png</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>resources</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/skillicon/</directory>
|
||||
<includes>
|
||||
<include>*.png</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>resources</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/sound/</directory>
|
||||
<includes>
|
||||
<include>*.wav</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>com/gmail/nossr50/locale</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/locale/</directory>
|
||||
<includes>
|
||||
<include>locale*.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<excludes>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/package.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.turt2live.metrics:MetricsExtension</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.turt2live.metrics</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.util.mcstats</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-file</artifactId>
|
||||
<version>2.2</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
<id>spout-repo</id>
|
||||
<url>http://nexus.spout.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
<checksumPolicy>fail</checksumPolicy>
|
||||
</snapshots>
|
||||
<id>Plugin MetricsExtension</id>
|
||||
<url>http://repo.turt2live.com</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>LATEST</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.getspout</groupId>
|
||||
<artifactId>spoutplugin</artifactId>
|
||||
<version>LATEST</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit-dep</artifactId>
|
||||
<version>4.10</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.turt2live.metrics</groupId>
|
||||
<artifactId>MetricsExtension</artifactId>
|
||||
<version>0.0.2-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>mcmmo-repo</id>
|
||||
<url>file:///var/lib/jenkins/repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.4.06-beta1</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO/issues</url>
|
||||
<system>GitHub</system>
|
||||
</issueManagement>
|
||||
<build>
|
||||
<finalName>mcMMO</finalName>
|
||||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>.</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/</directory>
|
||||
<includes>
|
||||
<include>*.yml</include>
|
||||
<include>.jenkins</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>resources</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/xpbar/</directory>
|
||||
<includes>
|
||||
<include>xpbar*.png</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>resources</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/healthbar/</directory>
|
||||
<includes>
|
||||
<include>health*.png</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>resources</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/skillicon/</directory>
|
||||
<includes>
|
||||
<include>*.png</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>resources</targetPath>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/resources/sound/</directory>
|
||||
<includes>
|
||||
<include>*.wav</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>com/gmail/nossr50/locale</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/locale/</directory>
|
||||
<includes>
|
||||
<include>locale*.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<excludes>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/package.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.turt2live.metrics:MetricsExtension</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.turt2live.metrics</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.metrics.mcstats</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-file</artifactId>
|
||||
<version>2.2</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spout-repo</id>
|
||||
<url>http://nexus.spout.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Plugin MetricsExtension</id>
|
||||
<url>http://repo.turt2live.com</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>LATEST</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.getspout</groupId>
|
||||
<artifactId>spoutplugin</artifactId>
|
||||
<version>LATEST</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit-dep</artifactId>
|
||||
<version>4.10</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.turt2live.metrics</groupId>
|
||||
<artifactId>MetricsExtension</artifactId>
|
||||
<version>0.0.4-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>mcmmo-repo</id>
|
||||
<url>file:///var/lib/jenkins/repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<ciManagement>
|
||||
<system>Jenkins</system>
|
||||
<url>ci.mcmmo.org</url>
|
||||
</ciManagement>
|
||||
</project>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<id>bin</id>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<files>
|
||||
<file>
|
||||
<source>${project.build.directory}/${artifactId}.jar</source>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<destName>mcMMO.jar</destName>
|
||||
</file>
|
||||
</files>
|
||||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<id>bin</id>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<files>
|
||||
<file>
|
||||
<source>${project.build.directory}/${artifactId}.jar</source>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<destName>mcMMO.jar</destName>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
||||
@@ -1,51 +1,51 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public final class AbilityAPI {
|
||||
private AbilityAPI() {}
|
||||
|
||||
public static boolean berserkEnabled(Player player) {
|
||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.BERSERK);
|
||||
}
|
||||
|
||||
public static boolean gigaDrillBreakerEnabled(Player player) {
|
||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.GIGA_DRILL_BREAKER);
|
||||
}
|
||||
|
||||
public static boolean greenTerraEnabled(Player player) {
|
||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.GREEN_TERRA);
|
||||
}
|
||||
|
||||
public static boolean serratedStrikesEnabled(Player player) {
|
||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.SERRATED_STRIKES);
|
||||
}
|
||||
|
||||
public static boolean skullSplitterEnabled(Player player) {
|
||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.SKULL_SPLIITER);
|
||||
}
|
||||
|
||||
public static boolean superBreakerEnabled(Player player) {
|
||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.SUPER_BREAKER);
|
||||
}
|
||||
|
||||
public static boolean treeFellerEnabled(Player player) {
|
||||
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.TREE_FELLER);
|
||||
}
|
||||
|
||||
public static boolean isAnyAbilityEnabled(Player player) {
|
||||
PlayerProfile profile = Users.getPlayer(player).getProfile();
|
||||
|
||||
for (AbilityType ability : AbilityType.values()) {
|
||||
if (profile.getAbilityMode(ability)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public final class AbilityAPI {
|
||||
private AbilityAPI() {}
|
||||
|
||||
public static boolean berserkEnabled(Player player) {
|
||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.BERSERK);
|
||||
}
|
||||
|
||||
public static boolean gigaDrillBreakerEnabled(Player player) {
|
||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.GIGA_DRILL_BREAKER);
|
||||
}
|
||||
|
||||
public static boolean greenTerraEnabled(Player player) {
|
||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.GREEN_TERRA);
|
||||
}
|
||||
|
||||
public static boolean serratedStrikesEnabled(Player player) {
|
||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.SERRATED_STRIKES);
|
||||
}
|
||||
|
||||
public static boolean skullSplitterEnabled(Player player) {
|
||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.SKULL_SPLITTER);
|
||||
}
|
||||
|
||||
public static boolean superBreakerEnabled(Player player) {
|
||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.SUPER_BREAKER);
|
||||
}
|
||||
|
||||
public static boolean treeFellerEnabled(Player player) {
|
||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.TREE_FELLER);
|
||||
}
|
||||
|
||||
public static boolean isAnyAbilityEnabled(Player player) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
for (AbilityType ability : AbilityType.values()) {
|
||||
if (mcMMOPlayer.getAbilityMode(ability)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public final class ChatAPI {
|
||||
private ChatAPI() {}
|
||||
@@ -39,22 +39,6 @@ public final class ChatAPI {
|
||||
ChatManager.handlePartyChat(plugin, PartyManager.getParty(party), sender, sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to all members of a party
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @deprecated Replaced by sendPartyChat(Plugin, String, String, String)
|
||||
*
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param party The name of the party to send to
|
||||
* @param message The message to send
|
||||
*/
|
||||
@Deprecated
|
||||
public static void sendPartyChat(String sender, String party, String message) {
|
||||
sendPartyChat(null, party, sender, sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to administrators
|
||||
* </br>
|
||||
@@ -82,21 +66,6 @@ public final class ChatAPI {
|
||||
ChatManager.handleAdminChat(plugin, sender, sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to administrators
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @deprecated Replaced by sendAdminChat(Plugin, String, String)
|
||||
*
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param message The message to send
|
||||
*/
|
||||
@Deprecated
|
||||
public static void sendAdminChat(String sender, String message) {
|
||||
sendAdminChat(null, sender, sender, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player is currently talking in party chat.
|
||||
*
|
||||
@@ -104,7 +73,7 @@ public final class ChatAPI {
|
||||
* @return true if the player is using party chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingPartyChat(Player player) {
|
||||
return Users.getPlayer(player).getPartyChatMode();
|
||||
return isUsingPartyChat(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,7 +83,7 @@ public final class ChatAPI {
|
||||
* @return true if the player is using party chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingPartyChat(String playerName) {
|
||||
return Users.getPlayer(playerName).getPartyChatMode();
|
||||
return UserManager.getPlayer(playerName).getPartyChatMode();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +93,7 @@ public final class ChatAPI {
|
||||
* @return true if the player is using admin chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingAdminChat(Player player) {
|
||||
return Users.getPlayer(player).getAdminChatMode();
|
||||
return isUsingAdminChat(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,6 +103,42 @@ public final class ChatAPI {
|
||||
* @return true if the player is using admin chat, false otherwise
|
||||
*/
|
||||
public static boolean isUsingAdminChat(String playerName) {
|
||||
return Users.getPlayer(playerName).getAdminChatMode();
|
||||
return UserManager.getPlayer(playerName).getAdminChatMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the party chat mode of a player.
|
||||
*
|
||||
* @param player The player to toggle party chat on.
|
||||
*/
|
||||
public static void togglePartyChat(Player player) {
|
||||
togglePartyChat(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the party chat mode of a player.
|
||||
*
|
||||
* @param playerName The name of the player to toggle party chat on.
|
||||
*/
|
||||
public static void togglePartyChat(String playerName) {
|
||||
UserManager.getPlayer(playerName).setPartyChat(!isUsingPartyChat(playerName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the admin chat mode of a player.
|
||||
*
|
||||
* @param player The player to toggle admin chat on.
|
||||
*/
|
||||
public static void toggleAdminChat(Player player) {
|
||||
toggleAdminChat(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the admin chat mode of a player.
|
||||
*
|
||||
* @param playerName The name of the player to toggle party chat on.
|
||||
*/
|
||||
public static void toggleAdminChat(String playerName){
|
||||
UserManager.getPlayer(playerName).setAdminChat(!isUsingAdminChat(playerName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,335 +1,584 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public final class ExperienceAPI {
|
||||
private ExperienceAPI() {}
|
||||
|
||||
/**
|
||||
* Check the XP of a player. This should be called after giving XP to process level-ups.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @param skillType The skill to check
|
||||
* @deprecated Calling this function is no longer needed and should be avoided
|
||||
*/
|
||||
@Deprecated
|
||||
private static void checkXP(Player player, SkillType skillType) {
|
||||
SkillTools.xpCheckSkill(skillType, player, Users.getProfile(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds raw XP to the player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @deprecated Use {@link #addRawXP(Player, String, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void addRawXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getPlayer(player).applyXpGain(skillType, XP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds raw XP to the player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public static void addRawXP(Player player, String skillType, int XP) {
|
||||
Users.getPlayer(player).applyXpGain(SkillType.getSkill(skillType), XP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, calculates for XP Rate only.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @deprecated Use {@link #addMultipliedXP(Player, String, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void addMultipliedXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getPlayer(player).applyXpGain(skillType, (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, calculates for XP Rate only.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public static void addMultipliedXP(Player player, String skillType, int XP) {
|
||||
Users.getPlayer(player).applyXpGain(SkillType.getSkill(skillType), (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, calculates for XP Rate, skill modifiers and perks. May be shared with the party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
* @deprecated Use {@link #addXP(Player, String, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void addXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getPlayer(player).beginXpGain(skillType, XP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, calculates for XP Rate, skill modifiers and perks. May be shared with the party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public static void addXP(Player player, String skillType, int XP) {
|
||||
Users.getPlayer(player).beginXpGain(SkillType.getSkill(skillType), XP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of XP a player has in a specific skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
* @return the amount of XP in a given skill
|
||||
* @deprecated Use {@link #getXP(Player, String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static int getXP(Player player, SkillType skillType) {
|
||||
return Users.getPlayer(player).getProfile().getSkillXpLevel(skillType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of XP a player has in a specific skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
* @return the amount of XP in a given skill
|
||||
*/
|
||||
public static int getXP(Player player, String skillType) {
|
||||
return Users.getPlayer(player).getProfile().getSkillXpLevel(SkillType.getSkill(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of XP left before leveling up.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the XP amount for
|
||||
* @param skillType The skill to get the XP amount for
|
||||
* @return the amount of XP left before leveling up a specifc skill
|
||||
* @deprecated Use {@link #getXPToNextLevel(Player, String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static int getXPToNextLevel(Player player, SkillType skillType) {
|
||||
return Users.getPlayer(player).getProfile().getXpToLevel(skillType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of XP left before leveling up.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the XP amount for
|
||||
* @param skillType The skill to get the XP amount for
|
||||
* @return the amount of XP left before leveling up a specifc skill
|
||||
*/
|
||||
public static int getXPToNextLevel(Player player, String skillType) {
|
||||
return Users.getPlayer(player).getProfile().getXpToLevel(SkillType.getSkill(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add levels to a skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add levels to
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
* @param notify Unused argument
|
||||
* @deprecated Use addLevel(Player, SKillType, int) instead
|
||||
*/
|
||||
public static void addLevel(Player player, SkillType skillType, int levels, boolean notify) {
|
||||
Users.getProfile(player).addLevels(skillType, levels);
|
||||
|
||||
if (notify) {
|
||||
checkXP(player, skillType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add levels to a skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add levels to
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
* @deprecated Use {@link #addLevel(Player, String, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void addLevel(Player player, SkillType skillType, int levels) {
|
||||
Users.getPlayer(player).getProfile().addLevels(skillType, levels);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add levels to a skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add levels to
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
*/
|
||||
public static void addLevel(Player player, String skillType, int levels) {
|
||||
Users.getPlayer(player).getProfile().addLevels(SkillType.getSkill(skillType), levels);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the level a player has in a specific skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the level for
|
||||
* @param skillType The skill to get the level for
|
||||
* @return the level of a given skill
|
||||
* @deprecated Use {@link #getLevel(Player, String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static int getLevel(Player player, SkillType skillType) {
|
||||
return Users.getPlayer(player).getProfile().getSkillLevel(skillType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the level a player has in a specific skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the level for
|
||||
* @param skillType The skill to get the level for
|
||||
* @return the level of a given skill
|
||||
*/
|
||||
public static int getLevel(Player player, String skillType) {
|
||||
return Users.getPlayer(player).getProfile().getSkillLevel(SkillType.getSkill(skillType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the power level of a player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the power level for
|
||||
* @return the power level of the player
|
||||
*/
|
||||
public static int getPowerLevel(Player player) {
|
||||
return Users.getPlayer(player).getPowerLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the level of a player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to set the level of
|
||||
* @param skillType The skill to set the level for
|
||||
* @param skillLevel The value to set the level to
|
||||
* @deprecated Use {@link #setLevel(Player, String, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setLevel(Player player, SkillType skillType, int skillLevel) {
|
||||
Users.getPlayer(player).getProfile().modifySkill(skillType, skillLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the level of a player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to set the level of
|
||||
* @param skillType The skill to set the level for
|
||||
* @param skillLevel The value to set the level to
|
||||
*/
|
||||
public static void setLevel(Player player, String skillType, int skillLevel) {
|
||||
Users.getPlayer(player).getProfile().modifySkill(SkillType.getSkill(skillType), skillLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XP of a player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to set the XP of
|
||||
* @param skillType The skill to set the XP for
|
||||
* @param newValue The value to set the XP to
|
||||
* @deprecated Use {@link #setXP(Player, String, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setXP(Player player, SkillType skillType, int newValue) {
|
||||
Users.getPlayer(player).getProfile().setSkillXpLevel(skillType, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XP of a player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to set the XP of
|
||||
* @param skillType The skill to set the XP for
|
||||
* @param newValue The value to set the XP to
|
||||
*/
|
||||
public static void setXP(Player player, String skillType, int newValue) {
|
||||
Users.getPlayer(player).getProfile().setSkillXpLevel(SkillType.getSkill(skillType), newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes XP from a player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to change the XP of
|
||||
* @param skillType The skill to change the XP for
|
||||
* @param xp The amount of XP to remove
|
||||
* @deprecated Use {@link #removeXP(Player, String, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static void removeXP(Player player, SkillType skillType, int xp) {
|
||||
Users.getPlayer(player).getProfile().removeXp(skillType, xp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes XP from a player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to change the XP of
|
||||
* @param skillType The skill to change the XP for
|
||||
* @param xp The amount of XP to remove
|
||||
*/
|
||||
public static void removeXP(Player player, String skillType, int xp) {
|
||||
Users.getPlayer(player).getProfile().removeXp(SkillType.getSkill(skillType), xp);
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.api.exceptions.InvalidPlayerException;
|
||||
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public final class ExperienceAPI {
|
||||
private ExperienceAPI() {}
|
||||
|
||||
/**
|
||||
* Adds raw XP to the player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void addRawXP(Player player, String skillType, int XP) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
UserManager.getPlayer(player).applyXpGain(skill, XP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds raw XP to an offline player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void addRawXPOffline(String playerName, String skillType, int XP) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
addOfflineXP(playerName, skill, XP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, calculates for XP Rate only.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void addMultipliedXP(Player player, String skillType, int XP) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
UserManager.getPlayer(player).applyXpGain(skill, (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to an offline player, calculates for XP Rate only.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void addMultipliedXPOffline(String playerName, String skillType, int XP) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
addOfflineXP(playerName, skill, (int) (XP * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, calculates for XP Rate and skill modifier.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void addModifiedXP(Player player, String skillType, int XP) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to an offline player, calculates for XP Rate and skill modifier.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void addModifiedXPOffline(String playerName, String skillType, int XP) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
addOfflineXP(playerName, skill, (int) (XP / skill.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, calculates for XP Rate, skill modifiers and perks. May be shared with the party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add XP to
|
||||
* @param skillType The skill to add XP to
|
||||
* @param XP The amount of XP to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void addXP(Player player, String skillType, int XP) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
UserManager.getPlayer(player).beginXpGain(skill, XP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of XP a player has in a specific skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
* @return the amount of XP in a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static int getXP(Player player, String skillType) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
return UserManager.getPlayer(player).getProfile().getSkillXpLevel(skill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of XP an offline player has in a specific skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
* @return the amount of XP in a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static int getOfflineXP(String playerName, String skillType) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
return getOfflineProfile(playerName).getSkillXpLevel(skill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of XP left before leveling up.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the XP amount for
|
||||
* @param skillType The skill to get the XP amount for
|
||||
* @return the amount of XP left before leveling up a specifc skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static int getXPToNextLevel(Player player, String skillType) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
return UserManager.getPlayer(player).getProfile().getXpToLevel(skill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of XP an offline player has left before leveling up.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to get XP for
|
||||
* @param skillType The skill to get XP for
|
||||
* @return the amount of XP in a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static int getOfflineXPToNextLevel(String playerName, String skillType) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
return getOfflineProfile(playerName).getXpToLevel(skill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add levels to a skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add levels to
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void addLevel(Player player, String skillType, int levels) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
UserManager.getPlayer(player).getProfile().addLevels(skill, levels);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add levels to a skill for an offline player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to add levels to
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void addLevelOffline(String playerName, String skillType, int levels) {
|
||||
PlayerProfile profile = getOfflineProfile(playerName);
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
if (skill.isChildSkill()) {
|
||||
Set<SkillType> parentSkills = FamilyTree.getParents(skill);
|
||||
|
||||
for (SkillType parentSkill : parentSkills) {
|
||||
profile.addLevels(parentSkill, (levels / parentSkills.size()));
|
||||
}
|
||||
|
||||
profile.save();
|
||||
return;
|
||||
}
|
||||
|
||||
profile.addLevels(skill, levels);
|
||||
profile.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the level a player has in a specific skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the level for
|
||||
* @param skillType The skill to get the level for
|
||||
* @return the level of a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static int getLevel(Player player, String skillType) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
return UserManager.getPlayer(player).getProfile().getSkillLevel(skill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the level an offline player has in a specific skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to get the level for
|
||||
* @param skillType The skill to get the level for
|
||||
* @return the level of a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static int getLevelOffline(String playerName, String skillType) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
return getOfflineProfile(playerName).getSkillLevel(skill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the power level of a player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the power level for
|
||||
* @return the power level of the player
|
||||
*/
|
||||
public static int getPowerLevel(Player player) {
|
||||
return UserManager.getPlayer(player).getPowerLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the power level of an offline player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to get the power level for
|
||||
* @return the power level of the player
|
||||
*
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static int getPowerLevelOffline(String playerName) {
|
||||
int powerLevel = 0;
|
||||
PlayerProfile profile = getOfflineProfile(playerName);
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
|
||||
return powerLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the level cap of a specific skill.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param skillType The skill to get the level cap for
|
||||
* @return the level cap of a given skill
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static int getLevelCap(String skillType) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
return Config.getInstance().getLevelCap(skill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the power level cap.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @return the overall power level cap
|
||||
*/
|
||||
public static int getPowerLevelCap() {
|
||||
return Config.getInstance().getPowerLevelCap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the level of a player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to set the level of
|
||||
* @param skillType The skill to set the level for
|
||||
* @param skillLevel The value to set the level to
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void setLevel(Player player, String skillType, int skillLevel) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
UserManager.getPlayer(player).getProfile().modifySkill(skill, skillLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the level of an offline player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to set the level of
|
||||
* @param skillType The skill to set the level for
|
||||
* @param skillLevel The value to set the level to
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void setLevelOffline(String playerName, String skillType, int skillLevel) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
getOfflineProfile(playerName).modifySkill(skill, skillLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XP of a player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to set the XP of
|
||||
* @param skillType The skill to set the XP for
|
||||
* @param newValue The value to set the XP to
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void setXP(Player player, String skillType, int newValue) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
UserManager.getPlayer(player).getProfile().setSkillXpLevel(skill, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XP of an offline player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to set the XP of
|
||||
* @param skillType The skill to set the XP for
|
||||
* @param newValue The value to set the XP to
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void setXPOffline(String playerName, String skillType, int newValue) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
getOfflineProfile(playerName).setSkillXpLevel(skill, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes XP from a player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to change the XP of
|
||||
* @param skillType The skill to change the XP for
|
||||
* @param xp The amount of XP to remove
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
*/
|
||||
public static void removeXP(Player player, String skillType, int xp) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
UserManager.getPlayer(player).getProfile().removeXp(skill, xp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes XP from an offline player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playerName The player to change the XP of
|
||||
* @param skillType The skill to change the XP for
|
||||
* @param xp The amount of XP to remove
|
||||
*
|
||||
* @throws InvalidSkillException if the given skill is not valid
|
||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||
*/
|
||||
public static void removeXPOffline(String playerName, String skillType, int xp) {
|
||||
SkillType skill = SkillType.getSkill(skillType);
|
||||
|
||||
if (skill == null) {
|
||||
throw new InvalidSkillException();
|
||||
}
|
||||
|
||||
getOfflineProfile(playerName).removeXp(skill, xp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add XP to an offline player.
|
||||
*
|
||||
* @param playerName The player to check
|
||||
* @param skillType The skill to check
|
||||
* @param XP The amount of XP to award.
|
||||
*/
|
||||
private static void addOfflineXP(String playerName, SkillType skill, int XP) {
|
||||
PlayerProfile profile = getOfflineProfile(playerName);
|
||||
|
||||
if (skill.isChildSkill()) {
|
||||
Set<SkillType> parentSkills = FamilyTree.getParents(skill);
|
||||
|
||||
for (SkillType parentSkill : parentSkills) {
|
||||
profile.setSkillXpLevel(parentSkill, profile.getSkillLevel(parentSkill) + (XP / parentSkills.size()));
|
||||
}
|
||||
|
||||
profile.save();
|
||||
return;
|
||||
}
|
||||
|
||||
profile.setSkillXpLevel(skill, profile.getSkillXpLevel(skill) + XP);
|
||||
profile.save();
|
||||
}
|
||||
|
||||
private static PlayerProfile getOfflineProfile(String playerName) {
|
||||
PlayerProfile profile = new PlayerProfile(playerName, false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
throw new InvalidPlayerException();
|
||||
}
|
||||
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,174 +1,157 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public final class PartyAPI {
|
||||
private PartyAPI() {}
|
||||
|
||||
/**
|
||||
* Get the name of the party a player is in.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check the party name of
|
||||
* @return the name of the player's party
|
||||
*/
|
||||
public static String getPartyName(Player player) {
|
||||
return Users.getPlayer(player).getParty().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player is in a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return true if the player is in a party, false otherwise
|
||||
*/
|
||||
public static boolean inParty(Player player) {
|
||||
return Users.getPlayer(player).inParty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two players are in the same party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playera The first player to check
|
||||
* @param playerb The second player to check
|
||||
* @return true if the two players are in the same party, false otherwise
|
||||
*/
|
||||
public static boolean inSameParty(Player playera, Player playerb) {
|
||||
return PartyManager.inSameParty(playera, playerb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all current parties.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @return the list of parties.
|
||||
*/
|
||||
public static List<Party> getParties() {
|
||||
return PartyManager.getParties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add to the party
|
||||
* @param partyName The party to add the player to
|
||||
*/
|
||||
public static void addToParty(Player player, String partyName) {
|
||||
Party party = PartyManager.getParty(partyName);
|
||||
|
||||
if (party == null) {
|
||||
party = new Party();
|
||||
party.setName(partyName);
|
||||
party.setLeader(player.getName());
|
||||
}
|
||||
|
||||
PartyManager.addToParty(player, Users.getPlayer(player), party);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to remove
|
||||
*/
|
||||
public static void removeFromParty(Player player) {
|
||||
PartyManager.removeFromParty(player, Users.getPlayer(player).getParty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the leader of a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param partyName The party name
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public static String getPartyLeader(String partyName) {
|
||||
return PartyManager.getPartyLeader(partyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the leader of a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param partyName The name of the party to set the leader of
|
||||
* @param player The player to set as leader
|
||||
*/
|
||||
public static void setPartyLeader(String partyName, String player) {
|
||||
PartyManager.setPartyLeader(player, PartyManager.getParty(partyName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all players in this player's party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all the players in the player's party
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<String> getAllMembers(Player player) {
|
||||
List<String> memberNames = new ArrayList<String>();
|
||||
|
||||
for (OfflinePlayer member : PartyManager.getAllMembers(player)) {
|
||||
memberNames.add(member.getName());
|
||||
}
|
||||
|
||||
return memberNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all players in this player's party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
|
||||
return PartyManager.getAllMembers(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all online players in this party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param partyName The party to check
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(String partyName) {
|
||||
return PartyManager.getOnlineMembers(partyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all online players in this player's party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all online players in the player's party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(Player player) {
|
||||
return PartyManager.getOnlineMembers(player);
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public final class PartyAPI {
|
||||
private PartyAPI() {}
|
||||
|
||||
/**
|
||||
* Get the name of the party a player is in.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check the party name of
|
||||
* @return the name of the player's party, or null if not in a party
|
||||
*/
|
||||
public static String getPartyName(Player player) {
|
||||
if (!inParty(player)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return UserManager.getPlayer(player).getParty().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player is in a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return true if the player is in a party, false otherwise
|
||||
*/
|
||||
public static boolean inParty(Player player) {
|
||||
return UserManager.getPlayer(player).inParty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two players are in the same party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playera The first player to check
|
||||
* @param playerb The second player to check
|
||||
* @return true if the two players are in the same party, false otherwise
|
||||
*/
|
||||
public static boolean inSameParty(Player playera, Player playerb) {
|
||||
return PartyManager.inSameParty(playera, playerb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all current parties.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @return the list of parties.
|
||||
*/
|
||||
public static List<Party> getParties() {
|
||||
return PartyManager.getParties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a player to a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add to the party
|
||||
* @param partyName The party to add the player to
|
||||
*/
|
||||
public static void addToParty(Player player, String partyName) {
|
||||
Party party = PartyManager.getParty(partyName);
|
||||
|
||||
if (party == null) {
|
||||
party = new Party();
|
||||
party.setName(partyName);
|
||||
party.setLeader(player.getName());
|
||||
}
|
||||
|
||||
PartyManager.addToParty(player, UserManager.getPlayer(player), party);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a player from a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to remove
|
||||
*/
|
||||
public static void removeFromParty(Player player) {
|
||||
PartyManager.removeFromParty(player, UserManager.getPlayer(player).getParty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the leader of a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param partyName The party name
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public static String getPartyLeader(String partyName) {
|
||||
return PartyManager.getPartyLeader(partyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the leader of a party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param partyName The name of the party to set the leader of
|
||||
* @param player The player to set as leader
|
||||
*/
|
||||
public static void setPartyLeader(String partyName, String player) {
|
||||
PartyManager.setPartyLeader(player, PartyManager.getParty(partyName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all players in this player's party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
|
||||
return PartyManager.getAllMembers(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all online players in this party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param partyName The party to check
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(String partyName) {
|
||||
return PartyManager.getOnlineMembers(partyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all online players in this player's party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all online players in the player's party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(Player player) {
|
||||
return PartyManager.getOnlineMembers(player);
|
||||
}
|
||||
}
|
||||
|
||||
29
src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java
Normal file
29
src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class SpoutHudAPI {
|
||||
private SpoutHudAPI() {}
|
||||
|
||||
/**
|
||||
* Disable the mcMMO XP bar for a player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*/
|
||||
public static void disableXpBar(Player player) {
|
||||
UserManager.getPlayer(player).getProfile().setHudType(HudType.DISABLED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the mcMMO XP bar for the server.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*/
|
||||
public static void disableXpBar() {
|
||||
SpoutConfig.getInstance().setXPBarEnabled(false);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +1,53 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.skills.utilities.ToolType;
|
||||
|
||||
public final class SpoutToolsAPI {
|
||||
public static final List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
|
||||
|
||||
private SpoutToolsAPI() {}
|
||||
|
||||
/**
|
||||
* Add a custom Spout tool to mcMMO for XP gain & ability use.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param spoutTool The tool to add
|
||||
* @param type The type of tool to add
|
||||
*/
|
||||
public static void addCustomTool(ItemStack spoutTool, ToolType type) {
|
||||
switch (type) {
|
||||
case AXE:
|
||||
spoutAxes.add(spoutTool);
|
||||
break;
|
||||
|
||||
case HOE:
|
||||
spoutHoes.add(spoutTool);
|
||||
break;
|
||||
|
||||
case PICKAXE:
|
||||
spoutPickaxes.add(spoutTool);
|
||||
break;
|
||||
|
||||
case SHOVEL:
|
||||
spoutShovels.add(spoutTool);
|
||||
break;
|
||||
|
||||
case SWORD:
|
||||
spoutSwords.add(spoutTool);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
|
||||
public final class SpoutToolsAPI {
|
||||
public static final List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
|
||||
|
||||
private SpoutToolsAPI() {}
|
||||
|
||||
/**
|
||||
* Add a custom Spout tool to mcMMO for XP gain & ability use.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param spoutTool The tool to add
|
||||
* @param type The type of tool to add
|
||||
*/
|
||||
public static void addCustomTool(ItemStack spoutTool, ToolType type) {
|
||||
switch (type) {
|
||||
case AXE:
|
||||
spoutAxes.add(spoutTool);
|
||||
break;
|
||||
|
||||
case HOE:
|
||||
spoutHoes.add(spoutTool);
|
||||
break;
|
||||
|
||||
case PICKAXE:
|
||||
spoutPickaxes.add(spoutTool);
|
||||
break;
|
||||
|
||||
case SHOVEL:
|
||||
spoutShovels.add(spoutTool);
|
||||
break;
|
||||
|
||||
case SWORD:
|
||||
spoutSwords.add(spoutTool);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.gmail.nossr50.api.exceptions;
|
||||
|
||||
public class InvalidPlayerException extends RuntimeException {
|
||||
private static final long serialVersionUID = 907213002618581385L;
|
||||
|
||||
public InvalidPlayerException() {
|
||||
super("That player does not exist in the database.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.gmail.nossr50.api.exceptions;
|
||||
|
||||
public class InvalidSkillException extends RuntimeException {
|
||||
private static final long serialVersionUID = 942705284195791157L;
|
||||
|
||||
public InvalidSkillException() {
|
||||
super("That is not a valid skill.");
|
||||
}
|
||||
}
|
||||
@@ -1,67 +1,78 @@
|
||||
package com.gmail.nossr50.chat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
|
||||
public final class ChatManager {
|
||||
public ChatManager () {}
|
||||
|
||||
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message) {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(Config.getInstance().getAdminDisplayNames())
|
||||
displayName = chatEvent.getDisplayName();
|
||||
else
|
||||
displayName = chatEvent.getSender();
|
||||
|
||||
String adminMessage = chatEvent.getMessage();
|
||||
|
||||
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Commands.AdminChat.Prefix", displayName) + adminMessage, "mcmmo.chat.adminchat");
|
||||
mcMMO.p.getLogger().info("[A]<" + ChatColor.stripColor(displayName) + "> " + adminMessage);
|
||||
}
|
||||
|
||||
public static void handleAdminChat(Plugin plugin, String senderName, String message) {
|
||||
handleAdminChat(plugin, senderName, senderName, message);
|
||||
}
|
||||
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message) {
|
||||
String partyName = party.getName();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, playerName, displayName, partyName, message);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(Config.getInstance().getPartyDisplayNames())
|
||||
displayName = chatEvent.getDisplayName();
|
||||
else
|
||||
displayName = chatEvent.getSender();
|
||||
|
||||
String partyMessage = chatEvent.getMessage();
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", displayName) + partyMessage);
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("[P](" + partyName + ")" + "<" + ChatColor.stripColor(displayName) + "> " + partyMessage);
|
||||
}
|
||||
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String senderName, String message) {
|
||||
handlePartyChat(plugin, party, senderName, senderName, message);
|
||||
}
|
||||
package com.gmail.nossr50.chat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public final class ChatManager {
|
||||
public ChatManager () {}
|
||||
|
||||
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message, boolean isAsync) {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message, isAsync);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getAdminDisplayNames()) {
|
||||
displayName = chatEvent.getDisplayName();
|
||||
}
|
||||
else {
|
||||
displayName = chatEvent.getSender();
|
||||
}
|
||||
|
||||
String adminMessage = chatEvent.getMessage();
|
||||
|
||||
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Commands.AdminChat.Prefix", displayName) + adminMessage, "mcmmo.chat.adminchat");
|
||||
}
|
||||
|
||||
public static void handleAdminChat(Plugin plugin, String senderName, String message) {
|
||||
handleAdminChat(plugin, senderName, senderName, message);
|
||||
}
|
||||
|
||||
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message) {
|
||||
handleAdminChat(plugin, playerName, displayName, message, false);
|
||||
}
|
||||
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message, boolean isAsync) {
|
||||
String partyName = party.getName();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(plugin, playerName, displayName, partyName, message, isAsync);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getPartyDisplayNames()) {
|
||||
displayName = chatEvent.getDisplayName();
|
||||
}
|
||||
else {
|
||||
displayName = chatEvent.getSender();
|
||||
}
|
||||
|
||||
String partyMessage = chatEvent.getMessage();
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
member.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", displayName) + partyMessage);
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("[P](" + partyName + ")" + "<" + ChatColor.stripColor(displayName) + "> " + partyMessage);
|
||||
}
|
||||
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String senderName, String message) {
|
||||
handlePartyChat(plugin, party, senderName, senderName, message);
|
||||
}
|
||||
|
||||
public static void handlePartyChat(Plugin plugin, Party party, String playerName, String displayName, String message) {
|
||||
handlePartyChat(plugin, party, playerName, displayName, message, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,70 +1,70 @@
|
||||
package com.gmail.nossr50.chat;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public enum ChatMode {
|
||||
ADMIN(LocaleLoader.getString("Commands.AdminChat.On"), LocaleLoader.getString("Commands.AdminChat.Off")),
|
||||
PARTY(LocaleLoader.getString("Commands.Party.Chat.On"), LocaleLoader.getString("Commands.Party.Chat.Off"));
|
||||
|
||||
private String enabledMessage;
|
||||
private String disabledMessage;
|
||||
|
||||
private ChatMode (String enabledMessage, String disabledMessage) {
|
||||
this.enabledMessage = enabledMessage;
|
||||
this.disabledMessage = disabledMessage;
|
||||
}
|
||||
|
||||
public boolean isEnabled(McMMOPlayer mcMMOPlayer) {
|
||||
switch (this) {
|
||||
case ADMIN:
|
||||
return mcMMOPlayer.getAdminChatMode();
|
||||
|
||||
case PARTY:
|
||||
return mcMMOPlayer.getPartyChatMode();
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void disable(McMMOPlayer mcMMOPlayer) {
|
||||
switch (this) {
|
||||
case ADMIN:
|
||||
mcMMOPlayer.setAdminChat(false);
|
||||
return;
|
||||
|
||||
case PARTY:
|
||||
mcMMOPlayer.setPartyChat(false);
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void enable(McMMOPlayer mcMMOPlayer) {
|
||||
switch (this) {
|
||||
case ADMIN:
|
||||
mcMMOPlayer.setAdminChat(true);
|
||||
mcMMOPlayer.setPartyChat(false);
|
||||
return;
|
||||
|
||||
case PARTY:
|
||||
mcMMOPlayer.setPartyChat(true);
|
||||
mcMMOPlayer.setAdminChat(false);
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public String getEnabledMessage() {
|
||||
return enabledMessage;
|
||||
}
|
||||
|
||||
public String getDisabledMessage() {
|
||||
return disabledMessage;
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.chat;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public enum ChatMode {
|
||||
ADMIN(LocaleLoader.getString("Commands.AdminChat.On"), LocaleLoader.getString("Commands.AdminChat.Off")),
|
||||
PARTY(LocaleLoader.getString("Commands.Party.Chat.On"), LocaleLoader.getString("Commands.Party.Chat.Off"));
|
||||
|
||||
private String enabledMessage;
|
||||
private String disabledMessage;
|
||||
|
||||
private ChatMode(String enabledMessage, String disabledMessage) {
|
||||
this.enabledMessage = enabledMessage;
|
||||
this.disabledMessage = disabledMessage;
|
||||
}
|
||||
|
||||
public boolean isEnabled(McMMOPlayer mcMMOPlayer) {
|
||||
switch (this) {
|
||||
case ADMIN:
|
||||
return mcMMOPlayer.getAdminChatMode();
|
||||
|
||||
case PARTY:
|
||||
return mcMMOPlayer.getPartyChatMode();
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void disable(McMMOPlayer mcMMOPlayer) {
|
||||
switch (this) {
|
||||
case ADMIN:
|
||||
mcMMOPlayer.setAdminChat(false);
|
||||
return;
|
||||
|
||||
case PARTY:
|
||||
mcMMOPlayer.setPartyChat(false);
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void enable(McMMOPlayer mcMMOPlayer) {
|
||||
switch (this) {
|
||||
case ADMIN:
|
||||
mcMMOPlayer.setAdminChat(true);
|
||||
mcMMOPlayer.setPartyChat(false);
|
||||
return;
|
||||
|
||||
case PARTY:
|
||||
mcMMOPlayer.setPartyChat(true);
|
||||
mcMMOPlayer.setAdminChat(false);
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public String getEnabledMessage() {
|
||||
return enabledMessage;
|
||||
}
|
||||
|
||||
public String getDisabledMessage() {
|
||||
return disabledMessage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.gmail.nossr50.chat.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.chat.ChatMode;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public abstract class ChatCommand implements CommandExecutor {
|
||||
protected McMMOPlayer mcMMOPlayer;
|
||||
protected ChatMode chatMode;
|
||||
|
||||
public ChatCommand (ChatMode chatMode) {
|
||||
this.chatMode = chatMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mcMMOPlayer = Users.getPlayer((Player) sender);
|
||||
|
||||
if (chatMode.isEnabled(mcMMOPlayer)) {
|
||||
disableChatMode(sender);
|
||||
}
|
||||
else {
|
||||
enableChatMode(sender);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("on")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
enableChatMode(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("off")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
disableChatMode(sender);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
handleChatSending(sender, args);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void enableChatMode(CommandSender sender) {
|
||||
chatMode.enable(mcMMOPlayer);
|
||||
sender.sendMessage(chatMode.getEnabledMessage());
|
||||
}
|
||||
|
||||
private void disableChatMode(CommandSender sender) {
|
||||
chatMode.disable(mcMMOPlayer);
|
||||
sender.sendMessage(chatMode.getDisabledMessage());
|
||||
}
|
||||
|
||||
protected String buildChatMessage(String[] args, int index) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(args[index]);
|
||||
|
||||
for (int i = index + 1; i < args.length; i++) {
|
||||
builder.append(" ");
|
||||
builder.append(args[i]);
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
protected abstract void handleChatSending(CommandSender sender, String[] args);
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
public final class CommandHelper {
|
||||
private CommandHelper() {}
|
||||
|
||||
public static boolean noConsoleUsage(CommandSender sender) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.NoConsole"));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out details on Gathering skills. Only for online players.
|
||||
*
|
||||
* @param inspect The player to retrieve stats for
|
||||
* @param profile The player's profile
|
||||
* @param display The sender to display stats to
|
||||
*/
|
||||
public static void printGatheringSkills(Player inspect, PlayerProfile profile, CommandSender display) {
|
||||
if (SkillTools.hasGatheringSkills(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.excavation")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.fishing")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.fishing")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.mining")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.woodcutting")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void printGatheringSkills(Player player, PlayerProfile profile) {
|
||||
printGatheringSkills(player, profile, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out details on Combat skills. Only for online players.
|
||||
*
|
||||
* @param inspect The player to retrieve stats for
|
||||
* @param profile The player's profile
|
||||
* @param display The sender to display stats to
|
||||
*/
|
||||
public static void printCombatSkills(Player inspect, PlayerProfile profile, CommandSender display) {
|
||||
if (SkillTools.hasCombatSkills(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.axes")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.archery")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.swords")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.taming")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.unarmed")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void printCombatSkills(Player player, PlayerProfile profile) {
|
||||
printCombatSkills(player, profile, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print out details on Misc skills. Only for online players.
|
||||
*
|
||||
* @param inspect The player to retrieve stats for
|
||||
* @param profile The player's profile
|
||||
* @param display The sender to display stats to
|
||||
*/
|
||||
public static void printMiscSkills(Player inspect, PlayerProfile profile, CommandSender display) {
|
||||
if (SkillTools.hasMiscSkills(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.acrobatics")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS)));
|
||||
}
|
||||
|
||||
if (inspect.hasPermission("mcmmo.skills.repair")) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void printMiscSkills(Player player, PlayerProfile profile) {
|
||||
printMiscSkills(player, profile, player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class McabilityCommand extends ToggleCommand {
|
||||
@Override
|
||||
protected boolean hasOtherPermission(CommandSender sender) {
|
||||
return Permissions.mcabilityOthers(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasSelfPermission(CommandSender sender) {
|
||||
return Permissions.mcability(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCommandAction() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Ability." + (mcMMOPlayer.getAbilityUse() ? "Off" : "On")));
|
||||
mcMMOPlayer.toggleAbilityUse();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendSuccessMessage(CommandSender sender) {
|
||||
sender.sendMessage("Ability use has been toggled for " + player.getName()); // TODO: Localize
|
||||
}
|
||||
}
|
||||
29
src/main/java/com/gmail/nossr50/commands/McgodCommand.java
Normal file
29
src/main/java/com/gmail/nossr50/commands/McgodCommand.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class McgodCommand extends ToggleCommand {
|
||||
@Override
|
||||
protected boolean hasOtherPermission(CommandSender sender) {
|
||||
return Permissions.mcgodOthers(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasSelfPermission(CommandSender sender) {
|
||||
return Permissions.mcgod(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCommandAction() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled")));
|
||||
mcMMOPlayer.toggleGodMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendSuccessMessage(CommandSender sender) {
|
||||
sender.sendMessage("God mode has been toggled for " + player.getName()); // TODO: Localize
|
||||
}
|
||||
}
|
||||
@@ -1,107 +1,113 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class McmmoCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
String description = LocaleLoader.getString("mcMMO.Description");
|
||||
String[] mcSplit = description.split(",");
|
||||
sender.sendMessage(mcSplit);
|
||||
|
||||
if (Config.getInstance().getDonateMessageEnabled()) {
|
||||
if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) {
|
||||
SpoutPlayer spoutPlayer = (SpoutPlayer) sender;
|
||||
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.Donate"), ChatColor.GREEN + "gjmcferrin@gmail.com", Material.DIAMOND);
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("commands")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.mcmmo.help")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcc.Header"));
|
||||
displayPartyCommands(sender);
|
||||
displayOtherCommands(sender);
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void displayPartyCommands(CommandSender sender) {
|
||||
if (sender.hasPermission("mcmmo.commands.party")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
|
||||
sender.sendMessage("/party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1"));
|
||||
sender.sendMessage("/party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2"));
|
||||
sender.sendMessage("/party quit " + LocaleLoader.getString("Commands.Party.Quit"));
|
||||
|
||||
if (sender.hasPermission("mcmmo.chat.party")) {
|
||||
sender.sendMessage("/party chat " + LocaleLoader.getString("Commands.Party.Toggle"));
|
||||
}
|
||||
|
||||
sender.sendMessage("/party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
|
||||
sender.sendMessage("/party accept " + LocaleLoader.getString("Commands.Party.Accept"));
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.ptp")) {
|
||||
sender.sendMessage("/party teleport " + LocaleLoader.getString("Commands.Party.Teleport"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void displayOtherCommands(CommandSender sender) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Other"));
|
||||
sender.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
|
||||
sender.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.skillreset")) {
|
||||
sender.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.mcability")) {
|
||||
sender.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("mcmmo.chat.admin")) {
|
||||
sender.sendMessage("/adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.inspect")) {
|
||||
sender.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.mmoedit")) {
|
||||
sender.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
|
||||
}
|
||||
|
||||
if (sender.hasPermission("mcmmo.commands.mcgod")) {
|
||||
sender.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod"));
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.SkillInfo"));
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.party.PartySubcommandType;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class McmmoCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!Permissions.mcmmoDescription(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
String description = LocaleLoader.getString("mcMMO.Description");
|
||||
String[] mcSplit = description.split(",");
|
||||
sender.sendMessage(mcSplit);
|
||||
|
||||
if (Config.getInstance().getDonateMessageEnabled()) {
|
||||
if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) {
|
||||
SpoutPlayer spoutPlayer = (SpoutPlayer) sender;
|
||||
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.Donate"), ChatColor.GREEN + "gjmcferrin@gmail.com", Material.DIAMOND);
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("commands")) {
|
||||
if (!Permissions.mcmmoHelp(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcc.Header"));
|
||||
displayPartyCommands(sender);
|
||||
displayOtherCommands(sender);
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void displayPartyCommands(CommandSender sender) {
|
||||
if (Permissions.party(sender)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
|
||||
sender.sendMessage("/party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1"));
|
||||
sender.sendMessage("/party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2"));
|
||||
sender.sendMessage("/party quit " + LocaleLoader.getString("Commands.Party.Quit"));
|
||||
|
||||
if (Permissions.partyChat(sender)) {
|
||||
sender.sendMessage("/party chat " + LocaleLoader.getString("Commands.Party.Toggle"));
|
||||
}
|
||||
|
||||
sender.sendMessage("/party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
|
||||
sender.sendMessage("/party accept " + LocaleLoader.getString("Commands.Party.Accept"));
|
||||
|
||||
if (Permissions.partySubcommand(sender, PartySubcommandType.TELEPORT)) {
|
||||
sender.sendMessage("/party teleport " + LocaleLoader.getString("Commands.Party.Teleport"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void displayOtherCommands(CommandSender sender) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Other"));
|
||||
sender.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
|
||||
sender.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
|
||||
|
||||
if (Permissions.skillreset(sender)) {
|
||||
sender.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
|
||||
}
|
||||
|
||||
if (Permissions.mcability(sender)) {
|
||||
sender.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
||||
}
|
||||
|
||||
if (Permissions.adminChat(sender)) {
|
||||
sender.sendMessage("/adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
|
||||
}
|
||||
|
||||
if (Permissions.inspect(sender)) {
|
||||
sender.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect"));
|
||||
}
|
||||
|
||||
if (Permissions.mmoedit(sender)) {
|
||||
sender.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
|
||||
}
|
||||
|
||||
if (Permissions.mcgod(sender)) {
|
||||
sender.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod"));
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.SkillInfo"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McnotifyCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On")));
|
||||
mcMMOPlayer.toggleChatNotifications();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class McrefreshCommand extends ToggleCommand {
|
||||
@Override
|
||||
protected boolean hasOtherPermission(CommandSender sender) {
|
||||
return Permissions.mcrefreshOthers(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasSelfPermission(CommandSender sender) {
|
||||
return Permissions.mcrefresh(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCommandAction() {
|
||||
mcMMOPlayer.setRecentlyHurt(0);
|
||||
mcMMOPlayer.getProfile().resetCooldowns();
|
||||
mcMMOPlayer.resetToolPrepMode();
|
||||
mcMMOPlayer.resetAbilityMode();
|
||||
|
||||
player.setCanPickupItems(true);
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendSuccessMessage(CommandSender sender) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", player.getName()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MobhealthCommand implements TabExecutor {
|
||||
private static final List<String> MOB_HEALTHBAR_TYPES;
|
||||
|
||||
static {
|
||||
ArrayList<String> types = new ArrayList<String>();
|
||||
|
||||
for (MobHealthbarType type : MobHealthbarType.values()) {
|
||||
types.add(type.toString());
|
||||
}
|
||||
|
||||
Collections.sort(types);
|
||||
MOB_HEALTHBAR_TYPES = ImmutableList.copyOf(types);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
PlayerProfile playerProfile = UserManager.getPlayer(sender.getName()).getProfile();
|
||||
|
||||
try {
|
||||
MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim());
|
||||
playerProfile.setMobHealthbarType(type);
|
||||
sender.sendMessage("Display type changed to: " + type); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
sender.sendMessage("Invalid type!"); //TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], MOB_HEALTHBAR_TYPES, new ArrayList<String>(MOB_HEALTHBAR_TYPES.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
84
src/main/java/com/gmail/nossr50/commands/ToggleCommand.java
Normal file
84
src/main/java/com/gmail/nossr50/commands/ToggleCommand.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class ToggleCommand implements TabExecutor {
|
||||
protected McMMOPlayer mcMMOPlayer;
|
||||
protected Player player;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!hasSelfPermission(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
applyCommandAction();
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!hasOtherPermission(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (CommandUtils.isOffline(sender, player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
applyCommandAction();
|
||||
sendSuccessMessage(sender);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean hasOtherPermission(CommandSender sender);
|
||||
protected abstract boolean hasSelfPermission(CommandSender sender);
|
||||
protected abstract void applyCommandAction();
|
||||
protected abstract void sendSuccessMessage(CommandSender sender);
|
||||
}
|
||||
101
src/main/java/com/gmail/nossr50/commands/XprateCommand.java
Normal file
101
src/main/java/com/gmail/nossr50/commands/XprateCommand.java
Normal file
@@ -0,0 +1,101 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class XprateCommand implements TabExecutor {
|
||||
private double originalRate;
|
||||
|
||||
public XprateCommand() {
|
||||
originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (!args[0].equalsIgnoreCase("reset")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Permissions.xprateReset(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mcMMO.p.isXPEventEnabled()) {
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.over"));
|
||||
mcMMO.p.toggleXpEventEnabled();
|
||||
}
|
||||
|
||||
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (CommandUtils.isInvalidInteger(sender, args[0])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.xprateSet(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.shouldDisableToggle(args[1])) {
|
||||
mcMMO.p.setXPEventEnabled(false);
|
||||
}
|
||||
else if (CommandUtils.shouldEnableToggle(args[1])) {
|
||||
mcMMO.p.setXPEventEnabled(true);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
int newXpRate = Integer.parseInt(args[0]);
|
||||
Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
|
||||
|
||||
if (mcMMO.p.isXPEventEnabled()) {
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.1", newXpRate));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (StringUtils.isInt(args[0])) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
return StringUtil.copyPartialMatches(args[0], CommandUtils.RESET_OPTIONS, new ArrayList<String>(CommandUtils.RESET_OPTIONS.size()));
|
||||
case 2:
|
||||
return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AddlevelsCommand implements CommandExecutor{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
int levels;
|
||||
boolean allSkills = false;
|
||||
SkillType skill = null;
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (!sender.hasPermission("mcmmo.commands.addlevels")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
}
|
||||
else if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!StringUtils.isInt(args[1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
levels = Integer.parseInt(args[1]);
|
||||
profile = Users.getPlayer((Player) sender).getProfile();
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.addLevels(skillType, levels);
|
||||
}
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[0]);
|
||||
profile.addLevels(skill, levels);
|
||||
}
|
||||
|
||||
if (allSkills) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, SkillTools.getSkillName(skill)));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
if (!sender.hasPermission("mcmmo.commands.addlevels.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
}
|
||||
else if (!SkillTools.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!StringUtils.isInt(args[2])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
levels = Integer.parseInt(args[2]);
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.addLevels(skillType, levels);
|
||||
}
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[1]);
|
||||
profile.addLevels(skill, levels);
|
||||
}
|
||||
|
||||
profile.save(); // Since this is a temporary profile, we save it here.
|
||||
}
|
||||
else {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.addLevels(skillType, levels);
|
||||
}
|
||||
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[1]);
|
||||
profile.addLevels(skill, levels);
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, SkillTools.getSkillName(skill)));
|
||||
}
|
||||
}
|
||||
|
||||
if (allSkills) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillTools.getSkillName(skill), args[0]));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AddxpCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
int xp;
|
||||
McMMOPlayer mcMMOPlayer;
|
||||
PlayerProfile profile;
|
||||
boolean allSkills = false;
|
||||
SkillType skill = null;
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (!sender.hasPermission("mcmmo.commands.addxp")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
}
|
||||
else if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!StringUtils.isInt(args[1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
xp = Integer.parseInt(args[1]);
|
||||
mcMMOPlayer = Users.getPlayer((Player) sender);
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mcMMOPlayer.applyXpGain(skillType, xp);
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[0]);
|
||||
|
||||
mcMMOPlayer.applyXpGain(skill, xp);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, SkillTools.getSkillName(skill)));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
if (!sender.hasPermission("mcmmo.commands.addxp.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
}
|
||||
else if (!SkillTools.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!StringUtils.isInt(args[2])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
xp = Integer.parseInt(args[2]);
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Currently the offline player doesn't level up automatically
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.setSkillXpLevel(skillType, xp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[1]);
|
||||
profile.setSkillXpLevel(skill, xp);
|
||||
}
|
||||
|
||||
profile.save(); // Since this is a temporary profile, we save it here.
|
||||
}
|
||||
else {
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mcMMOPlayer.applyXpGain(skillType, xp);
|
||||
}
|
||||
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[1]);
|
||||
mcMMOPlayer.applyXpGain(skill, xp);
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, SkillTools.getSkillName(skill)));
|
||||
}
|
||||
}
|
||||
|
||||
if (allSkills) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillTools.getSkillName(skill), args[0]));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class HardcoreCommand implements CommandExecutor{
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.hardcore.toggle")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getHardcoreEnabled()) {
|
||||
disableHardcore();
|
||||
}
|
||||
else {
|
||||
enableHardcore();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enabled")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.hardcore.toggle")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
enableHardcore();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disabled")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.hardcore.toggle")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
disableHardcore();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!StringUtils.isDouble(args[0])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.hardcore.modify")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
double newPercent = Double.parseDouble(args[0]);
|
||||
|
||||
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent);
|
||||
sender.sendMessage(LocaleLoader.getString("Hardcore.PercentageChanged", percent.format(newPercent / 100D)));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void disableHardcore() {
|
||||
Config.getInstance().setHardcoreEnabled(false);
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Disabled"));
|
||||
}
|
||||
|
||||
private void enableHardcore() {
|
||||
Config.getInstance().setHardcoreEnabled(true);
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Enabled"));
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McgodCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcgod")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
profile = Users.getPlayer((Player) sender).getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getGodMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||
}
|
||||
|
||||
profile.toggleGodMode();
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcgod.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (!player.isOnline()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getGodMode()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||
}
|
||||
|
||||
profile.toggleGodMode();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McrefreshCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcrefresh")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
profile = Users.getPlayer(sender.getName()).getProfile();
|
||||
|
||||
profile.setRecentlyHurt(0);
|
||||
profile.resetCooldowns();
|
||||
profile.resetToolPrepMode();
|
||||
profile.resetAbilityMode();
|
||||
SkillTools.handleAbilitySpeedDecrease((Player) sender); //Remove enchants left over
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcrefresh.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||
return true;
|
||||
}
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (!player.isOnline()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
profile.setRecentlyHurt(0);
|
||||
profile.resetCooldowns();
|
||||
profile.resetToolPrepMode();
|
||||
profile.resetAbilityMode();
|
||||
SkillTools.handleAbilitySpeedDecrease(player); //Remove enchants left over
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", args[0]));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MmoeditCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
int newValue;
|
||||
boolean allSkills = false;
|
||||
SkillType skill = null;
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (!sender.hasPermission("mcmmo.commands.mmoedit")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
}
|
||||
else if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!StringUtils.isInt(args[1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
newValue = Integer.parseInt(args[1]);
|
||||
profile = Users.getPlayer((Player) sender).getProfile();
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.modifySkill(skillType, newValue);
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[0]);
|
||||
profile.modifySkill(skill, newValue);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillTools.getSkillName(skill), newValue));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
if (!sender.hasPermission("mcmmo.commands.mmoedit.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
}
|
||||
else if (!SkillTools.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!StringUtils.isInt(args[2])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
newValue = Integer.parseInt(args[2]);
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.modifySkill(skillType, newValue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[1]);
|
||||
profile.modifySkill(skill, newValue);
|
||||
}
|
||||
|
||||
profile.save(); // Since this is a temporary profile, we save it here.
|
||||
}
|
||||
else {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.modifySkill(skillType, newValue);
|
||||
}
|
||||
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[1]);
|
||||
profile.modifySkill(skill, newValue);
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillTools.getSkillName(skill), newValue));
|
||||
}
|
||||
}
|
||||
|
||||
if (allSkills) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", SkillTools.getSkillName(skill), args[0]));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,168 +0,0 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SkillresetCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
boolean allSkills = false;
|
||||
SkillType skill = null;
|
||||
String skillName = "";
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
}
|
||||
else if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
profile = Users.getPlayer((Player) sender).getProfile();
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset." + skillType.toString().toLowerCase())) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.modifySkill(skillType, 0);
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[0]);
|
||||
skillName = SkillTools.getSkillName(skill);
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset." + skill.toString().toLowerCase())) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
profile.modifySkill(skill, 0);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skillName));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
}
|
||||
else if (!SkillTools.isSkill(args[1])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!allSkills) {
|
||||
skill = SkillType.getSkill(args[1]);
|
||||
skillName = SkillTools.getSkillName(skill);
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset.others." + skill.toString().toLowerCase())) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset.others." + skillType.toString().toLowerCase())) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.modifySkill(skillType, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
profile.modifySkill(skill, 0);
|
||||
}
|
||||
|
||||
profile.save(); // Since this is a temporary profile, we save it here.
|
||||
}
|
||||
else {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.skillreset.others." + skillType.toString().toLowerCase())) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
profile.modifySkill(skillType, 0);
|
||||
}
|
||||
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||
}
|
||||
else {
|
||||
profile.modifySkill(skill, 0);
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.Single", skillName));
|
||||
}
|
||||
}
|
||||
|
||||
if (allSkills) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", skillName, args[0]));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class VampirismCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Config.getInstance().getHardcoreEnabled()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Hardcore.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.vampirism.toggle")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
disableVampirism();
|
||||
}
|
||||
else {
|
||||
enableVampirism();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enabled")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.vampirism.toggle")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
enableVampirism();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disabled")) {
|
||||
if (!sender.hasPermission("mcmmo.commands.vampirism.toggle")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
disableVampirism();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!StringUtils.isDouble(args[0])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.vampirism.modify")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
double newPercent = Double.parseDouble(args[0]);
|
||||
|
||||
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent);
|
||||
sender.sendMessage(LocaleLoader.getString("Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void disableVampirism() {
|
||||
Config.getInstance().setHardcoreVampirismEnabled(false);
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Disabled"));
|
||||
}
|
||||
|
||||
private void enableVampirism() {
|
||||
Config.getInstance().setHardcoreVampirismEnabled(true);
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Enabled"));
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class XprateCommand implements CommandExecutor {
|
||||
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (!args[0].equalsIgnoreCase("reset")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.xprate.reset")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mcMMO.p.isXPEventEnabled()) {
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.over"));
|
||||
mcMMO.p.toggleXpEventEnabled();
|
||||
}
|
||||
|
||||
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!StringUtils.isInt(args[0])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.xprate.set")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!args[1].equalsIgnoreCase("true") && !args[1].equalsIgnoreCase("false")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1]));
|
||||
int newXpRate = Integer.parseInt(args[0]);
|
||||
Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
|
||||
|
||||
if (mcMMO.p.isXPEventEnabled()) {
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.1", newXpRate));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,26 @@
|
||||
package com.gmail.nossr50.chat.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.chat.ChatMode;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class AdminChatCommand extends ChatCommand {
|
||||
public AdminChatCommand() {
|
||||
super(ChatMode.ADMIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleChatSending(CommandSender sender, String[] args) {
|
||||
String message = buildChatMessage(args, 0);
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
ChatManager.handleAdminChat(mcMMO.p, player.getName(), player.getDisplayName(), message);
|
||||
}
|
||||
else {
|
||||
ChatManager.handleAdminChat(mcMMO.p, LocaleLoader.getString("Commands.Chat.Console"), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.commands.chat;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.chat.ChatMode;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class AdminChatCommand extends ChatCommand {
|
||||
public AdminChatCommand() {
|
||||
super(ChatMode.ADMIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleChatSending(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
ChatManager.handleAdminChat(mcMMO.p, player.getName(), player.getDisplayName(), buildChatMessage(args, 0));
|
||||
}
|
||||
else {
|
||||
ChatManager.handleAdminChat(mcMMO.p, LocaleLoader.getString("Commands.Chat.Console"), buildChatMessage(args, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
120
src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java
Normal file
120
src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java
Normal file
@@ -0,0 +1,120 @@
|
||||
package com.gmail.nossr50.commands.chat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.chat.ChatMode;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class ChatCommand implements TabExecutor {
|
||||
protected ChatMode chatMode;
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
|
||||
public ChatCommand(ChatMode chatMode) {
|
||||
this.chatMode = chatMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
|
||||
if (chatMode.isEnabled(mcMMOPlayer)) {
|
||||
disableChatMode(sender);
|
||||
}
|
||||
else {
|
||||
enableChatMode(sender);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (CommandUtils.shouldEnableToggle(args[0])) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
|
||||
enableChatMode(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.shouldDisableToggle(args[0])) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
|
||||
disableChatMode(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fallthrough
|
||||
|
||||
default:
|
||||
handleChatSending(sender, args);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
protected String buildChatMessage(String[] args, int index) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(args[index]);
|
||||
|
||||
for (int i = index + 1; i < args.length; i++) {
|
||||
builder.append(" ");
|
||||
builder.append(args[i]);
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
protected abstract void handleChatSending(CommandSender sender, String[] args);
|
||||
|
||||
private void enableChatMode(CommandSender sender) {
|
||||
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return;
|
||||
}
|
||||
|
||||
chatMode.enable(mcMMOPlayer);
|
||||
sender.sendMessage(chatMode.getEnabledMessage());
|
||||
}
|
||||
|
||||
private void disableChatMode(CommandSender sender) {
|
||||
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return;
|
||||
}
|
||||
|
||||
chatMode.disable(mcMMOPlayer);
|
||||
sender.sendMessage(chatMode.getDisabledMessage());
|
||||
}
|
||||
}
|
||||
@@ -1,48 +1,48 @@
|
||||
package com.gmail.nossr50.chat.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.chat.ChatMode;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PartyChatCommand extends ChatCommand {
|
||||
public PartyChatCommand() {
|
||||
super(ChatMode.PARTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleChatSending(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
Party party = Users.getPlayer(player).getParty();
|
||||
|
||||
if (party == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatManager.handlePartyChat(mcMMO.p, party, player.getName(), player.getDisplayName(), buildChatMessage(args, 0));
|
||||
}
|
||||
else {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Specify"));
|
||||
return;
|
||||
}
|
||||
|
||||
Party party = PartyManager.getParty(args[0]);
|
||||
|
||||
if (party == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatManager.handlePartyChat(mcMMO.p, party, LocaleLoader.getString("Commands.Chat.Console"), buildChatMessage(args, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.commands.chat;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.chat.ChatManager;
|
||||
import com.gmail.nossr50.chat.ChatMode;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyChatCommand extends ChatCommand {
|
||||
public PartyChatCommand() {
|
||||
super(ChatMode.PARTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleChatSending(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
Party party = UserManager.getPlayer(player).getParty();
|
||||
|
||||
if (party == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatManager.handlePartyChat(mcMMO.p, party, player.getName(), player.getDisplayName(), buildChatMessage(args, 0));
|
||||
}
|
||||
else {
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Specify"));
|
||||
return;
|
||||
}
|
||||
|
||||
Party party = PartyManager.getParty(args[0]);
|
||||
|
||||
if (party == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
|
||||
return;
|
||||
}
|
||||
|
||||
ChatManager.handlePartyChat(mcMMO.p, party, LocaleLoader.getString("Commands.Chat.Console"), buildChatMessage(args, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.gmail.nossr50.commands.database;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.database.LeaderboardManager;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McpurgeCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Permissions.mcpurge(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
DatabaseManager.purgePowerlessSQL();
|
||||
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
DatabaseManager.purgeOldSQL();
|
||||
}
|
||||
}
|
||||
else {
|
||||
LeaderboardManager.purgePowerlessFlatfile();
|
||||
|
||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||
LeaderboardManager.purgeOldFlatfile();
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success"));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.gmail.nossr50.commands.database;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.DatabaseManager;
|
||||
import com.gmail.nossr50.database.LeaderboardManager;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McremoveCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Permissions.mcremove(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (UserManager.getPlayer(args[0]) == null && CommandUtils.unloadedProfile(sender, new PlayerProfile(args[0], false))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* MySQL */
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
if (DatabaseManager.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + args[0] + "'") != 0) {
|
||||
Misc.profileCleanup(args[0]);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (LeaderboardManager.removeFlatFileUser(args[0])) {
|
||||
Misc.profileCleanup(args[0]);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", args[0]));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.gmail.nossr50.commands.database;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.database.SQLConversionTask;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MmoupdateCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Permissions.mmoupdate(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Config.getInstance().getUseMySQL()) {
|
||||
sender.sendMessage("SQL Mode is not enabled."); // TODO: Localize
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Start"));
|
||||
UserManager.saveAll();
|
||||
UserManager.clearAll();
|
||||
new SQLConversionTask().runTaskLaterAsynchronously(mcMMO.p, 1);
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
UserManager.addUser(player);
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoupdate.Finish"));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class AddlevelsCommand extends ExperienceCommand {
|
||||
@Override
|
||||
protected boolean permissionsCheckSelf(CommandSender sender) {
|
||||
return Permissions.addlevels(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean permissionsCheckOthers(CommandSender sender) {
|
||||
return Permissions.addlevelsOthers(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleCommand(SkillType skill) {
|
||||
profile.addLevels(skill, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageAll() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, SkillUtils.getSkillName(skill)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class AddxpCommand extends ExperienceCommand {
|
||||
@Override
|
||||
protected boolean permissionsCheckSelf(CommandSender sender) {
|
||||
return Permissions.addxp(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean permissionsCheckOthers(CommandSender sender) {
|
||||
return Permissions.addxpOthers(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleCommand(SkillType skill) {
|
||||
if (player != null) {
|
||||
mcMMOPlayer.applyXpGain(skill, value);
|
||||
}
|
||||
else {
|
||||
profile.addExperience(skill, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageAll() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, SkillUtils.getSkillName(skill)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class ExperienceCommand implements TabExecutor {
|
||||
protected McMMOPlayer mcMMOPlayer;
|
||||
protected Player player;
|
||||
protected PlayerProfile profile;
|
||||
|
||||
protected boolean allSkills;
|
||||
protected SkillType skill;
|
||||
protected int value;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!permissionsCheckSelf(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!validateArguments(sender, args[0], args[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
editValues();
|
||||
allSkills = false;
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
if (!permissionsCheckOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!validateArguments(sender, args[1], args[2])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (CommandUtils.unloadedProfile(sender, profile)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
editValues();
|
||||
profile.save(); // Since this is a temporary profile, we save it here.
|
||||
}
|
||||
else {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
editValues();
|
||||
}
|
||||
|
||||
handleSenderMessage(sender, args[0]);
|
||||
allSkills = false;
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
case 2:
|
||||
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean permissionsCheckSelf(CommandSender sender);
|
||||
protected abstract boolean permissionsCheckOthers(CommandSender sender);
|
||||
protected abstract void handleCommand(SkillType skill);
|
||||
protected abstract void handlePlayerMessageAll();
|
||||
protected abstract void handlePlayerMessageSkill();
|
||||
|
||||
private boolean validateArguments(CommandSender sender, String skillName, String value) {
|
||||
if (isInvalidInteger(sender, value) || isInvalidSkill(sender, skillName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isInvalidInteger(CommandSender sender, String value) {
|
||||
if (CommandUtils.isInvalidInteger(sender, value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
this.value = Integer.parseInt(value);
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isInvalidSkill(CommandSender sender, String skillName) {
|
||||
if (skillName.equalsIgnoreCase("all")) {
|
||||
allSkills = true;
|
||||
return false;
|
||||
}
|
||||
else if (CommandUtils.isInvalidSkill(sender, skillName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
skill = SkillType.getSkill(skillName);
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void handleSenderMessage(CommandSender sender, String playerName) {
|
||||
if (allSkills) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillUtils.getSkillName(skill), playerName));
|
||||
}
|
||||
}
|
||||
|
||||
protected void editValues() {
|
||||
if (allSkills) {
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
handleCommand(skillType);
|
||||
}
|
||||
|
||||
if (player != null) {
|
||||
handlePlayerMessageAll();
|
||||
}
|
||||
}
|
||||
else {
|
||||
handleCommand(skill);
|
||||
|
||||
if (player != null) {
|
||||
handlePlayerMessageSkill();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class MmoeditCommand extends ExperienceCommand {
|
||||
@Override
|
||||
protected boolean permissionsCheckSelf(CommandSender sender) {
|
||||
return Permissions.mmoedit(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean permissionsCheckOthers(CommandSender sender) {
|
||||
return Permissions.mmoeditOthers(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleCommand(SkillType skill) {
|
||||
profile.modifySkill(skill, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageAll() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillUtils.getSkillName(skill), value));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class SkillresetCommand extends ExperienceCommand {
|
||||
private CommandSender sender;
|
||||
private Command command;
|
||||
private int argsLength;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
this.command = command;
|
||||
this.sender = sender;
|
||||
argsLength = args.length;
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.skillreset(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isInvalidSkill(sender, args[0])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
editValues();
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!Permissions.skillresetOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isInvalidSkill(sender, args[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (CommandUtils.unloadedProfile(sender, profile)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
editValues();
|
||||
profile.save(); // Since this is a temporary profile, we save it here.
|
||||
}
|
||||
else {
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
editValues();
|
||||
}
|
||||
|
||||
handleSenderMessage(sender, args[0]);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean permissionsCheckSelf(CommandSender sender) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean permissionsCheckOthers(CommandSender sender) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleCommand(SkillType skill) {
|
||||
if (argsLength == 1 && !Permissions.skillreset(sender, skill) || (argsLength == 2 && !Permissions.skillresetOthers(sender, skill))) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
profile.modifySkill(skill, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageAll() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", SkillUtils.getSkillName(skill)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.gmail.nossr50.commands.hardcore;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class HardcoreCommand extends HardcoreModeCommand {
|
||||
@Override
|
||||
protected void disable() {
|
||||
Config.getInstance().setHardcoreEnabled(false);
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Disabled"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void enable() {
|
||||
Config.getInstance().setHardcoreEnabled(true);
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Enabled"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkTogglePermissions() {
|
||||
return Permissions.hardcoreToggle(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkModifyPermissions() {
|
||||
return Permissions.hardcoreModify(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkEnabled() {
|
||||
return Config.getInstance().getHardcoreEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void modify() {
|
||||
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent);
|
||||
sender.sendMessage(LocaleLoader.getString("Hardcore.PercentageChanged", percent.format(newPercent / 100D)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.gmail.nossr50.commands.hardcore;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class HardcoreModeCommand implements TabExecutor {
|
||||
protected CommandSender sender;
|
||||
protected double newPercent;
|
||||
protected DecimalFormat percent;
|
||||
|
||||
public HardcoreModeCommand() {
|
||||
percent = new DecimalFormat("##0.00%");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
this.sender = sender;
|
||||
|
||||
if (!checkTogglePermissions()) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkEnabled()) {
|
||||
disable();
|
||||
}
|
||||
else {
|
||||
enable();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (CommandUtils.shouldEnableToggle(args[0])) {
|
||||
if (!Permissions.hardcoreToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
enable();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.shouldDisableToggle(args[0])) {
|
||||
if (!Permissions.hardcoreToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
disable();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isInvalidPercentage(sender, args[0])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.hardcoreModify(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
modify();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (StringUtils.isDouble(args[0])) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean checkTogglePermissions();
|
||||
protected abstract boolean checkModifyPermissions();
|
||||
protected abstract boolean checkEnabled();
|
||||
protected abstract void enable();
|
||||
protected abstract void disable();
|
||||
protected abstract void modify();
|
||||
|
||||
private boolean isInvalidPercentage(CommandSender sender, String value) {
|
||||
if (CommandUtils.isInvalidDouble(sender, value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
newPercent = Double.parseDouble(value);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.gmail.nossr50.commands.hardcore;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class VampirismCommand extends HardcoreModeCommand {
|
||||
@Override
|
||||
protected boolean checkTogglePermissions() {
|
||||
return Permissions.vampirismToggle(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkModifyPermissions() {
|
||||
return Permissions.vampirismModify(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkEnabled() {
|
||||
return Config.getInstance().getHardcoreVampirismEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void enable() {
|
||||
Config.getInstance().setHardcoreVampirismEnabled(true);
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Enabled"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disable() {
|
||||
Config.getInstance().setHardcoreVampirismEnabled(false);
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Disabled"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void modify() {
|
||||
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent);
|
||||
sender.sendMessage(LocaleLoader.getString("Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyAcceptCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (!mcMMOPlayer.hasPartyInvite()) {
|
||||
sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Changing parties
|
||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), mcMMOPlayer.getPartyInvite().getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.joinInvitedParty(player, mcMMOPlayer);
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "accept"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyChangeOwnerCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
Party playerParty = UserManager.getPlayer(sender.getName()).getParty();
|
||||
|
||||
if (!playerParty.getMembers().contains(mcMMO.p.getServer().getOfflinePlayer(args[1]))) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.setPartyLeader(args[1], playerParty);
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyChangePasswordCommand implements CommandExecutor {
|
||||
private Party playerParty;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
playerParty = UserManager.getPlayer(sender.getName()).getParty();
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
unprotectParty(sender);
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (args[1].equalsIgnoreCase("clear") || args[1].equalsIgnoreCase("reset")) {
|
||||
unprotectParty(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
protectParty(sender, args[1]);
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "password", "[clear|reset]"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "password", "<" + LocaleLoader.getString("Commands.Usage.Password") + ">"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void unprotectParty(CommandSender sender) {
|
||||
playerParty.setLocked(true);
|
||||
playerParty.setPassword(null);
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Password.Removed"));
|
||||
}
|
||||
|
||||
private void protectParty(CommandSender sender, String password) {
|
||||
playerParty.setLocked(true);
|
||||
playerParty.setPassword(password);
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Password.Set", password));
|
||||
}
|
||||
}
|
||||
234
src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java
Normal file
234
src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java
Normal file
@@ -0,0 +1,234 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.chat.PartyChatCommand;
|
||||
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class PartyCommand implements TabExecutor {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private Player player;
|
||||
|
||||
private static final List<String> PARTY_SUBCOMMANDS;
|
||||
private static final List<String> EXPSHARE_COMPLETIONS = ImmutableList.of("none", "equal");
|
||||
private static final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting");
|
||||
|
||||
static {
|
||||
ArrayList<String> subcommands = new ArrayList<String>();
|
||||
|
||||
for (PartySubcommandType subcommand : PartySubcommandType.values()) {
|
||||
subcommands.add(subcommand.toString());
|
||||
}
|
||||
|
||||
Collections.sort(subcommands);
|
||||
PARTY_SUBCOMMANDS = ImmutableList.copyOf(subcommands);
|
||||
}
|
||||
|
||||
private CommandExecutor partyJoinCommand = new PartyJoinCommand();
|
||||
private CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
|
||||
private CommandExecutor partyCreateCommand = new PartyCreateCommand();
|
||||
private CommandExecutor partyQuitCommand = new PartyQuitCommand();
|
||||
private CommandExecutor partyExpShareCommand = new PartyExpShareCommand();
|
||||
private CommandExecutor partyItemShareCommand = new PartyItemShareCommand();
|
||||
private CommandExecutor partyInviteCommand = new PartyInviteCommand();
|
||||
private CommandExecutor partyKickCommand = new PartyKickCommand();
|
||||
private CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
|
||||
private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand();
|
||||
private CommandExecutor partyLockCommand = new PartyLockCommand();
|
||||
private CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand();
|
||||
private CommandExecutor partyRenameCommand = new PartyRenameCommand();
|
||||
private CommandExecutor partyInfoCommand = new PartyInfoCommand();
|
||||
private CommandExecutor partyHelpCommand = new PartyHelpCommand();
|
||||
private CommandExecutor partyTeleportCommand = mcMMO.p.getCommand("ptp").getExecutor();
|
||||
private CommandExecutor partyChatCommand = new PartyChatCommand();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.party(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (args.length < 1) {
|
||||
if (!mcMMOPlayer.inParty()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return printUsage();
|
||||
}
|
||||
|
||||
return partyInfoCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
|
||||
|
||||
if (subcommand == null) {
|
||||
return printUsage();
|
||||
}
|
||||
|
||||
// Can't use this for lock/unlock since they're handled by the same command
|
||||
if (subcommand != PartySubcommandType.LOCK && subcommand != PartySubcommandType.UNLOCK && !Permissions.partySubcommand(sender, subcommand)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (subcommand) {
|
||||
case JOIN:
|
||||
return partyJoinCommand.onCommand(sender, command, label, args);
|
||||
case ACCEPT:
|
||||
return partyAcceptCommand.onCommand(sender, command, label, args);
|
||||
case CREATE:
|
||||
return partyCreateCommand.onCommand(sender, command, label, args);
|
||||
case HELP:
|
||||
return partyHelpCommand.onCommand(sender, command, label, args);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Party member commands
|
||||
if (!mcMMOPlayer.inParty()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||
return printUsage();
|
||||
}
|
||||
|
||||
switch (subcommand) {
|
||||
case INFO:
|
||||
return partyInfoCommand.onCommand(sender, command, label, args);
|
||||
case QUIT:
|
||||
return partyQuitCommand.onCommand(sender, command, label, args);
|
||||
case INVITE:
|
||||
return partyInviteCommand.onCommand(sender, command, label, args);
|
||||
case TELEPORT:
|
||||
return partyTeleportCommand.onCommand(sender, command, label, extractArgs(args));
|
||||
case CHAT:
|
||||
return partyChatCommand.onCommand(sender, command, label, extractArgs(args));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Party leader commands
|
||||
if (!mcMMOPlayer.getParty().getLeader().equalsIgnoreCase(player.getName())) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (subcommand) {
|
||||
case EXPSHARE:
|
||||
return partyExpShareCommand.onCommand(sender, command, label, args);
|
||||
case ITEMSHARE:
|
||||
return partyItemShareCommand.onCommand(sender, command, label, args);
|
||||
case KICK:
|
||||
return partyKickCommand.onCommand(sender, command, label, args);
|
||||
case DISBAND:
|
||||
return partyDisbandCommand.onCommand(sender, command, label, args);
|
||||
case OWNER:
|
||||
return partyChangeOwnerCommand.onCommand(sender, command, label, args);
|
||||
case LOCK:
|
||||
case UNLOCK:
|
||||
return partyLockCommand.onCommand(sender, command, label, args);
|
||||
case PASSWORD:
|
||||
return partyChangePasswordCommand.onCommand(sender, command, label, args);
|
||||
case RENAME:
|
||||
return partyRenameCommand.onCommand(sender, command, label, args);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], PARTY_SUBCOMMANDS, new ArrayList<String>(PARTY_SUBCOMMANDS.size()));
|
||||
case 2:
|
||||
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
|
||||
|
||||
if (subcommand == null) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
switch (PartySubcommandType.valueOf(args[0].toUpperCase())) {
|
||||
case JOIN:
|
||||
case INVITE:
|
||||
case KICK:
|
||||
case OWNER:
|
||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
||||
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
case EXPSHARE:
|
||||
return StringUtil.copyPartialMatches(args[1], EXPSHARE_COMPLETIONS, new ArrayList<String>(EXPSHARE_COMPLETIONS.size()));
|
||||
case ITEMSHARE:
|
||||
return StringUtil.copyPartialMatches(args[1], ITEMSHARE_COMPLETIONS, new ArrayList<String>(ITEMSHARE_COMPLETIONS.size()));
|
||||
case LOCK:
|
||||
case CHAT:
|
||||
return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
case PASSWORD:
|
||||
return StringUtil.copyPartialMatches(args[1], CommandUtils.RESET_OPTIONS, new ArrayList<String>(CommandUtils.RESET_OPTIONS.size()));
|
||||
case TELEPORT:
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<String>(PtpCommand.TELEPORT_SUBCOMMANDS.size()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
playerNames = UserManager.getPlayers().keySet();
|
||||
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
}
|
||||
|
||||
return matches;
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
case 3:
|
||||
if (PartySubcommandType.getSubcommand(args[0]) == PartySubcommandType.ITEMSHARE && isItemShareCategory(args[1])) {
|
||||
return StringUtil.copyPartialMatches(args[2], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
}
|
||||
|
||||
return ImmutableList.of();
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean printUsage() {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.0", "/party join"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create"));
|
||||
player.sendMessage(LocaleLoader.getString("Party.Help.2", "/party ?"));
|
||||
return true;
|
||||
}
|
||||
|
||||
private String[] extractArgs(String[] args) {
|
||||
String[] newArgs = new String[args.length - 1];
|
||||
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
newArgs[i - 1] = args[i];
|
||||
}
|
||||
|
||||
return newArgs;
|
||||
}
|
||||
|
||||
private boolean isItemShareCategory(String category) {
|
||||
return category.equalsIgnoreCase("loot") || category.equalsIgnoreCase("mining") || category.equalsIgnoreCase("herbalism") || category.equalsIgnoreCase("woodcutting");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyCreateCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
case 3:
|
||||
Party newParty = PartyManager.getParty(args[1]);
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
// Check to see if the party exists, and if it does cancel creating a new party
|
||||
if (PartyManager.checkPartyExistence(player, newParty, args[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Changing parties
|
||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), args[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.createParty(player, mcMMOPlayer, args[1], getPassword(args));
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "create", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private String getPassword(String[] args) {
|
||||
if (args.length == 3) {
|
||||
return args[2];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyDisbandCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Party playerParty = UserManager.getPlayer(sender.getName()).getParty();
|
||||
String partyName = playerParty.getName();
|
||||
|
||||
for (Player member : playerParty.getOnlineMembers()) {
|
||||
if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
member.sendMessage(LocaleLoader.getString("Party.Disband"));
|
||||
}
|
||||
|
||||
PartyManager.disbandParty(playerParty);
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyExpShareCommand implements CommandExecutor {
|
||||
private Party playerParty;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Config.getInstance().getExpShareEnabled()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.ExpShare.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
playerParty = UserManager.getPlayer(sender.getName()).getParty();
|
||||
|
||||
if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) {
|
||||
handleChangingShareMode(ShareMode.NONE);
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) {
|
||||
handleChangingShareMode(ShareMode.EQUAL);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "<NONE | EQUAL>"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "<NONE | EQUAL>"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleChangingShareMode(ShareHandler.ShareMode mode) {
|
||||
playerParty.setXpShareMode(mode);
|
||||
|
||||
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
|
||||
|
||||
for (Player member : playerParty.getOnlineMembers()) {
|
||||
member.sendMessage(changeModeMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class PartyHelpCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.3", "/party join", "/party quit"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.4", "/party <lock|unlock>"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader"));
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband"));
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "help"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,97 +1,113 @@
|
||||
package com.gmail.nossr50.party.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PartyInfoCommand implements CommandExecutor {
|
||||
private Player player;
|
||||
private Party playerParty;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
||||
playerParty = mcMMOPlayer.getParty();
|
||||
|
||||
displayPartyHeader();
|
||||
displayShareModeInfo();
|
||||
displayMemberInfo();
|
||||
return true;
|
||||
}
|
||||
|
||||
private String createMembersList() {
|
||||
StringBuilder memberList = new StringBuilder();
|
||||
|
||||
for (OfflinePlayer member : playerParty.getMembers()) {
|
||||
if (playerParty.getLeader().equals(member.getName())) {
|
||||
memberList.append(ChatColor.GOLD).append(member.getName()).append(" ");
|
||||
}
|
||||
else if (member.isOnline()) {
|
||||
memberList.append(ChatColor.WHITE).append(member.getName()).append(" ");
|
||||
}
|
||||
else {
|
||||
memberList.append(ChatColor.GRAY).append(member.getName()).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
return memberList.toString();
|
||||
}
|
||||
|
||||
private void displayShareModeInfo() {
|
||||
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
|
||||
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
|
||||
|
||||
if (!xpShareEnabled && !itemShareEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
String expShareInfo = "";
|
||||
String itemShareInfo = "";
|
||||
String separator = "";
|
||||
|
||||
if (xpShareEnabled) {
|
||||
expShareInfo = LocaleLoader.getString("Commands.Party.ExpShare", playerParty.getXpShareMode().toString());
|
||||
}
|
||||
|
||||
if (itemShareEnabled) {
|
||||
itemShareInfo = LocaleLoader.getString("Commands.Party.ItemShare", playerParty.getItemShareMode().toString());
|
||||
}
|
||||
|
||||
if (xpShareEnabled && itemShareEnabled) {
|
||||
separator = ChatColor.DARK_GRAY + " || ";
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo);
|
||||
}
|
||||
|
||||
private void displayPartyHeader() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Header"));
|
||||
|
||||
if (playerParty.isLocked()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Locked")));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Unlocked")));
|
||||
}
|
||||
}
|
||||
|
||||
private void displayMemberInfo() {
|
||||
int membersNear = PartyManager.getNearMembers(player, playerParty, Config.getInstance().getPartyShareRange()).size();
|
||||
int membersOnline = playerParty.getOnlineMembers().size() - 1;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", membersNear, membersOnline));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", createMembersList()));
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyInfoCommand implements CommandExecutor {
|
||||
private Player player;
|
||||
private Party playerParty;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
case 1:
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
playerParty = mcMMOPlayer.getParty();
|
||||
|
||||
displayPartyHeader();
|
||||
displayShareModeInfo();
|
||||
displayMemberInfo();
|
||||
return true;
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "info"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private String createMembersList() {
|
||||
StringBuilder memberList = new StringBuilder();
|
||||
|
||||
for (OfflinePlayer member : playerParty.getMembers()) {
|
||||
String memberName = member.getName();
|
||||
|
||||
if (playerParty.getLeader().equalsIgnoreCase(memberName)) {
|
||||
memberList.append(ChatColor.GOLD);
|
||||
}
|
||||
else if (member.isOnline()) {
|
||||
memberList.append(ChatColor.WHITE);
|
||||
}
|
||||
else {
|
||||
memberList.append(ChatColor.GRAY);
|
||||
}
|
||||
|
||||
memberList.append(memberName).append(" ");
|
||||
}
|
||||
|
||||
return memberList.toString();
|
||||
}
|
||||
|
||||
private void displayShareModeInfo() {
|
||||
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
|
||||
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
|
||||
boolean itemSharingActive = (playerParty.getItemShareMode() != ShareHandler.ShareMode.NONE);
|
||||
|
||||
if (!xpShareEnabled && !itemShareEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
String expShareInfo = "";
|
||||
String itemShareInfo = "";
|
||||
String separator = "";
|
||||
|
||||
if (xpShareEnabled) {
|
||||
expShareInfo = LocaleLoader.getString("Commands.Party.ExpShare", playerParty.getXpShareMode().toString());
|
||||
}
|
||||
|
||||
if (itemShareEnabled) {
|
||||
itemShareInfo = LocaleLoader.getString("Commands.Party.ItemShare", playerParty.getItemShareMode().toString());
|
||||
}
|
||||
|
||||
if (xpShareEnabled && itemShareEnabled) {
|
||||
separator = ChatColor.DARK_GRAY + " || ";
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo);
|
||||
if (itemSharingActive) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.ItemShareCategories", playerParty.getItemShareCategories()));
|
||||
}
|
||||
}
|
||||
|
||||
private void displayPartyHeader() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Header"));
|
||||
|
||||
if (playerParty.isLocked()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Locked")));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Unlocked")));
|
||||
}
|
||||
}
|
||||
|
||||
private void displayMemberInfo() {
|
||||
int membersNear = PartyManager.getNearMembers(player, playerParty, Config.getInstance().getPartyShareRange()).size();
|
||||
int membersOnline = playerParty.getOnlineMembers().size() - 1;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", membersNear, membersOnline));
|
||||
player.sendMessage(createMembersList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyInviteCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
McMMOPlayer mcMMOTarget = UserManager.getPlayer(args[1]);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, args[1], mcMMOTarget)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player target = mcMMOTarget.getPlayer();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (player.equals(target)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PartyManager.inSameParty(player, target)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
Party playerParty = mcMMOPlayer.getParty();
|
||||
|
||||
if (!PartyManager.canInvite(player, playerParty)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOTarget.setPartyInvite(playerParty);
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), player.getName()));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.ShareHandler;
|
||||
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyItemShareCommand implements CommandExecutor {
|
||||
private Party playerParty;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Config.getInstance().getItemShareEnabled()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.ItemShare.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
playerParty = UserManager.getPlayer(sender.getName()).getParty();
|
||||
|
||||
if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) {
|
||||
handleChangingShareMode(ShareMode.NONE);
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even")) {
|
||||
handleChangingShareMode(ShareMode.EQUAL);
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("random")) {
|
||||
handleChangingShareMode(ShareMode.RANDOM);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
playerParty = UserManager.getPlayer(sender.getName()).getParty();
|
||||
boolean toggle = false;
|
||||
|
||||
if (CommandUtils.shouldEnableToggle(args[2])) {
|
||||
toggle = true;
|
||||
}
|
||||
else if (CommandUtils.shouldDisableToggle(args[2])) {
|
||||
toggle = false;
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting> <true | false>"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("loot")) {
|
||||
playerParty.setSharingLootDrops(toggle);
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("mining")) {
|
||||
playerParty.setSharingMiningDrops(toggle);
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("herbalism")) {
|
||||
playerParty.setSharingHerbalismDrops(toggle);
|
||||
}
|
||||
else if (args[1].equalsIgnoreCase("woodcutting")) {
|
||||
playerParty.setSharingWoodcuttingDrops(toggle);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting> <true | false>"));
|
||||
}
|
||||
|
||||
notifyToggleItemShareCategory(args[1], toggle);
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting> <true | false>"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleChangingShareMode(ShareHandler.ShareMode mode) {
|
||||
playerParty.setItemShareMode(mode);
|
||||
|
||||
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
|
||||
|
||||
for (Player member : playerParty.getOnlineMembers()) {
|
||||
member.sendMessage(changeModeMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyToggleItemShareCategory(String category, boolean toggle) {
|
||||
String state = toggle ? "enabled" : "disabled";
|
||||
|
||||
String toggleMessage = LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(category), state);
|
||||
|
||||
for (Player member : playerParty.getOnlineMembers()) {
|
||||
member.sendMessage(toggleMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyJoinCommand implements CommandExecutor {
|
||||
private McMMOPlayer mcMMOTarget;
|
||||
private Player target;
|
||||
private Party targetParty;
|
||||
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private Player player;
|
||||
private Party playerParty;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
case 3:
|
||||
// Verify target exists and is in a different party than the player
|
||||
if (!canJoinParty(sender, args[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
String password = getPassword(args);
|
||||
|
||||
// Make sure party passwords match
|
||||
if (!PartyManager.checkPartyPassword(player, targetParty, password)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Changing parties
|
||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, playerParty, targetParty.getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.joinParty(player, mcMMOPlayer, targetParty, password);
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "join", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private String getPassword(String[] args) {
|
||||
if (args.length == 3) {
|
||||
return args[2];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean canJoinParty(CommandSender sender, String targetName) {
|
||||
mcMMOTarget = UserManager.getPlayer(targetName);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
target = mcMMOTarget.getPlayer();
|
||||
|
||||
if (!mcMMOTarget.inParty()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
|
||||
return false;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
playerParty = mcMMOPlayer.getParty();
|
||||
targetParty = mcMMOTarget.getParty();
|
||||
|
||||
if (player.equals(target) || (mcMMOPlayer.inParty() && playerParty.equals(targetParty))) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyKickCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
Party playerParty = UserManager.getPlayer(sender.getName()).getParty();
|
||||
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]);
|
||||
|
||||
if (!playerParty.getMembers().contains(target)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target.isOnline()) {
|
||||
Player onlineTarget = target.getPlayer();
|
||||
String partyName = playerParty.getName();
|
||||
|
||||
if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
|
||||
}
|
||||
|
||||
PartyManager.removeFromParty(target, playerParty);
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyLockCommand implements CommandExecutor {
|
||||
private Party playerParty;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
playerParty = UserManager.getPlayer(sender.getName()).getParty();
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("lock")) {
|
||||
lockParty(sender, command.getPermissionMessage());
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("unlock")) {
|
||||
unlockParty(sender, command.getPermissionMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!args[0].equalsIgnoreCase("lock")) {
|
||||
sendUsageStrings(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.shouldEnableToggle(args[1])) {
|
||||
lockParty(sender, command.getPermissionMessage());
|
||||
}
|
||||
else if (CommandUtils.shouldDisableToggle(args[1])) {
|
||||
unlockParty(sender, command.getPermissionMessage());
|
||||
}
|
||||
else {
|
||||
sendUsageStrings(sender);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sendUsageStrings(sender);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle locking a party.
|
||||
*/
|
||||
private void lockParty(CommandSender sender, String permissionMessage) {
|
||||
if (!Permissions.partySubcommand(sender, PartySubcommandType.LOCK)) {
|
||||
sender.sendMessage(permissionMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerParty.isLocked()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.IsLocked"));
|
||||
return;
|
||||
}
|
||||
|
||||
playerParty.setLocked(true);
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle unlocking a party.
|
||||
*
|
||||
* @return true if party is successfully unlocked, false otherwise.
|
||||
*/
|
||||
private void unlockParty(CommandSender sender, String permissionMessage) {
|
||||
if (!Permissions.partySubcommand(sender, PartySubcommandType.UNLOCK)) {
|
||||
sender.sendMessage(permissionMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playerParty.isLocked()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.IsntLocked"));
|
||||
return;
|
||||
}
|
||||
|
||||
playerParty.setLocked(false);
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Unlocked"));
|
||||
}
|
||||
|
||||
private void sendUsageStrings(CommandSender sender) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "unlock"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyQuitCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Player player = (Player) sender;
|
||||
Party playerParty = UserManager.getPlayer(player).getParty();
|
||||
|
||||
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.removeFromParty(player, playerParty);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "quit"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PartyRenameCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Party playerParty = mcMMOPlayer.getParty();
|
||||
|
||||
String oldPartyName = playerParty.getName();
|
||||
String newPartyName = args[1];
|
||||
|
||||
// This is to prevent party leaders from spamming other players with the rename message
|
||||
if (oldPartyName.equalsIgnoreCase(newPartyName)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Rename.Same"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
Party newParty = PartyManager.getParty(newPartyName);
|
||||
|
||||
// Check to see if the party exists, and if it does cancel renaming the party
|
||||
if (PartyManager.checkPartyExistence(player, newParty, newPartyName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String leaderName = playerParty.getLeader();
|
||||
|
||||
for (Player member : playerParty.getOnlineMembers()) {
|
||||
if (!PartyManager.handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!member.getName().equalsIgnoreCase(leaderName)) {
|
||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName));
|
||||
}
|
||||
}
|
||||
|
||||
playerParty.setName(newPartyName);
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Rename", newPartyName));
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +1,48 @@
|
||||
package com.gmail.nossr50.party.commands;
|
||||
|
||||
public enum PartySubcommandType {
|
||||
JOIN,
|
||||
ACCEPT,
|
||||
CREATE,
|
||||
HELP,
|
||||
INFO,
|
||||
QUIT,
|
||||
EXPSHARE,
|
||||
ITEMSHARE,
|
||||
INVITE,
|
||||
KICK,
|
||||
DISBAND,
|
||||
OWNER,
|
||||
LOCK,
|
||||
UNLOCK,
|
||||
PASSWORD,
|
||||
RENAME,
|
||||
TELEPORT,
|
||||
CHAT;
|
||||
|
||||
public static PartySubcommandType getSubcommand(String commandName) {
|
||||
for (PartySubcommandType command : values()) {
|
||||
if (command.name().equalsIgnoreCase(commandName)) {
|
||||
return command;
|
||||
}
|
||||
}
|
||||
|
||||
if (commandName.equalsIgnoreCase("?")) {
|
||||
return HELP;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
|
||||
return QUIT;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
|
||||
return EXPSHARE;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) {
|
||||
return ITEMSHARE;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.commands.party;
|
||||
|
||||
public enum PartySubcommandType {
|
||||
JOIN,
|
||||
ACCEPT,
|
||||
CREATE,
|
||||
HELP,
|
||||
INFO,
|
||||
QUIT,
|
||||
EXPSHARE,
|
||||
ITEMSHARE,
|
||||
INVITE,
|
||||
KICK,
|
||||
DISBAND,
|
||||
OWNER,
|
||||
LOCK,
|
||||
UNLOCK,
|
||||
PASSWORD,
|
||||
RENAME,
|
||||
TELEPORT,
|
||||
CHAT;
|
||||
|
||||
public static PartySubcommandType getSubcommand(String commandName) {
|
||||
for (PartySubcommandType command : values()) {
|
||||
if (command.name().equalsIgnoreCase(commandName)) {
|
||||
return command;
|
||||
}
|
||||
}
|
||||
|
||||
if (commandName.equalsIgnoreCase("?")) {
|
||||
return HELP;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
|
||||
return QUIT;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("leader")) {
|
||||
return OWNER;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
|
||||
return EXPSHARE;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) {
|
||||
return ITEMSHARE;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.gmail.nossr50.commands.party.teleport;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PtpAcceptAnyCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Permissions.partyTeleportAcceptAll(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (mcMMOPlayer.getPtpConfirmRequired()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled"));
|
||||
}
|
||||
|
||||
mcMMOPlayer.togglePtpConfirmRequired();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.gmail.nossr50.commands.party.teleport;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PtpAcceptCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Permissions.partyTeleportAccept(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (!mcMMOPlayer.hasPtpRequest()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((mcMMOPlayer.getPtpTimeout() + Config.getInstance().getPTPCommandTimeout()) * Misc.TIME_CONVERSION_FACTOR < System.currentTimeMillis()) {
|
||||
mcMMOPlayer.removePtpRequest();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = mcMMOPlayer.getPtpRequest();
|
||||
mcMMOPlayer.removePtpRequest();
|
||||
|
||||
if (!PtpCommand.canTeleport(sender, player, target.getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getPTPCommandWorldPermissions()) {
|
||||
World targetWorld = target.getWorld();
|
||||
World playerWorld = player.getWorld();
|
||||
|
||||
if (!Permissions.partyTeleportAllWorlds(target)) {
|
||||
if (!Permissions.partyTeleportWorld(target, targetWorld)) {
|
||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName()));
|
||||
return true;
|
||||
}
|
||||
else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(target, playerWorld)) {
|
||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", playerWorld.getName()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PtpCommand.handleTeleportWarmup(target, player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.gmail.nossr50.commands.party.teleport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.items.TeleportationWarmup;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class PtpCommand implements TabExecutor {
|
||||
private static Player target;
|
||||
private static McMMOPlayer mcMMOTarget;
|
||||
|
||||
public static final List<String> TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall");
|
||||
|
||||
private CommandExecutor ptpToggleCommand = new PtpToggleCommand();
|
||||
private CommandExecutor ptpAcceptAnyCommand = new PtpAcceptAnyCommand();
|
||||
private CommandExecutor ptpAcceptCommand = new PtpAcceptCommand();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("toggle")) {
|
||||
return ptpToggleCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) {
|
||||
return ptpAcceptAnyCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
|
||||
int recentlyhurt_cooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
|
||||
|
||||
if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("accept")) {
|
||||
return ptpAcceptCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
if (!Permissions.partyTeleportSend(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
|
||||
long lastTeleport = mcMMOPlayer.getLastTeleport();
|
||||
|
||||
if (!SkillUtils.cooldownOver(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player)) {
|
||||
player.sendMessage(ChatColor.RED + "You need to wait before you can use this again! " + ChatColor.YELLOW + "(" + SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player) + ")"); //TODO Locale!
|
||||
return true;
|
||||
}
|
||||
|
||||
sendTeleportRequest(sender, player, args[0]);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<String>(TELEPORT_SUBCOMMANDS.size()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
}
|
||||
|
||||
return matches;
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendTeleportRequest(CommandSender sender, Player player, String targetName) {
|
||||
if (!canTeleport(sender, player, targetName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mcMMOTarget.getPtpConfirmRequired()) {
|
||||
handleTeleportWarmup(player, target);
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMOTarget.setPtpRequest(player);
|
||||
mcMMOTarget.actualizePtpTimeout();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||
|
||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName()));
|
||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", Config.getInstance().getPTPCommandTimeout()));
|
||||
}
|
||||
|
||||
protected static boolean canTeleport(CommandSender sender, Player player, String targetName) {
|
||||
mcMMOTarget = UserManager.getPlayer(targetName);
|
||||
|
||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
target = mcMMOTarget.getPlayer();
|
||||
targetName = target.getName();
|
||||
|
||||
if (player.equals(target)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!PartyManager.inSameParty(player, target)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mcMMOTarget.getPtpEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", targetName));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!target.isValid()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
|
||||
mcMMOTarget = UserManager.getPlayer(targetPlayer);
|
||||
|
||||
long warmup = Config.getInstance().getPTPCommandWarmup();
|
||||
|
||||
mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer);
|
||||
|
||||
if (warmup > 0) {
|
||||
teleportingPlayer.sendMessage(ChatColor.GRAY + "Commencing teleport in " + ChatColor.GOLD + "(" + warmup + ")" + ChatColor.GRAY + " seconds, please stand still..."); //TODO Locale!
|
||||
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
|
||||
}
|
||||
else {
|
||||
handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(teleportingPlayer, targetPlayer, mcMMOPlayer.getParty().getName());
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
teleportingPlayer.teleport(targetPlayer);
|
||||
|
||||
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName()));
|
||||
targetPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName()));
|
||||
|
||||
mcMMOPlayer.actualizeRecentlyHurt();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.gmail.nossr50.commands.party.teleport;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class PtpToggleCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!Permissions.partyTeleportToggle(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (mcMMOPlayer.getPtpEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled"));
|
||||
}
|
||||
|
||||
mcMMOPlayer.togglePtpUse();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,90 +1,89 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class InspectCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class InspectCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (!sender.hasPermission("mcmmo.commands.inspect")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
case 1:
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
PlayerProfile profile = new PlayerProfile(args[0], false); // Temporary Profile
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false); //Temporary Profile
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && !sender.hasPermission("mcmmo.commands.inspect.offline")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", args[0]));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING)));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED)));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS)));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR)));
|
||||
}
|
||||
else {
|
||||
Player target = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player inspector = (Player) sender;
|
||||
|
||||
if (!Misc.isNear(inspector.getLocation(), target.getLocation(), 5.0) && !inspector.hasPermission("mcmmo.commands.inspect.far")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
||||
if (CommandUtils.inspectOffline(sender, profile, Permissions.inspectOffline(sender))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", args[0]));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.EXCAVATION);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.FISHING);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.HERBALISM);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.MINING);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.WOODCUTTING);
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.AXES);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.ARCHERY);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.SWORDS);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.TAMING);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.UNARMED);
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.ACROBATICS);
|
||||
CommandUtils.displaySkill(sender, profile, SkillType.REPAIR);
|
||||
}
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
else {
|
||||
Player target = mcMMOPlayer.getPlayer();
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
||||
CommandHelper.printGatheringSkills(target, profile, sender);
|
||||
CommandHelper.printCombatSkills(target, profile, sender);
|
||||
CommandHelper.printMiscSkills(target, profile, sender);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
|
||||
}
|
||||
if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
||||
CommandUtils.printGatheringSkills(target, sender);
|
||||
CommandUtils.printCombatSkills(target, sender);
|
||||
CommandUtils.printMiscSkills(target, sender);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McabilityCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcability")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
profile = Users.getPlayer((Player) sender).getProfile();
|
||||
|
||||
if (profile.getAbilityUse()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
}
|
||||
|
||||
profile.toggleAbilityUse();
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcability.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (!player.isOnline()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getAbilityUse()) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
}
|
||||
|
||||
profile.toggleAbilityUse();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,113 +1,120 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Leaderboard;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.database.LeaderboardManager;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.McRankAsync;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class McrankCommand implements CommandExecutor {
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McrankCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcrank")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
case 0:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
if (!Permissions.mcrank(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
sqlDisplay(sender, sender.getName());
|
||||
}
|
||||
else {
|
||||
flatfileDisplay(sender, sender.getName());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!Permissions.mcrankOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = args[0];
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
|
||||
|
||||
if (mcMMOPlayer != null) {
|
||||
playerName = mcMMOPlayer.getPlayer().getName();
|
||||
|
||||
if (CommandUtils.tooFar(sender, mcMMOPlayer.getPlayer(), Permissions.mcrankFar(sender))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
} else if (CommandUtils.inspectOffline(sender, new PlayerProfile(playerName, false), Permissions.mcrankOffline(sender))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
sqlDisplay(sender, playerName);
|
||||
}
|
||||
else {
|
||||
flatfileDisplay(sender, playerName);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
sqlDisplay(sender, sender.getName());
|
||||
}
|
||||
else {
|
||||
Leaderboard.updateLeaderboards(); // Make sure the information is up to date
|
||||
flatfileDisplay(sender, sender.getName());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (!sender.hasPermission("mcmmo.commands.mcrank.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
PlayerProfile profile = new PlayerProfile(args[0], false); //Temporary Profile
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && !!sender.hasPermission("mcmmo.commands.mcrank.others.offline")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Player target = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !sender.hasPermission("mcmmo.commands.mcrank.others.far")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
sqlDisplay(sender, args[0]);
|
||||
}
|
||||
else {
|
||||
Leaderboard.updateLeaderboards(); // Make sure the information is up to date
|
||||
flatfileDisplay(sender, args[0]);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Set<String> playerNames = UserManager.getPlayers().keySet();
|
||||
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
private void flatfileDisplay(CommandSender sender, String playerName) {
|
||||
LeaderboardManager.updateLeaderboards(); // Make sure the information is up to date
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
||||
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
int[] rankInts = Leaderboard.getPlayerRank(playerName, skillType);
|
||||
int[] rankInts = LeaderboardManager.getPlayerRank(playerName, skillType);
|
||||
|
||||
if (skillType.isChildSkill()) {
|
||||
if (!Permissions.skillEnabled(sender, skillType) || skillType.isChildSkill()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rankInts[1] == 0) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.getSkillName(skillType), rankInts[0]));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skillType), rankInts[0]));
|
||||
}
|
||||
}
|
||||
|
||||
// Show the powerlevel ranking
|
||||
int[] rankInts = Leaderboard.getPlayerRank(playerName);
|
||||
int[] rankInts = LeaderboardManager.getPlayerRank(playerName);
|
||||
|
||||
if (rankInts[1] == 0) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
|
||||
@@ -118,6 +125,6 @@ public class McrankCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void sqlDisplay(CommandSender sender, String playerName) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new McRankAsync(playerName, sender));
|
||||
new McrankCommandAsyncTask(playerName, sender).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +1,57 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McstatsCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
|
||||
CommandHelper.printGatheringSkills(player, profile);
|
||||
CommandHelper.printCombatSkills(player, profile);
|
||||
CommandHelper.printMiscSkills(player, profile);
|
||||
|
||||
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
||||
|
||||
if (powerLevelCap != Integer.MAX_VALUE) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", mcMMOPlayer.getPowerLevel(), powerLevelCap));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class McstatsCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
|
||||
CommandUtils.printGatheringSkills(player);
|
||||
CommandUtils.printCombatSkills(player);
|
||||
CommandUtils.printMiscSkills(player);
|
||||
|
||||
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
||||
|
||||
if (powerLevelCap != Integer.MAX_VALUE) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,114 +1,146 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.Leaderboard;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.McTopAsync;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class MctopCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
boolean useMySQL = Config.getInstance().getUseMySQL();
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
display(1, "ALL", sender, useMySQL, command);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (StringUtils.isInt(args[0])) {
|
||||
display(Integer.parseInt(args[0]), "ALL", sender, useMySQL, command);
|
||||
}
|
||||
else if (SkillTools.isSkill(args[0])) {
|
||||
display(1, SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (!StringUtils.isInt(args[1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (SkillTools.isSkill(args[0])) {
|
||||
display(Integer.parseInt(args[1]), SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void display(int page, String skill, CommandSender sender, boolean sql, Command command) {
|
||||
if (sql) {
|
||||
if (skill.equalsIgnoreCase("all")) {
|
||||
sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender, command);
|
||||
}
|
||||
else {
|
||||
sqlDisplay(page, skill, sender, command);
|
||||
}
|
||||
}
|
||||
else {
|
||||
flatfileDisplay(page, skill, sender, command);
|
||||
}
|
||||
}
|
||||
|
||||
private void flatfileDisplay(int page, String skill, CommandSender sender, Command command) {
|
||||
if (!skill.equalsIgnoreCase("all") && !sender.hasPermission("mcmmo.commands.mctop." + skill.toLowerCase())) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
Leaderboard.updateLeaderboards(); //Make sure we have the latest information
|
||||
|
||||
String[] info = Leaderboard.retrieveInfo(skill, page);
|
||||
|
||||
if (skill.equalsIgnoreCase("all")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(skill)));
|
||||
}
|
||||
|
||||
int n = (page * 10) - 9; // Position
|
||||
for (String x : info) {
|
||||
if (x != null) {
|
||||
String digit = String.valueOf(n);
|
||||
|
||||
if (n < 10) {
|
||||
digit = "0" + digit;
|
||||
}
|
||||
|
||||
String[] splitx = x.split(":");
|
||||
|
||||
// Format: 1. Playername - skill value
|
||||
sender.sendMessage(digit + ". " + ChatColor.GREEN + splitx[1] + " - " + ChatColor.WHITE + splitx[0]);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||
}
|
||||
|
||||
private void sqlDisplay(int page, String query, CommandSender sender, Command command) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new McTopAsync(page, query, sender, command));
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.database.LeaderboardManager;
|
||||
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.google.common.collect.ImmutableList;
|
||||
|
||||
public class MctopCommand implements TabExecutor {
|
||||
private SkillType skill;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
boolean useMySQL = Config.getInstance().getUseMySQL();
|
||||
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
display(1, "ALL", sender, useMySQL, command);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (StringUtils.isInt(args[0])) {
|
||||
display(Math.abs(Integer.parseInt(args[0])), "ALL", sender, useMySQL, command);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!extractSkill(sender, args[0])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
display(1, skill.toString(), sender, useMySQL, command);
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (CommandUtils.isInvalidInteger(sender, args[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!extractSkill(sender, args[0])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
display(Math.abs(Integer.parseInt(args[1])), skill.toString(), sender, useMySQL, command);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
private void display(int page, String skill, CommandSender sender, boolean sql, Command command) {
|
||||
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, this.skill)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (sql) {
|
||||
if (skill.equalsIgnoreCase("all")) {
|
||||
sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender);
|
||||
}
|
||||
else {
|
||||
sqlDisplay(page, skill, sender);
|
||||
}
|
||||
}
|
||||
else {
|
||||
flatfileDisplay(page, skill, sender);
|
||||
}
|
||||
}
|
||||
|
||||
private void flatfileDisplay(int page, String skill, CommandSender sender) {
|
||||
LeaderboardManager.updateLeaderboards(); // Make sure we have the latest information
|
||||
|
||||
if (skill.equalsIgnoreCase("all")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(skill)));
|
||||
}
|
||||
|
||||
int position = (page * 10) - 9;
|
||||
|
||||
for (String playerStat : LeaderboardManager.retrieveInfo(skill, page)) {
|
||||
if (playerStat == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String digit = String.valueOf(position);
|
||||
|
||||
if (position < 10) {
|
||||
digit = "0" + digit;
|
||||
}
|
||||
|
||||
String[] splitStat = playerStat.split(":");
|
||||
|
||||
// Format: 1. Playername - skill value
|
||||
sender.sendMessage(digit + ". " + ChatColor.GREEN + splitStat[1] + " - " + ChatColor.WHITE + splitStat[0]);
|
||||
position++;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||
}
|
||||
|
||||
private void sqlDisplay(int page, String query, CommandSender sender) {
|
||||
new MctopCommandAsyncTask(page, query, sender).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
|
||||
private boolean extractSkill(CommandSender sender, String skillName) {
|
||||
if (CommandUtils.isInvalidSkill(sender, skillName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
skill = SkillType.getSkill(skillName);
|
||||
|
||||
if (CommandUtils.isChildSkill(sender, skill)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.acrobatics.Acrobatics;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class AcrobaticsCommand extends SkillCommand {
|
||||
private String dodgeChance;
|
||||
private String dodgeChanceLucky;
|
||||
private String rollChance;
|
||||
private String rollChanceLucky;
|
||||
private String gracefulRollChance;
|
||||
private String gracefulRollChanceLucky;
|
||||
|
||||
private boolean canDodge;
|
||||
private boolean canRoll;
|
||||
private boolean canGracefulRoll;
|
||||
|
||||
public AcrobaticsCommand() {
|
||||
super(SkillType.ACROBATICS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// DODGE
|
||||
if (canDodge) {
|
||||
String[] dodgeStrings = calculateAbilityDisplayValues(Acrobatics.dodgeMaxBonusLevel, Acrobatics.dodgeMaxChance);
|
||||
dodgeChance = dodgeStrings[0];
|
||||
dodgeChanceLucky = dodgeStrings[1];
|
||||
}
|
||||
|
||||
// ROLL
|
||||
if (canRoll) {
|
||||
String[] rollStrings = calculateAbilityDisplayValues(Acrobatics.rollMaxBonusLevel, Acrobatics.rollMaxChance);
|
||||
rollChance = rollStrings[0];
|
||||
rollChanceLucky = rollStrings[1];
|
||||
}
|
||||
|
||||
// GRACEFUL ROLL
|
||||
if (canGracefulRoll) {
|
||||
String[] gracefulRollStrings = calculateAbilityDisplayValues(Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollMaxChance);
|
||||
gracefulRollChance = gracefulRollStrings[0];
|
||||
gracefulRollChanceLucky = gracefulRollStrings[1];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canDodge = Permissions.dodge(player);
|
||||
canRoll = Permissions.roll(player);
|
||||
canGracefulRoll = Permissions.gracefulRoll(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canDodge || canGracefulRoll || canRoll;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canRoll) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1")));
|
||||
}
|
||||
|
||||
if (canGracefulRoll) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3")));
|
||||
}
|
||||
|
||||
if (canDodge) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canDodge || canGracefulRoll || canRoll;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canRoll) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", rollChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canGracefulRoll) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", gracefulRollChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canDodge) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", dodgeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", dodgeChanceLucky) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,104 +1,94 @@
|
||||
package com.gmail.nossr50.skills.archery;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillCommand;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class ArcheryCommand extends SkillCommand {
|
||||
private String skillShotBonus;
|
||||
private String dazeChance;
|
||||
private String dazeChanceLucky;
|
||||
private String retrieveChance;
|
||||
private String retrieveChanceLucky;
|
||||
|
||||
private boolean canSkillShot;
|
||||
private boolean canDaze;
|
||||
private boolean canRetrieve;
|
||||
|
||||
public ArcheryCommand() {
|
||||
super(SkillType.ARCHERY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
//SKILL SHOT
|
||||
double bonus = (skillValue / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage;
|
||||
|
||||
if (bonus > Archery.skillShotMaxBonusPercentage) {
|
||||
skillShotBonus = percent.format(Archery.skillShotMaxBonusPercentage);
|
||||
}
|
||||
else {
|
||||
skillShotBonus = percent.format(bonus);
|
||||
}
|
||||
|
||||
//DAZE
|
||||
String[] dazeStrings = calculateAbilityDisplayValues(Archery.dazeMaxBonusLevel, Archery.dazeMaxBonus);
|
||||
dazeChance = dazeStrings[0];
|
||||
dazeChanceLucky = dazeStrings[1];
|
||||
|
||||
//RETRIEVE
|
||||
String[] retrieveStrings = calculateAbilityDisplayValues(Archery.retrieveMaxBonusLevel, Archery.retrieveMaxChance);
|
||||
retrieveChance = retrieveStrings[0];
|
||||
retrieveChanceLucky = retrieveStrings[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canSkillShot = Permissions.archeryBonus(player);
|
||||
canDaze = Permissions.daze(player);
|
||||
canRetrieve = Permissions.trackArrows(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canSkillShot || canDaze || canRetrieve;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canSkillShot) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1")));
|
||||
}
|
||||
|
||||
if (canDaze) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeModifier)));
|
||||
}
|
||||
|
||||
if (canRetrieve) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canSkillShot || canDaze || canRetrieve;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canSkillShot) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", skillShotBonus));
|
||||
}
|
||||
|
||||
if (canDaze) {
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + LocaleLoader.getString("Perks.lucky.bonus", dazeChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance));
|
||||
}
|
||||
}
|
||||
|
||||
if (canRetrieve) {
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + LocaleLoader.getString("Perks.lucky.bonus", retrieveChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.archery.Archery;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class ArcheryCommand extends SkillCommand {
|
||||
private String skillShotBonus;
|
||||
private String dazeChance;
|
||||
private String dazeChanceLucky;
|
||||
private String retrieveChance;
|
||||
private String retrieveChanceLucky;
|
||||
|
||||
private boolean canSkillShot;
|
||||
private boolean canDaze;
|
||||
private boolean canRetrieve;
|
||||
|
||||
public ArcheryCommand() {
|
||||
super(SkillType.ARCHERY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// SKILL SHOT
|
||||
if (canSkillShot) {
|
||||
double bonus = (skillValue / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage;
|
||||
skillShotBonus = percent.format(Math.min(bonus, Archery.skillShotMaxBonusPercentage));
|
||||
}
|
||||
|
||||
// DAZE
|
||||
if (canDaze) {
|
||||
String[] dazeStrings = calculateAbilityDisplayValues(Archery.dazeMaxBonusLevel, Archery.dazeMaxBonus);
|
||||
dazeChance = dazeStrings[0];
|
||||
dazeChanceLucky = dazeStrings[1];
|
||||
}
|
||||
|
||||
// RETRIEVE
|
||||
if (canRetrieve) {
|
||||
String[] retrieveStrings = calculateAbilityDisplayValues(Archery.retrieveMaxBonusLevel, Archery.retrieveMaxChance);
|
||||
retrieveChance = retrieveStrings[0];
|
||||
retrieveChanceLucky = retrieveStrings[1];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canSkillShot = Permissions.bonusDamage(player, skill);
|
||||
canDaze = Permissions.daze(player);
|
||||
canRetrieve = Permissions.arrowRetrieval(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canSkillShot || canDaze || canRetrieve;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canSkillShot) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1")));
|
||||
}
|
||||
|
||||
if (canDaze) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeModifier)));
|
||||
}
|
||||
|
||||
if (canRetrieve) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canSkillShot || canDaze || canRetrieve;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canSkillShot) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", skillShotBonus));
|
||||
}
|
||||
|
||||
if (canDaze) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", dazeChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canRetrieve) {
|
||||
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", retrieveChanceLucky) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,128 +1,119 @@
|
||||
package com.gmail.nossr50.skills.axes;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillCommand;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class AxesCommand extends SkillCommand {
|
||||
private String critChance;
|
||||
private String critChanceLucky;
|
||||
private String bonusDamage;
|
||||
private String impactDamage;
|
||||
private String greaterImpactDamage;
|
||||
private String skullSplitterLength;
|
||||
private String skullSplitterLengthEndurance;
|
||||
|
||||
private boolean canSkullSplitter;
|
||||
private boolean canCritical;
|
||||
private boolean canBonusDamage;
|
||||
private boolean canImpact;
|
||||
private boolean canGreaterImpact;
|
||||
|
||||
public AxesCommand() {
|
||||
super(SkillType.AXES);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
//IMPACT
|
||||
impactDamage = String.valueOf(1 + (skillValue / Axes.impactIncreaseLevel));
|
||||
greaterImpactDamage = String.valueOf(Axes.greaterImpactBonusDamage);
|
||||
|
||||
//SKULL SPLITTER
|
||||
String[] skullSplitterStrings = calculateLengthDisplayValues();
|
||||
skullSplitterLength = skullSplitterStrings[0];
|
||||
skullSplitterLengthEndurance = skullSplitterStrings[1];
|
||||
|
||||
//CRITICAL STRIKES
|
||||
String[] criticalStrikeStrings = calculateAbilityDisplayValues(Axes.criticalHitMaxBonusLevel, Axes.criticalHitMaxChance);
|
||||
critChance = criticalStrikeStrings[0];
|
||||
critChanceLucky = criticalStrikeStrings[1];
|
||||
|
||||
//AXE MASTERY
|
||||
if (skillValue >= Axes.bonusDamageMaxBonusLevel) {
|
||||
bonusDamage = String.valueOf(Axes.bonusDamageMaxBonus);
|
||||
}
|
||||
else {
|
||||
bonusDamage = String.valueOf(skillValue / (Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canSkullSplitter = Permissions.skullSplitter(player);
|
||||
canCritical = Permissions.criticalHit(player);
|
||||
canBonusDamage = Permissions.axeBonus(player);
|
||||
canImpact = Permissions.impact(player);
|
||||
canGreaterImpact = Permissions.greaterImpact(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canSkullSplitter) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1")));
|
||||
}
|
||||
|
||||
if (canCritical) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3")));
|
||||
}
|
||||
|
||||
if (canBonusDamage) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5")));
|
||||
}
|
||||
|
||||
if (canImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7")));
|
||||
}
|
||||
|
||||
if (canGreaterImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canBonusDamage) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", bonusDamage)));
|
||||
}
|
||||
|
||||
if (canImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage)));
|
||||
}
|
||||
|
||||
if (canGreaterImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", greaterImpactDamage)));
|
||||
}
|
||||
|
||||
if (canCritical) {
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + LocaleLoader.getString("Perks.lucky.bonus", critChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance));
|
||||
}
|
||||
}
|
||||
|
||||
if (canSkullSplitter) {
|
||||
if (hasEndurance) {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + LocaleLoader.getString("Perks.activationtime.bonus", skullSplitterLengthEndurance));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.axes.Axes;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class AxesCommand extends SkillCommand {
|
||||
private String critChance;
|
||||
private String critChanceLucky;
|
||||
private float bonusDamage;
|
||||
private float impactDamage;
|
||||
private String skullSplitterLength;
|
||||
private String skullSplitterLengthEndurance;
|
||||
|
||||
private boolean canSkullSplitter;
|
||||
private boolean canCritical;
|
||||
private boolean canBonusDamage;
|
||||
private boolean canImpact;
|
||||
private boolean canGreaterImpact;
|
||||
|
||||
public AxesCommand() {
|
||||
super(SkillType.AXES);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// IMPACT
|
||||
if (canImpact) {
|
||||
impactDamage = 1 + (skillValue / Axes.impactIncreaseLevel);
|
||||
}
|
||||
|
||||
// SKULL SPLITTER
|
||||
if (canSkullSplitter) {
|
||||
String[] skullSplitterStrings = calculateLengthDisplayValues();
|
||||
skullSplitterLength = skullSplitterStrings[0];
|
||||
skullSplitterLengthEndurance = skullSplitterStrings[1];
|
||||
}
|
||||
|
||||
// CRITICAL STRIKES
|
||||
if (canCritical) {
|
||||
String[] criticalStrikeStrings = calculateAbilityDisplayValues(Axes.criticalHitMaxBonusLevel, Axes.criticalHitMaxChance);
|
||||
critChance = criticalStrikeStrings[0];
|
||||
critChanceLucky = criticalStrikeStrings[1];
|
||||
}
|
||||
|
||||
// AXE MASTERY
|
||||
if (canBonusDamage) {
|
||||
bonusDamage = Math.min(skillValue / (Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus), Axes.bonusDamageMaxBonus);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canSkullSplitter = Permissions.skullSplitter(player);
|
||||
canCritical = Permissions.criticalStrikes(player);
|
||||
canBonusDamage = Permissions.bonusDamage(player, skill);
|
||||
canImpact = Permissions.armorImpact(player);
|
||||
canGreaterImpact = Permissions.greaterImpact(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canSkullSplitter) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1")));
|
||||
}
|
||||
|
||||
if (canCritical) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3")));
|
||||
}
|
||||
|
||||
if (canBonusDamage) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5")));
|
||||
}
|
||||
|
||||
if (canImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7")));
|
||||
}
|
||||
|
||||
if (canGreaterImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canBonusDamage) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", bonusDamage)));
|
||||
}
|
||||
|
||||
if (canImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage)));
|
||||
}
|
||||
|
||||
if (canGreaterImpact) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", Axes.greaterImpactBonusDamage)));
|
||||
}
|
||||
|
||||
if (canCritical) {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", critChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canSkullSplitter) {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", skullSplitterLengthEndurance) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +1,63 @@
|
||||
package com.gmail.nossr50.skills.excavation;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillCommand;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class ExcavationCommand extends SkillCommand {
|
||||
private String gigaDrillBreakerLength;
|
||||
private String gigaDrillBreakerLengthEndurance;
|
||||
|
||||
private boolean canGigaDrill;
|
||||
private boolean canTreasureHunt;
|
||||
|
||||
public ExcavationCommand() {
|
||||
super(SkillType.EXCAVATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
//GIGA DRILL BREAKER
|
||||
String gigaDrillStrings[] = calculateLengthDisplayValues();
|
||||
gigaDrillBreakerLength = gigaDrillStrings[0];
|
||||
gigaDrillBreakerLengthEndurance = gigaDrillStrings[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canGigaDrill = Permissions.gigaDrillBreaker(player);
|
||||
canTreasureHunt = Permissions.excavationTreasures(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canGigaDrill || canTreasureHunt;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canGigaDrill) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1")));
|
||||
}
|
||||
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canGigaDrill;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canGigaDrill) {
|
||||
if (hasEndurance) {
|
||||
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + LocaleLoader.getString("Perks.activationtime.bonus", gigaDrillBreakerLengthEndurance));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class ExcavationCommand extends SkillCommand {
|
||||
private String gigaDrillBreakerLength;
|
||||
private String gigaDrillBreakerLengthEndurance;
|
||||
|
||||
private boolean canGigaDrill;
|
||||
private boolean canTreasureHunt;
|
||||
|
||||
public ExcavationCommand() {
|
||||
super(SkillType.EXCAVATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// GIGA DRILL BREAKER
|
||||
if (canGigaDrill) {
|
||||
String gigaDrillStrings[] = calculateLengthDisplayValues();
|
||||
gigaDrillBreakerLength = gigaDrillStrings[0];
|
||||
gigaDrillBreakerLengthEndurance = gigaDrillStrings[1];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canGigaDrill = Permissions.gigaDrillBreaker(player);
|
||||
canTreasureHunt = Permissions.excavationTreasureHunter(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canGigaDrill || canTreasureHunt;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canGigaDrill) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1")));
|
||||
}
|
||||
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canGigaDrill;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canGigaDrill) {
|
||||
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", gigaDrillBreakerLengthEndurance) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class FishingCommand extends SkillCommand {
|
||||
private int lootTier;
|
||||
private String magicChance;
|
||||
private String magicChanceLucky;
|
||||
private String chanceRaining = "";
|
||||
private String shakeChance;
|
||||
private String shakeChanceLucky;
|
||||
private int fishermansDietRank;
|
||||
private String biteChance;
|
||||
|
||||
private boolean canTreasureHunt;
|
||||
private boolean canMagicHunt;
|
||||
private boolean canShake;
|
||||
private boolean canFishermansDiet;
|
||||
private boolean canMasterAngler;
|
||||
|
||||
public FishingCommand() {
|
||||
super(SkillType.FISHING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
boolean isStorming = player.getWorld().hasStorm();
|
||||
|
||||
// TREASURE HUNTER
|
||||
if (canTreasureHunt) {
|
||||
lootTier = mcMMOPlayer.getFishingManager().getLootTier();
|
||||
double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();
|
||||
|
||||
if (isStorming) {
|
||||
chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining");
|
||||
enchantChance *= 1.1D;
|
||||
}
|
||||
|
||||
String[] treasureHunterStrings = calculateAbilityDisplayValues(enchantChance);
|
||||
magicChance = treasureHunterStrings[0];
|
||||
magicChanceLucky = treasureHunterStrings[1];
|
||||
}
|
||||
|
||||
// SHAKE
|
||||
if (canShake) {
|
||||
String[] shakeStrings = calculateAbilityDisplayValues(UserManager.getPlayer(player).getFishingManager().getShakeProbability());
|
||||
shakeChance = shakeStrings[0];
|
||||
shakeChanceLucky = shakeStrings[1];
|
||||
}
|
||||
|
||||
// FISHERMAN'S DIET
|
||||
if (canFishermansDiet) {
|
||||
fishermansDietRank = calculateRank(Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1);
|
||||
}
|
||||
|
||||
// MASTER ANGLER
|
||||
if (canMasterAngler) {
|
||||
biteChance = calculateAbilityDisplayValues((skillValue / 10) / (isStorming ? 300 : 500))[0];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canTreasureHunt = Permissions.fishingTreasureHunter(player);
|
||||
canMagicHunt = Permissions.magicHunter(player);
|
||||
canShake = Permissions.shake(player);
|
||||
canFishermansDiet = Permissions.fishermansDiet(player);
|
||||
canMasterAngler = Permissions.masterAngler(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1")));
|
||||
}
|
||||
|
||||
if (canMagicHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3")));
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
|
||||
}
|
||||
|
||||
if (canFishermansDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
|
||||
}
|
||||
|
||||
if (canMasterAngler) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canMasterAngler) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
|
||||
}
|
||||
|
||||
if (canTreasureHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier));
|
||||
}
|
||||
|
||||
if (canMagicHunt) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", magicChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getShakeUnlockLevel();
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", shakeChanceLucky) : ""));
|
||||
}
|
||||
}
|
||||
|
||||
if (canFishermansDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class HerbalismCommand extends SkillCommand {
|
||||
private String greenTerraLength;
|
||||
private String greenTerraLengthEndurance;
|
||||
private String greenThumbChance;
|
||||
private String greenThumbChanceLucky;
|
||||
private int greenThumbStage;
|
||||
private int farmersDietRank;
|
||||
private String doubleDropChance;
|
||||
private String doubleDropChanceLucky;
|
||||
private String hylianLuckChance;
|
||||
private String hylianLuckChanceLucky;
|
||||
private String shroomThumbChance;
|
||||
private String shroomThumbChanceLucky;
|
||||
|
||||
private boolean hasHylianLuck;
|
||||
private boolean canGreenTerra;
|
||||
private boolean canGreenThumbPlants;
|
||||
private boolean canGreenThumbBlocks;
|
||||
private boolean canFarmersDiet;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean canShroomThumb;
|
||||
|
||||
public HerbalismCommand() {
|
||||
super(SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// GREEN TERRA
|
||||
if (canGreenTerra) {
|
||||
String[] greenTerraStrings = calculateLengthDisplayValues();
|
||||
greenTerraLength = greenTerraStrings[0];
|
||||
greenTerraLengthEndurance = greenTerraStrings[1];
|
||||
}
|
||||
|
||||
// FARMERS DIET
|
||||
if (canFarmersDiet) {
|
||||
farmersDietRank = calculateRank(Herbalism.farmersDietMaxLevel, Herbalism.farmersDietRankLevel1);
|
||||
}
|
||||
|
||||
// GREEN THUMB
|
||||
if (canGreenThumbBlocks || canGreenThumbPlants) {
|
||||
greenThumbStage = calculateRank(Herbalism.greenThumbStageMaxLevel, Herbalism.greenThumbStageChangeLevel);
|
||||
|
||||
String[] greenThumbStrings = calculateAbilityDisplayValues(Herbalism.greenThumbMaxLevel, Herbalism.greenThumbMaxChance);
|
||||
greenThumbChance = greenThumbStrings[0];
|
||||
greenThumbChanceLucky = greenThumbStrings[1];
|
||||
}
|
||||
|
||||
// DOUBLE DROPS
|
||||
if (canDoubleDrop) {
|
||||
String[] doubleDropStrings = calculateAbilityDisplayValues(Herbalism.doubleDropsMaxLevel, Herbalism.doubleDropsMaxChance);
|
||||
doubleDropChance = doubleDropStrings[0];
|
||||
doubleDropChanceLucky = doubleDropStrings[1];
|
||||
}
|
||||
|
||||
// HYLIAN LUCK
|
||||
if (hasHylianLuck) {
|
||||
String[] hylianLuckStrings = calculateAbilityDisplayValues(Herbalism.hylianLuckMaxLevel, Herbalism.hylianLuckMaxChance);
|
||||
hylianLuckChance = hylianLuckStrings[0];
|
||||
hylianLuckChanceLucky = hylianLuckStrings[1];
|
||||
}
|
||||
|
||||
// SHROOM THUMB
|
||||
if (canShroomThumb) {
|
||||
String[] shroomThumbStrings = calculateAbilityDisplayValues(Herbalism.shroomThumbMaxLevel, Herbalism.shroomThumbMaxChance);
|
||||
shroomThumbChance = shroomThumbStrings[0];
|
||||
shroomThumbChanceLucky = shroomThumbStrings[1];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
hasHylianLuck = Permissions.hylianLuck(player);
|
||||
canGreenTerra = Permissions.greenTerra(player);
|
||||
canGreenThumbPlants = Permissions.greenThumbPlant(player, Material.CROPS) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.NETHER_WARTS) || Permissions.greenThumbPlant(player, Material.COCOA);
|
||||
canGreenThumbBlocks = Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLE_WALL) || Permissions.greenThumbBlock(player, Material.SMOOTH_BRICK);
|
||||
canFarmersDiet = Permissions.farmersDiet(player);
|
||||
canDoubleDrop = Permissions.doubleDrops(player, skill) && !skill.getDoubleDropsDisabled();
|
||||
canShroomThumb = Permissions.shroomThumb(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canGreenTerra || canDoubleDrop || canFarmersDiet || canGreenThumbBlocks || canGreenThumbPlants || canShroomThumb;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canGreenTerra) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1")));
|
||||
}
|
||||
|
||||
if (canGreenThumbPlants) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3")));
|
||||
}
|
||||
|
||||
if (canGreenThumbBlocks) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5")));
|
||||
}
|
||||
|
||||
if (canFarmersDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7")));
|
||||
}
|
||||
|
||||
if (hasHylianLuck) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11")));
|
||||
}
|
||||
|
||||
if (canShroomThumb) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.12"), LocaleLoader.getString("Herbalism.Effect.13")));
|
||||
}
|
||||
|
||||
if (canDoubleDrop) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canGreenTerra || canDoubleDrop || canFarmersDiet || canGreenThumbBlocks || canGreenThumbPlants || canShroomThumb;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canGreenTerra) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", greenTerraLengthEndurance) : ""));
|
||||
}
|
||||
|
||||
if (canGreenThumbBlocks || canGreenThumbPlants) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", greenThumbChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canGreenThumbPlants) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", greenThumbStage));
|
||||
}
|
||||
|
||||
if (canFarmersDiet) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", farmersDietRank));
|
||||
}
|
||||
|
||||
if (hasHylianLuck) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", hylianLuckChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canShroomThumb) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", shroomThumbChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canDoubleDrop) {
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.mining.Mining;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class MiningCommand extends SkillCommand {
|
||||
private String doubleDropChance;
|
||||
private String doubleDropChanceLucky;
|
||||
private String superBreakerLength;
|
||||
private String superBreakerLengthEndurance;
|
||||
|
||||
private int blastMiningRank;
|
||||
private int bonusTNTDrops;
|
||||
private double blastRadiusIncrease;
|
||||
private String oreBonus;
|
||||
private String debrisReduction;
|
||||
private String blastDamageDecrease;
|
||||
|
||||
private boolean canSuperBreaker;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean canBlast;
|
||||
private boolean canBiggerBombs;
|
||||
private boolean canDemoExpert;
|
||||
|
||||
public MiningCommand() {
|
||||
super(SkillType.MINING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// SUPER BREAKER
|
||||
if (canSuperBreaker) {
|
||||
String[] superBreakerStrings = calculateLengthDisplayValues();
|
||||
superBreakerLength = superBreakerStrings[0];
|
||||
superBreakerLengthEndurance = superBreakerStrings[1];
|
||||
}
|
||||
|
||||
// DOUBLE DROPS
|
||||
if (canDoubleDrop) {
|
||||
String[] doubleDropStrings = calculateAbilityDisplayValues(Mining.doubleDropsMaxLevel, Mining.doubleDropsMaxChance);
|
||||
doubleDropChance = doubleDropStrings[0];
|
||||
doubleDropChanceLucky = doubleDropStrings[1];
|
||||
}
|
||||
|
||||
// BLAST MINING
|
||||
if (canBlast || canDemoExpert || canBiggerBombs) {
|
||||
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
||||
|
||||
blastMiningRank = miningManager.getBlastMiningTier();
|
||||
bonusTNTDrops = miningManager.getDropMultiplier();
|
||||
oreBonus = percent.format(miningManager.getOreBonus() / 30.0D); // Base received in TNT is 30%
|
||||
debrisReduction = percent.format(miningManager.getDebrisReduction() / 30.0D); // Base received in TNT is 30%
|
||||
blastDamageDecrease = percent.format(miningManager.getBlastDamageModifier() / 100.0D);
|
||||
blastRadiusIncrease = miningManager.getBlastRadiusModifier();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBiggerBombs = Permissions.biggerBombs(player);
|
||||
canBlast = Permissions.remoteDetonation(player);
|
||||
canDemoExpert = Permissions.demolitionsExpertise(player);
|
||||
canDoubleDrop = Permissions.doubleDrops(player, skill) && !skill.getDoubleDropsDisabled();
|
||||
canSuperBreaker = Permissions.superBreaker(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBiggerBombs || canBlast || canDemoExpert || canDoubleDrop || canSuperBreaker;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canSuperBreaker) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1")));
|
||||
}
|
||||
|
||||
if (canDoubleDrop) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3")));
|
||||
}
|
||||
|
||||
if (canBlast) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5")));
|
||||
}
|
||||
|
||||
if (canBiggerBombs) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7")));
|
||||
}
|
||||
|
||||
if (canDemoExpert) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canBiggerBombs || canBlast || canDemoExpert || canDoubleDrop || canSuperBreaker;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canDoubleDrop) {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canSuperBreaker) {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", superBreakerLengthEndurance) : ""));
|
||||
}
|
||||
|
||||
if (canBlast) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank1();
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", unlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
|
||||
}
|
||||
}
|
||||
|
||||
if (canBiggerBombs) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank2();
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease));
|
||||
}
|
||||
}
|
||||
|
||||
if (canDemoExpert) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank4();
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,164 +1,159 @@
|
||||
package com.gmail.nossr50.skills.repair;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillCommand;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class RepairCommand extends SkillCommand {
|
||||
private int arcaneForgingRank;
|
||||
private String repairMasteryBonus;
|
||||
private String superRepairChance;
|
||||
private String superRepairChanceLucky;
|
||||
|
||||
private boolean canSuperRepair;
|
||||
private boolean canMasterRepair;
|
||||
private boolean canArcaneForge;
|
||||
private boolean canSalvage;
|
||||
private boolean canRepairStone;
|
||||
private boolean canRepairIron;
|
||||
private boolean canRepairGold;
|
||||
private boolean canRepairDiamond;
|
||||
private boolean canRepairString;
|
||||
private boolean canRepairLeather;
|
||||
private boolean canRepairWood;
|
||||
private boolean arcaneBypass;
|
||||
|
||||
private int diamondLevel;
|
||||
private int goldLevel;
|
||||
private int ironLevel;
|
||||
private int stoneLevel;
|
||||
|
||||
public RepairCommand() {
|
||||
super(SkillType.REPAIR);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// We're using pickaxes here, not the best but it works
|
||||
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(Material.DIAMOND_PICKAXE.getId());
|
||||
Repairable goldRepairable = mcMMO.repairManager.getRepairable(Material.GOLD_PICKAXE.getId());
|
||||
Repairable ironRepairable = mcMMO.repairManager.getRepairable(Material.IRON_PICKAXE.getId());
|
||||
Repairable stoneRepairable = mcMMO.repairManager.getRepairable(Material.STONE_PICKAXE.getId());
|
||||
|
||||
//TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
|
||||
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
||||
goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
|
||||
ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
|
||||
stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
|
||||
|
||||
//REPAIR MASTERY
|
||||
if (skillValue >= Repair.REPAIR_MASTERY_MAX_BONUS_LEVEL) {
|
||||
repairMasteryBonus = percent.format(Repair.REPAIR_MASTERY_CHANCE_MAX / 100D);
|
||||
}
|
||||
else {
|
||||
repairMasteryBonus = percent.format((( Repair.REPAIR_MASTERY_CHANCE_MAX / Repair.REPAIR_MASTERY_MAX_BONUS_LEVEL) * skillValue) / 100D);
|
||||
}
|
||||
|
||||
//SUPER REPAIR
|
||||
String[] superRepairStrings = calculateAbilityDisplayValues(Repair.SUPER_REPAIR_MAX_BONUS_LEVEL, Repair.SUPER_REPAIR_CHANCE_MAX);
|
||||
superRepairChance = superRepairStrings[0];
|
||||
superRepairChanceLucky = superRepairStrings[1];
|
||||
|
||||
//ARCANE FORGING
|
||||
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canSuperRepair = Permissions.repairBonus(player);
|
||||
canMasterRepair = Permissions.repairMastery(player);
|
||||
canArcaneForge = Permissions.arcaneForging(player);
|
||||
canSalvage = Permissions.salvage(player);
|
||||
canRepairDiamond = Permissions.diamondRepair(player);
|
||||
canRepairGold = Permissions.goldRepair(player);
|
||||
canRepairIron = Permissions.ironRepair(player);
|
||||
canRepairStone = Permissions.stoneRepair(player);
|
||||
canRepairString = Permissions.stringRepair(player);
|
||||
canRepairLeather = Permissions.leatherRepair(player);
|
||||
canRepairWood = Permissions.woodRepair(player);
|
||||
arcaneBypass = Permissions.arcaneBypass(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canArcaneForge || canSalvage || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1")));
|
||||
|
||||
if (canMasterRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3")));
|
||||
}
|
||||
|
||||
if (canSuperRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5")));
|
||||
}
|
||||
|
||||
/* Repair Level Requirements */
|
||||
|
||||
if (canRepairStone && stoneLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.14", stoneLevel), LocaleLoader.getString("Repair.Effect.15")));
|
||||
}
|
||||
|
||||
if (canRepairIron && ironLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.12", ironLevel), LocaleLoader.getString("Repair.Effect.13")));
|
||||
}
|
||||
|
||||
if (canRepairGold && goldLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.10", goldLevel), LocaleLoader.getString("Repair.Effect.11")));
|
||||
}
|
||||
|
||||
if (canRepairDiamond && diamondLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7")));
|
||||
}
|
||||
|
||||
if (canSalvage && Salvage.salvageUnlockLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Salvage.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17")));
|
||||
}
|
||||
|
||||
if (canArcaneForge) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canArcaneForge || canMasterRepair || canSuperRepair;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canMasterRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", repairMasteryBonus));
|
||||
}
|
||||
|
||||
if (canSuperRepair) {
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + LocaleLoader.getString("Perks.lucky.bonus", superRepairChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance));
|
||||
}
|
||||
}
|
||||
|
||||
if (canArcaneForge) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", arcaneForgingRank));
|
||||
|
||||
if (Repair.arcaneForgingEnchantLoss) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : Repair.getEnchantChance(arcaneForgingRank))));
|
||||
}
|
||||
|
||||
if (Repair.arcaneForgingDowngrades) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : Repair.getDowngradeChance(arcaneForgingRank))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.repair.ArcaneForging;
|
||||
import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class RepairCommand extends SkillCommand {
|
||||
private String repairMasteryBonus;
|
||||
private String superRepairChance;
|
||||
private String superRepairChanceLucky;
|
||||
|
||||
private boolean canSuperRepair;
|
||||
private boolean canMasterRepair;
|
||||
private boolean canArcaneForge;
|
||||
private boolean canSalvage;
|
||||
private boolean canRepairStone;
|
||||
private boolean canRepairIron;
|
||||
private boolean canRepairGold;
|
||||
private boolean canRepairDiamond;
|
||||
private boolean canRepairString;
|
||||
private boolean canRepairLeather;
|
||||
private boolean canRepairWood;
|
||||
private boolean arcaneBypass;
|
||||
|
||||
private int diamondLevel;
|
||||
private int goldLevel;
|
||||
private int ironLevel;
|
||||
private int stoneLevel;
|
||||
|
||||
public RepairCommand() {
|
||||
super(SkillType.REPAIR);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// We're using pickaxes here, not the best but it works
|
||||
Repairable diamondRepairable = mcMMO.repairableManager.getRepairable(Material.DIAMOND_PICKAXE.getId());
|
||||
Repairable goldRepairable = mcMMO.repairableManager.getRepairable(Material.GOLD_PICKAXE.getId());
|
||||
Repairable ironRepairable = mcMMO.repairableManager.getRepairable(Material.IRON_PICKAXE.getId());
|
||||
Repairable stoneRepairable = mcMMO.repairableManager.getRepairable(Material.STONE_PICKAXE.getId());
|
||||
|
||||
// TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
|
||||
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
||||
goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
|
||||
ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
|
||||
stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
|
||||
|
||||
// REPAIR MASTERY
|
||||
if (canMasterRepair) {
|
||||
repairMasteryBonus = percent.format(Math.min(((Repair.repairMasteryMaxBonus / Repair.repairMasteryMaxBonusLevel) * skillValue), Repair.repairMasteryMaxBonus) / 100D);
|
||||
}
|
||||
|
||||
// SUPER REPAIR
|
||||
if (canSuperRepair) {
|
||||
String[] superRepairStrings = calculateAbilityDisplayValues(Repair.superRepairMaxBonusLevel, Repair.superRepairMaxChance);
|
||||
superRepairChance = superRepairStrings[0];
|
||||
superRepairChanceLucky = superRepairStrings[1];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canSuperRepair = Permissions.superRepair(player);
|
||||
canMasterRepair = Permissions.repairMastery(player);
|
||||
canArcaneForge = Permissions.arcaneForging(player);
|
||||
canSalvage = Permissions.salvage(player);
|
||||
canRepairDiamond = Permissions.repairDiamond(player);
|
||||
canRepairGold = Permissions.repairGold(player);
|
||||
canRepairIron = Permissions.repairIron(player);
|
||||
canRepairStone = Permissions.repairStone(player);
|
||||
canRepairString = Permissions.repairString(player);
|
||||
canRepairLeather = Permissions.repairLeather(player);
|
||||
canRepairWood = Permissions.repairWood(player);
|
||||
arcaneBypass = Permissions.arcaneBypass(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canArcaneForge || canSalvage || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1")));
|
||||
|
||||
if (canMasterRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3")));
|
||||
}
|
||||
|
||||
if (canSuperRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5")));
|
||||
}
|
||||
|
||||
/* Repair Level Requirements */
|
||||
|
||||
if (canRepairStone && stoneLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.14", stoneLevel), LocaleLoader.getString("Repair.Effect.15")));
|
||||
}
|
||||
|
||||
if (canRepairIron && ironLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.12", ironLevel), LocaleLoader.getString("Repair.Effect.13")));
|
||||
}
|
||||
|
||||
if (canRepairGold && goldLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.10", goldLevel), LocaleLoader.getString("Repair.Effect.11")));
|
||||
}
|
||||
|
||||
if (canRepairDiamond && diamondLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7")));
|
||||
}
|
||||
|
||||
if (canSalvage && Repair.salvageUnlockLevel > 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Repair.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17")));
|
||||
}
|
||||
|
||||
if (canArcaneForge) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canArcaneForge || canMasterRepair || canSuperRepair;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canMasterRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", repairMasteryBonus));
|
||||
}
|
||||
|
||||
if (canSuperRepair) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", superRepairChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canArcaneForge) {
|
||||
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank()));
|
||||
|
||||
if (ArcaneForging.arcaneForgingEnchantLoss) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance())));
|
||||
}
|
||||
|
||||
if (ArcaneForging.arcaneForgingDowngrades) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : repairManager.getDowngradeEnchantChance())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class SkillCommand implements TabExecutor {
|
||||
protected SkillType skill;
|
||||
protected String skillName;
|
||||
|
||||
protected Player player;
|
||||
protected PlayerProfile profile;
|
||||
protected McMMOPlayer mcMMOPlayer;
|
||||
|
||||
protected float skillValue;
|
||||
protected boolean isLucky;
|
||||
protected boolean hasEndurance;
|
||||
|
||||
protected DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
protected DecimalFormat decimal = new DecimalFormat("##0.00");
|
||||
|
||||
private CommandExecutor skillGuideCommand;
|
||||
|
||||
public SkillCommand(SkillType skill) {
|
||||
this.skill = skill;
|
||||
skillName = SkillUtils.getSkillName(skill);
|
||||
skillGuideCommand = new SkillGuideCommand(skill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
player = mcMMOPlayer.getPlayer();
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
skillValue = profile.getSkillLevel(skill);
|
||||
isLucky = Permissions.lucky(sender, skill);
|
||||
hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
|
||||
|
||||
permissionsCheck();
|
||||
dataCalculations();
|
||||
|
||||
if (!skill.isChildSkill()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain.Child")));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Child", (int) skillValue));
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Skills.Parents")));
|
||||
Set<SkillType> parents = FamilyTree.getParents(skill);
|
||||
|
||||
for (SkillType parent : parents) {
|
||||
player.sendMessage(SkillUtils.getSkillName(parent) + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent)));
|
||||
}
|
||||
}
|
||||
|
||||
if (effectsHeaderPermissions()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));
|
||||
}
|
||||
|
||||
effectsDisplay();
|
||||
|
||||
if (statsHeaderPermissions()) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self")));
|
||||
}
|
||||
|
||||
statsDisplay();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase()));
|
||||
return true;
|
||||
|
||||
default:
|
||||
return skillGuideCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return ImmutableList.of("?");
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
protected int calculateRank(int maxLevel, int rankChangeLevel) {
|
||||
return Math.min((int) skillValue, maxLevel) / rankChangeLevel;
|
||||
}
|
||||
|
||||
protected String[] calculateAbilityDisplayValues(double chance) {
|
||||
String[] displayValues = new String[2];
|
||||
|
||||
displayValues[0] = percent.format(Math.min(chance, 100.0D) / 100.0D);
|
||||
displayValues[1] = isLucky ? percent.format(Math.min(chance * 1.3333D, 100.0D) / 100.0D) : null;
|
||||
|
||||
return displayValues;
|
||||
}
|
||||
|
||||
protected String[] calculateAbilityDisplayValues(int maxBonusLevel, double maxChance) {
|
||||
return calculateAbilityDisplayValues((maxChance / maxBonusLevel) * Math.min(skillValue, maxBonusLevel));
|
||||
}
|
||||
|
||||
protected String[] calculateLengthDisplayValues() {
|
||||
int maxLength = skill.getAbility().getMaxTicks();
|
||||
int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength());
|
||||
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
|
||||
|
||||
if (maxLength != 0) {
|
||||
length = Math.min(length, maxLength);
|
||||
}
|
||||
|
||||
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
|
||||
}
|
||||
|
||||
protected void luckyEffectsDisplay() {
|
||||
if (isLucky) {
|
||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", skillName)));
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void dataCalculations();
|
||||
|
||||
protected abstract void permissionsCheck();
|
||||
|
||||
protected abstract boolean effectsHeaderPermissions();
|
||||
|
||||
protected abstract void effectsDisplay();
|
||||
|
||||
protected abstract boolean statsHeaderPermissions();
|
||||
|
||||
protected abstract void statsDisplay();
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class SkillGuideCommand implements CommandExecutor {
|
||||
private String header;
|
||||
private String[] guide;
|
||||
|
||||
private String invalidPage;
|
||||
|
||||
public SkillGuideCommand(SkillType skillType) {
|
||||
header = LocaleLoader.getString("Guides.Header", SkillUtils.getSkillName(skillType));
|
||||
guide = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skillType.toString())).split("\n");
|
||||
|
||||
invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (!args[0].equals("?")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sendGuide(sender, 1);
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
int totalPages = getTotalPageNumber();
|
||||
|
||||
if (!StringUtils.isInt(args[1])) {
|
||||
sender.sendMessage(invalidPage);
|
||||
return true;
|
||||
}
|
||||
|
||||
int pageNumber = Integer.parseInt(args[1]);
|
||||
|
||||
if (pageNumber > totalPages || pageNumber <= 0) {
|
||||
sender.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", totalPages));
|
||||
return true;
|
||||
}
|
||||
|
||||
sendGuide(sender, pageNumber);
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private int getTotalPageNumber() {
|
||||
return (int) Math.ceil(guide.length / 8.0);
|
||||
}
|
||||
|
||||
private void sendGuide(CommandSender sender, int pageNumber) {
|
||||
for (String target : grabPageContents(pageNumber)) {
|
||||
sender.sendMessage(target);
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<String> grabPageContents(int pagenum) {
|
||||
int pageIndexStart = 8 * (pagenum - 1); // Determine what string to start at
|
||||
ArrayList<String> allStrings = new ArrayList<String>();
|
||||
|
||||
allStrings.add(header);
|
||||
|
||||
// Add targeted strings
|
||||
while (allStrings.size() < 9) {
|
||||
if (pageIndexStart + allStrings.size() > guide.length) {
|
||||
allStrings.add("");
|
||||
}
|
||||
else {
|
||||
allStrings.add(guide[pageIndexStart + (allStrings.size() - 1)]);
|
||||
}
|
||||
}
|
||||
|
||||
allStrings.add("Page " + pagenum + " of " + getTotalPageNumber());
|
||||
return allStrings;
|
||||
}
|
||||
}
|
||||
@@ -1,133 +1,116 @@
|
||||
package com.gmail.nossr50.skills.smelting;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillCommand;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class SmeltingCommand extends SkillCommand {
|
||||
private String burnTimeModifier;
|
||||
private String secondSmeltChance;
|
||||
private String secondSmeltChanceLucky;
|
||||
private String fluxMiningChance;
|
||||
private String fluxMiningChanceLucky;
|
||||
private String vanillaXPModifier;
|
||||
|
||||
private boolean canFuelEfficiency;
|
||||
private boolean canSecondSmelt;
|
||||
private boolean canFluxMine;
|
||||
private boolean canVanillaXPBoost;
|
||||
|
||||
public SmeltingCommand() {
|
||||
super(SkillType.SMELTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
//FUEL EFFICIENCY
|
||||
burnTimeModifier = decimal.format(1 + ((skillValue / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier));
|
||||
|
||||
//SECOND SMELT
|
||||
String[] secondSmeltStrings = calculateAbilityDisplayValues(Smelting.secondSmeltMaxLevel, Smelting.secondSmeltMaxChance);
|
||||
secondSmeltChance = secondSmeltStrings[0];
|
||||
secondSmeltChanceLucky = secondSmeltStrings[1];
|
||||
|
||||
//FLUX MINING
|
||||
String[] fluxMiningStrings = calculateAbilityDisplayValues(Smelting.fluxMiningChance);
|
||||
fluxMiningChance = fluxMiningStrings[0];
|
||||
fluxMiningChanceLucky = fluxMiningStrings[1];
|
||||
|
||||
//VANILLA XP BOOST
|
||||
if (skillValue >= Smelting.vanillaXPBoostRank5Level) {
|
||||
vanillaXPModifier = String.valueOf(Smelting.vanillaXPBoostRank5Multiplier);
|
||||
}
|
||||
else if (skillValue >= Smelting.vanillaXPBoostRank4Level) {
|
||||
vanillaXPModifier = String.valueOf(Smelting.vanillaXPBoostRank4Multiplier);
|
||||
}
|
||||
else if (skillValue >= Smelting.vanillaXPBoostRank3Level) {
|
||||
vanillaXPModifier = String.valueOf(Smelting.vanillaXPBoostRank3Multiplier);
|
||||
}
|
||||
else if (skillValue >= Smelting.vanillaXPBoostRank2Level) {
|
||||
vanillaXPModifier = String.valueOf(Smelting.vanillaXPBoostRank2Multiplier);
|
||||
}
|
||||
else {
|
||||
vanillaXPModifier = String.valueOf(Smelting.vanillaXPBoostRank1Multiplier);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canFuelEfficiency = Permissions.fuelEfficiency(player);
|
||||
canSecondSmelt = Permissions.secondSmelt(player);
|
||||
canFluxMine = Permissions.fluxMining(player);
|
||||
canVanillaXPBoost = Permissions.smeltingVanillaXPBoost(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canFuelEfficiency) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.0"), LocaleLoader.getString("Smelting.Effect.1")));
|
||||
}
|
||||
|
||||
if (canSecondSmelt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.2"), LocaleLoader.getString("Smelting.Effect.3")));
|
||||
}
|
||||
|
||||
if (canVanillaXPBoost) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.4"), LocaleLoader.getString("Smelting.Effect.5")));
|
||||
}
|
||||
|
||||
if (canFluxMine) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.6"), LocaleLoader.getString("Smelting.Effect.7")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canFuelEfficiency) {
|
||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FuelEfficiency", burnTimeModifier));
|
||||
}
|
||||
|
||||
if (canSecondSmelt) {
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + LocaleLoader.getString("Perks.lucky.bonus", secondSmeltChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance));
|
||||
}
|
||||
}
|
||||
|
||||
if (canVanillaXPBoost) {
|
||||
if (skillValue < Smelting.vanillaXPBoostRank1Level) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", Smelting.vanillaXPBoostRank1Level)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", vanillaXPModifier));
|
||||
}
|
||||
}
|
||||
|
||||
if (canFluxMine) {
|
||||
if (skillValue < Smelting.fluxMiningUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.1", Smelting.fluxMiningUnlockLevel)));
|
||||
}
|
||||
else if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + LocaleLoader.getString("Perks.lucky.bonus", fluxMiningChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.smelting.Smelting;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class SmeltingCommand extends SkillCommand {
|
||||
private String burnTimeModifier;
|
||||
private String secondSmeltChance;
|
||||
private String secondSmeltChanceLucky;
|
||||
private String fluxMiningChance;
|
||||
private String fluxMiningChanceLucky;
|
||||
|
||||
private boolean canFuelEfficiency;
|
||||
private boolean canSecondSmelt;
|
||||
private boolean canFluxMine;
|
||||
private boolean canVanillaXPBoost;
|
||||
|
||||
public SmeltingCommand() {
|
||||
super(SkillType.SMELTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// FUEL EFFICIENCY
|
||||
if (canFuelEfficiency) {
|
||||
burnTimeModifier = decimal.format(1 + ((skillValue / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier));
|
||||
}
|
||||
|
||||
// SECOND SMELT
|
||||
if (canSecondSmelt) {
|
||||
String[] secondSmeltStrings = calculateAbilityDisplayValues(Smelting.secondSmeltMaxLevel, Smelting.secondSmeltMaxChance);
|
||||
secondSmeltChance = secondSmeltStrings[0];
|
||||
secondSmeltChanceLucky = secondSmeltStrings[1];
|
||||
}
|
||||
|
||||
// FLUX MINING
|
||||
if (canFluxMine) {
|
||||
String[] fluxMiningStrings = calculateAbilityDisplayValues(Smelting.fluxMiningChance);
|
||||
fluxMiningChance = fluxMiningStrings[0];
|
||||
fluxMiningChanceLucky = fluxMiningStrings[1];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canFuelEfficiency = Permissions.fuelEfficiency(player);
|
||||
canSecondSmelt = Permissions.doubleDrops(player, skill);
|
||||
canFluxMine = Permissions.fluxMining(player);
|
||||
canVanillaXPBoost = Permissions.vanillaXpBoost(player, skill);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canFuelEfficiency) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.0"), LocaleLoader.getString("Smelting.Effect.1")));
|
||||
}
|
||||
|
||||
if (canSecondSmelt) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.2"), LocaleLoader.getString("Smelting.Effect.3")));
|
||||
}
|
||||
|
||||
if (canVanillaXPBoost) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.4"), LocaleLoader.getString("Smelting.Effect.5")));
|
||||
}
|
||||
|
||||
if (canFluxMine) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.6"), LocaleLoader.getString("Smelting.Effect.7")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canFuelEfficiency) {
|
||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FuelEfficiency", burnTimeModifier));
|
||||
}
|
||||
|
||||
if (canSecondSmelt) {
|
||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", secondSmeltChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canVanillaXPBoost) {
|
||||
int unlockLevel = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level();
|
||||
|
||||
if (skillValue < unlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", unlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", mcMMOPlayer.getSmeltingManager().getVanillaXpMultiplier()));
|
||||
}
|
||||
}
|
||||
|
||||
if (canFluxMine) {
|
||||
if (skillValue < Smelting.fluxMiningUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.1", Smelting.fluxMiningUnlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", fluxMiningChanceLucky) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,117 +1,102 @@
|
||||
package com.gmail.nossr50.skills.swords;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillCommand;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class SwordsCommand extends SkillCommand {
|
||||
private String counterAttackChance;
|
||||
private String counterAttackChanceLucky;
|
||||
private String bleedLength;
|
||||
private String bleedChance;
|
||||
private String bleedChanceLucky;
|
||||
private String serratedStrikesLength;
|
||||
private String serratedStrikesLengthEndurance;
|
||||
|
||||
private boolean canCounter;
|
||||
private boolean canSerratedStrike;
|
||||
private boolean canBleed;
|
||||
|
||||
public SwordsCommand() {
|
||||
super(SkillType.SWORDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
//SERRATED STRIKES
|
||||
String[] serratedStrikesStrings = calculateLengthDisplayValues();
|
||||
serratedStrikesLength = serratedStrikesStrings[0];
|
||||
serratedStrikesLengthEndurance = serratedStrikesStrings[1];
|
||||
|
||||
//BLEED
|
||||
if (skillValue >= Swords.bleedMaxBonusLevel) {
|
||||
bleedLength = String.valueOf(Swords.bleedMaxTicks);
|
||||
}
|
||||
else {
|
||||
bleedLength = String.valueOf(Swords.bleedBaseTicks);
|
||||
}
|
||||
|
||||
String[] bleedStrings = calculateAbilityDisplayValues(Swords.bleedMaxBonusLevel, Swords.bleedMaxChance);
|
||||
bleedChance = bleedStrings[0];
|
||||
bleedChanceLucky = bleedStrings[1];
|
||||
|
||||
//COUNTER ATTACK
|
||||
String[] counterAttackStrings = calculateAbilityDisplayValues(Swords.counterAttackMaxBonusLevel, Swords.counterAttackMaxChance);
|
||||
counterAttackChance = counterAttackStrings[0];
|
||||
counterAttackChanceLucky = counterAttackStrings[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBleed = Permissions.swordsBleed(player);
|
||||
canCounter = Permissions.counterAttack(player);
|
||||
canSerratedStrike = Permissions.serratedStrikes(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBleed || canCounter || canSerratedStrike;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canCounter) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1", percent.format(1.0D / Swords.counterAttackModifier))));
|
||||
}
|
||||
|
||||
if (canSerratedStrike) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3", percent.format(1.0D / Swords.serratedStrikesModifier))));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5", Swords.serratedStrikesBleedTicks)));
|
||||
}
|
||||
|
||||
if (canBleed) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canBleed || canCounter || canSerratedStrike;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canCounter) {
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + LocaleLoader.getString("Perks.lucky.bonus", counterAttackChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance));
|
||||
}
|
||||
}
|
||||
|
||||
if (canBleed) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", bleedLength));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
|
||||
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + LocaleLoader.getString("Perks.lucky.bonus", bleedChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance));
|
||||
}
|
||||
}
|
||||
|
||||
if (canSerratedStrike) {
|
||||
if (hasEndurance) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + LocaleLoader.getString("Perks.activationtime.bonus", serratedStrikesLengthEndurance));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.swords.Swords;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class SwordsCommand extends SkillCommand {
|
||||
private String counterAttackChance;
|
||||
private String counterAttackChanceLucky;
|
||||
private int bleedLength;
|
||||
private String bleedChance;
|
||||
private String bleedChanceLucky;
|
||||
private String serratedStrikesLength;
|
||||
private String serratedStrikesLengthEndurance;
|
||||
|
||||
private boolean canCounter;
|
||||
private boolean canSerratedStrike;
|
||||
private boolean canBleed;
|
||||
|
||||
public SwordsCommand() {
|
||||
super(SkillType.SWORDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// SERRATED STRIKES
|
||||
if (canSerratedStrike) {
|
||||
String[] serratedStrikesStrings = calculateLengthDisplayValues();
|
||||
serratedStrikesLength = serratedStrikesStrings[0];
|
||||
serratedStrikesLengthEndurance = serratedStrikesStrings[1];
|
||||
}
|
||||
|
||||
// BLEED
|
||||
if (canBleed) {
|
||||
bleedLength = (skillValue >= Swords.bleedMaxBonusLevel) ? Swords.bleedMaxTicks : Swords.bleedBaseTicks;
|
||||
|
||||
String[] bleedStrings = calculateAbilityDisplayValues(Swords.bleedMaxBonusLevel, Swords.bleedMaxChance);
|
||||
bleedChance = bleedStrings[0];
|
||||
bleedChanceLucky = bleedStrings[1];
|
||||
}
|
||||
|
||||
// COUNTER ATTACK
|
||||
if (canCounter) {
|
||||
String[] counterAttackStrings = calculateAbilityDisplayValues(Swords.counterAttackMaxBonusLevel, Swords.counterAttackMaxChance);
|
||||
counterAttackChance = counterAttackStrings[0];
|
||||
counterAttackChanceLucky = counterAttackStrings[1];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBleed = Permissions.bleed(player);
|
||||
canCounter = Permissions.counterAttack(player);
|
||||
canSerratedStrike = Permissions.serratedStrikes(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBleed || canCounter || canSerratedStrike;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canCounter) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1", percent.format(1.0D / Swords.counterAttackModifier))));
|
||||
}
|
||||
|
||||
if (canSerratedStrike) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3", percent.format(1.0D / Swords.serratedStrikesModifier))));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5", Swords.serratedStrikesBleedTicks)));
|
||||
}
|
||||
|
||||
if (canBleed) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canBleed || canCounter || canSerratedStrike;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canCounter) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", counterAttackChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canBleed) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", bleedLength));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", bleedChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canSerratedStrike) {
|
||||
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", serratedStrikesLengthEndurance) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,150 +1,162 @@
|
||||
package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillCommand;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class TamingCommand extends SkillCommand {
|
||||
private String goreChance;
|
||||
private String goreChanceLucky;
|
||||
|
||||
private boolean canBeastLore;
|
||||
private boolean canGore;
|
||||
private boolean canSharpenedClaws;
|
||||
private boolean canEnvironmentallyAware;
|
||||
private boolean canThickFur;
|
||||
private boolean canShockProof;
|
||||
private boolean canCallWild;
|
||||
private boolean canFastFood;
|
||||
|
||||
public TamingCommand() {
|
||||
super(SkillType.TAMING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
String[] goreStrings = calculateAbilityDisplayValues(Taming.goreMaxBonusLevel, Taming.goreMaxChance);
|
||||
goreChance = goreStrings[0];
|
||||
goreChanceLucky = goreStrings[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBeastLore = Permissions.beastLore(player);
|
||||
canCallWild = Permissions.callOfTheWild(player);
|
||||
canEnvironmentallyAware = Permissions.environmentallyAware(player);
|
||||
canFastFood = Permissions.fastFoodService(player);
|
||||
canGore = Permissions.gore(player);
|
||||
canSharpenedClaws = Permissions.sharpenedClaws(player);
|
||||
canShockProof = Permissions.shockProof(player);
|
||||
canThickFur = Permissions.thickFur(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canBeastLore) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1")));
|
||||
}
|
||||
|
||||
if (canGore) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3")));
|
||||
}
|
||||
|
||||
if (canSharpenedClaws) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5")));
|
||||
}
|
||||
|
||||
if (canEnvironmentallyAware) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7")));
|
||||
}
|
||||
|
||||
if (canThickFur) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9")));
|
||||
}
|
||||
|
||||
if (canShockProof) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11")));
|
||||
}
|
||||
|
||||
if (canFastFood) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17")));
|
||||
}
|
||||
|
||||
if (canCallWild) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost()));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canFastFood) {
|
||||
if (skillValue < Taming.fastFoodServiceUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.4", Taming.fastFoodServiceUnlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9", percent.format(Taming.fastFoodServiceActivationChance / 100D))));
|
||||
}
|
||||
}
|
||||
|
||||
if (canEnvironmentallyAware) {
|
||||
if (skillValue < Taming.environmentallyAwareUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.0", Taming.environmentallyAwareUnlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1")));
|
||||
}
|
||||
}
|
||||
|
||||
if (canThickFur) {
|
||||
if (skillValue < Taming.thickFurUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.1", Taming.thickFurUnlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3", Taming.thickFurModifier)));
|
||||
}
|
||||
}
|
||||
|
||||
if (canShockProof) {
|
||||
if (skillValue < Taming.shockProofUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.2", Taming.shockProofUnlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5", Taming.shockProofModifier)));
|
||||
}
|
||||
}
|
||||
|
||||
if (canSharpenedClaws) {
|
||||
if (skillValue < Taming.sharpenedClawsUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.3", Taming.sharpenedClawsUnlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7", Taming.sharpenedClawsBonusDamage)));
|
||||
}
|
||||
}
|
||||
|
||||
if (canGore) {
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + LocaleLoader.getString("Perks.lucky.bonus", goreChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.taming.Taming;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class TamingCommand extends SkillCommand {
|
||||
private String goreChance;
|
||||
private String goreChanceLucky;
|
||||
|
||||
private boolean canBeastLore;
|
||||
private boolean canGore;
|
||||
private boolean canSharpenedClaws;
|
||||
private boolean canEnvironmentallyAware;
|
||||
private boolean canThickFur;
|
||||
private boolean canShockProof;
|
||||
private boolean canCallWild;
|
||||
private boolean canFastFood;
|
||||
private boolean canHolyHound;
|
||||
|
||||
public TamingCommand() {
|
||||
super(SkillType.TAMING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
if (canGore) {
|
||||
String[] goreStrings = calculateAbilityDisplayValues(Taming.goreMaxBonusLevel, Taming.goreMaxChance);
|
||||
goreChance = goreStrings[0];
|
||||
goreChanceLucky = goreStrings[1];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBeastLore = Permissions.beastLore(player);
|
||||
canCallWild = Permissions.callOfTheWild(player);
|
||||
canEnvironmentallyAware = Permissions.environmentallyAware(player);
|
||||
canFastFood = Permissions.fastFoodService(player);
|
||||
canGore = Permissions.gore(player);
|
||||
canSharpenedClaws = Permissions.sharpenedClaws(player);
|
||||
canShockProof = Permissions.shockProof(player);
|
||||
canThickFur = Permissions.thickFur(player);
|
||||
canHolyHound = Permissions.holyHound(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canBeastLore) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1")));
|
||||
}
|
||||
|
||||
if (canGore) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3")));
|
||||
}
|
||||
|
||||
if (canSharpenedClaws) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5")));
|
||||
}
|
||||
|
||||
if (canEnvironmentallyAware) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7")));
|
||||
}
|
||||
|
||||
if (canThickFur) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9")));
|
||||
}
|
||||
|
||||
if (canShockProof) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11")));
|
||||
}
|
||||
|
||||
if (canFastFood) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17")));
|
||||
}
|
||||
|
||||
if (canHolyHound) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.18"), LocaleLoader.getString("Taming.Effect.19")));
|
||||
}
|
||||
|
||||
if (canCallWild) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost()));
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canFastFood) {
|
||||
if (skillValue < Taming.fastFoodServiceUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.4", Taming.fastFoodServiceUnlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9", percent.format(Taming.fastFoodServiceActivationChance / 100D))));
|
||||
}
|
||||
}
|
||||
|
||||
if (canEnvironmentallyAware) {
|
||||
if (skillValue < Taming.environmentallyAwareUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.0", Taming.environmentallyAwareUnlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1")));
|
||||
}
|
||||
}
|
||||
|
||||
if (canThickFur) {
|
||||
if (skillValue < Taming.thickFurUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.1", Taming.thickFurUnlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3", Taming.thickFurModifier)));
|
||||
}
|
||||
}
|
||||
|
||||
if (canHolyHound) {
|
||||
if (skillValue < Taming.holyHoundUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.5", Taming.holyHoundUnlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.10"), LocaleLoader.getString("Taming.Ability.Bonus.11")));
|
||||
}
|
||||
}
|
||||
|
||||
if (canShockProof) {
|
||||
if (skillValue < Taming.shockProofUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.2", Taming.shockProofUnlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5", Taming.shockProofModifier)));
|
||||
}
|
||||
}
|
||||
|
||||
if (canSharpenedClaws) {
|
||||
if (skillValue < Taming.sharpenedClawsUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.3", Taming.sharpenedClawsUnlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7", Taming.sharpenedClawsBonusDamage)));
|
||||
}
|
||||
}
|
||||
|
||||
if (canGore) {
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", goreChanceLucky) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.unarmed.Unarmed;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class UnarmedCommand extends SkillCommand {
|
||||
private String berserkLength;
|
||||
private String berserkLengthEndurance;
|
||||
private String deflectChance;
|
||||
private String deflectChanceLucky;
|
||||
private String disarmChance;
|
||||
private String disarmChanceLucky;
|
||||
private String ironGripChance;
|
||||
private String ironGripChanceLucky;
|
||||
private int ironArmBonus;
|
||||
|
||||
private boolean canBerserk;
|
||||
private boolean canDisarm;
|
||||
private boolean canBonusDamage;
|
||||
private boolean canDeflect;
|
||||
private boolean canIronGrip;
|
||||
|
||||
public UnarmedCommand() {
|
||||
super(SkillType.UNARMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// BERSERK
|
||||
if (canBerserk) {
|
||||
String[] berserkStrings = calculateLengthDisplayValues();
|
||||
berserkLength = berserkStrings[0];
|
||||
berserkLengthEndurance = berserkStrings[1];
|
||||
}
|
||||
|
||||
// DISARM
|
||||
if (canDisarm) {
|
||||
String[] disarmStrings = calculateAbilityDisplayValues(Unarmed.disarmMaxBonusLevel, Unarmed.disarmMaxChance);
|
||||
disarmChance = disarmStrings[0];
|
||||
disarmChanceLucky = disarmStrings[1];
|
||||
}
|
||||
|
||||
// DEFLECT
|
||||
if (canDeflect) {
|
||||
String[] deflectStrings = calculateAbilityDisplayValues(Unarmed.deflectMaxBonusLevel, Unarmed.deflectMaxChance);
|
||||
deflectChance = deflectStrings[0];
|
||||
deflectChanceLucky = deflectStrings[1];
|
||||
}
|
||||
|
||||
// IRON ARM
|
||||
if (canBonusDamage) {
|
||||
ironArmBonus = Math.min(3 + ((int) skillValue / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage);
|
||||
}
|
||||
|
||||
// IRON GRIP
|
||||
if (canIronGrip) {
|
||||
String[] ironGripStrings = calculateAbilityDisplayValues(Unarmed.ironGripMaxBonusLevel, Unarmed.ironGripMaxChance);
|
||||
ironGripChance = ironGripStrings[0];
|
||||
ironGripChanceLucky = ironGripStrings[1];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canBerserk = Permissions.berserk(player);
|
||||
canBonusDamage = Permissions.bonusDamage(player, skill);
|
||||
canDeflect = Permissions.arrowDeflect(player);
|
||||
canDisarm = Permissions.disarm(player);
|
||||
canIronGrip = Permissions.ironGrip(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canBerserk) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1")));
|
||||
}
|
||||
|
||||
if (canDisarm) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3")));
|
||||
}
|
||||
|
||||
if (canBonusDamage) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5")));
|
||||
}
|
||||
|
||||
if (canDeflect) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7")));
|
||||
}
|
||||
|
||||
if (canIronGrip) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.8"), LocaleLoader.getString("Unarmed.Effect.9")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canBonusDamage) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", ironArmBonus)));
|
||||
}
|
||||
|
||||
if (canDeflect) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", deflectChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canDisarm) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", disarmChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canIronGrip) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", ironGripChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canBerserk) {
|
||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", berserkLengthEndurance) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,103 +1,95 @@
|
||||
package com.gmail.nossr50.skills.woodcutting;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillCommand;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class WoodcuttingCommand extends SkillCommand {
|
||||
private String treeFellerLength;
|
||||
private String treeFellerLengthEndurance;
|
||||
private String doubleDropChance;
|
||||
private String doubleDropChanceLucky;
|
||||
|
||||
private boolean canTreeFell;
|
||||
private boolean canLeafBlow;
|
||||
private boolean canDoubleDrop;
|
||||
|
||||
public WoodcuttingCommand() {
|
||||
super(SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
//TREE FELLER
|
||||
String[] treeFellerStrings = calculateLengthDisplayValues();
|
||||
treeFellerLength = treeFellerStrings[0];
|
||||
treeFellerLengthEndurance = treeFellerStrings[1];
|
||||
|
||||
//DOUBLE DROPS
|
||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
String[] doubleDropStrings = calculateAbilityDisplayValues(advancedConfig.getWoodcuttingDoubleDropMaxLevel(), advancedConfig.getWoodcuttingDoubleDropChance());
|
||||
doubleDropChance = doubleDropStrings[0];
|
||||
doubleDropChanceLucky = doubleDropStrings[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canTreeFell = Permissions.treeFeller(player);
|
||||
canDoubleDrop = Permissions.woodcuttingDoubleDrops(player);
|
||||
canLeafBlow = Permissions.leafBlower(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return (canDoubleDrop && !Config.getInstance().woodcuttingDoubleDropsDisabled()) || canLeafBlow || canTreeFell;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canTreeFell) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1")));
|
||||
}
|
||||
|
||||
if (canLeafBlow) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3")));
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !Config.getInstance().woodcuttingDoubleDropsDisabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return (canDoubleDrop && !Config.getInstance().woodcuttingDoubleDropsDisabled()) || canLeafBlow || canTreeFell;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canLeafBlow) {
|
||||
int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
|
||||
|
||||
if (skillValue < leafBlowerUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Woodcutting.Ability.Locked.0", leafBlowerUnlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1")));
|
||||
}
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !Config.getInstance().woodcuttingDoubleDropsDisabled()) {
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance));
|
||||
}
|
||||
}
|
||||
|
||||
if (canTreeFell) {
|
||||
if (hasEndurance) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + LocaleLoader.getString("Perks.activationtime.bonus", treeFellerLengthEndurance));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.woodcutting.Woodcutting;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class WoodcuttingCommand extends SkillCommand {
|
||||
private String treeFellerLength;
|
||||
private String treeFellerLengthEndurance;
|
||||
private String doubleDropChance;
|
||||
private String doubleDropChanceLucky;
|
||||
|
||||
private boolean canTreeFell;
|
||||
private boolean canLeafBlow;
|
||||
private boolean canDoubleDrop;
|
||||
|
||||
public WoodcuttingCommand() {
|
||||
super(SkillType.WOODCUTTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// TREE FELLER
|
||||
if (canTreeFell) {
|
||||
String[] treeFellerStrings = calculateLengthDisplayValues();
|
||||
treeFellerLength = treeFellerStrings[0];
|
||||
treeFellerLengthEndurance = treeFellerStrings[1];
|
||||
}
|
||||
|
||||
// DOUBLE DROPS
|
||||
if (canDoubleDrop) {
|
||||
String[] doubleDropStrings = calculateAbilityDisplayValues(Woodcutting.doubleDropsMaxLevel, Woodcutting.doubleDropsMaxChance);
|
||||
doubleDropChance = doubleDropStrings[0];
|
||||
doubleDropChanceLucky = doubleDropStrings[1];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canTreeFell = Permissions.treeFeller(player);
|
||||
canDoubleDrop = Permissions.doubleDrops(player, skill) && !skill.getDoubleDropsDisabled();
|
||||
canLeafBlow = Permissions.leafBlower(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return canDoubleDrop || canLeafBlow || canTreeFell;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void effectsDisplay() {
|
||||
luckyEffectsDisplay();
|
||||
|
||||
if (canTreeFell) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1")));
|
||||
}
|
||||
|
||||
if (canLeafBlow) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3")));
|
||||
}
|
||||
|
||||
if (canDoubleDrop) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return canDoubleDrop || canLeafBlow || canTreeFell;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void statsDisplay() {
|
||||
if (canLeafBlow) {
|
||||
int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
|
||||
|
||||
if (skillValue < leafBlowerUnlockLevel) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Woodcutting.Ability.Locked.0", leafBlowerUnlockLevel)));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1")));
|
||||
}
|
||||
}
|
||||
|
||||
if (canDoubleDrop) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canTreeFell) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", treeFellerLengthEndurance) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.gmail.nossr50.commands.spout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MchudCommand extends SpoutCommand {
|
||||
private static final List<String> HUD_TYPES;
|
||||
|
||||
static {
|
||||
ArrayList<String> types = new ArrayList<String>();
|
||||
|
||||
for (HudType type : HudType.values()) {
|
||||
types.add(type.toString());
|
||||
}
|
||||
|
||||
Collections.sort(types);
|
||||
HUD_TYPES = ImmutableList.copyOf(types);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], HUD_TYPES, new ArrayList<String>(HUD_TYPES.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean noArguments(Command command, CommandSender sender, String[] args) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean oneArgument(Command command, CommandSender sender, String[] args) {
|
||||
try {
|
||||
playerProfile.setHudType(HudType.valueOf(args[0].toUpperCase().trim()));
|
||||
spoutHud.initializeXpBar();
|
||||
spoutHud.updateXpBar();
|
||||
return true;
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mchud.Invalid"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +1,53 @@
|
||||
package com.gmail.nossr50.spout.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.spout.huds.SpoutHud;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public abstract class SpoutCommand implements CommandExecutor {
|
||||
protected PlayerProfile playerProfile;
|
||||
protected SpoutHud spoutHud;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
playerProfile = Users.getPlayer((Player) sender).getProfile();
|
||||
spoutHud = playerProfile.getSpoutHud();
|
||||
|
||||
if (spoutHud == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
return noArguments(command, sender, args);
|
||||
|
||||
case 1:
|
||||
return oneArgument(command, sender, args);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean noArguments(Command command, CommandSender sender, String[] args);
|
||||
protected abstract boolean oneArgument(Command command, CommandSender sender, String[] args);
|
||||
}
|
||||
package com.gmail.nossr50.commands.spout;
|
||||
|
||||
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.spout.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public abstract class SpoutCommand implements TabExecutor {
|
||||
protected PlayerProfile playerProfile;
|
||||
protected McMMOHud spoutHud;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
playerProfile = UserManager.getPlayer(sender.getName()).getProfile();
|
||||
spoutHud = playerProfile.getSpoutHud();
|
||||
|
||||
if (spoutHud == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
return noArguments(command, sender, args);
|
||||
|
||||
case 1:
|
||||
return oneArgument(command, sender, args);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean noArguments(Command command, CommandSender sender, String[] args);
|
||||
|
||||
protected abstract boolean oneArgument(Command command, CommandSender sender, String[] args);
|
||||
}
|
||||
@@ -1,63 +1,89 @@
|
||||
package com.gmail.nossr50.spout.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
public class XplockCommand extends SpoutCommand {
|
||||
@Override
|
||||
protected boolean noArguments(Command command, CommandSender sender, String[] args) {
|
||||
if (spoutHud.getXpBarLocked()) {
|
||||
unlockXpBar(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
lockXpBar(sender, spoutHud.getLastGained());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean oneArgument(Command command, CommandSender sender, String[] args) {
|
||||
if (args[0].equalsIgnoreCase("on")) {
|
||||
lockXpBar(sender, spoutHud.getLastGained());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("off")) {
|
||||
unlockXpBar(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!SkillTools.isSkill(args[0])) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
SkillType skill = SkillType.getSkill(args[0]);
|
||||
|
||||
if (!sender.hasPermission("mcmmo.commands.xplock." + skill.toString().toLowerCase())) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
lockXpBar(sender, skill);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void lockXpBar(CommandSender sender, SkillType skill) {
|
||||
if (skill != null) {
|
||||
spoutHud.setXpBarLocked(true);
|
||||
spoutHud.setSkillLock(skill);
|
||||
spoutHud.updateXpBar();
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.xplock.locked", SkillTools.getSkillName(skill)));
|
||||
}
|
||||
}
|
||||
|
||||
private void unlockXpBar(CommandSender sender) {
|
||||
spoutHud.setXpBarLocked(false);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.xplock.unlocked"));
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.commands.spout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.util.StringUtil;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class XplockCommand extends SpoutCommand {
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
return StringUtil.copyPartialMatches(args[0], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||
}
|
||||
|
||||
return matches;
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean noArguments(Command command, CommandSender sender, String[] args) {
|
||||
if (spoutHud.getXpBarLocked()) {
|
||||
unlockXpBar(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
lockXpBar(sender, spoutHud.getLastGained());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean oneArgument(Command command, CommandSender sender, String[] args) {
|
||||
if (CommandUtils.shouldEnableToggle(args[0])) {
|
||||
lockXpBar(sender, spoutHud.getLastGained());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.shouldDisableToggle(args[0])) {
|
||||
unlockXpBar(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandUtils.isInvalidSkill(sender, args[0])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SkillType skill = SkillType.getSkill(args[0]);
|
||||
|
||||
if (CommandUtils.isChildSkill(sender, skill)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Permissions.xplock(sender, skill)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
lockXpBar(sender, skill);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void lockXpBar(CommandSender sender, SkillType skill) {
|
||||
if (skill != null) {
|
||||
spoutHud.setXpBarLocked(true);
|
||||
spoutHud.setSkillLock(skill);
|
||||
spoutHud.updateXpBar();
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.xplock.locked", SkillUtils.getSkillName(skill)));
|
||||
}
|
||||
}
|
||||
|
||||
private void unlockXpBar(CommandSender sender) {
|
||||
spoutHud.setXpBarLocked(false);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.xplock.unlocked"));
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
public class AdvancedConfig extends ConfigLoader {
|
||||
public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
private static AdvancedConfig instance;
|
||||
|
||||
private AdvancedConfig() {
|
||||
super("advanced.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static AdvancedConfig getInstance() {
|
||||
@@ -17,21 +16,25 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
// TODO Do we need to use this?
|
||||
}
|
||||
protected void loadKeys() {}
|
||||
|
||||
/* GENERAL */
|
||||
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
|
||||
public int getEnchantBuff() { return config.getInt("Skills.General.Ability_EnchantBuff", 5); }
|
||||
|
||||
/* ACROBATICS */
|
||||
public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); }
|
||||
public int getDodgeMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Dodge_MaxBonusLevel", 800); }
|
||||
public int getDodgeDamageModifier() { return config.getInt("Skills.Acrobatics.Dodge_DamageModifer", 2); }
|
||||
|
||||
public double getRollChanceMax() { return config.getDouble("Skills.Acrobatics.Roll_ChanceMax", 100.0D); }
|
||||
public int getRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Roll_MaxBonusLevel", 1000); }
|
||||
public int getRollDamageThreshold() { return config.getInt("Skills.Acrobatics.Roll_DamageThreshold", 7); }
|
||||
|
||||
public double getGracefulRollChanceMax() { return config.getDouble("Skills.Acrobatics.GracefulRoll_ChanceMax", 100.0D); }
|
||||
public int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); }
|
||||
public int getGracefulRollDamageThreshold() { return config.getInt("Skills.Acrobatics.GracefulRoll_DamageThreshold", 14); }
|
||||
public int getGracefulRollSuccessModifer() { return config.getInt("Skills.Acrobatics.GracefulRoll_SuccessModifier", 2); }
|
||||
|
||||
public int getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); }
|
||||
public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); }
|
||||
@@ -63,6 +66,7 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); }
|
||||
|
||||
public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); }
|
||||
public double getImpactChance() { return config.getDouble("Skills.Axes.ArmorImpact_Chance", 25.0D); }
|
||||
public double getArmorImpactMaxDurabilityDamage() { return config.getDouble("Skills.Axes.ArmorImpact_MaxPercentageDurabilityDamage", 20.0D); }
|
||||
|
||||
public int getSkullSplitterModifier() { return config.getInt("Skills.Axes.SkullSplitter_DamagerModifier", 2); }
|
||||
@@ -107,7 +111,10 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getHerbalismDoubleDropsMaxLevel() { return config.getInt("Skills.Herbalism.DoubleDrops_MaxBonusLevel", 1000); }
|
||||
|
||||
public double getHylianLuckChanceMax() { return config.getDouble("Skills.Herbalism.HylianLuck_ChanceMax", 10.0D); }
|
||||
public int getHylianLucksMaxLevel() { return config.getInt("Skills.Herbalism.HylianLuck_MaxBonusLevel", 1000); }
|
||||
public int getHylianLuckMaxLevel() { return config.getInt("Skills.Herbalism.HylianLuck_MaxBonusLevel", 1000); }
|
||||
|
||||
public double getShroomThumbChanceMax() { return config.getDouble("Skills.Herbalism.ShroomThumb_ChanceMax", 50.0D); }
|
||||
public int getShroomThumbMaxLevel() { return config.getInt("Skills.Herbalism.ShroomThumb_MaxBonusLevel", 1500); }
|
||||
|
||||
/* MINING */
|
||||
public double getMiningDoubleDropChance() { return config.getDouble("Skills.Mining.DoubleDrops_ChanceMax", 100.0D); }
|
||||
@@ -122,11 +129,57 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getBlastMiningRank7() { return config.getInt("Skills.Mining.BlastMining_Rank7", 875); }
|
||||
public int getBlastMiningRank8() { return config.getInt("Skills.Mining.BlastMining_Rank8", 1000); }
|
||||
|
||||
public double getBlastDamageDecreaseRank1() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank1", 0.0D); }
|
||||
public double getBlastDamageDecreaseRank2() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank2", 0.0D); }
|
||||
public double getBlastDamageDecreaseRank3() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank3", 0.0D); }
|
||||
public double getBlastDamageDecreaseRank4() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank4", 25.0D); }
|
||||
public double getBlastDamageDecreaseRank5() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank5", 25.0D); }
|
||||
public double getBlastDamageDecreaseRank6() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank6", 50.0D); }
|
||||
public double getBlastDamageDecreaseRank7() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank7", 50.0D); }
|
||||
public double getBlastDamageDecreaseRank8() { return config.getDouble("Skills.Mining.BlastDamageDecrease_Rank8", 100.0D); }
|
||||
|
||||
public double getOreBonusRank1() { return config.getDouble("Skills.Mining.OreBonus_Rank1", 35.0D); }
|
||||
public double getOreBonusRank2() { return config.getDouble("Skills.Mining.OreBonus_Rank2", 40.0D); }
|
||||
public double getOreBonusRank3() { return config.getDouble("Skills.Mining.OreBonus_Rank3", 45.0D); }
|
||||
public double getOreBonusRank4() { return config.getDouble("Skills.Mining.OreBonus_Rank4", 50.0D); }
|
||||
public double getOreBonusRank5() { return config.getDouble("Skills.Mining.OreBonus_Rank5", 55.0D); }
|
||||
public double getOreBonusRank6() { return config.getDouble("Skills.Mining.OreBonus_Rank6", 60.0D); }
|
||||
public double getOreBonusRank7() { return config.getDouble("Skills.Mining.OreBonus_Rank7", 65.0D); }
|
||||
public double getOreBonusRank8() { return config.getDouble("Skills.Mining.OreBonus_Rank8", 70.0D); }
|
||||
|
||||
public double getDebrisReductionRank1() { return config.getDouble("Skills.Mining.DebrisReduction_Rank1", 10.0D); }
|
||||
public double getDebrisReductionRank2() { return config.getDouble("Skills.Mining.DebrisReduction_Rank2", 20.0D); }
|
||||
public double getDebrisReductionRank3() { return config.getDouble("Skills.Mining.DebrisReduction_Rank3", 30.0D); }
|
||||
public double getDebrisReductionRank4() { return config.getDouble("Skills.Mining.DebrisReduction_Rank4", 30.0D); }
|
||||
public double getDebrisReductionRank5() { return config.getDouble("Skills.Mining.DebrisReduction_Rank5", 30.0D); }
|
||||
public double getDebrisReductionRank6() { return config.getDouble("Skills.Mining.DebrisReduction_Rank6", 30.0D); }
|
||||
public double getDebrisReductionRank7() { return config.getDouble("Skills.Mining.DebrisReduction_Rank7", 30.0D); }
|
||||
public double getDebrisReductionRank8() { return config.getDouble("Skills.Mining.DebrisReduction_Rank8", 30.0D); }
|
||||
|
||||
public int getDropMultiplierRank1() { return config.getInt("Skills.Mining.DropMultiplier_Rank1", 1); }
|
||||
public int getDropMultiplierRank2() { return config.getInt("Skills.Mining.DropMultiplier_Rank2", 1); }
|
||||
public int getDropMultiplierRank3() { return config.getInt("Skills.Mining.DropMultiplier_Rank3", 1); }
|
||||
public int getDropMultiplierRank4() { return config.getInt("Skills.Mining.DropMultiplier_Rank4", 1); }
|
||||
public int getDropMultiplierRank5() { return config.getInt("Skills.Mining.DropMultiplier_Rank5", 2); }
|
||||
public int getDropMultiplierRank6() { return config.getInt("Skills.Mining.DropMultiplier_Rank6", 2); }
|
||||
public int getDropMultiplierRank7() { return config.getInt("Skills.Mining.DropMultiplier_Rank7", 3); }
|
||||
public int getDropMultiplierRank8() { return config.getInt("Skills.Mining.DropMultiplier_Rank8", 3); }
|
||||
|
||||
public double getBlastRadiusModifierRank1() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank1", 1.0); }
|
||||
public double getBlastRadiusModifierRank2() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank2", 1.0); }
|
||||
public double getBlastRadiusModifierRank3() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank3", 2.0); }
|
||||
public double getBlastRadiusModifierRank4() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank4", 2.0); }
|
||||
public double getBlastRadiusModifierRank5() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank5", 3.0); }
|
||||
public double getBlastRadiusModifierRank6() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank6", 3.0); }
|
||||
public double getBlastRadiusModifierRank7() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank7", 4.0); }
|
||||
public double getBlastRadiusModifierRank8() { return config.getDouble("Skills.Mining.BlastRadiusModifier_Rank8", 4.0); }
|
||||
|
||||
/* REPAIR */
|
||||
public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery_MaxBonusPercentage", 200.0D); }
|
||||
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusLevel", 1000); }
|
||||
public double getSuperRepairChanceMax() { return config.getDouble("Skills.Repair.SuperRepair_ChanceMax", 100.0D); }
|
||||
public int getSuperRepairMaxLevel() { return config.getInt("Skills.Repair.SuperRepair_MaxBonusLevel", 1000); }
|
||||
public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage_UnlockLevel", 600); }
|
||||
|
||||
/* Arcane Forging */
|
||||
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Skills.Repair.Arcane_Forging.Downgrades.Enabled", true); }
|
||||
@@ -193,6 +246,8 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getThickFurUnlock() { return config.getInt("Skills.Taming.ThickFur_UnlockLevel", 250); }
|
||||
public int getThickFurModifier() { return config.getInt("Skills.Taming.ThickFur_Modifier", 2); }
|
||||
|
||||
public int getHolyHoundUnlock() {return config.getInt("Skills.Taming.HolyHound_UnlockLevel", 375); }
|
||||
|
||||
public int getShockProofUnlock() { return config.getInt("Skills.Taming.ShockProof_UnlockLevel", 500); }
|
||||
public int getShockProofModifier() { return config.getInt("Skills.Taming.ShockProof_Modifier", 6); }
|
||||
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gmail.nossr50.metrics.MetricsManager;
|
||||
|
||||
public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
||||
public AutoUpdateConfigLoader(String relativePath, String fileName) {
|
||||
super(relativePath, fileName);
|
||||
}
|
||||
|
||||
public AutoUpdateConfigLoader(String fileName) {
|
||||
super(fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadFile() {
|
||||
super.loadFile();
|
||||
FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(plugin.getResource(fileName));
|
||||
|
||||
Set<String> configKeys = config.getKeys(true);
|
||||
Set<String> internalConfigKeys = internalConfig.getKeys(true);
|
||||
|
||||
boolean needSave = false;
|
||||
|
||||
Set<String> oldKeys = new HashSet<String>(configKeys);
|
||||
oldKeys.removeAll(internalConfigKeys);
|
||||
|
||||
Set<String> newKeys = new HashSet<String>(internalConfigKeys);
|
||||
newKeys.removeAll(configKeys);
|
||||
|
||||
// Don't need a re-save if we have old keys sticking around?
|
||||
// Would be less saving, but less... correct?
|
||||
if (!newKeys.isEmpty() || !oldKeys.isEmpty()) {
|
||||
needSave = true;
|
||||
}
|
||||
|
||||
for (String key : oldKeys) {
|
||||
plugin.debug("Removing unused key: " + key);
|
||||
config.set(key, null);
|
||||
}
|
||||
|
||||
for (String key : newKeys) {
|
||||
plugin.debug("Adding new key: " + key + " = " + internalConfig.get(key));
|
||||
config.set(key, internalConfig.get(key));
|
||||
}
|
||||
|
||||
if (needSave) {
|
||||
// Get Bukkit's version of an acceptable config with new keys, and no old keys
|
||||
String output = config.saveToString();
|
||||
|
||||
// Convert to the superior 4 space indentation
|
||||
output = output.replace(" ", " ");
|
||||
|
||||
// Rip out Bukkit's attempt to save comments at the top of the file
|
||||
while (output.indexOf('#') != -1) {
|
||||
output = output.substring(output.indexOf('\n', output.indexOf('#')) + 1);
|
||||
}
|
||||
|
||||
// Read the internal config to get comments, then put them in the new one
|
||||
try {
|
||||
// Read internal
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getResource(fileName)));
|
||||
HashMap<String, String> comments = new HashMap<String, String>();
|
||||
String temp = "";
|
||||
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (line.contains("#")) {
|
||||
temp += line + "\n";
|
||||
}
|
||||
else if (line.contains(":")) {
|
||||
line = line.substring(0, line.indexOf(":") + 1);
|
||||
if (!temp.isEmpty()) {
|
||||
comments.put(line, temp);
|
||||
temp = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dump to the new one
|
||||
for (String key : comments.keySet()) {
|
||||
if (output.indexOf(key) != -1) {
|
||||
output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Save it
|
||||
try {
|
||||
String saveName = fileName;
|
||||
// At this stage we cannot guarantee that Config has been loaded, so we do the check directly here
|
||||
if (!plugin.getConfig().getBoolean("General.Config_Update_Overwrite", true)) {
|
||||
saveName += ".new";
|
||||
}
|
||||
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(plugin.getDataFolder(), saveName)));
|
||||
writer.write(output);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (String key : configKeys) {
|
||||
if (!config.isConfigurationSection(key) && !config.get(key).equals(internalConfig.get(key))) {
|
||||
MetricsManager.customConfig();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,20 @@ package com.gmail.nossr50.config;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
public class Config extends ConfigLoader {
|
||||
public class Config extends AutoUpdateConfigLoader {
|
||||
private static Config instance;
|
||||
|
||||
private Config() {
|
||||
super("config.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static Config getInstance() {
|
||||
@@ -35,11 +39,28 @@ public class Config extends ConfigLoader {
|
||||
public boolean getDonateMessageEnabled() { return config.getBoolean("Commands.mcmmo.Donate_Message", true); }
|
||||
public int getSaveInterval() { return config.getInt("General.Save_Interval", 10); }
|
||||
public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); }
|
||||
public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); }
|
||||
public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
|
||||
public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); }
|
||||
public boolean getBackupsEnabled() { return config.getBoolean("General.Generate_Backups", true); }
|
||||
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
|
||||
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
|
||||
|
||||
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
|
||||
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
|
||||
|
||||
/* Mob Healthbar */
|
||||
public MobHealthbarType getMobHealthbarDefault() {
|
||||
try {
|
||||
return MobHealthbarType.valueOf(config.getString("Mob_Healthbar.Display_Type", "HEARTS").toUpperCase().trim());
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
return MobHealthbarType.HEARTS;
|
||||
}
|
||||
}
|
||||
|
||||
public int getMobHealthbarTime() { return config.getInt("Mob_Healthbar.Display_Time", 3); }
|
||||
|
||||
/* Database Purging */
|
||||
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
|
||||
public int getOldUsersCutoff() { return config.getInt("Database_Purging.Old_User_Cutoff", 6); }
|
||||
@@ -62,10 +83,14 @@ public class Config extends ConfigLoader {
|
||||
|
||||
private static String getStringIncludingInts(ConfigurationSection cfg, String key) {
|
||||
String str = cfg.getString(key);
|
||||
if (str == null)
|
||||
|
||||
if (str == null) {
|
||||
str = String.valueOf(cfg.getInt(key));
|
||||
if (str == null)
|
||||
}
|
||||
|
||||
if (str == "0") {
|
||||
str = "No value set for '" + key + "'";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -89,9 +114,23 @@ public class Config extends ConfigLoader {
|
||||
public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
|
||||
|
||||
/* Items */
|
||||
public int getChimaeraCost() { return config.getInt("Items.Chimaera_Wing.Feather_Cost", 10); }
|
||||
public int getChimaeraUseCost() { return config.getInt("Items.Chimaera_Wing.Use_Cost", 1); }
|
||||
public int getChimaeraRecipeCost() { return config.getInt("Items.Chimaera_Wing.Recipe_Cost", 5); }
|
||||
public int getChimaeraItemId() { return config.getInt("Items.Chimaera_Wing.Item_ID", 288); }
|
||||
public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); }
|
||||
public boolean getChimaeraPreventUseUnderground() { return config.getBoolean("Items.Chimaera_Wing.Prevent_Use_Underground", true); }
|
||||
public int getChimaeraCooldown() { return config.getInt("Items.Chimaera_Wing.Cooldown", 240); }
|
||||
public int getChimaeraWarmup() { return config.getInt("Items.Chimaera_Wing.Warmup", 5); }
|
||||
public int getChimaeraRecentlyHurtCooldown() { return config.getInt("Items.Chimaera_Wing.RecentlyHurt_Cooldown", 60); }
|
||||
|
||||
/* Particles */
|
||||
public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", true); }
|
||||
public boolean getAbilityDeactivationEffectEnabled() { return config.getBoolean("Particles.Ability_Deactivation", true); }
|
||||
public boolean getDodgeEffectEnabled() { return config.getBoolean("Particles.Dodge", true); }
|
||||
public boolean getBleedEffectEnabled() { return config.getBoolean("Particles.Bleed", true); }
|
||||
public boolean getGreaterImpactEffectEnabled() { return config.getBoolean("Particles.Greater_Impact", true); }
|
||||
public boolean getLevelUpEffectsEnabled() { return config.getBoolean("Particles.LevelUp_Enabled", true); }
|
||||
public int getLevelUpEffectsTier() { return config.getInt("Particles.LevelUp_Tier", 100); }
|
||||
|
||||
/* PARTY SETTINGS */
|
||||
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
|
||||
@@ -104,7 +143,9 @@ public class Config extends ConfigLoader {
|
||||
public double getPartyShareRange() { return config.getDouble("Party.Sharing.Range", 75.0); }
|
||||
|
||||
/* Party Teleport Settings */
|
||||
public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 30); }
|
||||
public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 120); }
|
||||
public int getPTPCommandWarmup() { return config.getInt("Commands.ptp.Warmup", 5); }
|
||||
public int getPTPCommandRecentlyHurtCooldown() { return config.getInt("Commands.ptp.RecentlyHurt_Cooldown", 60); }
|
||||
public int getPTPCommandTimeout() { return config.getInt("Commands.ptp.Request_Timeout", 300); }
|
||||
public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Confirm_Required", true); }
|
||||
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
|
||||
@@ -118,30 +159,13 @@ public class Config extends ConfigLoader {
|
||||
public boolean getAbilitiesEnabled() { return config.getBoolean("Abilities.Enabled", true); }
|
||||
public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); }
|
||||
|
||||
public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); }
|
||||
public int getMaxTicks(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
|
||||
|
||||
/* Durability Settings */
|
||||
public boolean getAbilitiesDamageTools() { return config.getBoolean("Abilities.Tools.Durability_Loss_Enabled", true); }
|
||||
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 2); }
|
||||
|
||||
/* Cooldowns */
|
||||
public int getAbilityCooldownGreenTerra() { return config.getInt("Abilities.Cooldowns.Green_Terra", 240); }
|
||||
public int getAbilityCooldownSuperBreaker() { return config.getInt("Abilities.Cooldowns.Super_Breaker", 240); }
|
||||
public int getAbilityCooldownGigaDrillBreaker() { return config.getInt("Abilities.Cooldowns.Giga_Drill_Breaker", 240); }
|
||||
public int getAbilityCooldownTreeFeller() { return config.getInt("Abilities.Cooldowns.Tree_Feller", 240); }
|
||||
public int getAbilityCooldownBerserk() { return config.getInt("Abilities.Cooldowns.Berserk", 240); }
|
||||
public int getAbilityCooldownSerratedStrikes() { return config.getInt("Abilities.Cooldowns.Serrated_Strikes", 240); }
|
||||
public int getAbilityCooldownSkullSplitter() { return config.getInt("Abilities.Cooldowns.Skull_Splitter", 240); }
|
||||
public int getAbilityCooldownBlastMining() { return config.getInt("Abilities.Cooldowns.Blast_Mining", 60); }
|
||||
|
||||
/* Max ticks */
|
||||
public int getAbilityMaxTicksGreenTerra() { return config.getInt("Abilities.Max_Seconds.Green_Terra", 0); }
|
||||
public int getAbilityMaxTicksSuperBreaker() { return config.getInt("Abilities.Max_Seconds.Super_Breaker", 0); }
|
||||
public int getAbilityMaxTicksGigaDrillBreaker() { return config.getInt("Abilities.Max_Seconds.Giga_Drill_Breaker", 0); }
|
||||
public int getAbilityMaxTicksTreeFeller() { return config.getInt("Abilities.Max_Seconds.Tree_Feller", 0); }
|
||||
public int getAbilityMaxTicksBerserk() { return config.getInt("Abilities.Max_Seconds.Berserk", 0); }
|
||||
public int getAbilityMaxTicksSerratedStrikes() { return config.getInt("Abilities.Max_Seconds.Serrated_Strikes", 0); }
|
||||
public int getAbilityMaxTicksSkullSplitter() { return config.getInt("Abilities.Max_Seconds.Skull_Splitter", 0); }
|
||||
public int getAbilityMaxTicksBlastMining() { return config.getInt("Abilities.Max_Seconds.Blast_Mining", 0); }
|
||||
|
||||
/* Thresholds */
|
||||
public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); }
|
||||
|
||||
@@ -149,119 +173,42 @@ public class Config extends ConfigLoader {
|
||||
* SKILL SETTINGS
|
||||
*/
|
||||
|
||||
/* Tool Requirements */
|
||||
public boolean getMiningRequiresTool() { return config.getBoolean("Skills.Mining.Requires_Pickaxe", true); }
|
||||
public boolean getExcavationRequiresTool() { return config.getBoolean("Skills.Excavation.Requires_Shovel", true); }
|
||||
public boolean getWoodcuttingRequiresTool() { return config.getBoolean("Skills.Woodcutting.Requires_Axe", true); }
|
||||
public int getXp(SkillType skill, Material material) { return config.getInt("Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
|
||||
public boolean getDoubleDropsEnabled(SkillType skill, Material material) { return config.getBoolean("Double_Drops." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
|
||||
|
||||
/* Excavation */
|
||||
public int getExcavationClayXP() { return config.getInt("Experience.Excavation.Clay", 40); }
|
||||
public int getExcavationDirtXP() { return config.getInt("Experience.Excavation.Dirt", 40); }
|
||||
public int getExcavationGrassXP() { return config.getInt("Experience.Excavation.Grass", 40); }
|
||||
public int getExcavationGravelXP() { return config.getInt("Experience.Excavation.Gravel", 40); }
|
||||
public int getExcavationMycelXP() { return config.getInt("Experience.Excavation.Mycel", 40); }
|
||||
public int getExcavationSandXP() { return config.getInt("Experience.Excavation.Sand", 40); }
|
||||
public int getExcavationSoulSandXP() { return config.getInt("Experience.Excavation.SoulSand", 40); }
|
||||
public boolean getDoubleDropsDisabled(SkillType skill) {
|
||||
String skillName = StringUtils.getCapitalized(skill.toString());
|
||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops." + skillName);
|
||||
Set<String> keys = section.getKeys(false);
|
||||
boolean disabled = true;
|
||||
|
||||
for (String key : keys) {
|
||||
if (config.getBoolean("Double_Drops." + skillName + "." + key)) {
|
||||
disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
/* Acrobatics */
|
||||
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
|
||||
|
||||
/* Fishing */
|
||||
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
|
||||
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
|
||||
|
||||
/* Herbalism */
|
||||
public int getHerbalismXPSugarCane() { return config.getInt("Experience.Herbalism.Sugar_Cane", 30); }
|
||||
public int getHerbalismXPWheat() { return config.getInt("Experience.Herbalism.Wheat", 50); }
|
||||
public int getHerbalismXPCactus() { return config.getInt("Experience.Herbalism.Cactus", 30); }
|
||||
public int getHerbalismXPPumpkin() { return config.getInt("Experience.Herbalism.Pumpkin", 20); }
|
||||
public int getHerbalismXPFlowers() { return config.getInt("Experience.Herbalism.Flowers", 100); }
|
||||
public int getHerbalismXPMushrooms() { return config.getInt("Experience.Herbalism.Mushrooms", 150); }
|
||||
public int getHerbalismXPMelon() { return config.getInt("Experience.Herbalism.Melon", 20); }
|
||||
public int getHerbalismXPNetherWart() { return config.getInt("Experience.Herbalism.Nether_Wart", 50); }
|
||||
public int getHerbalismXPLilyPads() { return config.getInt("Experience.Herbalism.Lily_Pads", 100); }
|
||||
public int getHerbalismXPVines() { return config.getInt("Experience.Herbalism.Vines", 10); }
|
||||
public int getHerbalismXPCocoa() { return config.getInt("Experience.Herbalism.Cocoa", 30); }
|
||||
public int getHerbalismXPCarrot() { return config.getInt("Experience.Herbalism.Carrot", 50); }
|
||||
public int getHerbalismXPPotato() { return config.getInt("Experience.Herbalism.Potato", 50); }
|
||||
|
||||
public boolean getHerbalismGreenThumbCobbleToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Cobble_To_Mossy", true); }
|
||||
public boolean getHerbalismGreenThumbCobbleWallToMossyWall() { return config.getBoolean("Skills.Herbalism.Green_Thumb.CobbleWall_To_MossyWall", true); }
|
||||
public boolean getHerbalismGreenThumbSmoothbrickToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.SmoothBrick_To_MossyBrick", true); }
|
||||
public boolean getHerbalismGreenThumbDirtToGrass() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Dirt_To_Grass", true); }
|
||||
|
||||
public boolean getBrownMushroomsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Brown_Mushrooms", true); }
|
||||
public boolean getCactiDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Cacti", true); }
|
||||
public boolean getWheatDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Wheat", true); }
|
||||
public boolean getMelonsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Melons", true); }
|
||||
public boolean getNetherWartsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Nether_Warts", true); }
|
||||
public boolean getPumpkinsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Pumpkins", true); }
|
||||
public boolean getRedMushroomsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Red_Mushrooms", true); }
|
||||
public boolean getRedRosesDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Red_Roses", true); }
|
||||
public boolean getSugarCaneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Sugar_Cane", true); }
|
||||
public boolean getVinesDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Vines", true); }
|
||||
public boolean getWaterLiliesDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Water_Lilies", true); }
|
||||
public boolean getYellowFlowersDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Yellow_Flowers", true); }
|
||||
public boolean getCocoaDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Cocoa", true); }
|
||||
public boolean getCarrotDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Carrot", true); }
|
||||
public boolean getPotatoDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Potato", true); }
|
||||
|
||||
public boolean herbalismDoubleDropsDisabled() {
|
||||
return doubleDropsDisabled("Herbalism");
|
||||
}
|
||||
|
||||
/* Mining */
|
||||
public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); }
|
||||
public int getMiningXPDiamondOre() { return config.getInt("Experience.Mining.Diamond", 750); }
|
||||
public int getMiningXPIronOre() { return config.getInt("Experience.Mining.Iron", 250); }
|
||||
public int getMiningXPRedstoneOre() { return config.getInt("Experience.Mining.Redstone", 150); }
|
||||
public int getMiningXPLapisOre() { return config.getInt("Experience.Mining.Lapis", 400); }
|
||||
public int getMiningXPObsidian() { return config.getInt("Experience.Mining.Obsidian", 150); }
|
||||
public int getMiningXPNetherrack() { return config.getInt("Experience.Mining.Netherrack", 30); }
|
||||
public int getMiningXPGlowstone() { return config.getInt("Experience.Mining.Glowstone", 30); }
|
||||
public int getMiningXPCoalOre() { return config.getInt("Experience.Mining.Coal", 100); }
|
||||
public int getMiningXPStone() { return config.getInt("Experience.Mining.Stone", 30); }
|
||||
public int getMiningXPSandstone() { return config.getInt("Experience.Mining.Sandstone", 30); }
|
||||
public int getMiningXPEndStone() { return config.getInt("Experience.Mining.End_Stone", 150); }
|
||||
public int getMiningXPMossyStone() { return config.getInt("Experience.Mining.Moss_Stone", 30); }
|
||||
public int getMiningXPEmeraldOre() { return config.getInt("Experience.Mining.Emerald", 1000); }
|
||||
|
||||
public boolean getCoalDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Coal", true); }
|
||||
public boolean getDiamondDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Diamond", true); }
|
||||
public boolean getEndStoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.End_Stone", true); }
|
||||
public boolean getGlowstoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Glowstone", true); }
|
||||
public boolean getGoldDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Gold", true); }
|
||||
public boolean getIronDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Iron", true); }
|
||||
public boolean getLapisDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Lapis", true); }
|
||||
public boolean getMossyCobblestoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Moss_Stone", true); }
|
||||
public boolean getNetherrackDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Netherrack", true); }
|
||||
public boolean getObsidianDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Obsidian", true); }
|
||||
public boolean getRedstoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Redstone", true); }
|
||||
public boolean getSandstoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Sandstone", true); }
|
||||
public boolean getStoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Stone", true); }
|
||||
public boolean getEmeraldDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Emerald", true); }
|
||||
|
||||
public boolean miningDoubleDropsDisabled() {
|
||||
return doubleDropsDisabled("Mining");
|
||||
}
|
||||
|
||||
public int getDetonatorItemID() { return config.getInt("Skills.Mining.Detonator_ID", 259); }
|
||||
|
||||
/* Repair */
|
||||
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
|
||||
public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); }
|
||||
public boolean getSalvageEnabled() { return config.getBoolean("Skills.Repair.Salvage_enabled", true); }
|
||||
public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); }
|
||||
public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage_UnlockLevel", 600); }
|
||||
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
|
||||
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
|
||||
|
||||
/* Smelting */
|
||||
public int getSmeltingXPCoal() { return config.getInt("Experience.Smelting.Coal", 10); }
|
||||
public int getSmeltingXPRedstone() { return config.getInt("Experience.Smelting.Redstone", 15); }
|
||||
public int getSmeltingXPIron() { return config.getInt("Experience.Smelting.Iron", 25); }
|
||||
public int getSmeltingXPGold() { return config.getInt("Experience.Smelting.Gold", 35); }
|
||||
public int getSmeltingXPDiamond() { return config.getInt("Experience.Smelting.Diamond", 75); }
|
||||
public int getSmeltingXPLapis() { return config.getInt("Experience.Smelting.Lapis", 40); }
|
||||
public int getSmeltingXPEmerald() { return config.getInt("Experience.Smelting.Emerald", 100); }
|
||||
|
||||
/* Unarmed */
|
||||
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
|
||||
|
||||
@@ -278,94 +225,30 @@ public class Config extends ConfigLoader {
|
||||
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
|
||||
public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
|
||||
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
|
||||
|
||||
|
||||
public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); }
|
||||
public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
|
||||
public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); }
|
||||
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
|
||||
|
||||
public boolean woodcuttingDoubleDropsDisabled() {
|
||||
return doubleDropsDisabled("Woodcutting");
|
||||
}
|
||||
|
||||
/* AFK Leveling */
|
||||
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
|
||||
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
|
||||
|
||||
/* Dogde Lightning */
|
||||
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
|
||||
|
||||
/* Level Caps */
|
||||
public int getLevelCapAcrobatics() {
|
||||
return getLevelCap("Skills.Acrobatics.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapArchery() {
|
||||
return getLevelCap("Skills.Archery.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapAxes() {
|
||||
return getLevelCap("Skills.Axes.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapExcavation() {
|
||||
return getLevelCap("Skills.Excavation.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapFishing() {
|
||||
return getLevelCap("Skills.Fishing.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapHerbalism() {
|
||||
return getLevelCap("Skills.Herbalism.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapMining() {
|
||||
return getLevelCap("Skills.Mining.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapRepair() {
|
||||
return getLevelCap("Skills.Repair.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapSmelting() {
|
||||
return getLevelCap("Skills.Smelting.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapSwords() {
|
||||
return getLevelCap("Skills.Swords.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapTaming() {
|
||||
return getLevelCap("Skills.Taming.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapUnarmed() {
|
||||
return getLevelCap("Skills.Unarmed.Level_Cap");
|
||||
}
|
||||
|
||||
public int getLevelCapWoodcutting() {
|
||||
return getLevelCap("Skills.Woodcutting.Level_Cap");
|
||||
}
|
||||
|
||||
public int getPowerLevelCap() {
|
||||
return getLevelCap("General.Power_Level_Cap");
|
||||
int cap = config.getInt("General.Power_Level_Cap", 0);
|
||||
return (cap <= 0) ? Integer.MAX_VALUE : cap;
|
||||
}
|
||||
|
||||
public int getLevelCap(SkillType skill) {
|
||||
int cap = config.getInt("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Level_Cap");
|
||||
return (cap <= 0) ? Integer.MAX_VALUE : cap;
|
||||
}
|
||||
|
||||
/* PVP & PVE Settings */
|
||||
public boolean getAcrobaticsPVP() { return config.getBoolean("Skills.Acrobatics.Enabled_For_PVP", true); }
|
||||
public boolean getAcrobaticsPVE() { return config.getBoolean("Skills.Acrobatics.Enabled_For_PVE", true); }
|
||||
public boolean getArcheryPVP() { return config.getBoolean("Skills.Archery.Enabled_For_PVP", true); }
|
||||
public boolean getArcheryPVE() { return config.getBoolean("Skills.Archery.Enabled_For_PVE", true); }
|
||||
public boolean getAxesPVP() { return config.getBoolean("Skills.Axes.Enabled_For_PVP", true); }
|
||||
public boolean getAxesPVE() { return config.getBoolean("Skills.Axes.Enabled_For_PVE", true); }
|
||||
public boolean getSwordsPVP() { return config.getBoolean("Skills.Swords.Enabled_For_PVP", true); }
|
||||
public boolean getSwordsPVE() { return config.getBoolean("Skills.Swords.Enabled_For_PVE", true); }
|
||||
public boolean getTamingPVP() { return config.getBoolean("Skills.Taming.Enabled_For_PVP", true); }
|
||||
public boolean getTamingPVE() { return config.getBoolean("Skills.Taming.Enabled_For_PVE", true); }
|
||||
public boolean getUnarmedPVP() { return config.getBoolean("Skills.Unarmed.Enabled_For_PVP", true); }
|
||||
public boolean getUnarmedPVE() { return config.getBoolean("Skills.Unarmed.Enabled_For_PVE", 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); }
|
||||
|
||||
/*
|
||||
* XP SETTINGS
|
||||
@@ -374,70 +257,19 @@ public class Config extends ConfigLoader {
|
||||
/* General Settings */
|
||||
public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
|
||||
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
|
||||
|
||||
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
|
||||
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience.Gains.Multiplier.Global", value); }
|
||||
|
||||
/* Combat XP Multipliers */
|
||||
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
|
||||
public double getCombatXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
|
||||
|
||||
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
|
||||
public double getCreeperXP() { return config.getDouble("Experience.Combat.Multiplier.Creeper", 4.0); }
|
||||
public double getSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Skeleton", 2.0); }
|
||||
public double getSpiderXP() { return config.getDouble("Experience.Combat.Multiplier.Spider", 3.0); }
|
||||
public double getGhastXP() { return config.getDouble("Experience.Combat.Multiplier.Ghast", 3.0); }
|
||||
public double getSlimeXP() { return config.getDouble("Experience.Combat.Multiplier.Slime", 2.0); }
|
||||
public double getZombieXP() { return config.getDouble("Experience.Combat.Multiplier.Zombie", 2.0); }
|
||||
public double getPigZombieXP() { return config.getDouble("Experience.Combat.Multiplier.Pig_Zombie", 3.0); }
|
||||
public double getEndermanXP() { return config.getDouble("Experience.Combat.Multiplier.Enderman", 1.0); }
|
||||
public double getCaveSpiderXP() { return config.getDouble("Experience.Combat.Multiplier.Cave_Spider", 3.0); }
|
||||
public double getSilverfishXP() { return config.getDouble("Experience.Combat.Multiplier.Silverfish", 3.0); }
|
||||
public double getBlazeXP() { return config.getDouble("Experience.Combat.Multiplier.Blaze", 3.0); }
|
||||
public double getMagmaCubeXP() { return config.getDouble("Experience.Combat.Multiplier.Magma_Cube", 2.0); }
|
||||
public double getEnderDragonXP() { return config.getDouble("Experience.Combat.Multiplier.Ender_Dragon", 8.0); }
|
||||
public double getIronGolemXP() { return config.getDouble("Experience.Combat.Multiplier.Iron_Golem", 2.0); }
|
||||
public double getGiantXP() { return config.getDouble("Experience.Combat.Multiplier.Giant", 4.0); }
|
||||
public double getWitherXP() { return config.getDouble("Experience.Combat.Multiplier.Wither", 7.0); }
|
||||
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
|
||||
public double getWitchXP() { return config.getDouble("Experience.Combat.Multiplier.Witch", 4.0); }
|
||||
|
||||
|
||||
/* XP Formula Multiplier */
|
||||
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
|
||||
public double getFormulaMultiplierTaming() { return config.getDouble("Experience.Formula.Multiplier.Taming", 1.0); }
|
||||
public double getFormulaMultiplierMining() { return config.getDouble("Experience.Formula.Multiplier.Mining", 1.0); }
|
||||
public double getFormulaMultiplierRepair() { return config.getDouble("Experience.Formula.Multiplier.Repair", 1.0); }
|
||||
public double getFormulaMultiplierWoodcutting() { return config.getDouble("Experience.Formula.Multiplier.Woodcutting", 1.0); }
|
||||
public double getFormulaMultiplierUnarmed() { return config.getDouble("Experience.Formula.Multiplier.Unarmed", 1.0); }
|
||||
public double getFormulaMultiplierHerbalism() { return config.getDouble("Experience.Formula.Multiplier.Herbalism", 1.0); }
|
||||
public double getFormulaMultiplierExcavation() { return config.getDouble("Experience.Formula.Multiplier.Excavation", 1.0); }
|
||||
public double getFormulaMultiplierArchery() { return config.getDouble("Experience.Formula.Multiplier.Archery", 1.0); }
|
||||
public double getFormulaMultiplierSwords() { return config.getDouble("Experience.Formula.Multiplier.Swords", 1.0); }
|
||||
public double getFormulaMultiplierAxes() { return config.getDouble("Experience.Formula.Multiplier.Axes", 1.0); }
|
||||
public double getFormulaMultiplierAcrobatics() { return config.getDouble("Experience.Formula.Multiplier.Acrobatics", 1.0); }
|
||||
public double getFormulaMultiplierFishing() { return config.getDouble("Experience.Formula.Multiplier.Fishing", 1.0); }
|
||||
|
||||
private boolean doubleDropsDisabled(String skillName) {
|
||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops." + skillName);
|
||||
|
||||
if (section == null) {
|
||||
mcMMO.p.getLogger().warning("The configuration files are outdated!"); //TODO Locale and more descriptive message!
|
||||
return false;
|
||||
}
|
||||
|
||||
Set<String> keys = section.getKeys(false);
|
||||
|
||||
boolean disabled = true;
|
||||
|
||||
for (String key : keys) {
|
||||
if (config.getBoolean("Double_Drops." + skillName + "." + key)) {
|
||||
disabled = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return disabled;
|
||||
}
|
||||
|
||||
private int getLevelCap(String configString) {
|
||||
int cap = config.getInt(configString, 0);
|
||||
return ((cap <= 0) ? Integer.MAX_VALUE : cap);
|
||||
}
|
||||
public double getForumulaMultiplier(SkillType skill) { return config.getDouble("Experience.Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
|
||||
}
|
||||
|
||||
@@ -1,79 +1,80 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public abstract class ConfigLoader {
|
||||
protected static final mcMMO plugin = mcMMO.p;
|
||||
protected String fileName;
|
||||
protected File configFile;
|
||||
protected FileConfiguration config;
|
||||
|
||||
public ConfigLoader(String relativePath, String fileName) {
|
||||
this.fileName = fileName;
|
||||
configFile = new File(plugin.getDataFolder(), relativePath + File.separator + fileName);
|
||||
loadFile();
|
||||
}
|
||||
|
||||
public ConfigLoader(String fileName) {
|
||||
this.fileName = fileName;
|
||||
configFile = new File(plugin.getDataFolder(), fileName);
|
||||
loadFile();
|
||||
}
|
||||
|
||||
protected void loadFile() {
|
||||
if (!configFile.exists()) {
|
||||
plugin.getLogger().info("Creating mcMMO " + fileName + " File...");
|
||||
createFile();
|
||||
}
|
||||
else {
|
||||
plugin.getLogger().info("Loading mcMMO " + fileName + " File...");
|
||||
}
|
||||
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
}
|
||||
|
||||
protected abstract void loadKeys();
|
||||
|
||||
protected void createFile() {
|
||||
if (configFile.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
configFile.getParentFile().mkdirs();
|
||||
|
||||
InputStream inputStream = plugin.getResource(fileName);
|
||||
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
copyStreamToFile(inputStream, configFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
plugin.getLogger().severe("Missing resource file: '" + fileName + "' please notify the plugin authors");
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyStreamToFile(InputStream inputStream, File file) throws Exception {
|
||||
OutputStream outputStream = new FileOutputStream(file);
|
||||
|
||||
int read = 0;
|
||||
byte[] bytes = new byte[1024];
|
||||
|
||||
while ((read = inputStream.read(bytes)) != -1) {
|
||||
outputStream.write(bytes, 0, read);
|
||||
}
|
||||
|
||||
inputStream.close();
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public abstract class ConfigLoader {
|
||||
protected static final mcMMO plugin = mcMMO.p;
|
||||
protected String fileName;
|
||||
protected File configFile;
|
||||
protected FileConfiguration config;
|
||||
|
||||
public ConfigLoader(String relativePath, String fileName) {
|
||||
this.fileName = fileName;
|
||||
configFile = new File(plugin.getDataFolder(), relativePath + File.separator + fileName);
|
||||
loadFile();
|
||||
}
|
||||
|
||||
public ConfigLoader(String fileName) {
|
||||
this.fileName = fileName;
|
||||
configFile = new File(plugin.getDataFolder(), fileName);
|
||||
loadFile();
|
||||
}
|
||||
|
||||
protected void loadFile() {
|
||||
if (!configFile.exists()) {
|
||||
plugin.getLogger().info("Creating mcMMO " + fileName + " File...");
|
||||
createFile();
|
||||
}
|
||||
else {
|
||||
plugin.getLogger().info("Loading mcMMO " + fileName + " File...");
|
||||
}
|
||||
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
}
|
||||
|
||||
protected abstract void loadKeys();
|
||||
|
||||
protected void createFile() {
|
||||
if (configFile.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
configFile.getParentFile().mkdirs();
|
||||
|
||||
InputStream inputStream = plugin.getResource(fileName);
|
||||
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
copyStreamToFile(inputStream, configFile);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
plugin.getLogger().severe("Missing resource file: '" + fileName + "' please notify the plugin authors");
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyStreamToFile(InputStream inputStream, File file) throws Exception {
|
||||
OutputStream outputStream = new FileOutputStream(file);
|
||||
|
||||
int read = 0;
|
||||
byte[] bytes = new byte[1024];
|
||||
|
||||
while ((read = inputStream.read(bytes)) != -1) {
|
||||
outputStream.write(bytes, 0, read);
|
||||
}
|
||||
|
||||
inputStream.close();
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ public class HiddenConfig {
|
||||
private static YamlConfiguration config;
|
||||
private static boolean chunkletsEnabled;
|
||||
private static int conversionRate;
|
||||
private static boolean useEnchantmentBuffs;
|
||||
private static boolean resendChunksAfterBlockAbility;
|
||||
|
||||
public HiddenConfig(String fileName) {
|
||||
HiddenConfig.fileName = fileName;
|
||||
@@ -29,6 +31,8 @@ public class HiddenConfig {
|
||||
config = YamlConfiguration.loadConfiguration(mcMMO.p.getResource(fileName));
|
||||
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
|
||||
conversionRate = config.getInt("Options.ConversionRate", 1);
|
||||
useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true);
|
||||
resendChunksAfterBlockAbility = config.getBoolean("Options.RefreshChunks", false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,4 +43,12 @@ public class HiddenConfig {
|
||||
public int getConversionRate() {
|
||||
return conversionRate;
|
||||
}
|
||||
|
||||
public boolean useEnchantmentBuffs() {
|
||||
return useEnchantmentBuffs;
|
||||
}
|
||||
|
||||
public boolean resendChunksAfterBlockAbility() {
|
||||
return resendChunksAfterBlockAbility;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,94 +1,101 @@
|
||||
package com.gmail.nossr50.mods.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomItem;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
|
||||
public class CustomArmorConfig extends ConfigLoader{
|
||||
private static CustomArmorConfig instance;
|
||||
private List<Repairable> repairables;
|
||||
public List<Integer> customBootIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
|
||||
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
|
||||
|
||||
public CustomArmorConfig() {
|
||||
super("ModConfigs", "armor.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static CustomArmorConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomArmorConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
loadArmor("Boots", customBootIDs);
|
||||
loadArmor("Chestplates", customChestplateIDs);
|
||||
loadArmor("Helmets", customHelmetIDs);
|
||||
loadArmor("Leggings", customLeggingIDs);
|
||||
}
|
||||
|
||||
private void loadArmor(String armorType, List<Integer> idList) {
|
||||
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
||||
|
||||
if (armorSection == null)
|
||||
return;
|
||||
|
||||
Set<String> armorConfigSet = armorSection.getKeys(false);
|
||||
|
||||
for (String armorName : armorConfigSet) {
|
||||
int id = config.getInt(armorType + "." + armorName + ".ID", 0);
|
||||
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
|
||||
int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0);
|
||||
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", 0);
|
||||
int repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Quantity", 0);
|
||||
short durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 0);
|
||||
|
||||
if (id == 0) {
|
||||
plugin.getLogger().warning("Missing ID. This item will be skipped.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
|
||||
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
|
||||
repairable = false;
|
||||
}
|
||||
|
||||
CustomItem armor;
|
||||
|
||||
if (repairable) {
|
||||
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
|
||||
}
|
||||
|
||||
armor = new CustomItem(id, durability);
|
||||
|
||||
idList.add(id);
|
||||
customIDs.add(id);
|
||||
customArmorList.add(armor);
|
||||
customArmor.put(id, armor);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
if (repairables == null) return new ArrayList<Repairable>();
|
||||
return repairables;
|
||||
}
|
||||
}
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
|
||||
public class CustomArmorConfig extends ConfigLoader {
|
||||
private static CustomArmorConfig instance;
|
||||
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public List<Integer> customBootIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||
|
||||
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
|
||||
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
|
||||
|
||||
public CustomArmorConfig() {
|
||||
super("ModConfigs", "armor.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static CustomArmorConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomArmorConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public List<Repairable> getLoadedRepairables() {
|
||||
if (repairables == null) {
|
||||
return new ArrayList<Repairable>();
|
||||
}
|
||||
|
||||
return repairables;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
loadArmor("Boots", customBootIDs);
|
||||
loadArmor("Chestplates", customChestplateIDs);
|
||||
loadArmor("Helmets", customHelmetIDs);
|
||||
loadArmor("Leggings", customLeggingIDs);
|
||||
}
|
||||
|
||||
private void loadArmor(String armorType, List<Integer> idList) {
|
||||
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
||||
|
||||
if (armorSection == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> armorConfigSet = armorSection.getKeys(false);
|
||||
|
||||
for (String armorName : armorConfigSet) {
|
||||
int id = config.getInt(armorType + "." + armorName + ".ID", 0);
|
||||
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
|
||||
int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0);
|
||||
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", 0);
|
||||
int repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Quantity", 0);
|
||||
short durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 0);
|
||||
|
||||
if (id == 0) {
|
||||
plugin.getLogger().warning("Missing ID. This item will be skipped.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
|
||||
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
|
||||
repairable = false;
|
||||
}
|
||||
|
||||
CustomItem armor;
|
||||
|
||||
if (repairable) {
|
||||
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
|
||||
}
|
||||
|
||||
armor = new CustomItem(id, durability);
|
||||
|
||||
idList.add(id);
|
||||
customIDs.add(id);
|
||||
customArmorList.add(armor);
|
||||
customArmor.put(id, armor);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user