mirror of
https://github.com/EssentialsX/Essentials.git
synced 2026-11-05 01:00:13 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
279d6f16e1 | ||
|
|
a747eccaa3 | ||
|
|
0bafbc3184 | ||
|
|
8069370b8c | ||
|
|
46f4b92ff7 | ||
|
|
d92f5ce71c | ||
|
|
2314bf8bd4 | ||
|
|
7808b21496 | ||
|
|
18ef412211 | ||
|
|
0678328253 | ||
|
|
5503e1e14c | ||
|
|
9e89cfa4ed | ||
|
|
13f454a022 | ||
|
|
129650dade | ||
|
|
6fa5b80c0a | ||
|
|
04dfcd0965 | ||
|
|
2e818ac709 | ||
|
|
32ef61197f | ||
|
|
fa06cd8253 | ||
|
|
5020983af5 | ||
|
|
f4496b6977 | ||
|
|
552dcb56a1 | ||
|
|
e158a65603 | ||
|
|
b694e8aaa2 | ||
|
|
a2e09121ba | ||
|
|
4ce7dfa8f0 | ||
|
|
1c4ce7b4bd | ||
|
|
8a04c1e232 | ||
|
|
6e5d378324 | ||
|
|
8e1f3617fd | ||
|
|
2549ed830f | ||
|
|
0ebd64d314 | ||
|
|
843ecb4a42 | ||
|
|
a1a0d34940 | ||
|
|
15bb978dab | ||
|
|
6a7cf39548 | ||
|
|
8ccb70d07d | ||
|
|
45461a93b0 | ||
|
|
b3a54a78bc | ||
|
|
a4182b5ff9 | ||
|
|
215dcde4b9 | ||
|
|
67b2a9a4f4 | ||
|
|
3b51b23ac2 | ||
|
|
e0f19f8121 | ||
|
|
e720fb528a | ||
|
|
518a5454c6 | ||
|
|
2d9c846084 | ||
|
|
59e30f05fc | ||
|
|
0f1085a02d | ||
|
|
882699919e | ||
|
|
f6a70a542e | ||
|
|
bae909ba10 | ||
|
|
dbb9757a9f | ||
|
|
deaeb46ce9 | ||
|
|
219012bc35 | ||
|
|
5f9eb22d23 | ||
|
|
2c33fb6834 | ||
|
|
8bcef6022b | ||
|
|
93d36779f0 | ||
|
|
2502f5e6f2 | ||
|
|
95f2852cf3 | ||
|
|
ff9f712d65 | ||
|
|
60c4e75a1c | ||
|
|
ccf7c48bf1 | ||
|
|
65d81eb31e | ||
|
|
b97eb12dfc | ||
|
|
d2724d77df | ||
|
|
119b21ac67 | ||
|
|
1ff73b3837 | ||
|
|
d98f8b3467 | ||
|
|
ac8b8861cb | ||
|
|
22dc5dcebd | ||
|
|
3c09e72ce4 | ||
|
|
fffc3fcac7 | ||
|
|
bcdbbe9546 | ||
|
|
19f03cd70e | ||
|
|
9b7858b830 | ||
|
|
8bc55387dd | ||
|
|
0584353bfa | ||
|
|
2938330222 | ||
|
|
ef7393036e | ||
|
|
0409f5bc4a | ||
|
|
8ff1ebd7c2 | ||
|
|
9089fe8be3 | ||
|
|
74d96ce624 | ||
|
|
8b7bcbb880 | ||
|
|
dbd86155fb | ||
|
|
9b77c0802b | ||
|
|
cd7fa79560 | ||
|
|
10e9879a64 | ||
|
|
d1dcc47a27 | ||
|
|
7a73301a37 | ||
|
|
e1dec7d9e7 | ||
|
|
99fefdb47d | ||
|
|
5ebce8965e | ||
|
|
5a0b7285d4 | ||
|
|
829110e89a | ||
|
|
dc1a0b65fa | ||
|
|
b140826e60 | ||
|
|
0d9387458d | ||
|
|
f2447a9134 | ||
|
|
2ea3d8943e | ||
|
|
e4cc78a750 | ||
|
|
a08832cfc8 | ||
|
|
c97918df24 | ||
|
|
e9833d1cd2 | ||
|
|
111a18585d | ||
|
|
155d3ec938 | ||
|
|
8bafacbd51 | ||
|
|
0e3f48ee54 | ||
|
|
b566b4a0c6 | ||
|
|
a9ed66d5e0 | ||
|
|
94131edb32 | ||
|
|
e21863956c | ||
|
|
4201e6ef85 | ||
|
|
5deb1de555 | ||
|
|
c65534ebb1 | ||
|
|
f22efce3ca | ||
|
|
5f0909047d | ||
|
|
7cc4dc2f07 | ||
|
|
60ebe9e738 | ||
|
|
a1297feb9d | ||
|
|
09598d0173 | ||
|
|
35fc845040 | ||
|
|
e59950966f | ||
|
|
98cc5b33a3 | ||
|
|
d107d00ac3 | ||
|
|
ccc000a416 | ||
|
|
7790f8818b | ||
|
|
72ca629cf1 | ||
|
|
65017d7f5c | ||
|
|
6d4f7afc79 | ||
|
|
4fcb032791 | ||
|
|
0e668fa0f2 | ||
|
|
68b933a501 | ||
|
|
5236ad9f64 | ||
|
|
937c18fe1d | ||
|
|
fb48aaba9d | ||
|
|
365efe4f2d | ||
|
|
78b2dba42a | ||
|
|
f793b7607f | ||
|
|
c567bc22e9 | ||
|
|
d282462547 | ||
|
|
af4cfd3fe9 | ||
|
|
cfba203981 | ||
|
|
d680ed7363 | ||
|
|
69232c0717 | ||
|
|
b4baa28f01 | ||
|
|
0aa11b58b9 | ||
|
|
7b60b562b9 | ||
|
|
6377cbfb2b | ||
|
|
3f5f9cc717 | ||
|
|
eac1e9b574 | ||
|
|
26d63da7aa | ||
|
|
722181439e | ||
|
|
ddcb7041f1 | ||
|
|
8af33e0ae2 | ||
|
|
d01e12ac14 | ||
|
|
8c0aa840ab | ||
|
|
05118e9498 | ||
|
|
7838adf833 | ||
|
|
e230cee91e | ||
|
|
8e4fc77244 | ||
|
|
0d572036f8 | ||
|
|
26fdd0ff6b | ||
|
|
70a4aee930 | ||
|
|
3631323aa7 | ||
|
|
1fd7d18056 | ||
|
|
a60f67cd0a | ||
|
|
5ba781d00e | ||
|
|
17c5d25996 | ||
|
|
bd9f271eff | ||
|
|
89b4bd2405 | ||
|
|
4da9095c59 | ||
|
|
75e84a5797 | ||
|
|
54d64dbb5f | ||
|
|
03e746953c | ||
|
|
ec8a51b06c | ||
|
|
369c08a624 | ||
|
|
7a8e5e92d9 | ||
|
|
185ec7ff2b | ||
|
|
af986cc7b2 | ||
|
|
25d96ccfa7 | ||
|
|
b45c42ef22 | ||
|
|
ea2ac3d483 | ||
|
|
873df96d0d | ||
|
|
d69495baa7 | ||
|
|
06ff8f24fe | ||
|
|
b996608455 | ||
|
|
6c1c22132e | ||
|
|
8b326d5852 | ||
|
|
dd34f65c98 | ||
|
|
0bd0f853f3 | ||
|
|
e7a75efaff | ||
|
|
2904b50061 | ||
|
|
3b6ac632d9 | ||
|
|
9ad3f0e0d7 | ||
|
|
9529a4ba02 | ||
|
|
69b9ab097b | ||
|
|
4b14c4bcc6 | ||
|
|
5154c670c0 | ||
|
|
09b699cc9c | ||
|
|
f2a212e3a4 | ||
|
|
19ca946e3b | ||
|
|
e21be39c13 | ||
|
|
8fcfff7abd | ||
|
|
bcc150a014 | ||
|
|
3d97e93831 | ||
|
|
9d93d4db54 | ||
|
|
0d8aec7eea | ||
|
|
7b165c6c2c | ||
|
|
d3cee314c6 | ||
|
|
4395245aab | ||
|
|
9d4b0a13c5 | ||
|
|
c908290c27 | ||
|
|
f5c21d1089 | ||
|
|
883fc75f47 | ||
|
|
eaac3049af | ||
|
|
f68fb52af1 | ||
|
|
863bd5a89e | ||
|
|
50225624a5 | ||
|
|
25ddaef423 | ||
|
|
585f2bef07 | ||
|
|
017ea1a4fe | ||
|
|
3b4b5bcd8e | ||
|
|
f57557b43a | ||
|
|
0711fd6f9e | ||
|
|
b5ecbd1739 | ||
|
|
dda5e4e333 | ||
|
|
74b0e71015 | ||
|
|
dde4a36df0 | ||
|
|
31b98fb9f3 | ||
|
|
289d34d96c | ||
|
|
eafd110ed0 | ||
|
|
e72644abf4 | ||
|
|
b267103274 | ||
|
|
3856a690eb | ||
|
|
f214696664 | ||
|
|
9e73c29b40 | ||
|
|
aca83bd462 | ||
|
|
189d6a23c6 | ||
|
|
441f88deea | ||
|
|
6d6666dace | ||
|
|
fb779533e6 | ||
|
|
7325113a8c | ||
|
|
827217823e | ||
|
|
060dfc69f4 | ||
|
|
b831713737 | ||
|
|
7da90b3a6b | ||
|
|
32540c23ab | ||
|
|
d24b0616f8 | ||
|
|
9aef2ef883 | ||
|
|
727d473319 | ||
|
|
8225e51867 | ||
|
|
1ba6c2a596 | ||
|
|
60a166aeb0 | ||
|
|
65c2155bca | ||
|
|
6031c01584 | ||
|
|
da8e8c8a25 | ||
|
|
70a750a32d | ||
|
|
7c63324504 | ||
|
|
dd41b10522 | ||
|
|
7948e764d4 | ||
|
|
82ede4530a | ||
|
|
e8ab2db8e8 | ||
|
|
8882e0214c | ||
|
|
4adb669cdd | ||
|
|
7e1d258dd3 | ||
|
|
417fe29e21 | ||
|
|
bd8ef2a25d | ||
|
|
fd01b75c33 | ||
|
|
1388755d2a | ||
|
|
97cc3d0066 | ||
|
|
694cf7a79e | ||
|
|
da89efb79f | ||
|
|
04ec013407 | ||
|
|
023cf6a1aa | ||
|
|
f7cbb141f8 | ||
|
|
5690952516 | ||
|
|
e94202c55a | ||
|
|
aa6ad271a0 | ||
|
|
3b41bb47b6 | ||
|
|
e7bdb7fabc | ||
|
|
110698223d | ||
|
|
437be593b9 | ||
|
|
502d37b574 | ||
|
|
df59f9f859 | ||
|
|
f436fbab6b | ||
|
|
8404720501 | ||
|
|
4431d452f1 | ||
|
|
6a529d6671 | ||
|
|
78fca9a67a | ||
|
|
0114b5e4f6 | ||
|
|
5a14a64b6c | ||
|
|
b555ea6350 | ||
|
|
361ae1dd16 | ||
|
|
58117eba88 | ||
|
|
6260b49b4f | ||
|
|
988239267b | ||
|
|
19cffe3872 | ||
|
|
3b1cef918e | ||
|
|
3d004d2a81 | ||
|
|
d1bbebad3a | ||
|
|
42714ff8af | ||
|
|
3553328f7a | ||
|
|
0202271f00 | ||
|
|
d91d6a419c | ||
|
|
5173090474 | ||
|
|
c26df8318f | ||
|
|
7b44f0088a | ||
|
|
aa4d3cc9fd | ||
|
|
246fd03265 | ||
|
|
55074872fe | ||
|
|
28559dda3a | ||
|
|
cbcfad5b2e | ||
|
|
a9ad440860 | ||
|
|
5104463593 | ||
|
|
4b1c51c21d | ||
|
|
236ef52980 | ||
|
|
f220c5b406 | ||
|
|
9415582fe1 | ||
|
|
a5a3630727 | ||
|
|
f4c36d9c43 | ||
|
|
64930e3771 | ||
|
|
16381234e0 | ||
|
|
492005d00a | ||
|
|
149d9b61cc | ||
|
|
77ffb6a3d5 | ||
|
|
d95b632884 | ||
|
|
579f554edb | ||
|
|
050287f306 | ||
|
|
dafe156212 | ||
|
|
48bf264178 | ||
|
|
769dbe8852 | ||
|
|
67bccb865a | ||
|
|
d1e60de04a | ||
|
|
89d592ce43 | ||
|
|
c06dda886d | ||
|
|
7b67b3b858 | ||
|
|
22538ba7c9 | ||
|
|
a9fe842242 | ||
|
|
0432546746 | ||
|
|
3395bab928 | ||
|
|
70387f73f6 | ||
|
|
7adb931ea8 | ||
|
|
5f7d226158 | ||
|
|
0897ca57ff | ||
|
|
cfcdb47529 | ||
|
|
76f845f5f4 | ||
|
|
c65b7b6462 | ||
|
|
67528b25a8 | ||
|
|
b096ee9703 | ||
|
|
9e2bb0b277 | ||
|
|
b8df59ae46 | ||
|
|
98f42c6974 | ||
|
|
db19788e21 | ||
|
|
67d17472e0 | ||
|
|
f68a6eb00d | ||
|
|
b5a6df4fe2 | ||
|
|
290379651d | ||
|
|
6ffbb86169 | ||
|
|
d8b6f87087 | ||
|
|
7aad95ec08 | ||
|
|
574e1bc1e7 | ||
|
|
081c6f0263 | ||
|
|
fc590f82a2 | ||
|
|
729af4bb4d | ||
|
|
c8cb9b3735 | ||
|
|
4f8ea06db1 | ||
|
|
9378df0ff2 | ||
|
|
3444c8b0d6 | ||
|
|
822315a279 | ||
|
|
732da86710 | ||
|
|
5fbc412542 | ||
|
|
f0b262cbd5 | ||
|
|
ff37ef3bc5 | ||
|
|
68fab2c328 | ||
|
|
f9d81c4302 | ||
|
|
3d33bbc33d | ||
|
|
53c604c1b5 | ||
|
|
2975118e5b | ||
|
|
e3ee9cb4c7 | ||
|
|
297a616460 | ||
|
|
afe0ff0ca7 | ||
|
|
adf1bc291c | ||
|
|
034ffbd0bc | ||
|
|
127a7bb2ce | ||
|
|
e8bfac0790 | ||
|
|
62d5dd3516 | ||
|
|
bcd66fec39 | ||
|
|
849b329213 | ||
|
|
d555c1b081 | ||
|
|
43cbab37f0 | ||
|
|
6f7af90488 | ||
|
|
fcda6c3b3b | ||
|
|
910ef26c79 | ||
|
|
1664da55a4 | ||
|
|
f8ea7f5e1f | ||
|
|
b0205b9499 | ||
|
|
e05796f80e | ||
|
|
a70fa78267 | ||
|
|
e20693de60 | ||
|
|
f10a766442 | ||
|
|
86315fed8d | ||
|
|
4ff9fe8666 | ||
|
|
3512c4c8e6 |
No files matched your search
@@ -0,0 +1,13 @@
|
||||
# Currently used
|
||||
patreon: EssentialsX
|
||||
ko_fi: essentialsx
|
||||
|
||||
# Currently not used
|
||||
#github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
#open_collective: # Replace with a single Open Collective username
|
||||
#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
#liberapay: # Replace with a single Liberapay username
|
||||
#issuehunt: # Replace with a single IssueHunt username
|
||||
#otechie: # Replace with a single Otechie username
|
||||
#custom: # Replace with a single custom sponsorship URL
|
||||
@@ -0,0 +1,41 @@
|
||||
name: Build EssentialsX
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 2.x
|
||||
- mc/*
|
||||
pull_request:
|
||||
branches:
|
||||
- 2.x
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Git repo
|
||||
uses: actions/checkout@v1
|
||||
- name: Restore Maven cache
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Run BuildTools
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: chmod +x scripts/buildtools.sh && ./scripts/buildtools.sh
|
||||
- name: Build with Maven
|
||||
run: mvn package --file pom.xml
|
||||
- name: Copy artifacts
|
||||
run: mkdir -p ./out/ && cp -t ./out/ **/target/Essentials*.jar
|
||||
- uses: actions/upload-artifact@master
|
||||
with:
|
||||
name: Plugin jars
|
||||
path: out/
|
||||
+18
-52
@@ -1,52 +1,18 @@
|
||||
.DS_Store
|
||||
/BuildAll/nbproject/private/
|
||||
/EssentialsProtect/nbproject/private/
|
||||
/EssentialsChat/nbproject/private/
|
||||
/EssentialsGroupBridge/nbproject/private/
|
||||
/EssentialsGeoIP/nbproject/private/
|
||||
/EssentialsSpawn/nbproject/private/
|
||||
/EssentialsXMPP/nbproject/private/
|
||||
/BuildAll/build/
|
||||
/EssentialsGroupBridge/dist/
|
||||
/EssentialsGroupBridge/build/
|
||||
/EssentialsGeoIP/dist/
|
||||
/EssentialsGeoIP/build/
|
||||
/BuildAll/dist/
|
||||
/EssentialsChat/build/
|
||||
/EssentialsChat/dist/
|
||||
/EssentialsSpawn/build/
|
||||
/EssentialsSpawn/dist/
|
||||
/EssentialsXMPP/dist/
|
||||
/EssentialsXMPP/build/
|
||||
/EssentialsProtect/dist/
|
||||
/EssentialsProtect/build/
|
||||
/EssentialsPermissionsCommands/nbproject/private/
|
||||
/EssentialsPermissionsCommands/build/
|
||||
/EssentialsPermissionsCommands/dist/
|
||||
/Essentials/nbproject/private/
|
||||
/Essentials/dist/
|
||||
/Essentials/build/
|
||||
/YamlAnnotations/
|
||||
/EssentialsUpdate/nbproject/private/
|
||||
/EssentialsRelease/
|
||||
/EssentialsUpdate/dist/
|
||||
/EssentialsUpdate/build/
|
||||
/WebPush/apikey.php
|
||||
/WebPush/nbproject/private
|
||||
/EssentialsAntiBuild/nbproject/private/
|
||||
/EssentialsAntiBuild/dist/
|
||||
/EssentialsAntiBuild/build/
|
||||
/jars
|
||||
/out
|
||||
.idea/
|
||||
*.iml
|
||||
*.classpath
|
||||
*.project
|
||||
*.settings/
|
||||
target/
|
||||
dependency-reduced-pom.xml
|
||||
/Essentials/config.yml
|
||||
/Essentials/userdata/testplayer1.yml
|
||||
/Essentials/usermap.csv
|
||||
/Essentials/userdata
|
||||
/EssentialsGroupManager/target/
|
||||
# IDE files
|
||||
*.classpath
|
||||
*.project
|
||||
*.settings/
|
||||
.idea/
|
||||
*.iml
|
||||
.DS_Store
|
||||
|
||||
# Essentials files
|
||||
/Essentials/userdata
|
||||
/Essentials/config.yml
|
||||
/Essentials/kits.yml
|
||||
/Essentials/userdata/testplayer1.yml
|
||||
/Essentials/usermap.csv
|
||||
|
||||
# Build files
|
||||
target/
|
||||
jars/
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
language: java
|
||||
|
||||
branches:
|
||||
only:
|
||||
- 2.x
|
||||
- 1.13
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- .buildtools
|
||||
- $HOME/.m2
|
||||
|
||||
before_install:
|
||||
- mkdir -p .buildtools
|
||||
- cd .buildtools
|
||||
- wget -O BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
|
||||
- rm -r work/
|
||||
- java -jar BuildTools.jar --rev 1.8
|
||||
- java -jar BuildTools.jar --rev 1.8.3
|
||||
- java -jar BuildTools.jar --rev 1.9
|
||||
- java -jar BuildTools.jar --rev 1.9.4
|
||||
- java -jar BuildTools.jar --rev 1.13.1
|
||||
- cd ..
|
||||
+28
-32
@@ -6,25 +6,18 @@
|
||||
<parent>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>EssentialsXParent</artifactId>
|
||||
<version>2.16.0</version>
|
||||
<version>2.17.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>EssentialsX</artifactId>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>GPLv3</name>
|
||||
<url>http://www.gnu.org/copyleft/gpl.html</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<build>
|
||||
<finalName>EssentialsX-${full.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
<showDeprecation>false</showDeprecation>
|
||||
</configuration>
|
||||
@@ -32,7 +25,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
@@ -41,33 +34,48 @@
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>io.papermc.lib</pattern>
|
||||
<shadedPattern>com.earth2me.essentials.paperlib</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>Vault</artifactId>
|
||||
<version>1.5.6</version>
|
||||
<groupId>com.github.milkbowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>NMSProvider</artifactId>
|
||||
<version>2.16.0</version>
|
||||
<version>2.17.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>UpdatedMetaProvider</artifactId>
|
||||
<version>2.16.0</version>
|
||||
<version>2.17.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>1_8_R1Provider</artifactId>
|
||||
<version>2.16.0</version>
|
||||
<version>2.17.2</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@@ -79,7 +87,7 @@
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>1_8_R2Provider</artifactId>
|
||||
<version>2.16.0</version>
|
||||
<version>2.17.2</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@@ -91,32 +99,20 @@
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>LegacyProvider</artifactId>
|
||||
<version>2.16.0</version>
|
||||
<version>2.17.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>ReflectionProvider</artifactId>
|
||||
<version>2.16.0</version>
|
||||
<version>2.17.2</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
<artifactId>FlattenedProvider</artifactId>
|
||||
<version>2.16.0</version>
|
||||
<version>2.17.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
@@ -25,12 +25,7 @@ public class Backup implements Runnable {
|
||||
this.ess = ess;
|
||||
server = ess.getServer();
|
||||
if (!ess.getOnlinePlayers().isEmpty()) {
|
||||
ess.runTaskAsynchronously(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
startTask();
|
||||
}
|
||||
});
|
||||
ess.runTaskAsynchronously(this::startTask);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
@@ -15,6 +13,7 @@ import java.util.Set;
|
||||
public class Enchantments {
|
||||
private static final Map<String, Enchantment> ENCHANTMENTS = new HashMap<String, Enchantment>();
|
||||
private static final Map<String, Enchantment> ALIASENCHANTMENTS = new HashMap<String, Enchantment>();
|
||||
private static boolean isFlat;
|
||||
|
||||
static {
|
||||
ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL);
|
||||
@@ -199,10 +198,75 @@ public class Enchantments {
|
||||
ALIASENCHANTMENTS.put("sweeping", sweeping);
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) {}
|
||||
|
||||
|
||||
try { // 1.13
|
||||
Enchantment loyalty = Enchantment.getByName("LOYALTY");
|
||||
if (loyalty != null) {
|
||||
ENCHANTMENTS.put("loyalty", loyalty);
|
||||
ALIASENCHANTMENTS.put("loyal", loyalty);
|
||||
ALIASENCHANTMENTS.put("return", loyalty);
|
||||
}
|
||||
Enchantment impaling = Enchantment.getByName("IMPALING");
|
||||
if (impaling != null) {
|
||||
ENCHANTMENTS.put("impaling", impaling);
|
||||
ALIASENCHANTMENTS.put("impale", impaling);
|
||||
ALIASENCHANTMENTS.put("oceandamage", impaling);
|
||||
ALIASENCHANTMENTS.put("oceandmg", impaling);
|
||||
}
|
||||
Enchantment riptide = Enchantment.getByName("RIPTIDE");
|
||||
if (riptide != null) {
|
||||
ENCHANTMENTS.put("riptide", riptide);
|
||||
ALIASENCHANTMENTS.put("rip", riptide);
|
||||
ALIASENCHANTMENTS.put("tide", riptide);
|
||||
ALIASENCHANTMENTS.put("launch", riptide);
|
||||
}
|
||||
Enchantment channelling = Enchantment.getByName("CHANNELING");
|
||||
if (channelling != null) {
|
||||
ENCHANTMENTS.put("channelling", channelling);
|
||||
ALIASENCHANTMENTS.put("chanelling", channelling);
|
||||
ALIASENCHANTMENTS.put("channeling", channelling);
|
||||
ALIASENCHANTMENTS.put("chaneling", channelling);
|
||||
ALIASENCHANTMENTS.put("channel", channelling);
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) {}
|
||||
|
||||
|
||||
try { // 1.14
|
||||
Enchantment multishot = Enchantment.getByName("MULTISHOT");
|
||||
if (multishot != null) {
|
||||
ENCHANTMENTS.put("multishot", multishot);
|
||||
ALIASENCHANTMENTS.put("tripleshot", multishot);
|
||||
}
|
||||
Enchantment quickCharge = Enchantment.getByName("QUICK_CHARGE");
|
||||
if (quickCharge != null) {
|
||||
ENCHANTMENTS.put("quickcharge", quickCharge);
|
||||
ALIASENCHANTMENTS.put("quickdraw", quickCharge);
|
||||
ALIASENCHANTMENTS.put("fastcharge", quickCharge);
|
||||
ALIASENCHANTMENTS.put("fastdraw", quickCharge);
|
||||
}
|
||||
Enchantment piercing = Enchantment.getByName("PIERCING");
|
||||
if (piercing != null) {
|
||||
ENCHANTMENTS.put("piercing", piercing);
|
||||
}
|
||||
} catch (IllegalArgumentException ignored) {}
|
||||
|
||||
try {
|
||||
Class<?> namespacedKeyClass = Class.forName("org.bukkit.NamespacedKey");
|
||||
Class<?> enchantmentClass = Class.forName("org.bukkit.enchantments.Enchantment");
|
||||
enchantmentClass.getDeclaredMethod("getByKey", namespacedKeyClass);
|
||||
isFlat = true;
|
||||
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
||||
isFlat = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Enchantment getByName(String name) {
|
||||
Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(name.toLowerCase()));
|
||||
Enchantment enchantment = null;
|
||||
if (isFlat) { // 1.13+ only
|
||||
enchantment = Enchantment.getByKey(NamespacedKey.minecraft(name.toLowerCase()));
|
||||
}
|
||||
|
||||
if (enchantment == null) {
|
||||
enchantment = Enchantment.getByName(name.toUpperCase());
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.*;
|
||||
import com.earth2me.essentials.items.AbstractItemDb;
|
||||
import com.earth2me.essentials.items.CustomItemResolver;
|
||||
import com.earth2me.essentials.items.FlatItemDb;
|
||||
import com.earth2me.essentials.items.LegacyItemDb;
|
||||
import com.earth2me.essentials.metrics.Metrics;
|
||||
@@ -32,12 +33,18 @@ import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.textreader.SimpleTextInput;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Iterables;
|
||||
import net.ess3.api.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.ISettings;
|
||||
import net.ess3.api.*;
|
||||
import net.ess3.nms.PotionMetaProvider;
|
||||
import net.ess3.nms.SpawnEggProvider;
|
||||
import net.ess3.nms.SpawnerProvider;
|
||||
@@ -76,14 +83,6 @@ import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.yaml.snakeyaml.error.YAMLException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
|
||||
@@ -97,6 +96,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
private transient List<IConf> confList;
|
||||
private transient Backup backup;
|
||||
private transient AbstractItemDb itemDb;
|
||||
private transient CustomItemResolver customItemResolver;
|
||||
private transient final Methods paymentMethod = new Methods();
|
||||
private transient PermissionsHandler permissionsHandler;
|
||||
private transient AlternativeCommandsHandler alternativeCommandsHandler;
|
||||
@@ -196,27 +196,46 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
|
||||
upgrade.beforeSettings();
|
||||
execTimer.mark("Upgrade");
|
||||
|
||||
confList = new ArrayList<>();
|
||||
settings = new Settings(this);
|
||||
confList.add(settings);
|
||||
execTimer.mark("Settings");
|
||||
|
||||
userMap = new UserMap(this);
|
||||
confList.add(userMap);
|
||||
execTimer.mark("Init(Usermap)");
|
||||
|
||||
kits = new Kits(this);
|
||||
confList.add(kits);
|
||||
upgrade.convertKits();
|
||||
execTimer.mark("Kits");
|
||||
|
||||
upgrade.afterSettings();
|
||||
execTimer.mark("Upgrade2");
|
||||
|
||||
warps = new Warps(getServer(), this.getDataFolder());
|
||||
confList.add(warps);
|
||||
execTimer.mark("Init(Spawn/Warp)");
|
||||
execTimer.mark("Init(Warp)");
|
||||
|
||||
worth = new Worth(this.getDataFolder());
|
||||
confList.add(worth);
|
||||
execTimer.mark("Init(Worth)");
|
||||
|
||||
itemDb = getItemDbFromConfig();
|
||||
confList.add(itemDb);
|
||||
execTimer.mark("Init(Worth/ItemDB)");
|
||||
execTimer.mark("Init(ItemDB)");
|
||||
|
||||
customItemResolver = new CustomItemResolver(this);
|
||||
try {
|
||||
itemDb.registerResolver(this, "custom_items", customItemResolver);
|
||||
confList.add(customItemResolver);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
customItemResolver = null;
|
||||
}
|
||||
execTimer.mark("Init(CustomItemResolver)");
|
||||
|
||||
jails = new Jails(this);
|
||||
confList.add(jails);
|
||||
execTimer.mark("Init(Jails)");
|
||||
@@ -241,6 +260,10 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
), "potion meta").getProvider();
|
||||
execTimer.mark("Init(Providers)");
|
||||
reload();
|
||||
|
||||
// The item spawn blacklist is loaded with all other settings, before the item
|
||||
// DB, but it depends on the item DB, so we need to reload it again here:
|
||||
((Settings) settings)._lateLoadItemSpawnBlacklist();
|
||||
} catch (YAMLException exception) {
|
||||
if (pm.getPlugin("EssentialsUpdate") != null) {
|
||||
LOGGER.log(Level.SEVERE, tl("essentialsHelp2"));
|
||||
@@ -476,7 +499,9 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
}
|
||||
|
||||
if (bSenderBlock != null) {
|
||||
Bukkit.getLogger().log(Level.INFO, "CommandBlock at {0},{1},{2} issued server command: /{3} {4}", new Object[]{bSenderBlock.getX(), bSenderBlock.getY(), bSenderBlock.getZ(), commandLabel, EssentialsCommand.getFinalArg(args, 0)});
|
||||
if (getSettings().logCommandBlockCommands()) {
|
||||
Bukkit.getLogger().log(Level.INFO, "CommandBlock at {0},{1},{2} issued server command: /{3} {4}", new Object[]{bSenderBlock.getX(), bSenderBlock.getY(), bSenderBlock.getZ(), commandLabel, EssentialsCommand.getFinalArg(args, 0)});
|
||||
}
|
||||
} else if (user == null) {
|
||||
Bukkit.getLogger().log(Level.INFO, "{0} issued server command: /{1} {2}", new Object[]{cSender.getName(), commandLabel, EssentialsCommand.getFinalArg(args, 0)});
|
||||
}
|
||||
@@ -860,13 +885,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
|
||||
@Override
|
||||
public Iterable<User> getOnlineUsers() {
|
||||
return Iterables.transform(getOnlinePlayers(), new Function<Player, User>() {
|
||||
|
||||
@Override
|
||||
public User apply(Player player) {
|
||||
return getUser(player);
|
||||
}
|
||||
});
|
||||
return getOnlinePlayers().stream().map(this::getUser).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -884,6 +903,11 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
||||
return potionMetaProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomItemResolver getCustomItemResolver() {
|
||||
return customItemResolver;
|
||||
}
|
||||
|
||||
private static void addDefaultBackPermissionsToWorld(World w) {
|
||||
String permName = "essentials.back.into." + w.getName();
|
||||
|
||||
|
||||
@@ -1,25 +1,31 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import net.ess3.api.InvalidWorldException;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
import java.io.*;
|
||||
import com.google.common.io.Files;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -28,8 +34,18 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
import net.ess3.api.InvalidWorldException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
||||
public class EssentialsConf extends YamlConfiguration {
|
||||
@@ -108,20 +124,21 @@ public class EssentialsConf extends YamlConfiguration {
|
||||
if (length > buffer.remaining()) {
|
||||
ByteBuffer resize = ByteBuffer.allocate(buffer.capacity() + length - buffer.remaining());
|
||||
int resizePosition = buffer.position();
|
||||
buffer.rewind();
|
||||
// Fix builds compiled against Java 9+ breaking on Java 8
|
||||
((Buffer) buffer).rewind();
|
||||
resize.put(buffer);
|
||||
resize.position(resizePosition);
|
||||
buffer = resize;
|
||||
}
|
||||
buffer.put(bytebuffer, 0, length);
|
||||
}
|
||||
buffer.rewind();
|
||||
((Buffer) buffer).rewind();
|
||||
final CharBuffer data = CharBuffer.allocate(buffer.capacity());
|
||||
CharsetDecoder decoder = UTF8.newDecoder();
|
||||
CoderResult result = decoder.decode(buffer, data, true);
|
||||
if (result.isError()) {
|
||||
buffer.rewind();
|
||||
data.clear();
|
||||
((Buffer) buffer).rewind();
|
||||
((Buffer) data).clear();
|
||||
LOGGER.log(Level.INFO, "File " + configFile.getAbsolutePath() + " is not utf-8 encoded, trying " + Charset.defaultCharset().displayName());
|
||||
decoder = Charset.defaultCharset().newDecoder();
|
||||
result = decoder.decode(buffer, data, true);
|
||||
@@ -134,7 +151,7 @@ public class EssentialsConf extends YamlConfiguration {
|
||||
decoder.flush(data);
|
||||
}
|
||||
final int end = data.position();
|
||||
data.rewind();
|
||||
((Buffer) data).rewind();
|
||||
super.loadFromString(data.subSequence(0, end).toString());
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
|
||||
@@ -92,7 +92,7 @@ public class EssentialsEntityListener implements Listener {
|
||||
class PowerToolInteractTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
attacker.getServer().dispatchCommand(attacker.getBase(), command);
|
||||
attacker.getBase().chat("/" + command);
|
||||
LOGGER.log(Level.INFO, String.format("[PT] %s issued server command: /%s", attacker.getName(), command));
|
||||
}
|
||||
}
|
||||
@@ -159,6 +159,15 @@ public class EssentialsEntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerDeathInvEvent(final PlayerDeathEvent event) {
|
||||
final User user = ess.getUser(event.getEntity());
|
||||
if (user.isAuthorized("essentials.keepinv")) {
|
||||
event.setKeepInventory(true);
|
||||
event.getDrops().clear();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onFoodLevelChange(final FoodLevelChangeEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
|
||||
@@ -7,13 +7,10 @@ import com.earth2me.essentials.textreader.TextPager;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.ess3.api.IEssentials;
|
||||
|
||||
import org.bukkit.BanEntry;
|
||||
import org.bukkit.BanList;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -34,11 +31,7 @@ import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -55,12 +48,35 @@ public class EssentialsPlayerListener implements Listener {
|
||||
this.ess = parent;
|
||||
}
|
||||
|
||||
private static boolean isEntityPickupEvent() {
|
||||
try {
|
||||
Class.forName("org.bukkit.event.entity.EntityPickupItemEvent");
|
||||
return true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isCommandSendEvent() {
|
||||
try {
|
||||
Class.forName("org.bukkit.event.player.PlayerCommandSendEvent");
|
||||
return true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void registerEvents() {
|
||||
ess.getServer().getPluginManager().registerEvents(this, ess);
|
||||
|
||||
if (isEntityPickupEvent()) {
|
||||
ess.getServer().getPluginManager().registerEvents(new PlayerListener1_12(), ess);
|
||||
ess.getServer().getPluginManager().registerEvents(new PickupListener1_12(), ess);
|
||||
} else {
|
||||
ess.getServer().getPluginManager().registerEvents(new PlayerListenerPre1_12(), ess);
|
||||
ess.getServer().getPluginManager().registerEvents(new PickupListenerPre1_12(), ess);
|
||||
}
|
||||
|
||||
if (isCommandSendEvent()) {
|
||||
ess.getServer().getPluginManager().registerEvents(new CommandSendListener(), ess);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +96,9 @@ public class EssentialsPlayerListener implements Listener {
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isMuted()) {
|
||||
event.setCancelled(true);
|
||||
user.sendMessage(tl("voiceSilenced"));
|
||||
|
||||
user.sendMessage(user.hasMuteReason() ? tl("voiceSilencedReason", user.getMuteReason()) : tl("voiceSilenced"));
|
||||
|
||||
LOGGER.info(tl("mutedUserSpeaks", user.getName(), event.getMessage()));
|
||||
}
|
||||
try {
|
||||
@@ -152,7 +170,12 @@ public class EssentialsPlayerListener implements Listener {
|
||||
event.setQuitMessage(null);
|
||||
} else if (ess.getSettings().isCustomQuitMessage() && event.getQuitMessage() != null) {
|
||||
final Player player = event.getPlayer();
|
||||
event.setQuitMessage(ess.getSettings().getCustomQuitMessage().replace("{PLAYER}", player.getDisplayName()).replace("{USERNAME}", player.getName()).replace("{ONLINE}", NumberFormat.getInstance().format(ess.getOnlinePlayers().size())));
|
||||
final String msg = ess.getSettings().getCustomQuitMessage()
|
||||
.replace("{PLAYER}", player.getDisplayName())
|
||||
.replace("{USERNAME}", player.getName())
|
||||
.replace("{ONLINE}", NumberFormat.getInstance().format(ess.getOnlinePlayers().size()));
|
||||
|
||||
event.setQuitMessage(msg.isEmpty() ? null : msg);
|
||||
}
|
||||
|
||||
user.startTransaction();
|
||||
@@ -176,7 +199,7 @@ public class EssentialsPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
user.updateActivityOnInteract(false);
|
||||
user.updateActivity(false);
|
||||
if (!user.isHidden()) {
|
||||
user.setLastLogout(System.currentTimeMillis());
|
||||
}
|
||||
@@ -188,12 +211,8 @@ public class EssentialsPlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event) {
|
||||
final String joinMessage = event.getJoinMessage();
|
||||
ess.runTaskAsynchronously(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
delayedJoin(event.getPlayer(), joinMessage);
|
||||
}
|
||||
});
|
||||
ess.runTaskAsynchronously(() -> delayedJoin(event.getPlayer(), joinMessage));
|
||||
|
||||
if (ess.getSettings().allowSilentJoinQuit() || ess.getSettings().isCustomJoinMessage()) {
|
||||
event.setJoinMessage(null);
|
||||
}
|
||||
@@ -214,7 +233,7 @@ public class EssentialsPlayerListener implements Listener {
|
||||
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
dUser.checkMuteTimeout(currentTime);
|
||||
dUser.updateActivityOnInteract(false);
|
||||
dUser.updateActivity(false);
|
||||
dUser.stopTransaction();
|
||||
|
||||
class DelayJoinTask implements Runnable {
|
||||
@@ -257,10 +276,12 @@ public class EssentialsPlayerListener implements Listener {
|
||||
//NOOP
|
||||
} else if (ess.getSettings().isCustomJoinMessage()) {
|
||||
String msg = ess.getSettings().getCustomJoinMessage()
|
||||
.replace("{PLAYER}", player.getDisplayName()).replace("{USERNAME}", player.getName())
|
||||
.replace("{UNIQUE}", NumberFormat.getInstance().format(ess.getUserMap().getUniqueUsers()))
|
||||
.replace("{ONLINE}", NumberFormat.getInstance().format(ess.getOnlinePlayers().size()));
|
||||
ess.getServer().broadcastMessage(msg);
|
||||
.replace("{PLAYER}", player.getDisplayName()).replace("{USERNAME}", player.getName())
|
||||
.replace("{UNIQUE}", NumberFormat.getInstance().format(ess.getUserMap().getUniqueUsers()))
|
||||
.replace("{ONLINE}", NumberFormat.getInstance().format(ess.getOnlinePlayers().size()));
|
||||
if (!msg.isEmpty()) {
|
||||
ess.getServer().broadcastMessage(msg);
|
||||
}
|
||||
} else if (ess.getSettings().allowSilentJoinQuit()) {
|
||||
ess.getServer().broadcastMessage(message);
|
||||
}
|
||||
@@ -309,7 +330,7 @@ public class EssentialsPlayerListener implements Listener {
|
||||
user.setGodModeEnabled(false);
|
||||
ess.getLogger().log(Level.INFO, "Set god mode to false for {0} because they had it enabled without permission.", user.getName());
|
||||
}
|
||||
|
||||
|
||||
user.setConfirmingClearCommand(null);
|
||||
user.getConfirmingPayments().clear();
|
||||
|
||||
@@ -439,12 +460,7 @@ public class EssentialsPlayerListener implements Listener {
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.hasUnlimited(new ItemStack(event.getBucket()))) {
|
||||
event.getItemStack().setType(event.getBucket());
|
||||
ess.scheduleSyncDelayedTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
user.getBase().updateInventory();
|
||||
}
|
||||
});
|
||||
ess.scheduleSyncDelayedTask(user.getBase()::updateInventory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,7 +495,7 @@ public class EssentialsPlayerListener implements Listener {
|
||||
LOGGER.info(tl("mutedUserSpeaks", player.getName(), event.getMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
boolean broadcast = true; // whether to broadcast the updated activity
|
||||
boolean update = true; // Only modified when the command is afk
|
||||
|
||||
@@ -498,16 +514,16 @@ public class EssentialsPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
if (ess.getSettings().isCommandCooldownsEnabled() && pluginCommand != null
|
||||
&& !user.isAuthorized("essentials.commandcooldowns.bypass")) {
|
||||
&& !user.isAuthorized("essentials.commandcooldowns.bypass")) {
|
||||
int argStartIndex = event.getMessage().indexOf(" ");
|
||||
String args = argStartIndex == -1 ? "" // No arguments present
|
||||
: " " + event.getMessage().substring(argStartIndex); // arguments start at argStartIndex; substring from there.
|
||||
String args = argStartIndex == -1 ? "" // No arguments present
|
||||
: " " + event.getMessage().substring(argStartIndex); // arguments start at argStartIndex; substring from there.
|
||||
String fullCommand = pluginCommand.getName() + args;
|
||||
|
||||
// Used to determine whether a user already has an existing cooldown
|
||||
// If so, no need to check for (and write) new ones.
|
||||
boolean cooldownFound = false;
|
||||
|
||||
|
||||
// Iterate over a copy of getCommandCooldowns in case of concurrent modifications
|
||||
for (Entry<Pattern, Long> entry : new HashMap<>(user.getCommandCooldowns()).entrySet()) {
|
||||
// Remove any expired cooldowns
|
||||
@@ -545,8 +561,8 @@ public class EssentialsPlayerListener implements Listener {
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.getBase().getGameMode() != GameMode.CREATIVE
|
||||
// COMPAT: String compare for 1.7.10
|
||||
&& !user.getBase().getGameMode().name().equals("SPECTATOR")
|
||||
&& !user.isAuthorized("essentials.fly")) {
|
||||
&& !user.getBase().getGameMode().name().equals("SPECTATOR")
|
||||
&& !user.isAuthorized("essentials.fly")) {
|
||||
user.getBase().setFallDistance(0f);
|
||||
user.getBase().setAllowFlight(false);
|
||||
}
|
||||
@@ -590,13 +606,18 @@ public class EssentialsPlayerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event) {
|
||||
boolean updateActivity = true;
|
||||
|
||||
switch (event.getAction()) {
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
if (!event.isCancelled() && MaterialUtil.isBed(event.getClickedBlock().getType()) && ess.getSettings().getUpdateBedAtDaytime()) {
|
||||
User player = ess.getUser(event.getPlayer());
|
||||
if (player.isAuthorized("essentials.sethome.bed")) {
|
||||
if (player.isAuthorized("essentials.sethome.bed") && player.getWorld().getEnvironment().equals(World.Environment.NORMAL)) {
|
||||
player.getBase().setBedSpawnLocation(event.getClickedBlock().getLocation());
|
||||
player.sendMessage(tl("bedSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
|
||||
// In 1.15 and above, vanilla sends its own bed spawn message.
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_15_R01)) {
|
||||
player.sendMessage(tl("bedSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -616,8 +637,16 @@ public class EssentialsPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PHYSICAL:
|
||||
updateActivity = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (updateActivity) {
|
||||
ess.getUser(event.getPlayer()).updateActivityOnInteract(true);
|
||||
}
|
||||
}
|
||||
|
||||
// This method allows the /jump lock feature to work, allows teleporting while flying #EasterEgg
|
||||
@@ -634,7 +663,7 @@ public class EssentialsPlayerListener implements Listener {
|
||||
while (LocationUtil.isBlockDamaging(loc.getWorld(), loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ())) {
|
||||
loc.setY(loc.getY() + 1d);
|
||||
}
|
||||
user.getBase().teleport(loc, TeleportCause.PLUGIN);
|
||||
PaperLib.teleportAsync(user.getBase(), loc, TeleportCause.PLUGIN);
|
||||
}
|
||||
}
|
||||
ess.scheduleSyncDelayedTask(new DelayedClickJumpTask());
|
||||
@@ -664,7 +693,7 @@ public class EssentialsPlayerListener implements Listener {
|
||||
class PowerToolUseTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
user.getServer().dispatchCommand(user.getBase(), command);
|
||||
user.getBase().chat("/" + command);
|
||||
LOGGER.log(Level.INFO, String.format("[PT] %s issued server command: /%s", user.getName(), command));
|
||||
}
|
||||
}
|
||||
@@ -719,8 +748,9 @@ public class EssentialsPlayerListener implements Listener {
|
||||
}
|
||||
} else if (clickedInventory != null && clickedInventory.getType() == InventoryType.PLAYER) {
|
||||
if (ess.getSettings().isDirectHatAllowed() && event.getClick() == ClickType.LEFT && event.getSlot() == 39
|
||||
&& event.getCursor().getType() != Material.AIR && event.getCursor().getType().getMaxDurability() == 0
|
||||
&& ess.getUser(event.getWhoClicked()).isAuthorized("essentials.hat")) {
|
||||
&& event.getCursor().getType() != Material.AIR && event.getCursor().getType().getMaxDurability() == 0
|
||||
&& !MaterialUtil.isSkull(event.getCursor().getType())
|
||||
&& ess.getUser(event.getWhoClicked()).isAuthorized("essentials.hat") && !ess.getUser(event.getWhoClicked()).isAuthorized("essentials.hat.prevent-type." + event.getCursor().getType().name().toLowerCase())) {
|
||||
event.setCancelled(true);
|
||||
final PlayerInventory inv = (PlayerInventory) clickedInventory;
|
||||
final ItemStack head = inv.getHelmet();
|
||||
@@ -731,12 +761,7 @@ public class EssentialsPlayerListener implements Listener {
|
||||
|
||||
if (refreshPlayer != null) {
|
||||
final Player player = refreshPlayer;
|
||||
ess.scheduleSyncDelayedTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.updateInventory();
|
||||
}
|
||||
}, 1);
|
||||
ess.scheduleSyncDelayedTask(player::updateInventory, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -771,32 +796,17 @@ public class EssentialsPlayerListener implements Listener {
|
||||
|
||||
if (refreshPlayer != null) {
|
||||
final Player player = refreshPlayer;
|
||||
ess.scheduleSyncDelayedTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.updateInventory();
|
||||
}
|
||||
}, 1);
|
||||
ess.scheduleSyncDelayedTask(player::updateInventory, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerFishEvent(final PlayerFishEvent event) {
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.updateActivityOnInteract(true);
|
||||
user.updateActivityOnInteract(true);
|
||||
}
|
||||
|
||||
private static boolean isEntityPickupEvent() {
|
||||
try {
|
||||
Class.forName("org.bukkit.event.entity.EntityPickupItemEvent");
|
||||
return true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private final class PlayerListenerPre1_12 implements Listener {
|
||||
|
||||
private final class PickupListenerPre1_12 implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerPickupItem(final org.bukkit.event.player.PlayerPickupItemEvent event) {
|
||||
if (ess.getSettings().getDisableItemPickupWhileAfk()) {
|
||||
@@ -807,8 +817,7 @@ public class EssentialsPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private final class PlayerListener1_12 implements Listener {
|
||||
|
||||
private final class PickupListener1_12 implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerPickupItem(final org.bukkit.event.entity.EntityPickupItemEvent event) {
|
||||
if (ess.getSettings().getDisableItemPickupWhileAfk() && event.getEntity() instanceof Player) {
|
||||
@@ -818,4 +827,46 @@ public class EssentialsPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final class CommandSendListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onCommandSend(final PlayerCommandSendEvent event) {
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
|
||||
Set<PluginCommand> checked = new HashSet<>();
|
||||
Set<PluginCommand> toRemove = new HashSet<>();
|
||||
|
||||
event.getCommands().removeIf(label -> {
|
||||
if (isEssentialsCommand(label)) {
|
||||
PluginCommand command = ess.getServer().getPluginCommand(label);
|
||||
if (!checked.contains(command)) {
|
||||
checked.add(command);
|
||||
if (!user.isAuthorized(command.getName().equals("r") ? "essentials.msg" : "essentials." + command.getName())) {
|
||||
toRemove.add(command);
|
||||
}
|
||||
}
|
||||
return toRemove.contains(command);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().info("Removed commands: " + toRemove.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if all of the following are true:
|
||||
* - The command is a plugin command
|
||||
* - The plugin command is from Essentials
|
||||
* - There is no known alternative OR the alternative is overridden by Essentials
|
||||
*/
|
||||
private boolean isEssentialsCommand(String label) {
|
||||
PluginCommand command = ess.getServer().getPluginCommand(label);
|
||||
|
||||
return command != null
|
||||
&& command.getPlugin() == ess
|
||||
&& (ess.getSettings().isCommandOverridden(label) || (ess.getAlternativeCommandsHandler().getAlternative(label) == null));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,18 @@ import org.bukkit.event.server.ServerListPingEvent;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
||||
public class EssentialsServerListener implements Listener {
|
||||
private static List<String> ignoredSLPECallers = Arrays.asList(
|
||||
".LegacyPingHandler.channelRead(", // CB responding to pings from pre-Netty clients
|
||||
"de.dytanic.cloudnet.bridge.BukkitBootstrap" // CloudNet v2 doing... something
|
||||
);
|
||||
|
||||
private final transient IEssentials ess;
|
||||
private boolean unsupportedLogged = false;
|
||||
private boolean npeWarned = false;
|
||||
@@ -31,13 +37,13 @@ public class EssentialsServerListener implements Listener {
|
||||
setSampleText = ReflUtil.getMethodCached(ServerListPingEvent.class, "setSampleText", List.class);
|
||||
getSampleText = ReflUtil.getMethodCached(ServerListPingEvent.class, "getSampleText");
|
||||
if (setSampleText != null && getSampleText != null) {
|
||||
ess.getLogger().info("Using Paper 1.12+ ServerListPingEvent methods");
|
||||
ess.getLogger().info("ServerListPingEvent: Paper 1.12.2 setSampleText API");
|
||||
isPaperSample = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ess.getLogger().info("Using Spigot 1.7.10+ ServerListPingEvent iterator");
|
||||
ess.getLogger().info("ServerListPingEvent: Spigot iterator API");
|
||||
isPaperSample = false;
|
||||
}
|
||||
|
||||
@@ -46,22 +52,16 @@ public class EssentialsServerListener implements Listener {
|
||||
if (isPaperSample) {
|
||||
try {
|
||||
List<String> playerNames = (List<String>) getSampleText.invoke(event, null);
|
||||
Iterator<String> iterator = playerNames.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String player = iterator.next();
|
||||
if (ess.getUser(player).isVanished()) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
playerNames.removeIf(player -> ess.getUser(player).isVanished());
|
||||
setSampleText.invoke(event, playerNames);
|
||||
} catch (IllegalAccessException | InvocationTargetException | ClassCastException e) {
|
||||
if (!unsupportedLogged) {
|
||||
if (!unsupportedLogged && shouldWarnSLPECaller(e)) {
|
||||
ess.getLogger().log(Level.WARNING, "Unable to hide players from server list ping "
|
||||
+ "using Paper 1.12+ method!", e);
|
||||
+ "using Paper 1.12 method!", e);
|
||||
unsupportedLogged = true;
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
if (!npeWarned) {
|
||||
if (!npeWarned && shouldWarnSLPECaller(e)) {
|
||||
npeWarned = true;
|
||||
Exception ex = new Exception("A plugin has fired a ServerListPingEvent "
|
||||
+ "without implementing Paper's methods. Point the author to https://git.io/v7Xzl.");
|
||||
@@ -79,12 +79,38 @@ public class EssentialsServerListener implements Listener {
|
||||
}
|
||||
}
|
||||
} catch (UnsupportedOperationException e) {
|
||||
if (!unsupportedLogged) {
|
||||
ess.getLogger().warning("Current server implementation does not support "
|
||||
+ "hiding players from server list ping. Update or contact the maintainers.");
|
||||
if (!unsupportedLogged && shouldWarnSLPECaller(e)) {
|
||||
ess.getLogger().log(Level.WARNING, "Could not hide vanished players while handling " + event.getClass().getName(), e);
|
||||
unsupportedLogged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should we warn about this SLPE caller, or should we silently ignore it?
|
||||
* This checks against the ignoredSLPECallers strings, and if it matches one of those, we
|
||||
* return false.
|
||||
*
|
||||
* @param throwable A throwable caught by a catch block
|
||||
* @return Whether or not to send a warning about this particular caller
|
||||
*/
|
||||
private boolean shouldWarnSLPECaller(Throwable throwable) {
|
||||
final int maxStackDepth = 20; // Limit the depth when searching through the stack trace
|
||||
int depth = 0;
|
||||
for (StackTraceElement element : throwable.getStackTrace()) {
|
||||
depth++;
|
||||
if (depth > maxStackDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
for (String ignoredString : ignoredSLPECallers) {
|
||||
if (element.toString().contains(ignoredString)) {
|
||||
return false; // We know about this error and should ignore it, so don't warn
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true; // We don't know for certain that we can ignore this, so warn just to be safe
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class I18n implements net.ess3.api.II18n {
|
||||
}
|
||||
messageFormatCache.put(format, messageFormat);
|
||||
}
|
||||
return messageFormat.format(objects);
|
||||
return messageFormat.format(objects).replace(' ', ' '); // replace nbsp with a space
|
||||
}
|
||||
|
||||
public void updateLocale(final String loc) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
@@ -185,6 +186,8 @@ public interface ISettings extends IConf {
|
||||
|
||||
boolean cancelAfkOnInteract();
|
||||
|
||||
boolean sleepIgnoresAfkPlayers();
|
||||
|
||||
boolean isAfkListName();
|
||||
|
||||
String getAfkListName();
|
||||
@@ -313,6 +316,8 @@ public interface ISettings extends IConf {
|
||||
|
||||
boolean isConfirmCommandEnabledByDefault(String commandName);
|
||||
|
||||
boolean isTeleportBackWhenFreedFromJail();
|
||||
|
||||
boolean isCompassTowardsHomePerm();
|
||||
|
||||
boolean isAllowWorldInBroadcastworld();
|
||||
@@ -320,4 +325,18 @@ public interface ISettings extends IConf {
|
||||
String getItemDbType();
|
||||
|
||||
boolean isForceEnableRecipe();
|
||||
|
||||
boolean allowOldIdSigns();
|
||||
|
||||
boolean isWaterSafe();
|
||||
|
||||
boolean isSafeUsermap();
|
||||
|
||||
boolean logCommandBlockCommands();
|
||||
|
||||
Set<Predicate<String>> getNickBlacklist();
|
||||
|
||||
double getMaxProjectileSpeed();
|
||||
|
||||
boolean isSpawnIfNoHome();
|
||||
}
|
||||
@@ -22,6 +22,8 @@ public interface IUser {
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
||||
|
||||
boolean isPermissionSet(String node);
|
||||
|
||||
void healCooldown() throws Exception;
|
||||
|
||||
void giveMoney(BigDecimal value) throws MaxMoneyException;
|
||||
@@ -184,5 +186,9 @@ public interface IUser {
|
||||
|
||||
void setPromptingClearConfirm(boolean prompt);
|
||||
|
||||
boolean isLastMessageReplyRecipient();
|
||||
|
||||
void setLastMessageReplyRecipient(boolean enabled);
|
||||
|
||||
Map<User, BigDecimal> getConfirmingPayments();
|
||||
}
|
||||
@@ -16,10 +16,7 @@ import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
@@ -203,6 +200,14 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onJailPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onJailPlayerRespawn(final PlayerRespawnEvent event) {
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
||||
@@ -79,6 +79,12 @@ public class Kits implements IConf {
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void removeKit(String name) {
|
||||
config.set("kits." + name, null);
|
||||
kits = _getKits();
|
||||
config.save();
|
||||
}
|
||||
|
||||
public String listKits(final net.ess3.api.IEssentials ess, final User user) throws Exception {
|
||||
try {
|
||||
final ConfigurationSection kits = config.getConfigurationSection("kits");
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.security.DigestInputStream;
|
||||
@@ -13,6 +10,9 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ManagedFile {
|
||||
try {
|
||||
copyResourceAscii("/" + filename, file);
|
||||
} catch (IOException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, tl("itemsCsvNotLoaded"), ex);
|
||||
Bukkit.getLogger().log(Level.SEVERE, tl("itemsCsvNotLoaded", filename), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,12 @@ import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.google.common.base.Joiner;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.nms.refl.ReflUtil;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.FireworkEffect;
|
||||
@@ -26,11 +28,6 @@ import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
|
||||
@@ -165,8 +162,8 @@ public class MetaItemStack {
|
||||
stack.setItemMeta(meta);
|
||||
} else if (split.length > 1 && (split[0].equalsIgnoreCase("lore") || split[0].equalsIgnoreCase("desc")) && hasMetaPermission(sender, "lore", false, true, ess)) {
|
||||
final List<String> lore = new ArrayList<String>();
|
||||
for (String line : split[1].split("\\|")) {
|
||||
lore.add(FormatUtil.replaceFormat(line.replace('_', ' ')));
|
||||
for (String line : split[1].split("(?<!\\\\)\\|")) {
|
||||
lore.add(FormatUtil.replaceFormat(line.replace('_', ' ').replace("\\|", "|")));
|
||||
}
|
||||
final ItemMeta meta = stack.getItemMeta();
|
||||
meta.setLore(lore);
|
||||
@@ -177,9 +174,7 @@ public class MetaItemStack {
|
||||
} else if (split.length > 1 && (split[0].equalsIgnoreCase("player") || split[0].equalsIgnoreCase("owner")) && hasMetaPermission(sender, "head", false, true, ess)) {
|
||||
if (MaterialUtil.isPlayerHead(stack.getType(), stack.getDurability())) {
|
||||
final String owner = split[1];
|
||||
final SkullMeta meta = (SkullMeta) stack.getItemMeta();
|
||||
meta.setOwningPlayer(ess.getServer().getOfflinePlayer(owner));
|
||||
stack.setItemMeta(meta);
|
||||
setSkullOwner(ess, stack, owner);
|
||||
} else {
|
||||
throw new Exception(tl("onlyPlayerSkulls"));
|
||||
}
|
||||
@@ -208,13 +203,19 @@ public class MetaItemStack {
|
||||
stack.setItemMeta(meta);
|
||||
} else if (split.length > 1 && split[0].equalsIgnoreCase("itemflags") && hasMetaPermission(sender, "itemflags", false, true, ess)) {
|
||||
addItemFlags(string);
|
||||
} else if (MaterialUtil.isFirework(stack.getType())) {//WARNING - Meta for fireworks will be ignored after this point.
|
||||
} else if (MaterialUtil.isFirework(stack.getType())) {
|
||||
//WARNING - Meta for fireworks will be ignored after this point.
|
||||
addFireworkMeta(sender, false, string, ess);
|
||||
} else if (MaterialUtil.isPotion(stack.getType())) { //WARNING - Meta for potions will be ignored after this point.
|
||||
} else if (MaterialUtil.isPotion(stack.getType())) {
|
||||
//WARNING - Meta for potions will be ignored after this point.
|
||||
addPotionMeta(sender, false, string, ess);
|
||||
} else if (MaterialUtil.isBanner(stack.getType())) {
|
||||
//WARNING - Meta for banners will be ignored after this point.
|
||||
addBannerMeta(sender, false, string, ess);
|
||||
if (stack.getType().toString().equals("SHIELD") && Enchantments.getByName(split[0]) != null) {
|
||||
parseEnchantmentStrings(sender, allowUnsafe, split, ess);
|
||||
} else {
|
||||
//WARNING - Meta for banners will be ignored after this point.
|
||||
addBannerMeta(sender, false, string, ess);
|
||||
}
|
||||
} else if (split.length > 1 && (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour")) && MaterialUtil.isLeatherArmor(stack.getType())) {
|
||||
final String[] color = split[1].split("(\\||,)");
|
||||
if (color.length == 1 && (NumberUtil.isInt(color[0]) || color[0].startsWith("#"))) {
|
||||
@@ -578,4 +579,24 @@ public class MetaItemStack {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean useNewSkullMethod = true;
|
||||
|
||||
private static void setSkullOwner(final IEssentials ess, final ItemStack stack, final String owner) {
|
||||
if (!(stack.getItemMeta() instanceof SkullMeta)) return;
|
||||
|
||||
SkullMeta meta = (SkullMeta) stack.getItemMeta();
|
||||
if (useNewSkullMethod) {
|
||||
try {
|
||||
meta.setOwningPlayer(ess.getServer().getOfflinePlayer(owner));
|
||||
stack.setItemMeta(meta);
|
||||
return;
|
||||
} catch (NoSuchMethodError e) {
|
||||
useNewSkullMethod = false;
|
||||
}
|
||||
}
|
||||
|
||||
meta.setOwner(owner);
|
||||
stack.setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
@@ -77,12 +77,20 @@ public enum Mob {
|
||||
PARROT("Parrot", Enemies.NEUTRAL, "PARROT"),
|
||||
TURTLE("Turtle", Enemies.NEUTRAL, "TURTLE"),
|
||||
PHANTOM("Phantom", Enemies.ENEMY, "PHANTOM"),
|
||||
COD("Cod", Enemies.NEUTRAL, "COD"),
|
||||
SALMON("Salmon", Enemies.NEUTRAL, "SALMON"),
|
||||
PUFFERFISH("Pufferfish", Enemies.NEUTRAL, "PUFFERFISH"),
|
||||
TROPICAL_FISH("TropicalFish", Enemies.NEUTRAL, "TROPICAL_FISH"),
|
||||
COD("Cod", Enemies.NEUTRAL, "", "COD"),
|
||||
SALMON("Salmon", Enemies.NEUTRAL, "", "SALMON"),
|
||||
PUFFERFISH("Pufferfish", Enemies.NEUTRAL, "", "PUFFERFISH"),
|
||||
TROPICAL_FISH("TropicalFish", Enemies.NEUTRAL, "", "TROPICAL_FISH"),
|
||||
DROWNED("Drowned", Enemies.ENEMY, "DROWNED"),
|
||||
DOLPHIN("Dolphin", Enemies.NEUTRAL, "DOLPHIN"),
|
||||
CAT("Cat", Enemies.FRIENDLY, "CAT"),
|
||||
FOX("Fox", Enemies.FRIENDLY, "es", "FOX"),
|
||||
PANDA("Panda", Enemies.NEUTRAL, "PANDA"),
|
||||
PILLAGER("Pillager", Enemies.ENEMY, "PILLAGER"),
|
||||
RAVAGER("Ravager", Enemies.ENEMY, "RAVAGER"),
|
||||
TRADER_LLAMA("TraderLlama", Enemies.FRIENDLY, "TRADER_LLAMA"),
|
||||
WANDERING_TRADER("WanderingTrader", Enemies.FRIENDLY, "WANDERING_TRADER"),
|
||||
BEE("Bee", Enemies.NEUTRAL, "BEE")
|
||||
;
|
||||
|
||||
public static final Logger logger = Logger.getLogger("Essentials");
|
||||
@@ -100,16 +108,17 @@ public enum Mob {
|
||||
this.bukkitType = type;
|
||||
}
|
||||
|
||||
Mob(String n, Enemies en, String s, String typeName) {
|
||||
this.suffix = s;
|
||||
this.name = n;
|
||||
this.type = en;
|
||||
bukkitType = EnumUtil.getEntityType(typeName);
|
||||
}
|
||||
|
||||
Mob(String n, Enemies en, String typeName) {
|
||||
this.name = n;
|
||||
this.type = en;
|
||||
EntityType entityType;
|
||||
try {
|
||||
entityType = EntityType.valueOf(typeName);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
entityType = null;
|
||||
}
|
||||
bukkitType = entityType;
|
||||
bukkitType = EnumUtil.getEntityType(typeName);
|
||||
}
|
||||
|
||||
public String suffix = "s";
|
||||
|
||||
@@ -0,0 +1,224 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import net.ess3.nms.refl.ReflUtil;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Villager;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import static com.earth2me.essentials.utils.EnumUtil.getEntityType;
|
||||
|
||||
public class MobCompat {
|
||||
|
||||
// Constants for mobs added in later versions
|
||||
public static final EntityType LLAMA = getEntityType("LLAMA");
|
||||
public static final EntityType PARROT = getEntityType("PARROT");
|
||||
public static final EntityType TROPICAL_FISH = getEntityType("TROPICAL_FISH");
|
||||
public static final EntityType PANDA = getEntityType("PANDA");
|
||||
public static final EntityType TRADER_LLAMA = getEntityType("TRADER_LLAMA");
|
||||
|
||||
// Constants for mobs that have changed since earlier versions
|
||||
public static final EntityType CAT = getEntityType("CAT", "OCELOT");
|
||||
|
||||
public enum CatType {
|
||||
// These are (loosely) Mojang names for the cats
|
||||
SIAMESE("SIAMESE", "SIAMESE_CAT"),
|
||||
WHITE("WHITE", "SIAMESE_CAT"),
|
||||
RED("RED", "RED_CAT"),
|
||||
TABBY("TABBY", "RED_CAT"),
|
||||
TUXEDO("BLACK", "BLACK_CAT"),
|
||||
BRITISH_SHORTHAIR("BRITISH_SHORTHAIR", "SIAMESE_CAT"),
|
||||
CALICO("CALICO", "RED_CAT"),
|
||||
PERSIAN("PERSIAN", "RED_CAT"),
|
||||
RAGDOLL("RAGDOLL", "SIAMESE_CAT"),
|
||||
JELLIE("JELLIE", "SIAMESE_CAT"),
|
||||
BLACK("ALL_BLACK", "BLACK_CAT"),
|
||||
;
|
||||
|
||||
private final String catTypeName;
|
||||
private final String ocelotTypeName;
|
||||
|
||||
CatType(final String catTypeName, final String ocelotTypeName) {
|
||||
this.catTypeName = catTypeName;
|
||||
this.ocelotTypeName = ocelotTypeName;
|
||||
}
|
||||
}
|
||||
|
||||
public enum VillagerProfession {
|
||||
// These are 1.14+ villager professions mapped to their respective pre-V&P profession and career
|
||||
NONE("FARMER", "FARMER", "NONE"),
|
||||
ARMORER("BLACKSMITH", "ARMORER"),
|
||||
BUTCHER("FARMER", "BUTCHER"),
|
||||
CARTOGRAPHER("LIBRARIAN", "CARTOGRAPHER"),
|
||||
CLERIC("PRIEST", "CLERIC"),
|
||||
FARMER("FARMER", "FARMER"),
|
||||
FISHERMAN("FARMER", "FISHERMAN"),
|
||||
FLETCHER("FARMER", "FLETCHER"),
|
||||
LEATHERWORKER("BUTCHER", "LEATHERWORKER"),
|
||||
LIBRARIAN("LIBRARIAN", "LIBRARIAN"),
|
||||
MASON(null, null, "MASON"),
|
||||
NITWIT("NITWIT", "NITWIT"),
|
||||
SHEPHERD("FARMER", "SHEPHERD"),
|
||||
TOOLSMITH("BLACKSMITH", "TOOL_SMITH", "TOOLSMITH"),
|
||||
WEAPONSMITH("BLACKSMITH", "WEAPON_SMITH", "WEAPONSMITH")
|
||||
;
|
||||
|
||||
private String oldProfession;
|
||||
private String oldCareer;
|
||||
private String newProfession;
|
||||
|
||||
VillagerProfession(final String oldProfession, final String career) {
|
||||
this.oldProfession = oldProfession;
|
||||
this.oldCareer = career;
|
||||
this.newProfession = career;
|
||||
}
|
||||
|
||||
VillagerProfession(final String oldProfession, final String oldCareer, final String newProfession) {
|
||||
this.oldProfession = oldProfession;
|
||||
this.oldCareer = oldCareer;
|
||||
this.newProfession = newProfession;
|
||||
}
|
||||
|
||||
private Villager.Profession asEnum() {
|
||||
return EnumUtil.valueOf(Villager.Profession.class, newProfession, oldProfession);
|
||||
}
|
||||
}
|
||||
|
||||
// Older cats are Ocelots, whereas 1.14+ cats are Cats
|
||||
private static Class catClass = ReflUtil.getClassCached("org.bukkit.entity.Cat");
|
||||
private static Class catTypeClass = ReflUtil.getClassCached("org.bukkit.entity.Cat.Type");
|
||||
private static Method catSetTypeMethod = (catClass == null || catTypeClass == null) ? null : ReflUtil.getMethodCached(catClass, "setCatType", catTypeClass);
|
||||
|
||||
private static boolean isNewCat() {
|
||||
return (catClass != null && catTypeClass != null && catSetTypeMethod != null);
|
||||
}
|
||||
|
||||
public static void setCatType(final Entity entity, final CatType type) {
|
||||
if (isNewCat()) {
|
||||
try {
|
||||
catSetTypeMethod.invoke(entity, EnumUtil.valueOf(catTypeClass, type.catTypeName));
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
((Ocelot) entity).setCatType(Ocelot.Type.valueOf(type.ocelotTypeName));
|
||||
}
|
||||
}
|
||||
|
||||
// Older villagers have professions and careers, 1.14+ villagers only have professions
|
||||
private static Class villagerCareerClass = ReflUtil.getClassCached("org.bukkit.entity.Villager.Career");
|
||||
private static Method villagerSetCareerMethod = (villagerCareerClass == null) ? null : ReflUtil.getMethodCached(Villager.class, "setCareer", villagerCareerClass);
|
||||
|
||||
private static boolean isCareerVillager() {
|
||||
return (villagerCareerClass != null && villagerSetCareerMethod != null);
|
||||
}
|
||||
|
||||
public static void setVillagerProfession(final Entity entity, final VillagerProfession profession) {
|
||||
if (!isCareerVillager()) {
|
||||
((Villager) entity).setProfession(profession.asEnum());
|
||||
} else {
|
||||
((Villager) entity).setProfession(profession.asEnum());
|
||||
try {
|
||||
villagerSetCareerMethod.invoke(entity, EnumUtil.valueOf(villagerCareerClass, profession.oldCareer));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only 1.14+ villagers have biome variants
|
||||
public static void setVillagerType(final Entity entity, final String type) {
|
||||
Class typeEnum = ReflUtil.getClassCached("org.bukkit.entity.Villager.Type");
|
||||
if (typeEnum == null) return;
|
||||
|
||||
Method villagerSetTypeMethod = ReflUtil.getMethodCached(Villager.class, "setVillagerType", typeEnum);
|
||||
try {
|
||||
villagerSetTypeMethod.invoke(entity, EnumUtil.valueOf(typeEnum, type));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Llamas only exist in 1.11+
|
||||
public static void setLlamaColor(final Entity entity, final String color) {
|
||||
Class llamaClass = ReflUtil.getClassCached("org.bukkit.entity.Llama");
|
||||
if (llamaClass == null) return;
|
||||
|
||||
Class colorEnum = ReflUtil.getClassCached("org.bukkit.entity.Llama.Color");
|
||||
Method setVariantMethod = ReflUtil.getMethodCached(llamaClass, "setColor");
|
||||
|
||||
try {
|
||||
setVariantMethod.invoke(entity, EnumUtil.valueOf(colorEnum, color));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Parrots only exist in 1.12+
|
||||
public static void setParrotVariant(final Entity entity, final String variant) {
|
||||
Class parrotClass = ReflUtil.getClassCached("org.bukkit.entity.Parrot");
|
||||
if (parrotClass == null) return;
|
||||
|
||||
Class variantEnum = ReflUtil.getClassCached("org.bukkit.entity.Parrot.Variant");
|
||||
Method setVariantMethod = ReflUtil.getMethodCached(parrotClass, "setVariant");
|
||||
try {
|
||||
setVariantMethod.invoke(entity, EnumUtil.valueOf(variantEnum, variant));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Tropical fish only exist in 1.13+
|
||||
public static void setTropicalFishPattern(final Entity entity, final String pattern) {
|
||||
Class tropicalFishClass = ReflUtil.getClassCached("org.bukkit.entity.TropicalFish");
|
||||
if (tropicalFishClass == null) return;
|
||||
|
||||
Class patternEnum = ReflUtil.getClassCached("org.bukkit.entity.TropicalFish.Pattern");
|
||||
Method setPatternMethod = ReflUtil.getMethodCached(tropicalFishClass, "setPattern");
|
||||
try {
|
||||
setPatternMethod.invoke(entity, EnumUtil.valueOf(patternEnum, pattern));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Mushroom cow variant API only exists in 1.14+
|
||||
public static void setMooshroomVariant(final Entity entity, final String variant) {
|
||||
Class mushroomCowClass = ReflUtil.getClassCached("org.bukkit.entity.MushroomCow");
|
||||
Class variantEnum = ReflUtil.getClassCached("org.bukkit.entity.MushroomCow.Variant");
|
||||
if (mushroomCowClass == null || variantEnum == null) return;
|
||||
|
||||
Method setVariantMethod = ReflUtil.getMethodCached(mushroomCowClass, "setVariant");
|
||||
try {
|
||||
setVariantMethod.invoke(entity, EnumUtil.valueOf(variantEnum, variant));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Pandas only exists in 1.14+
|
||||
public static void setPandaGene(final Entity entity, final String gene, final boolean mainGene) {
|
||||
Class pandaClass = ReflUtil.getClassCached("org.bukkit.entity.Panda");
|
||||
if (pandaClass == null) return;
|
||||
|
||||
Class geneEnum = ReflUtil.getClassCached("org.bukkit.entity.Panda.Gene");
|
||||
Method setGeneMethod;
|
||||
|
||||
if (mainGene) {
|
||||
setGeneMethod = ReflUtil.getMethodCached(pandaClass, "setMainGene");
|
||||
} else {
|
||||
setGeneMethod = ReflUtil.getMethodCached(pandaClass, "setHiddenGene");
|
||||
}
|
||||
|
||||
try {
|
||||
setGeneMethod.invoke(entity, EnumUtil.valueOf(geneEnum, gene));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -16,8 +17,10 @@ import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
|
||||
public enum MobData {
|
||||
|
||||
BABY_AGEABLE("baby", Ageable.class, Data.BABY, true),
|
||||
ADULT_AGEABLE("adult", Ageable.class, Data.ADULT, true),
|
||||
BABY_CAT("kitten", MobCompat.CAT, Data.BABY, false),
|
||||
BABY_PIG("piglet", EntityType.PIG, Data.BABY, false),
|
||||
BABY_WOLF("puppy", EntityType.WOLF, Data.BABY, false),
|
||||
BABY_CHICKEN("chick", EntityType.CHICKEN, Data.BABY, false),
|
||||
@@ -53,25 +56,31 @@ public enum MobData {
|
||||
BAY_HORSE("bay", EntityType.HORSE, Horse.Color.BROWN, true),
|
||||
BROWN_HORSE("brown", EntityType.HORSE, Horse.Color.BROWN, false),
|
||||
SADDLE_HORSE("saddle", EntityType.HORSE, Data.HORSESADDLE, true),
|
||||
GOLD_ARMOR_HORSE("goldarmor", EntityType.HORSE, Material.GOLDEN_HORSE_ARMOR, true),
|
||||
DIAMOND_ARMOR_HORSE("diamondarmor", EntityType.HORSE, Material.DIAMOND_HORSE_ARMOR, true),
|
||||
ARMOR_HORSE("armor", EntityType.HORSE, Material.IRON_HORSE_ARMOR, true),
|
||||
SIAMESE_CAT("siamese", EntityType.OCELOT, Ocelot.Type.SIAMESE_CAT, true),
|
||||
WHITE_CAT("white", EntityType.OCELOT, Ocelot.Type.SIAMESE_CAT, false),
|
||||
RED_CAT("red", EntityType.OCELOT, Ocelot.Type.RED_CAT, true),
|
||||
ORANGE_CAT("orange", EntityType.OCELOT, Ocelot.Type.RED_CAT, false),
|
||||
TABBY_CAT("tabby", EntityType.OCELOT, Ocelot.Type.RED_CAT, false),
|
||||
BLACK_CAT("black", EntityType.OCELOT, Ocelot.Type.BLACK_CAT, true),
|
||||
TUXEDO_CAT("tuxedo", EntityType.OCELOT, Ocelot.Type.BLACK_CAT, false),
|
||||
GOLD_ARMOR_HORSE("goldarmor", EntityType.HORSE, EnumUtil.getMaterial("GOLDEN_HORSE_ARMOR", "GOLD_BARDING"), true),
|
||||
DIAMOND_ARMOR_HORSE("diamondarmor", EntityType.HORSE, EnumUtil.getMaterial("DIAMOND_HORSE_ARMOR", "DIAMOND_BARDING"), true),
|
||||
ARMOR_HORSE("armor", EntityType.HORSE, EnumUtil.getMaterial("IRON_HORSE_ARMOR", "IRON_BARDING"), true),
|
||||
SIAMESE_CAT("siamese", MobCompat.CAT, MobCompat.CatType.SIAMESE, true),
|
||||
WHITE_CAT("white", MobCompat.CAT, MobCompat.CatType.WHITE, false),
|
||||
RED_CAT("red", MobCompat.CAT, MobCompat.CatType.RED, true),
|
||||
ORANGE_CAT("orange", MobCompat.CAT, MobCompat.CatType.RED, false),
|
||||
TABBY_CAT("tabby", MobCompat.CAT, MobCompat.CatType.TABBY, true),
|
||||
BLACK_CAT("black", MobCompat.CAT, MobCompat.CatType.BLACK, true),
|
||||
TUXEDO_CAT("tuxedo", MobCompat.CAT, MobCompat.CatType.TUXEDO, true),
|
||||
BRITISH_SHORTHAIR_CAT("britishshorthair", MobCompat.CAT, MobCompat.CatType.BRITISH_SHORTHAIR, true),
|
||||
CALICO_CAT("calico", MobCompat.CAT, MobCompat.CatType.CALICO, true),
|
||||
PERSIAN_CAT("persian", MobCompat.CAT, MobCompat.CatType.PERSIAN, true),
|
||||
RAGDOLL_CAT("ragdoll", MobCompat.CAT, MobCompat.CatType.RAGDOLL, true),
|
||||
JELLIE_CAT("jellie", MobCompat.CAT, MobCompat.CatType.JELLIE, true),
|
||||
ALL_BLACK_CAT("allblack", MobCompat.CAT, MobCompat.CatType.BLACK, true),
|
||||
BABY_ZOMBIE("baby", EntityType.ZOMBIE.getEntityClass(), Data.BABYZOMBIE, true),
|
||||
ADULT_ZOMBIE("adult", EntityType.ZOMBIE.getEntityClass(), Data.ADULTZOMBIE, true),
|
||||
DIAMOND_SWORD_ZOMBIE("diamondsword", EntityType.ZOMBIE.getEntityClass(), Material.DIAMOND_SWORD, true),
|
||||
GOLD_SWORD_ZOMBIE("goldsword", EntityType.ZOMBIE.getEntityClass(), Material.GOLDEN_SWORD, true),
|
||||
GOLD_SWORD_ZOMBIE("goldsword", EntityType.ZOMBIE.getEntityClass(), EnumUtil.getMaterial("GOLDEN_SWORD", "GOLD_SWORD"), true),
|
||||
IRON_SWORD_ZOMBIE("ironsword", EntityType.ZOMBIE.getEntityClass(), Material.IRON_SWORD, true),
|
||||
STONE_SWORD_ZOMBIE("stonesword", EntityType.ZOMBIE.getEntityClass(), Material.STONE_SWORD, false),
|
||||
SWORD_ZOMBIE("sword", EntityType.ZOMBIE.getEntityClass(), Material.STONE_SWORD, true),
|
||||
DIAMOND_SWORD_SKELETON("diamondsword", EntityType.SKELETON, Material.DIAMOND_SWORD, true),
|
||||
GOLD_SWORD_SKELETON("goldsword", EntityType.SKELETON, Material.GOLDEN_SWORD, true),
|
||||
GOLD_SWORD_SKELETON("goldsword", EntityType.SKELETON, EnumUtil.getMaterial("GOLDEN_SWORD", "GOLD_SWORD"), true),
|
||||
IRON_SWORD_SKELETON("ironsword", EntityType.SKELETON, Material.IRON_SWORD, true),
|
||||
STONE_SWORD_SKELETON("stonesword", EntityType.SKELETON, Material.STONE_SWORD, false),
|
||||
SWORD_SKELETON("sword", EntityType.SKELETON, Material.STONE_SWORD, true),
|
||||
@@ -82,31 +91,69 @@ public enum MobData {
|
||||
SADDLE_PIG("saddle", EntityType.PIG, Data.PIGSADDLE, true),
|
||||
ANGRY_WOLF("angry", EntityType.WOLF, Data.ANGRY, true),
|
||||
RABID_WOLF("rabid", EntityType.WOLF, Data.ANGRY, false),
|
||||
FARMER_VILLAGER("farmer", EntityType.VILLAGER, Villager.Profession.FARMER, true),
|
||||
LIBRARIAN_VILLAGER("librarian", EntityType.VILLAGER, Villager.Profession.LIBRARIAN, true),
|
||||
PRIEST_VILLAGER("priest", EntityType.VILLAGER, Villager.Profession.PRIEST, true),
|
||||
FATHER_VILLAGER("father", EntityType.VILLAGER, Villager.Profession.PRIEST, false),
|
||||
SMITH_VILLAGER("smith", EntityType.VILLAGER, Villager.Profession.BLACKSMITH, true),
|
||||
BUTCHER_VILLAGER("butcher", EntityType.VILLAGER, Villager.Profession.BUTCHER, true),
|
||||
VILLAGER("villager", EntityType.VILLAGER, MobCompat.VillagerProfession.NONE, true),
|
||||
ARMORER_VILLAGER("armorer", EntityType.VILLAGER, MobCompat.VillagerProfession.ARMORER, true),
|
||||
BUTCHER_VILLAGER("butcher", EntityType.VILLAGER, MobCompat.VillagerProfession.BUTCHER, true),
|
||||
CARTOGRAPHER_VILLAGER("cartographer", EntityType.VILLAGER, MobCompat.VillagerProfession.CARTOGRAPHER, true),
|
||||
CLERIC_VILLAGER("cleric", EntityType.VILLAGER, MobCompat.VillagerProfession.CLERIC, true),
|
||||
FARMER_VILLAGER("farmer", EntityType.VILLAGER, MobCompat.VillagerProfession.FARMER, true),
|
||||
FISHERMAN_VILLAGER("fisherman", EntityType.VILLAGER, MobCompat.VillagerProfession.FISHERMAN, true),
|
||||
FLETCHER_VILLAGER("fletcher", EntityType.VILLAGER, MobCompat.VillagerProfession.FLETCHER, true),
|
||||
LEATHERWORKER_VILLAGER("leatherworker", EntityType.VILLAGER, MobCompat.VillagerProfession.LEATHERWORKER, true),
|
||||
LIBRARIAN_VILLAGER("librarian", EntityType.VILLAGER, MobCompat.VillagerProfession.LIBRARIAN, true),
|
||||
MASON_VILLAGER("mason", EntityType.VILLAGER, MobCompat.VillagerProfession.MASON, true),
|
||||
NITWIT_VILLAGER("nitwit", EntityType.VILLAGER, MobCompat.VillagerProfession.NITWIT, true),
|
||||
SHEPHERD_VILLAGER("shepherd", EntityType.VILLAGER, MobCompat.VillagerProfession.SHEPHERD, true),
|
||||
TOOLSMITH_VILLAGER("toolsmith", EntityType.VILLAGER, MobCompat.VillagerProfession.TOOLSMITH, true),
|
||||
WEAPONSMITH_VILLAGER("weaponsmith", EntityType.VILLAGER, MobCompat.VillagerProfession.WEAPONSMITH, true),
|
||||
DESERT_VILLAGER("desert", EntityType.VILLAGER, "villagertype:DESERT", true),
|
||||
JUNGLE_VILLAGER("jungle", EntityType.VILLAGER, "villagertype:JUNGLE", true),
|
||||
PLAINS_VILLAGER("plains", EntityType.VILLAGER, "villagertype:PLAINS", true),
|
||||
SAVANNA_VILLAGER("savanna", EntityType.VILLAGER, "villagertype:SAVANNA", true),
|
||||
SNOWY_VILLAGER("snowy", EntityType.VILLAGER, "villagertype:SNOWY", true),
|
||||
SWAMP_VILLAGER("swamp", EntityType.VILLAGER, "villagertype:SWAMP", true),
|
||||
TAIGA_VILLAGER("taiga", EntityType.VILLAGER, "villagertype:TAIGA", true),
|
||||
SIZE_SLIME("", "<1-100>", EntityType.SLIME.getEntityClass(), Data.SIZE, true),
|
||||
NUM_EXPERIENCE_ORB("", "<1-2000000000>", EntityType.EXPERIENCE_ORB, Data.EXP, true),
|
||||
RED_PARROT("red", EntityType.PARROT, Parrot.Variant.RED, true),
|
||||
GREEN_PARROT("green", EntityType.PARROT, Parrot.Variant.GREEN, true),
|
||||
BLUE_PARROT("blue", EntityType.PARROT, Parrot.Variant.BLUE, true),
|
||||
CYAN_PARROT("cyan", EntityType.PARROT, Parrot.Variant.CYAN, true),
|
||||
GRAY_PARROT("gray", EntityType.PARROT, Parrot.Variant.GRAY, true),
|
||||
KOB_TROPICAL_FISH("kob", EntityType.TROPICAL_FISH, TropicalFish.Pattern.KOB, true),
|
||||
SUNSTREAK_TROPICAL_FISH("sunstreak", EntityType.TROPICAL_FISH, TropicalFish.Pattern.SUNSTREAK, true),
|
||||
SNOOPER_TROPICAL_FISH("snooper", EntityType.TROPICAL_FISH, TropicalFish.Pattern.SNOOPER, true),
|
||||
DASHER_TROPICAL_FISH("dasher", EntityType.TROPICAL_FISH, TropicalFish.Pattern.DASHER, true),
|
||||
BRINELY_TROPICAL_FISH("brinely", EntityType.TROPICAL_FISH, TropicalFish.Pattern.BRINELY, true),
|
||||
SPOTTY_TROPICAL_FISH("spotty", EntityType.TROPICAL_FISH, TropicalFish.Pattern.SPOTTY, true),
|
||||
FLOPPER_TROPICAL_FISH("flopper", EntityType.TROPICAL_FISH, TropicalFish.Pattern.FLOPPER, true),
|
||||
STRIPEY_TROPICAL_FISH("stripey", EntityType.TROPICAL_FISH, TropicalFish.Pattern.STRIPEY, true),
|
||||
GLITTER_TROPICAL_FISH("glitter", EntityType.TROPICAL_FISH, TropicalFish.Pattern.GLITTER, true),
|
||||
BLOCKFISH_TROPICAL_FISH("blockfish", EntityType.TROPICAL_FISH, TropicalFish.Pattern.BLOCKFISH, true),
|
||||
BETTY_TROPICAL_FISH("betty", EntityType.TROPICAL_FISH, TropicalFish.Pattern.BETTY, true),
|
||||
CLAYFISH_TROPICAL_FISH("clayfish", EntityType.TROPICAL_FISH, TropicalFish.Pattern.CLAYFISH, true);
|
||||
RED_PARROT("red", MobCompat.PARROT, "parrot:RED", true),
|
||||
GREEN_PARROT("green", MobCompat.PARROT, "parrot:GREEN", true),
|
||||
BLUE_PARROT("blue", MobCompat.PARROT, "parrot:BLUE", true),
|
||||
CYAN_PARROT("cyan", MobCompat.PARROT, "parrot:CYAN", true),
|
||||
GRAY_PARROT("gray", MobCompat.PARROT, "parrot:GRAY", true),
|
||||
KOB_TROPICAL_FISH("kob", MobCompat.TROPICAL_FISH, "tropicalfish:KOB", true),
|
||||
SUNSTREAK_TROPICAL_FISH("sunstreak", MobCompat.TROPICAL_FISH, "tropicalfish:SUNSTREAK", true),
|
||||
SNOOPER_TROPICAL_FISH("snooper", MobCompat.TROPICAL_FISH, "tropicalfish:SNOOPER", true),
|
||||
DASHER_TROPICAL_FISH("dasher", MobCompat.TROPICAL_FISH, "tropicalfish:DASHER", true),
|
||||
BRINELY_TROPICAL_FISH("brinely", MobCompat.TROPICAL_FISH, "tropicalfish:BRINELY", true),
|
||||
SPOTTY_TROPICAL_FISH("spotty", MobCompat.TROPICAL_FISH, "tropicalfish:SPOTTY", true),
|
||||
FLOPPER_TROPICAL_FISH("flopper", MobCompat.TROPICAL_FISH, "tropicalfish:FLOPPER", true),
|
||||
STRIPEY_TROPICAL_FISH("stripey", MobCompat.TROPICAL_FISH, "tropicalfish:STRIPEY", true),
|
||||
GLITTER_TROPICAL_FISH("glitter", MobCompat.TROPICAL_FISH, "tropicalfish:GLITTER", true),
|
||||
BLOCKFISH_TROPICAL_FISH("blockfish", MobCompat.TROPICAL_FISH, "tropicalfish:BLOCKFISH", true),
|
||||
BETTY_TROPICAL_FISH("betty", MobCompat.TROPICAL_FISH, "tropicalfish:BETTY", true),
|
||||
CLAYFISH_TROPICAL_FISH("clayfish", MobCompat.TROPICAL_FISH, "tropicalfish:CLAYFISH", true),
|
||||
BROWN_MUSHROOM_COW("brown", EntityType.MUSHROOM_COW, "mooshroom:BROWN", true),
|
||||
RED_MUSHROOM_COW("red", EntityType.MUSHROOM_COW, "mooshroom:RED", true),
|
||||
AGGRESSIVE_PANDA_MAIN("aggressive", MobCompat.PANDA, "pandamain:AGGRESSIVE", true),
|
||||
LAZY_PANDA_MAIN("lazy", MobCompat.PANDA, "pandamain:LAZY", true),
|
||||
WORRIED_PANDA_MAIN("worried", MobCompat.PANDA, "pandamain:WORRIED", true),
|
||||
PLAYFUL_PANDA_MAIN("playful", MobCompat.PANDA, "pandamain:PLAYFUL", true),
|
||||
BROWN_PANDA_MAIN("brown", MobCompat.PANDA, "pandamain:BROWN", true),
|
||||
WEAK_PANDA_MAIN("weak", MobCompat.PANDA, "pandamain:WEAK", true),
|
||||
AGGRESSIVE_PANDA_HIDDEN("aggressive_hidden", MobCompat.PANDA, "pandahidden:AGGRESSIVE", true),
|
||||
LAZY_PANDA_HIDDEN("lazy_hidden", MobCompat.PANDA, "pandahidden:LAZY", true),
|
||||
WORRIED_PANDA_HIDDEN("worried_hidden", MobCompat.PANDA, "pandahidden:WORRIED", true),
|
||||
PLAYFUL_PANDA_HIDDEN("playful_hidden", MobCompat.PANDA, "pandahidden:PLAYFUL", true),
|
||||
BROWN_PANDA_HIDDEN("brown_hidden", MobCompat.PANDA, "pandahidden:BROWN", true),
|
||||
WEAK_PANDA_HIDDEN("weak_hidden", MobCompat.PANDA, "pandahidden:WEAK", true),
|
||||
CREAMY_LLAMA("creamy", MobCompat.LLAMA, "llama:CREAMY", true),
|
||||
WHITE_LLAMA("white", MobCompat.LLAMA, "llama:WHITE", true),
|
||||
BROWN_LLAMA("brown", MobCompat.LLAMA, "llama:BROWN", true),
|
||||
GRAY_LLAMA("gray", MobCompat.LLAMA, "llama:GRAY", true),
|
||||
CREAMY_TRADER_LLAMA("creamy", MobCompat.TRADER_LLAMA, "llama:CREAMY", true),
|
||||
WHITE_TRADER_LLAMA("white", MobCompat.TRADER_LLAMA, "llama:WHITE", true),
|
||||
BROWN_TRADER_LLAMA("brown", MobCompat.TRADER_LLAMA, "llama:BROWN", true),
|
||||
GRAY_TRADER_LLAMA("gray", MobCompat.TRADER_LLAMA, "llama:GRAY", true)
|
||||
;
|
||||
|
||||
|
||||
@@ -126,6 +173,8 @@ public enum MobData {
|
||||
SIZE
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static final Logger logger = Logger.getLogger("Essentials");
|
||||
|
||||
MobData(String n, Object type, Object value, boolean isPublic) {
|
||||
@@ -156,9 +205,11 @@ public enum MobData {
|
||||
public static LinkedHashMap<String, MobData> getPossibleData(final Entity spawned, boolean publicOnly) {
|
||||
LinkedHashMap<String, MobData> mobList = new LinkedHashMap<String, MobData>();
|
||||
for (MobData data : MobData.values()) {
|
||||
if (data.type instanceof EntityType && spawned.getType().equals(data.type) && ((publicOnly && data.isPublic) || !publicOnly)) {
|
||||
if (data.type == null || (publicOnly && !data.isPublic)) continue;
|
||||
|
||||
if (data.type instanceof EntityType && spawned.getType().equals(data.type)) {
|
||||
mobList.put(data.nickname.toLowerCase(Locale.ENGLISH), data);
|
||||
} else if (data.type instanceof Class && ((Class) data.type).isAssignableFrom(spawned.getClass()) && ((publicOnly && data.isPublic) || !publicOnly)) {
|
||||
} else if (data.type instanceof Class && ((Class) data.type).isAssignableFrom(spawned.getClass())) {
|
||||
mobList.put(data.nickname.toLowerCase(Locale.ENGLISH), data);
|
||||
}
|
||||
}
|
||||
@@ -249,10 +300,10 @@ public enum MobData {
|
||||
((Horse) spawned).setColor((Horse.Color) this.value);
|
||||
} else if (this.value instanceof Horse.Style) {
|
||||
((Horse) spawned).setStyle((Horse.Style) this.value);
|
||||
} else if (this.value instanceof Ocelot.Type) {
|
||||
((Ocelot) spawned).setCatType((Ocelot.Type) this.value);
|
||||
} else if (this.value instanceof Villager.Profession) {
|
||||
((Villager) spawned).setProfession((Villager.Profession) this.value);
|
||||
} else if (this.value instanceof MobCompat.CatType) {
|
||||
MobCompat.setCatType(spawned, (MobCompat.CatType) this.value);
|
||||
} else if (this.value instanceof MobCompat.VillagerProfession) {
|
||||
MobCompat.setVillagerProfession(spawned, (MobCompat.VillagerProfession) this.value);
|
||||
} else if (this.value instanceof Material) {
|
||||
if (this.type.equals(EntityType.HORSE)) {
|
||||
((Horse) spawned).setTamed(true);
|
||||
@@ -262,10 +313,33 @@ public enum MobData {
|
||||
InventoryWorkaround.setItemInMainHand(invent, new ItemStack((Material) this.value, 1));
|
||||
InventoryWorkaround.setItemInMainHandDropChance(invent, 0.1f);
|
||||
}
|
||||
} else if (this.value instanceof Parrot.Variant) {
|
||||
((Parrot) spawned).setVariant((Parrot.Variant) this.value);
|
||||
} else if (this.value instanceof TropicalFish.Pattern) {
|
||||
((TropicalFish) spawned).setPattern((TropicalFish.Pattern) this.value);
|
||||
} else if (this.value instanceof String) {
|
||||
final String[] split = ((String) this.value).split(":");
|
||||
switch (split[0]) {
|
||||
case "parrot":
|
||||
MobCompat.setParrotVariant(spawned, split[1]);
|
||||
break;
|
||||
case "tropicalfish":
|
||||
MobCompat.setTropicalFishPattern(spawned, split[1]);
|
||||
break;
|
||||
case "mooshroom":
|
||||
MobCompat.setMooshroomVariant(spawned, split[1]);
|
||||
break;
|
||||
case "pandamain":
|
||||
MobCompat.setPandaGene(spawned, split[1], true);
|
||||
break;
|
||||
case "pandahidden":
|
||||
MobCompat.setPandaGene(spawned, split[1], false);
|
||||
break;
|
||||
case "llama":
|
||||
MobCompat.setLlamaColor(spawned, split[1]);
|
||||
break;
|
||||
case "villagertype":
|
||||
MobCompat.setVillagerType(spawned, split[1]);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
logger.warning("Unknown mob data type: " + this.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationAbandonedEvent;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.memory.MemoryKey;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.*;
|
||||
@@ -23,6 +24,7 @@ import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@@ -108,6 +110,15 @@ public class OfflinePlayer implements Player {
|
||||
public void setHealth(double d) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAbsorptionAmount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAbsorptionAmount(double v) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInsideVehicle() {
|
||||
return false;
|
||||
@@ -133,15 +144,24 @@ public class OfflinePlayer implements Player {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotation(float yaw, float pitch) {
|
||||
location.setYaw(yaw);
|
||||
location.setPitch(pitch);
|
||||
}
|
||||
|
||||
public void setLocation(Location loc) {
|
||||
location = loc;
|
||||
world = loc.getWorld();
|
||||
}
|
||||
|
||||
public void teleportTo(Location lctn) {
|
||||
location = lctn;
|
||||
world = location.getWorld();
|
||||
}
|
||||
|
||||
public void teleportTo(Entity entity) {
|
||||
teleportTo(entity.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,6 +173,11 @@ public class OfflinePlayer implements Player {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pose getPose() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performCommand(String string) {
|
||||
return false;
|
||||
@@ -411,19 +436,6 @@ public class OfflinePlayer implements Player {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void awardAchievement(Achievement a) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAchievement(Achievement achievement) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAchievement(Achievement achievement) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementStatistic(Statistic ststc) {
|
||||
}
|
||||
@@ -641,6 +653,14 @@ public class OfflinePlayer implements Player {
|
||||
public void setTotalExperience(int i) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendExperienceChange(float v) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendExperienceChange(float v, int i) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExhaustion() {
|
||||
return 0F;
|
||||
@@ -787,6 +807,21 @@ public class OfflinePlayer implements Player {
|
||||
public void setBedSpawnLocation(Location lctn, boolean force) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sleep(Location location, boolean force) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wakeup(boolean setSpawnLocation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBedLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playEffect(EntityEffect ee) {
|
||||
}
|
||||
@@ -1311,6 +1346,16 @@ public class OfflinePlayer implements Player {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getMemory(MemoryKey<T> memoryKey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void setMemory(MemoryKey<T> memoryKey, T t) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Projectile> T launchProjectile(Class<? extends T> type, Vector vector) {
|
||||
return null;
|
||||
@@ -1320,6 +1365,11 @@ public class OfflinePlayer implements Player {
|
||||
public void sendSignChange(Location arg0, String[] arg1) throws IllegalArgumentException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSignChange(Location loc, String[] lines, DyeColor dyeColor) throws IllegalArgumentException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBedSpawnLocation() {
|
||||
return null;
|
||||
@@ -1590,4 +1640,13 @@ public class OfflinePlayer implements Player {
|
||||
@Override
|
||||
public void updateCommands() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openBook(ItemStack book) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PersistentDataContainer getPersistentDataContainer() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IItemDb;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.signs.EssentialsSign;
|
||||
import com.earth2me.essentials.signs.Signs;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.SimpleTextInput;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -22,21 +24,30 @@ import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
|
||||
public class Settings implements net.ess3.api.ISettings {
|
||||
private final transient EssentialsConf config;
|
||||
private static final Logger logger = Logger.getLogger("Essentials");
|
||||
private final transient IEssentials ess;
|
||||
private boolean metricsEnabled = true;
|
||||
|
||||
public Settings(IEssentials ess) {
|
||||
this.ess = ess;
|
||||
@@ -428,6 +439,7 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
mFormat = mFormat.replace("{TEAMNAME}", "{5}");
|
||||
mFormat = mFormat.replace("{PREFIX}", "{6}");
|
||||
mFormat = mFormat.replace("{SUFFIX}", "{7}");
|
||||
mFormat = mFormat.replace("{USERNAME}", "{8}");
|
||||
mFormat = "§r".concat(mFormat);
|
||||
chatFormats.put(group, mFormat);
|
||||
}
|
||||
@@ -493,6 +505,7 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
cancelAfkOnInteract = _cancelAfkOnInteract();
|
||||
cancelAfkOnMove = _cancelAfkOnMove();
|
||||
getFreezeAfkPlayers = _getFreezeAfkPlayers();
|
||||
sleepIgnoresAfkPlayers = _sleepIgnoresAfkPlayers();
|
||||
afkListName = _getAfkListName();
|
||||
isAfkListName = !afkListName.equalsIgnoreCase("none");
|
||||
itemSpawnBl = _getItemSpawnBlacklist();
|
||||
@@ -535,13 +548,24 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
currencyFormat = _getCurrencyFormat();
|
||||
unprotectedSigns = _getUnprotectedSign();
|
||||
defaultEnabledConfirmCommands = _getDefaultEnabledConfirmCommands();
|
||||
teleportBackWhenFreedFromJail = _isTeleportBackWhenFreedFromJail();
|
||||
isCompassTowardsHomePerm = _isCompassTowardsHomePerm();
|
||||
isAllowWorldInBroadcastworld = _isAllowWorldInBroadcastworld();
|
||||
itemDbType = _getItemDbType();
|
||||
forceEnableRecipe = _isForceEnableRecipe();
|
||||
allowOldIdSigns = _allowOldIdSigns();
|
||||
isWaterSafe = _isWaterSafe();
|
||||
isSafeUsermap = _isSafeUsermap();
|
||||
logCommandBlockCommands = _logCommandBlockCommands();
|
||||
nickBlacklist = _getNickBlacklist();
|
||||
maxProjectileSpeed = _getMaxProjectileSpeed();
|
||||
}
|
||||
|
||||
private List<Material> itemSpawnBl = new ArrayList<Material>();
|
||||
void _lateLoadItemSpawnBlacklist() {
|
||||
itemSpawnBl = _getItemSpawnBlacklist();
|
||||
}
|
||||
|
||||
private List<Material> itemSpawnBl = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public List<Material> itemSpawnBlacklist() {
|
||||
@@ -550,8 +574,9 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
|
||||
private List<Material> _getItemSpawnBlacklist() {
|
||||
final List<Material> epItemSpwn = new ArrayList<>();
|
||||
if (ess.getItemDb() == null) {
|
||||
logger.log(Level.FINE, "Aborting ItemSpawnBL read, itemDB not yet loaded.");
|
||||
final IItemDb itemDb = ess.getItemDb();
|
||||
if (itemDb == null || !itemDb.isReady()) {
|
||||
logger.log(Level.FINE, "Skipping item spawn blacklist read; item DB not yet loaded.");
|
||||
return epItemSpwn;
|
||||
}
|
||||
for (String itemName : config.getString("item-spawn-blacklist", "").split(",")) {
|
||||
@@ -560,10 +585,10 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
final ItemStack iStack = ess.getItemDb().get(itemName);
|
||||
final ItemStack iStack = itemDb.get(itemName);
|
||||
epItemSpwn.add(iStack.getType());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, tl("unknownItemInList", itemName, "item-spawn-blacklist"));
|
||||
logger.log(Level.SEVERE, tl("unknownItemInList", itemName, "item-spawn-blacklist"), ex);
|
||||
}
|
||||
}
|
||||
return epItemSpwn;
|
||||
@@ -685,12 +710,20 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack itemStack;
|
||||
try {
|
||||
itemStack = ess.getItemDb().get(itemName);
|
||||
list.add(itemStack.getType());
|
||||
} catch (Exception ex) {
|
||||
|
||||
Material mat = EnumUtil.getMaterial(itemName.toUpperCase());
|
||||
|
||||
if (mat == null) {
|
||||
try {
|
||||
ItemStack itemStack = ess.getItemDb().get(itemName);
|
||||
mat = itemStack.getType();
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
if (mat == null) {
|
||||
logger.log(Level.SEVERE, tl("unknownItemInList", itemName, configName));
|
||||
} else {
|
||||
list.add(mat);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
@@ -878,6 +911,17 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return config.getBoolean("cancel-afk-on-interact", true);
|
||||
}
|
||||
|
||||
private boolean sleepIgnoresAfkPlayers;
|
||||
|
||||
@Override
|
||||
public boolean sleepIgnoresAfkPlayers() {
|
||||
return sleepIgnoresAfkPlayers;
|
||||
}
|
||||
|
||||
private boolean _sleepIgnoresAfkPlayers() {
|
||||
return config.getBoolean("sleep-ignores-afk-players", true);
|
||||
}
|
||||
|
||||
private String afkListName;
|
||||
private boolean isAfkListName;
|
||||
|
||||
@@ -1447,6 +1491,17 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return getDefaultEnabledConfirmCommands().contains(commandName.toLowerCase());
|
||||
}
|
||||
|
||||
private boolean teleportBackWhenFreedFromJail;
|
||||
|
||||
private boolean _isTeleportBackWhenFreedFromJail() {
|
||||
return config.getBoolean("teleport-back-when-freed-from-jail", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTeleportBackWhenFreedFromJail() {
|
||||
return teleportBackWhenFreedFromJail;
|
||||
}
|
||||
|
||||
private boolean isCompassTowardsHomePerm;
|
||||
|
||||
private boolean _isCompassTowardsHomePerm() {
|
||||
@@ -1488,6 +1543,90 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
|
||||
@Override
|
||||
public boolean isForceEnableRecipe() {
|
||||
return false;
|
||||
return forceEnableRecipe;
|
||||
}
|
||||
|
||||
private boolean allowOldIdSigns;
|
||||
|
||||
private boolean _allowOldIdSigns() {
|
||||
return config.getBoolean("allow-old-id-signs", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowOldIdSigns() {
|
||||
return allowOldIdSigns;
|
||||
}
|
||||
|
||||
private boolean isWaterSafe;
|
||||
|
||||
private boolean _isWaterSafe() {
|
||||
boolean _isWaterSafe = config.getBoolean("is-water-safe", false);
|
||||
LocationUtil.setIsWaterSafe(_isWaterSafe);
|
||||
|
||||
return _isWaterSafe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWaterSafe() {
|
||||
return isWaterSafe;
|
||||
}
|
||||
|
||||
private boolean isSafeUsermap;
|
||||
|
||||
private boolean _isSafeUsermap() {
|
||||
return config.getBoolean("safe-usermap-names", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSafeUsermap() {
|
||||
return isSafeUsermap;
|
||||
}
|
||||
|
||||
private boolean logCommandBlockCommands;
|
||||
|
||||
private boolean _logCommandBlockCommands() {
|
||||
return config.getBoolean("log-command-block-commands", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean logCommandBlockCommands() {
|
||||
return logCommandBlockCommands;
|
||||
}
|
||||
|
||||
private Set<Predicate<String>> nickBlacklist;
|
||||
|
||||
private Set<Predicate<String>> _getNickBlacklist() {
|
||||
Set<Predicate<String>> blacklist = new HashSet<>();
|
||||
|
||||
config.getStringList("nick-blacklist").forEach(entry -> {
|
||||
try {
|
||||
blacklist.add(Pattern.compile(entry).asPredicate());
|
||||
} catch (PatternSyntaxException e) {
|
||||
logger.warning("Invalid nickname blacklist regex: " + entry);
|
||||
}
|
||||
});
|
||||
|
||||
return blacklist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Predicate<String>> getNickBlacklist() {
|
||||
return nickBlacklist;
|
||||
}
|
||||
|
||||
private double maxProjectileSpeed;
|
||||
|
||||
private double _getMaxProjectileSpeed() {
|
||||
return config.getDouble("max-projectile-speed", 8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxProjectileSpeed() {
|
||||
return maxProjectileSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpawnIfNoHome() {
|
||||
return config.getBoolean("spawn-if-no-home", true);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.Mob.MobException;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
@@ -19,6 +20,13 @@ import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
|
||||
public class SpawnMob {
|
||||
|
||||
private static final Material GOLDEN_HELMET = EnumUtil.getMaterial("GOLDEN_HELMET", "GOLD_HELMET");
|
||||
private static final Material GOLDEN_CHESTPLATE = EnumUtil.getMaterial("GOLDEN_CHESTPLATE", "GOLD_CHESTPLATE");
|
||||
private static final Material GOLDEN_LEGGINGS = EnumUtil.getMaterial("GOLDEN_LEGGINGS", "GOLD_LEGGINGS");
|
||||
private static final Material GOLDEN_BOOTS = EnumUtil.getMaterial("GOLDEN_BOOTS", "GOLD_BOOTS");
|
||||
private static final Material GOLDEN_SWORD = EnumUtil.getMaterial("GOLDEN_SWORD", "GOLD_SWORD");
|
||||
|
||||
public static String mobList(final User user) {
|
||||
final Set<String> mobList = Mob.getMobList();
|
||||
final Set<String> availableList = new HashSet<String>();
|
||||
@@ -191,10 +199,10 @@ public class SpawnMob {
|
||||
invent.setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE, 1));
|
||||
invent.setHelmet(new ItemStack(Material.DIAMOND_HELMET, 1));
|
||||
} else if (inputData.contains("gold")) {
|
||||
invent.setBoots(new ItemStack(Material.GOLDEN_BOOTS, 1));
|
||||
invent.setLeggings(new ItemStack(Material.GOLDEN_LEGGINGS, 1));
|
||||
invent.setChestplate(new ItemStack(Material.GOLDEN_CHESTPLATE, 1));
|
||||
invent.setHelmet(new ItemStack(Material.GOLDEN_HELMET, 1));
|
||||
invent.setBoots(new ItemStack(GOLDEN_BOOTS, 1));
|
||||
invent.setLeggings(new ItemStack(GOLDEN_LEGGINGS, 1));
|
||||
invent.setChestplate(new ItemStack(GOLDEN_CHESTPLATE, 1));
|
||||
invent.setHelmet(new ItemStack(GOLDEN_HELMET, 1));
|
||||
} else if (inputData.contains("leather")) {
|
||||
invent.setBoots(new ItemStack(Material.LEATHER_BOOTS, 1));
|
||||
invent.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS, 1));
|
||||
@@ -228,7 +236,7 @@ public class SpawnMob {
|
||||
InventoryWorkaround.setItemInMainHand(invent, new ItemStack(Material.BOW, 1));
|
||||
InventoryWorkaround.setItemInMainHandDropChance(invent, 0.1f);
|
||||
|
||||
invent.setBoots(new ItemStack(Material.GOLDEN_BOOTS, 1));
|
||||
invent.setBoots(new ItemStack(GOLDEN_BOOTS, 1));
|
||||
invent.setBootsDropChance(0.0f);
|
||||
}
|
||||
|
||||
@@ -237,10 +245,10 @@ public class SpawnMob {
|
||||
setVillager(zombie, false);
|
||||
|
||||
final EntityEquipment invent = zombie.getEquipment();
|
||||
InventoryWorkaround.setItemInMainHand(invent, new ItemStack(Material.GOLDEN_SWORD, 1));
|
||||
InventoryWorkaround.setItemInMainHand(invent, new ItemStack(GOLDEN_SWORD, 1));
|
||||
InventoryWorkaround.setItemInMainHandDropChance(invent, 0.1f);
|
||||
|
||||
invent.setBoots(new ItemStack(Material.GOLDEN_BOOTS, 1));
|
||||
invent.setBoots(new ItemStack(GOLDEN_BOOTS, 1));
|
||||
invent.setBootsDropChance(0.0f);
|
||||
}
|
||||
|
||||
@@ -249,7 +257,7 @@ public class SpawnMob {
|
||||
setVillager(zombie, false);
|
||||
|
||||
final EntityEquipment invent = zombie.getEquipment();
|
||||
invent.setBoots(new ItemStack(Material.GOLDEN_BOOTS, 1));
|
||||
invent.setBoots(new ItemStack(GOLDEN_BOOTS, 1));
|
||||
invent.setBootsDropChance(0.0f);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.ITeleport;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.api.events.UserWarpEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -18,7 +20,7 @@ import java.util.GregorianCalendar;
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
|
||||
public class Teleport implements net.ess3.api.ITeleport {
|
||||
public class Teleport implements ITeleport {
|
||||
private final IUser teleportOwner;
|
||||
private final IEssentials ess;
|
||||
private TimedTeleport timedTeleport;
|
||||
@@ -49,7 +51,7 @@ public class Teleport implements net.ess3.api.ITeleport {
|
||||
final long earliestLong = earliestTime.getTimeInMillis();
|
||||
|
||||
// When was the last teleportPlayer used?
|
||||
final Long lastTime = teleportOwner.getLastTeleportTimestamp();
|
||||
final long lastTime = teleportOwner.getLastTeleportTimestamp();
|
||||
|
||||
if (lastTime > time.getTimeInMillis()) {
|
||||
// This is to make sure time didn't get messed up on last teleportPlayer use.
|
||||
@@ -124,21 +126,21 @@ public class Teleport implements net.ess3.api.ITeleport {
|
||||
if (LocationUtil.isBlockUnsafeForUser(teleportee, loc.getWorld(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
|
||||
if (ess.getSettings().isTeleportSafetyEnabled()) {
|
||||
if (ess.getSettings().isForceDisableTeleportSafety()) {
|
||||
teleportee.getBase().teleport(loc, cause);
|
||||
PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
|
||||
} else {
|
||||
teleportee.getBase().teleport(LocationUtil.getSafeDestination(ess, teleportee, loc), cause);
|
||||
PaperLib.teleportAsync(teleportee.getBase(), LocationUtil.getSafeDestination(ess, teleportee, loc), cause);
|
||||
}
|
||||
} else {
|
||||
throw new Exception(tl("unsafeTeleportDestination", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
}
|
||||
} else {
|
||||
if (ess.getSettings().isForceDisableTeleportSafety()) {
|
||||
teleportee.getBase().teleport(loc, cause);
|
||||
PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
|
||||
} else {
|
||||
if (ess.getSettings().isTeleportToCenterLocation()) {
|
||||
loc = LocationUtil.getRoundedDestination(loc);
|
||||
}
|
||||
teleportee.getBase().teleport(loc, cause);
|
||||
PaperLib.teleportAsync(teleportee.getBase(), loc, cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,6 +211,39 @@ public class Teleport implements net.ess3.api.ITeleport {
|
||||
initTimer((long) (delay * 1000.0), teleportee, target, cashCharge, cause, false);
|
||||
}
|
||||
|
||||
private void teleportOther(IUser teleporter, IUser teleportee, ITarget target, Trade chargeFor, TeleportCause cause) throws Exception {
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
Trade cashCharge = chargeFor;
|
||||
|
||||
if (teleporter != null && chargeFor != null) {
|
||||
chargeFor.isAffordableFor(teleporter);
|
||||
|
||||
//This code is to make sure that commandcosts are checked in the initial world, and not in the resulting world.
|
||||
if (!chargeFor.getCommandCost(teleporter).equals(BigDecimal.ZERO)) {
|
||||
//By converting a command cost to a regular cost, the command cost permission isn't checked when executing the charge after teleport.
|
||||
cashCharge = new Trade(chargeFor.getCommandCost(teleporter), ess);
|
||||
}
|
||||
}
|
||||
|
||||
cooldown(true);
|
||||
if (delay <= 0 || teleporter == null
|
||||
|| teleporter.isAuthorized("essentials.teleport.timer.bypass")
|
||||
|| teleportOwner.isAuthorized("essentials.teleport.timer.bypass")
|
||||
|| teleportee.isAuthorized("essentials.teleport.timer.bypass")) {
|
||||
cooldown(false);
|
||||
now(teleportee, target, cause);
|
||||
if (teleporter != null && cashCharge != null) {
|
||||
cashCharge.charge(teleporter);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
cancel(false);
|
||||
warnUser(teleportee, delay);
|
||||
initTimer((long) (delay * 1000.0), teleportee, target, cashCharge, cause, false);
|
||||
}
|
||||
|
||||
//The respawn function is a wrapper used to handle tp fallback, on /jail and /home
|
||||
@Override
|
||||
public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception {
|
||||
@@ -231,7 +266,7 @@ public class Teleport implements net.ess3.api.ITeleport {
|
||||
initTimer((long) (delay * 1000.0), teleportOwner, null, chargeFor, cause, true);
|
||||
}
|
||||
|
||||
protected void respawnNow(IUser teleportee, TeleportCause cause) throws Exception {
|
||||
void respawnNow(IUser teleportee, TeleportCause cause) throws Exception {
|
||||
final Player player = teleportee.getBase();
|
||||
Location bed = player.getBedSpawnLocation();
|
||||
if (bed != null) {
|
||||
@@ -267,10 +302,16 @@ public class Teleport implements net.ess3.api.ITeleport {
|
||||
//The back function is a wrapper used to teleportPlayer a player /back to their previous location.
|
||||
@Override
|
||||
public void back(Trade chargeFor) throws Exception {
|
||||
back(teleportOwner, chargeFor);
|
||||
}
|
||||
|
||||
//This function is a wrapper over the other back function for cases where another player performs back for them
|
||||
@Override
|
||||
public void back(IUser teleporter, Trade chargeFor) throws Exception {
|
||||
tpType = TeleportType.BACK;
|
||||
final Location loc = teleportOwner.getLastLocation();
|
||||
teleportOwner.sendMessage(tl("backUsageMsg", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
teleport(teleportOwner, new LocationTarget(loc), chargeFor, TeleportCause.COMMAND);
|
||||
teleportOther(teleporter, teleportOwner, new LocationTarget(loc), chargeFor, TeleportCause.COMMAND);
|
||||
}
|
||||
|
||||
//This function is used to throw a user back after a jail sentence
|
||||
|
||||
@@ -16,9 +16,9 @@ public class TimedTeleport implements Runnable {
|
||||
private final IEssentials ess;
|
||||
private final Teleport teleport;
|
||||
private final UUID timer_teleportee;
|
||||
private int timer_task = -1;
|
||||
private final long timer_started; // time this task was initiated
|
||||
private final long timer_delay; // how long to delay the teleportPlayer
|
||||
private int timer_task;
|
||||
private final long timer_started; // time this task was initiated
|
||||
private final long timer_delay; // how long to delay the teleportPlayer
|
||||
private double timer_health;
|
||||
// note that I initially stored a clone of the location for reference, but...
|
||||
// when comparing locations, I got incorrect mismatches (rounding errors, looked like)
|
||||
@@ -32,8 +32,7 @@ public class TimedTeleport implements Runnable {
|
||||
private final Trade timer_chargeFor;
|
||||
private final TeleportCause timer_cause;
|
||||
|
||||
public TimedTeleport(IUser user, IEssentials ess, Teleport teleport, long delay, IUser teleportUser, ITarget target, Trade chargeFor, TeleportCause cause, boolean respawn) {
|
||||
|
||||
TimedTeleport(IUser user, IEssentials ess, Teleport teleport, long delay, IUser teleportUser, ITarget target, Trade chargeFor, TeleportCause cause, boolean respawn) {
|
||||
this.teleportOwner = user;
|
||||
this.ess = ess;
|
||||
this.teleport = teleport;
|
||||
@@ -111,8 +110,7 @@ public class TimedTeleport implements Runnable {
|
||||
if (timer_chargeFor != null) {
|
||||
timer_chargeFor.charge(teleportOwner);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
} catch (Exception ex) {
|
||||
ess.showError(teleportOwner.getSource(), ex, "\\ teleport");
|
||||
@@ -124,7 +122,7 @@ public class TimedTeleport implements Runnable {
|
||||
}
|
||||
|
||||
//If we need to cancelTimer a pending teleportPlayer call this method
|
||||
public void cancelTimer(boolean notifyUser) {
|
||||
void cancelTimer(boolean notifyUser) {
|
||||
if (timer_task == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.earth2me.essentials.register.payment.Methods;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import net.ess3.api.events.AfkStatusChangeEvent;
|
||||
@@ -27,12 +28,7 @@ import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -101,6 +97,11 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(final String node) {
|
||||
return isPermSetCheck(node);
|
||||
}
|
||||
|
||||
private boolean isAuthorizedCheck(final String node) {
|
||||
|
||||
if (base instanceof OfflinePlayer) {
|
||||
@@ -120,6 +121,24 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPermSetCheck(final String node) {
|
||||
if (base instanceof OfflinePlayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return ess.getPermissionsHandler().isPermissionSet(base, node);
|
||||
} catch (Exception ex) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().log(Level.SEVERE, "Permission System Error: " + ess.getPermissionsHandler().getName() + " returned: " + ex.getMessage(), ex);
|
||||
} else {
|
||||
ess.getLogger().log(Level.SEVERE, "Permission System Error: " + ess.getPermissionsHandler().getName() + " returned: " + ex.getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void healCooldown() throws Exception {
|
||||
final Calendar now = new GregorianCalendar();
|
||||
@@ -143,10 +162,14 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
|
||||
@Override
|
||||
public void giveMoney(final BigDecimal value, final CommandSource initiator) throws MaxMoneyException {
|
||||
giveMoney(value, initiator, UserBalanceUpdateEvent.Cause.UNKNOWN);
|
||||
}
|
||||
|
||||
public void giveMoney(final BigDecimal value, final CommandSource initiator, UserBalanceUpdateEvent.Cause cause) throws MaxMoneyException {
|
||||
if (value.signum() == 0) {
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney().add(value));
|
||||
setMoney(getMoney().add(value), cause);
|
||||
sendMessage(tl("addedToAccount", NumberUtil.displayCurrency(value, ess)));
|
||||
if (initiator != null) {
|
||||
initiator.sendMessage(tl("addedToOthersAccount", NumberUtil.displayCurrency(value, ess), this.getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess)));
|
||||
@@ -155,6 +178,10 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
|
||||
@Override
|
||||
public void payUser(final User reciever, final BigDecimal value) throws Exception {
|
||||
payUser(reciever, value, UserBalanceUpdateEvent.Cause.UNKNOWN);
|
||||
}
|
||||
|
||||
public void payUser(final User reciever, final BigDecimal value, UserBalanceUpdateEvent.Cause cause) throws Exception {
|
||||
if (value.compareTo(BigDecimal.ZERO) < 1) {
|
||||
throw new Exception(tl("payMustBePositive"));
|
||||
}
|
||||
@@ -176,11 +203,15 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
|
||||
@Override
|
||||
public void takeMoney(final BigDecimal value, final CommandSource initiator) {
|
||||
takeMoney(value, initiator, UserBalanceUpdateEvent.Cause.UNKNOWN);
|
||||
}
|
||||
|
||||
public void takeMoney(final BigDecimal value, final CommandSource initiator, UserBalanceUpdateEvent.Cause cause) {
|
||||
if (value.signum() == 0) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
setMoney(getMoney().subtract(value));
|
||||
setMoney(getMoney().subtract(value), cause);
|
||||
} catch (MaxMoneyException ex) {
|
||||
ess.getLogger().log(Level.WARNING, "Invalid call to takeMoney, total balance can't be more than the max-money limit.", ex);
|
||||
}
|
||||
@@ -224,7 +255,18 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
|
||||
@Override
|
||||
public Boolean canSpawnItem(final Material material) {
|
||||
return !ess.getSettings().itemSpawnBlacklist().contains(material);
|
||||
if (ess.getSettings().permissionBasedItemSpawn()) {
|
||||
final String name = material.toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
|
||||
if (isAuthorized("essentials.itemspawn.item-all") || isAuthorized("essentials.itemspawn.item-" + name)) return true;
|
||||
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_13_0_R01)) {
|
||||
final int id = material.getId();
|
||||
if (isAuthorized("essentials.itemspawn.item-" + id)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
return isAuthorized("essentials.itemspawn.exempt") || !ess.getSettings().itemSpawnBlacklist().contains(material);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -410,6 +452,10 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
|
||||
@Override
|
||||
public void setMoney(final BigDecimal value) throws MaxMoneyException {
|
||||
setMoney(value, UserBalanceUpdateEvent.Cause.UNKNOWN);
|
||||
}
|
||||
|
||||
public void setMoney(final BigDecimal value, UserBalanceUpdateEvent.Cause cause) throws MaxMoneyException {
|
||||
if (ess.getSettings().isEcoDisabled()) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().info("Internal economy functions disabled, aborting balance change.");
|
||||
@@ -417,11 +463,11 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
return;
|
||||
}
|
||||
final BigDecimal oldBalance = _getMoney();
|
||||
|
||||
UserBalanceUpdateEvent updateEvent = new UserBalanceUpdateEvent(this.getBase(), oldBalance, value);
|
||||
|
||||
UserBalanceUpdateEvent updateEvent = new UserBalanceUpdateEvent(this.getBase(), oldBalance, value, cause);
|
||||
ess.getServer().getPluginManager().callEvent(updateEvent);
|
||||
BigDecimal newBalance = updateEvent.getNewBalance();
|
||||
|
||||
|
||||
if (Methods.hasMethod()) {
|
||||
try {
|
||||
final Method method = Methods.getMethod();
|
||||
@@ -458,7 +504,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
return;
|
||||
}
|
||||
|
||||
this.getBase().setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
|
||||
this.getBase().setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") || set && ess.getSettings().sleepIgnoresAfkPlayers());
|
||||
if (set && !isAfk()) {
|
||||
afkPosition = this.getLocation();
|
||||
this.afkSince = System.currentTimeMillis();
|
||||
@@ -515,12 +561,14 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
setJailed(false);
|
||||
sendMessage(tl("haveBeenReleased"));
|
||||
setJail(null);
|
||||
try {
|
||||
getTeleport().back();
|
||||
} catch (Exception ex) {
|
||||
if (ess.getSettings().isTeleportBackWhenFreedFromJail()) {
|
||||
try {
|
||||
getTeleport().respawn(null, TeleportCause.PLUGIN);
|
||||
} catch (Exception ex1) {
|
||||
getTeleport().back();
|
||||
} catch (Exception ex) {
|
||||
try {
|
||||
getTeleport().respawn(null, TeleportCause.PLUGIN);
|
||||
} catch (Exception ex1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -539,6 +587,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
setMuteTimeout(0);
|
||||
sendMessage(tl("canTalkAgain"));
|
||||
setMuted(false);
|
||||
setMuteReason(null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -872,7 +921,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||
* Returns the {@link ItemStack} in the main hand or off-hand. If the main hand is empty then the offhand item is returned - also nullable.
|
||||
*/
|
||||
public ItemStack getItemInHand() {
|
||||
if (ReflUtil.getNmsVersionObject().isLowerThan(ReflUtil.V1_9_R1)) {
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_9_R01)) {
|
||||
return getBase().getInventory().getItemInHand();
|
||||
} else {
|
||||
PlayerInventory inventory = getBase().getInventory();
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
@@ -74,6 +75,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
godmode = _getGodModeEnabled();
|
||||
muted = _getMuted();
|
||||
muteTimeout = _getMuteTimeout();
|
||||
muteReason = _getMuteReason();
|
||||
jailed = _getJailed();
|
||||
jailTimeout = _getJailTimeout();
|
||||
lastLogin = _getLastLogin();
|
||||
@@ -93,6 +95,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
acceptingPay = _getAcceptingPay();
|
||||
confirmPay = _getConfirmPay();
|
||||
confirmClear = _getConfirmClear();
|
||||
lastMessageReplyRecipient = _getLastMessageReplyRecipient();
|
||||
}
|
||||
|
||||
private BigDecimal money;
|
||||
@@ -232,10 +235,10 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
config.save();
|
||||
}
|
||||
|
||||
private List<Material> unlimited;
|
||||
private Set<Material> unlimited;
|
||||
|
||||
private List<Material> _getUnlimited() {
|
||||
List<Material> retlist = new ArrayList<>();
|
||||
private Set<Material> _getUnlimited() {
|
||||
Set<Material> retlist = new HashSet<>();
|
||||
List<String> configList = config.getStringList("unlimited");
|
||||
for(String s : configList) {
|
||||
Material mat = Material.matchMaterial(s);
|
||||
@@ -247,7 +250,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
return retlist;
|
||||
}
|
||||
|
||||
public List<Material> getUnlimited() {
|
||||
public Set<Material> getUnlimited() {
|
||||
return unlimited;
|
||||
}
|
||||
|
||||
@@ -256,13 +259,20 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
}
|
||||
|
||||
public void setUnlimited(ItemStack stack, boolean state) {
|
||||
if (unlimited.contains(stack.getType())) {
|
||||
unlimited.remove(stack.getType());
|
||||
}
|
||||
boolean wasUpdated;
|
||||
if (state) {
|
||||
unlimited.add(stack.getType());
|
||||
wasUpdated = unlimited.add(stack.getType());
|
||||
} else {
|
||||
wasUpdated = unlimited.remove(stack.getType());
|
||||
}
|
||||
config.setProperty("unlimited", unlimited);
|
||||
|
||||
if (wasUpdated) {
|
||||
applyUnlimited();
|
||||
}
|
||||
}
|
||||
|
||||
private void applyUnlimited() {
|
||||
config.setProperty("unlimited", unlimited.stream().map(Enum::name).collect(Collectors.toList()));
|
||||
config.save();
|
||||
}
|
||||
|
||||
@@ -446,6 +456,22 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
config.save();
|
||||
}
|
||||
|
||||
private boolean autoTeleportEnabled;
|
||||
|
||||
private boolean _getAutoTeleportEnabled() {
|
||||
return config.getBoolean("teleportauto", false);
|
||||
}
|
||||
|
||||
public boolean isAutoTeleportEnabled() {
|
||||
return autoTeleportEnabled;
|
||||
}
|
||||
|
||||
public void setAutoTeleportEnabled(boolean set) {
|
||||
autoTeleportEnabled = set;
|
||||
config.setProperty("teleportauto", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private List<String> ignoredPlayers;
|
||||
|
||||
public List<String> _getIgnoredPlayers() {
|
||||
@@ -503,6 +529,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
}
|
||||
|
||||
private boolean muted;
|
||||
private String muteReason;
|
||||
|
||||
public boolean _getMuted() {
|
||||
return config.getBoolean("muted", false);
|
||||
@@ -522,6 +549,29 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
config.save();
|
||||
}
|
||||
|
||||
public String _getMuteReason() {
|
||||
return config.getString("muteReason");
|
||||
}
|
||||
|
||||
public String getMuteReason() {
|
||||
return muteReason;
|
||||
}
|
||||
|
||||
public void setMuteReason(String reason) {
|
||||
if (reason == null) {
|
||||
config.removeProperty("muteReason");
|
||||
muteReason = null;
|
||||
} else {
|
||||
muteReason = reason;
|
||||
config.setProperty("muteReason", reason);
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean hasMuteReason(){
|
||||
return muteReason != null;
|
||||
}
|
||||
|
||||
private long muteTimeout;
|
||||
|
||||
private long _getMuteTimeout() {
|
||||
@@ -759,15 +809,16 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
}
|
||||
|
||||
public long getKitTimestamp(String name) {
|
||||
name = name.replace('.', '_').replace('/', '_');
|
||||
name = name.replace('.', '_').replace('/', '_').toLowerCase(Locale.ENGLISH);
|
||||
if (kitTimestamps != null && kitTimestamps.containsKey(name)) {
|
||||
return kitTimestamps.get(name);
|
||||
}
|
||||
return 0l;
|
||||
return 0L;
|
||||
}
|
||||
|
||||
public void setKitTimestamp(final String name, final long time) {
|
||||
kitTimestamps.put(name.toLowerCase(Locale.ENGLISH), time);
|
||||
public void setKitTimestamp(String name, final long time) {
|
||||
name = name.replace('.', '_').replace('/', '_').toLowerCase(Locale.ENGLISH);
|
||||
kitTimestamps.put(name, time);
|
||||
config.setProperty("timestamps.kits", kitTimestamps);
|
||||
config.save();
|
||||
}
|
||||
@@ -814,7 +865,7 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
private Map<Pattern, Long> commandCooldowns;
|
||||
|
||||
private Map<Pattern, Long> _getCommandCooldowns() {
|
||||
if (!config.isConfigurationSection("timestamps.command-cooldowns")) {
|
||||
if (!config.contains("timestamps.command-cooldowns")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -941,6 +992,22 @@ public abstract class UserData extends PlayerExtension implements IConf {
|
||||
save();
|
||||
}
|
||||
|
||||
private boolean lastMessageReplyRecipient;
|
||||
|
||||
private boolean _getLastMessageReplyRecipient() {
|
||||
return config.getBoolean("last-message-reply-recipient", ess.getSettings().isLastMessageReplyRecipient());
|
||||
}
|
||||
|
||||
public boolean isLastMessageReplyRecipient() {
|
||||
return this.lastMessageReplyRecipient;
|
||||
}
|
||||
|
||||
public void setLastMessageReplyRecipient(boolean enabled) {
|
||||
this.lastMessageReplyRecipient = enabled;
|
||||
config.setProperty("last-message-reply-recipient", enabled);
|
||||
save();
|
||||
}
|
||||
|
||||
public UUID getConfigUUID() {
|
||||
return config.uuid;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf {
|
||||
if (uuid != null) {
|
||||
keys.add(uuid);
|
||||
if (name != null && name.length() > 0) {
|
||||
final String keyName = StringUtil.safeString(name);
|
||||
final String keyName = ess.getSettings().isSafeUsermap() ? StringUtil.safeString(name) : name;
|
||||
if (!names.containsKey(keyName)) {
|
||||
names.put(keyName, uuid);
|
||||
uuidMap.writeUUIDMap();
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.earth2me.essentials.utils.StringUtil;
|
||||
import com.google.common.base.Charsets;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import net.ess3.api.events.UserBalanceUpdateEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
@@ -18,7 +20,7 @@ import java.util.logging.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* Instead of using this api directly, we recommend to use the register plugin: http://bit.ly/RegisterMethod
|
||||
* You should use Vault instead of directly using this class.
|
||||
*/
|
||||
public class Economy {
|
||||
public Economy() {
|
||||
@@ -64,7 +66,24 @@ public class Economy {
|
||||
if (name == null) {
|
||||
throw new RuntimeException("Economy username cannot be null");
|
||||
}
|
||||
return ess.getUser(name);
|
||||
|
||||
User user = ess.getUser(name);
|
||||
if (user == null) {
|
||||
/*
|
||||
Attempt lookup using UUID - this prevents balance resets when accessing economy
|
||||
via Vault during player join.
|
||||
See: https://github.com/EssentialsX/Essentials/issues/2400
|
||||
*/
|
||||
Player player = ess.getServer().getPlayerExact(name);
|
||||
if (player != null) {
|
||||
user = ess.getUser(player.getUniqueId());
|
||||
if (user != null) {
|
||||
logger.info(String.format("[Economy] Found player %s by UUID %s but not by their actual name - they may have changed their username", name, player.getUniqueId().toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +145,7 @@ public class Economy {
|
||||
throw new NoLoanPermittedException();
|
||||
}
|
||||
try {
|
||||
user.setMoney(balance);
|
||||
user.setMoney(balance, UserBalanceUpdateEvent.Cause.API);
|
||||
} catch (MaxMoneyException ex) {
|
||||
//TODO: Update API to show max balance errors
|
||||
}
|
||||
|
||||
@@ -1,33 +1,168 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
public interface IItemDb {
|
||||
ItemStack get(final String name, final int quantity) throws Exception;
|
||||
|
||||
/**
|
||||
* Create a stack from the given name with the given quantity.
|
||||
*
|
||||
* @param name Item name to look up in the database
|
||||
* @param quantity Quantity of the item stack
|
||||
* @return The requested item stack
|
||||
* @throws Exception if the item stack cannot be created
|
||||
*/
|
||||
default ItemStack get(final String name, final int quantity) throws Exception {
|
||||
final ItemStack stack = get(name.toLowerCase(Locale.ENGLISH));
|
||||
stack.setAmount(quantity);
|
||||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a stack from the given name with the maximum stack size for that material.
|
||||
*
|
||||
* Note that this will always check against resolver functions from other plugins as well.
|
||||
* To avoid this behaviour, use net.ess3.api.IItemDb#get(String name, boolean useResolvers).
|
||||
*
|
||||
* @param name Item name to look up in the database
|
||||
* @return The requested item stack with the maximum stack size
|
||||
* @throws Exception if the item stack cannot be created
|
||||
*/
|
||||
ItemStack get(final String name) throws Exception;
|
||||
|
||||
String names(ItemStack item);
|
||||
/**
|
||||
* Get a comma-separated string list of up to 15 aliases for the given stack.
|
||||
*
|
||||
* @param item Item stack whose names to find
|
||||
* @return Comma-separated list of up to 15 item names
|
||||
*/
|
||||
default String names(ItemStack item) {
|
||||
List<String> nameList = nameList(item);
|
||||
|
||||
if (nameList.size() > 15) {
|
||||
nameList = nameList.subList(0, 14);
|
||||
}
|
||||
return StringUtil.joinList(", ", nameList);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a List of all aliases for the given item stack.
|
||||
*
|
||||
* @param item Item stack whose names to find
|
||||
* @return List of all names
|
||||
*/
|
||||
List<String> nameList(ItemStack item);
|
||||
|
||||
/**
|
||||
* Get the primary name for the given item stack.
|
||||
*
|
||||
* @param item Item stack whose name to find
|
||||
* @return Primary name of the item
|
||||
*/
|
||||
String name(ItemStack item);
|
||||
|
||||
/**
|
||||
* Get all stacks in a given User's inventory that matches the given arguments.
|
||||
*
|
||||
* @param user The user with the player inventory to search
|
||||
* @param args Either an item name, or one of the following:
|
||||
* hand (default), inventory/invent/all, blocks
|
||||
* @return A List of all matching ItemStacks
|
||||
* @throws Exception if the given args are invalid or no blocks are found
|
||||
*/
|
||||
List<ItemStack> getMatching(User user, String[] args) throws Exception;
|
||||
|
||||
/**
|
||||
* Serialise an ItemStack into a format that can be decoded by
|
||||
* {@link #get(String) get} and
|
||||
* {@link com.earth2me.essentials.MetaItemStack#parseStringMeta(CommandSource, boolean, String[], int, IEssentials)} MetaItemStack#parseStringMeta}.
|
||||
* Used to encode items for kits.
|
||||
*
|
||||
* @param is Stack to serialise
|
||||
* @return Serialised stack
|
||||
*/
|
||||
String serialize(ItemStack is);
|
||||
|
||||
/**
|
||||
* Return names recognised by the database, intended for tab-completion.
|
||||
*
|
||||
* @return Collection of all item names
|
||||
*/
|
||||
Collection<String> listNames();
|
||||
|
||||
/**
|
||||
* Get the material matching the given legacy ID. Used for conversion from item IDs to
|
||||
* modern names.
|
||||
*
|
||||
* @param id Legacy ID of material to find
|
||||
* @return Updated material
|
||||
*/
|
||||
@Deprecated
|
||||
Material getFromLegacyId(int id);
|
||||
default Material getFromLegacyId(int id) {
|
||||
return getFromLegacy(id, (byte) 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the legacy ID for the given material.
|
||||
*
|
||||
* @param material Material to look up
|
||||
* @return Legacy ID of given material
|
||||
* @throws Exception if the ID cannot be looked up
|
||||
* @deprecated Item IDs are no longer supported.
|
||||
*/
|
||||
@Deprecated
|
||||
int getLegacyId(Material material) throws Exception;
|
||||
|
||||
/**
|
||||
* Convert colon syntax (eg. "13", "1:5") legacy IDs to Material. Used for conversion from
|
||||
* item IDs to modern names.
|
||||
*
|
||||
* @param item Legacy ID in colon syntax.
|
||||
* @return Material if an appropriate material exists, else null.
|
||||
*/
|
||||
default Material getFromLegacy(String item) {
|
||||
final String[] split = item.split(":");
|
||||
|
||||
if (!NumberUtil.isInt(split[0])) return null;
|
||||
|
||||
final int id = Integer.parseInt(split[0]);
|
||||
byte damage = 0;
|
||||
|
||||
if (split.length > 1 && NumberUtil.isInt(split[1])) {
|
||||
damage = Byte.parseByte(split[1]);
|
||||
}
|
||||
|
||||
return getFromLegacy(id, damage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert legacy ID and damage value to Material. Used for conversion from item IDs to
|
||||
* modern names.
|
||||
*
|
||||
* @param id Legacy ID
|
||||
* @param damage Damage value
|
||||
* @return Material
|
||||
*/
|
||||
default Material getFromLegacy(final int id, final byte damage) {
|
||||
return MaterialUtil.convertFromLegacy(id, damage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the item database is loaded and ready for use.
|
||||
*
|
||||
* @return Whether items have finished loading
|
||||
*/
|
||||
boolean isReady();
|
||||
}
|
||||
@@ -110,6 +110,19 @@ public interface ITeleport {
|
||||
*/
|
||||
void back(Trade chargeFor) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle /back teleports that
|
||||
* are executed by a different player with this
|
||||
* instance of teleport as a target.
|
||||
*
|
||||
* @param teleporter - The user performing the /back command.
|
||||
* This value may be {@code null} to indicate console.
|
||||
* @param chargeFor - What the {@code teleporter} will be charged if teleportPlayer is successful
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
void back(IUser teleporter, Trade chargeFor) throws Exception;
|
||||
|
||||
/**
|
||||
* Teleport wrapper used to handle throwing user home after a jail sentence
|
||||
*
|
||||
|
||||
@@ -24,10 +24,6 @@ public class Commandafk extends EssentialsCommand {
|
||||
afkUser = getPlayer(server, user, args, 0);
|
||||
message = args.length > 1 ? getFinalArg(args, 1) : null;
|
||||
} catch (PlayerNotFoundException e) {
|
||||
// If only one arg is passed, assume the command executor is targeting another player.
|
||||
if (args.length == 1) {
|
||||
throw e;
|
||||
}
|
||||
message = getFinalArg(args, 0);
|
||||
}
|
||||
toggleAfk(user, afkUser, message);
|
||||
@@ -51,7 +47,7 @@ public class Commandafk extends EssentialsCommand {
|
||||
private void toggleAfk(User sender, User user, String message) throws Exception {
|
||||
if (message != null && sender != null) {
|
||||
if (sender.isMuted()) {
|
||||
throw new Exception(tl("voiceSilenced"));
|
||||
throw new Exception(sender.hasMuteReason() ? tl("voiceSilencedReason", sender.getMuteReason()) : tl("voiceSilenced"));
|
||||
}
|
||||
if (!sender.isAuthorized("essentials.afk.message")) {
|
||||
throw new Exception(tl("noPermToAFKMessage"));
|
||||
@@ -79,6 +75,7 @@ public class Commandafk extends EssentialsCommand {
|
||||
if (!msg.isEmpty()) {
|
||||
ess.broadcastMessage(user, msg);
|
||||
}
|
||||
user.setDisplayNick(); // Set this again after toggling
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
@@ -13,24 +20,82 @@ public class Commandback extends EssentialsCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception {
|
||||
CommandSource sender = user.getSource();
|
||||
if (args.length > 0 && user.isAuthorized("essentials.back.others")) {
|
||||
this.parseCommand(server, sender, args, true);
|
||||
return;
|
||||
}
|
||||
|
||||
teleportBack(sender, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSource sender, String commandLabel, String[] args) throws Exception {
|
||||
if (args.length < 1) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
this.parseCommand(server, sender, args, true);
|
||||
}
|
||||
|
||||
private void parseCommand(Server server, CommandSource sender, String[] args, boolean allowOthers) throws Exception {
|
||||
Collection<Player> players = new ArrayList<>();
|
||||
|
||||
if (allowOthers && args.length > 0 && args[0].trim().length() > 2) {
|
||||
players = server.matchPlayer(args[0].trim());
|
||||
}
|
||||
|
||||
if (players.size() < 1) {
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
|
||||
for (Player player : players) {
|
||||
sender.sendMessage(tl("backOther", player.getName()));
|
||||
teleportBack(sender, ess.getUser(player));
|
||||
}
|
||||
}
|
||||
|
||||
private void teleportBack(CommandSource sender, User user) throws Exception {
|
||||
if (user.getLastLocation() == null) {
|
||||
throw new Exception(tl("noLocationFound"));
|
||||
}
|
||||
|
||||
String lastWorldName = user.getLastLocation().getWorld().getName();
|
||||
|
||||
if (user.getWorld() != user.getLastLocation().getWorld() && ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + lastWorldName)) {
|
||||
throw new Exception(tl("noPerm", "essentials.worlds." + lastWorldName));
|
||||
User requester = null;
|
||||
if (sender.isPlayer()) {
|
||||
requester = ess.getUser(sender.getPlayer());
|
||||
|
||||
if (user.getWorld() != user.getLastLocation().getWorld() && this.ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.worlds." + lastWorldName)) {
|
||||
throw new Exception(tl("noPerm", "essentials.worlds." + lastWorldName));
|
||||
}
|
||||
|
||||
if (!requester.isAuthorized("essentials.back.into." + lastWorldName)) {
|
||||
throw new Exception(tl("noPerm", "essentials.back.into." + lastWorldName));
|
||||
}
|
||||
}
|
||||
|
||||
if (!user.isAuthorized("essentials.back.into." + lastWorldName)) {
|
||||
throw new Exception(tl("noPerm", "essentials.back.into." + lastWorldName));
|
||||
if (requester == null) {
|
||||
user.getTeleport().back(null, null);
|
||||
} else if (!requester.equals(user)) {
|
||||
Trade charge = new Trade(this.getName(), this.ess);
|
||||
charge.isAffordableFor(requester);
|
||||
user.getTeleport().back(requester, charge);
|
||||
} else {
|
||||
Trade charge = new Trade(this.getName(), this.ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getTeleport().back(charge);
|
||||
}
|
||||
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getTeleport().back(charge);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(Server server, User user, String commandLabel, String[] args) {
|
||||
if (user.isAuthorized("essentials.back.others") && args.length == 1) {
|
||||
return getPlayers(server, user);
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -102,11 +102,13 @@ public class Commandbalancetop extends EssentialsCommand {
|
||||
// Don't list NPCs in output
|
||||
continue;
|
||||
}
|
||||
final BigDecimal userMoney = user.getMoney();
|
||||
user.updateMoneyCache(userMoney);
|
||||
totalMoney = totalMoney.add(userMoney);
|
||||
final String name = user.isHidden() ? user.getName() : user.getDisplayName();
|
||||
balances.put(name, userMoney);
|
||||
if (!user.isAuthorized("essentials.balancetop.exclude")) {
|
||||
final BigDecimal userMoney = user.getMoney();
|
||||
user.updateMoneyCache(userMoney);
|
||||
totalMoney = totalMoney.add(userMoney);
|
||||
final String name = user.isHidden() ? user.getName() : user.getDisplayName();
|
||||
balances.put(name, userMoney);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Mob;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandbeezooka extends EssentialsCommand {
|
||||
|
||||
public Commandbeezooka() {
|
||||
super("beezooka");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_15_R01)) {
|
||||
user.sendMessage(tl("unsupportedFeature"));
|
||||
return;
|
||||
}
|
||||
|
||||
final Entity bee = Mob.BEE.spawn(user.getWorld(), server, user.getBase().getEyeLocation());
|
||||
bee.setVelocity(user.getBase().getEyeLocation().getDirection().multiply(2));
|
||||
|
||||
ess.scheduleSyncDelayedTask(() -> {
|
||||
final Location loc = bee.getLocation();
|
||||
bee.remove();
|
||||
loc.getWorld().createExplosion(loc, 0F);
|
||||
}, 20);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
@@ -15,6 +16,9 @@ import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
|
||||
public class Commandbook extends EssentialsCommand {
|
||||
|
||||
private static final Material WRITABLE_BOOK = EnumUtil.getMaterial("WRITABLE_BOOK", "BOOK_AND_QUILL");
|
||||
|
||||
public Commandbook() {
|
||||
super("book");
|
||||
}
|
||||
@@ -44,7 +48,7 @@ public class Commandbook extends EssentialsCommand {
|
||||
}
|
||||
} else {
|
||||
if (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others")) {
|
||||
ItemStack newItem = new ItemStack(Material.WRITABLE_BOOK, item.getAmount());
|
||||
ItemStack newItem = new ItemStack(WRITABLE_BOOK, item.getAmount());
|
||||
newItem.setItemMeta(bmeta);
|
||||
InventoryWorkaround.setItemInMainHand(user.getBase(), newItem);
|
||||
user.sendMessage(tl("editBookContents"));
|
||||
@@ -52,7 +56,7 @@ public class Commandbook extends EssentialsCommand {
|
||||
throw new Exception(tl("denyBookEdit"));
|
||||
}
|
||||
}
|
||||
} else if (item.getType() == Material.WRITABLE_BOOK) {
|
||||
} else if (item.getType() == WRITABLE_BOOK) {
|
||||
BookMeta bmeta = (BookMeta) item.getItemMeta();
|
||||
if (!user.isAuthorized("essentials.book.author")) {
|
||||
bmeta.setAuthor(player);
|
||||
|
||||
@@ -135,6 +135,10 @@ public class Commandcondense extends EssentialsCommand {
|
||||
|
||||
if (recipe instanceof ShapedRecipe) {
|
||||
ShapedRecipe sRecipe = (ShapedRecipe) recipe;
|
||||
if (sRecipe.getShape().length != sRecipe.getShape()[0].length()) {
|
||||
// Only accept square recipes
|
||||
return null;
|
||||
}
|
||||
inputList = sRecipe.getIngredientMap().values();
|
||||
} else if (recipe instanceof ShapelessRecipe) {
|
||||
ShapelessRecipe slRecipe = (ShapelessRecipe) recipe;
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.Kit;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
|
||||
public class Commanddelkit extends EssentialsCommand {
|
||||
public Commanddelkit() {
|
||||
super("delkit");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length < 1) {
|
||||
final String kitList = ess.getKits().listKits(ess, null);
|
||||
sender.sendMessage(kitList.length() > 0 ? tl("kits", kitList) : tl("noKits"));
|
||||
throw new NoChargeException();
|
||||
} else {
|
||||
final String kitName = args[0];
|
||||
final Kit kit = new Kit(kitName, ess);
|
||||
|
||||
if (sender.getPlayer() != null) {
|
||||
kit.checkPerms(ess.getUser(sender.getPlayer()));
|
||||
}
|
||||
|
||||
ess.getKits().removeKit(kitName);
|
||||
sender.sendMessage(tl("deleteKit", kitName));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
return Lists.newArrayList(ess.getKits().getKits().getKeys(false));
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public class Commanddisposal extends EssentialsCommand {
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception {
|
||||
user.sendMessage(tl("openingDisposal"));
|
||||
user.getBase().openInventory(ess.getServer().createInventory(user.getBase(), 36, "Disposal"));
|
||||
user.getBase().openInventory(ess.getServer().createInventory(user.getBase(), 36, tl("disposal")));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import net.ess3.api.events.UserBalanceUpdateEvent;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -54,7 +55,7 @@ public class Commandeco extends EssentialsLoopCommand {
|
||||
protected void updatePlayer(final Server server, final CommandSource sender, final User player, final String[] args) throws NotEnoughArgumentsException, ChargeException, MaxMoneyException {
|
||||
switch (cmd) {
|
||||
case GIVE:
|
||||
player.giveMoney(amount, sender);
|
||||
player.giveMoney(amount, sender, UserBalanceUpdateEvent.Cause.COMMAND_ECO);
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
@@ -72,10 +73,10 @@ public class Commandeco extends EssentialsLoopCommand {
|
||||
BigDecimal money = player.getMoney();
|
||||
BigDecimal minBalance = ess.getSettings().getMinMoney();
|
||||
if (money.subtract(amount).compareTo(minBalance) >= 0) {
|
||||
player.takeMoney(amount, sender);
|
||||
player.takeMoney(amount, sender, UserBalanceUpdateEvent.Cause.COMMAND_ECO);
|
||||
} else if (sender == null) {
|
||||
try {
|
||||
player.setMoney(minBalance);
|
||||
player.setMoney(minBalance, UserBalanceUpdateEvent.Cause.COMMAND_ECO);
|
||||
} catch (MaxMoneyException ex) {
|
||||
// Take shouldn't be able to throw a max money exception
|
||||
}
|
||||
@@ -90,7 +91,7 @@ public class Commandeco extends EssentialsLoopCommand {
|
||||
BigDecimal maxBalance = ess.getSettings().getMaxMoney();
|
||||
boolean underMinimum = (amount.compareTo(minBalance) < 0);
|
||||
boolean aboveMax = (amount.compareTo(maxBalance) > 0);
|
||||
player.setMoney(underMinimum ? minBalance : aboveMax ? maxBalance : amount);
|
||||
player.setMoney(underMinimum ? minBalance : aboveMax ? maxBalance : amount, UserBalanceUpdateEvent.Cause.COMMAND_ECO);
|
||||
player.sendMessage(tl("setBal", NumberUtil.displayCurrency(player.getMoney(), ess)));
|
||||
if (sender != null) {
|
||||
sender.sendMessage(tl("setBalOthers", player.getDisplayName(), NumberUtil.displayCurrency(player.getMoney(), ess)));
|
||||
|
||||
@@ -4,97 +4,146 @@ import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.EssentialsUpgrade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.UserMap;
|
||||
import com.earth2me.essentials.metrics.Metrics;
|
||||
import com.earth2me.essentials.utils.*;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
// This command has 4 undocumented behaviours #EasterEgg
|
||||
public class Commandessentials extends EssentialsCommand {
|
||||
|
||||
private static final Sound NOTE_HARP = EnumUtil.valueOf(Sound.class, "BLOCK_NOTE_BLOCK_HARP", "BLOCK_NOTE_HARP", "NOTE_PIANO");
|
||||
private static final Sound MOO_SOUND = EnumUtil.valueOf(Sound.class, "COW_IDLE", "ENTITY_COW_MILK");
|
||||
|
||||
private static final String NYAN_TUNE = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1B,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,";
|
||||
private static final String[] CONSOLE_MOO = new String[]{" (__)", " (oo)", " /------\\/", " / | ||", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..."};
|
||||
private static final String[] PLAYER_MOO = new String[]{" (__)", " (oo)", " /------\\/", " / | | |", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..."};
|
||||
|
||||
public Commandessentials() {
|
||||
super("essentials");
|
||||
}
|
||||
|
||||
private transient int taskid;
|
||||
private final transient Map<Player, Block> noteBlocks = new HashMap<Player, Block>();
|
||||
private transient TuneRunnable currentTune = null;
|
||||
|
||||
private final List<String> versionPlugins = Arrays.asList(
|
||||
"Vault",
|
||||
"LuckPerms",
|
||||
"PermissionsEx",
|
||||
"GroupManager"
|
||||
private static final List<String> versionPlugins = Arrays.asList(
|
||||
"Vault", // API
|
||||
"Reserve", // API
|
||||
"PlaceholderAPI", // API
|
||||
"CMI", // potential for issues
|
||||
"Towny", // past issues; admins should ensure latest
|
||||
"ChestShop", // past issues; admins should ensure latest
|
||||
"Citizens", // fires player events
|
||||
"LuckPerms", // permissions (recommended)
|
||||
"UltraPermissions",
|
||||
"PermissionsEx", // permissions (unsupported)
|
||||
"GroupManager", // permissions (unsupported)
|
||||
"bPermissions" // permissions (unsupported)
|
||||
);
|
||||
|
||||
private final List<String> officialPlugins = Arrays.asList(
|
||||
"EssentialsAntiBuild",
|
||||
"EssentialsChat",
|
||||
"EssentialsGeoIP",
|
||||
"EssentialsProtect",
|
||||
"EssentialsSpawn",
|
||||
"EssentialsXMPP"
|
||||
private static final List<String> officialPlugins = Arrays.asList(
|
||||
"EssentialsAntiBuild",
|
||||
"EssentialsChat",
|
||||
"EssentialsGeoIP",
|
||||
"EssentialsProtect",
|
||||
"EssentialsSpawn",
|
||||
"EssentialsXMPP"
|
||||
);
|
||||
|
||||
private final List<String> warnPlugins = Arrays.asList(
|
||||
"PermissionsEx",
|
||||
"GroupManager"
|
||||
private static final List<String> warnPlugins = Arrays.asList(
|
||||
"PermissionsEx",
|
||||
"GroupManager",
|
||||
"bPremissions"
|
||||
);
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length == 0) {
|
||||
run_disabled(server, sender, commandLabel, args);
|
||||
} else if (args[0].equalsIgnoreCase("debug")) {
|
||||
run_debug(server, sender, commandLabel, args);
|
||||
} else if (args[0].equalsIgnoreCase("nya")) {
|
||||
run_nya(server, sender, commandLabel, args);
|
||||
} else if (args[0].equalsIgnoreCase("moo")) {
|
||||
run_moo(server, sender, commandLabel, args);
|
||||
} else if (args[0].equalsIgnoreCase("reset")) {
|
||||
run_reset(server, sender, commandLabel, args);
|
||||
} else if (args[0].equalsIgnoreCase("cleanup")) {
|
||||
run_cleanup(server, sender, commandLabel, args);
|
||||
} else if (args[0].equalsIgnoreCase("uuidconvert")) {
|
||||
run_uuidconvert(server, sender, commandLabel, args);
|
||||
} else if (args[0].equalsIgnoreCase("uuidtest")) {
|
||||
run_uuidtest(server, sender, commandLabel, args);
|
||||
} else if (args[0].equalsIgnoreCase("version")) {
|
||||
run_version(server, sender, commandLabel, args);
|
||||
} else {
|
||||
run_reload(server, sender, commandLabel, args);
|
||||
showUsage(sender);
|
||||
}
|
||||
|
||||
switch(args[0]) {
|
||||
// Info commands
|
||||
case "debug":
|
||||
case "verbose":
|
||||
runDebug(server, sender, commandLabel, args);
|
||||
break;
|
||||
|
||||
case "ver":
|
||||
case "version":
|
||||
runVersion(server, sender, commandLabel, args);
|
||||
break;
|
||||
|
||||
case "cmd":
|
||||
case "commands":
|
||||
runCommands(server, sender, commandLabel, args);
|
||||
break;
|
||||
|
||||
// Data commands
|
||||
case "reload":
|
||||
runReload(server, sender, commandLabel, args);
|
||||
break;
|
||||
case "reset":
|
||||
runReset(server, sender, commandLabel, args);
|
||||
break;
|
||||
case "cleanup":
|
||||
runCleanup(server, sender, commandLabel, args);
|
||||
break;
|
||||
case "uuidconvert":
|
||||
runUUIDConvert(server, sender, commandLabel, args);
|
||||
break;
|
||||
case "uuidtest":
|
||||
runUUIDTest(server, sender, commandLabel, args);
|
||||
break;
|
||||
|
||||
// "#EasterEgg"
|
||||
case "nya":
|
||||
case "nyan":
|
||||
runNya(server, sender, commandLabel, args);
|
||||
break;
|
||||
case "moo":
|
||||
runMoo(server, sender, commandLabel, args);
|
||||
break;
|
||||
default:
|
||||
showUsage(sender);
|
||||
}
|
||||
}
|
||||
|
||||
//If you do not supply an argument this command will list 'overridden' commands.
|
||||
private void run_disabled(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
sender.sendMessage("/<command> <reload/debug>");
|
||||
// Displays the command's usage.
|
||||
private void showUsage(final CommandSource sender) throws Exception {
|
||||
throw new NotEnoughArgumentsException("/<command> <reload/debug/commands>");
|
||||
}
|
||||
|
||||
// Lists commands that are being handed over to other plugins.
|
||||
private void runCommands(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
final StringBuilder disabledCommands = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : ess.getAlternativeCommandsHandler().disabledCommands().entrySet()) {
|
||||
if (disabledCommands.length() > 0) {
|
||||
disabledCommands.append(", ");
|
||||
disabledCommands.append("\n");
|
||||
}
|
||||
disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue());
|
||||
}
|
||||
if (disabledCommands.length() > 0) {
|
||||
sender.sendMessage(tl("blockList"));
|
||||
sender.sendMessage(disabledCommands.toString());
|
||||
} else {
|
||||
sender.sendMessage(tl("blockListEmpty"));
|
||||
}
|
||||
}
|
||||
|
||||
private void run_reset(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
// Resets the given player's user data.
|
||||
private void runReset(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length < 2) {
|
||||
throw new Exception("/<command> reset <player>");
|
||||
}
|
||||
@@ -103,114 +152,59 @@ public class Commandessentials extends EssentialsCommand {
|
||||
sender.sendMessage("Reset Essentials userdata for player: " + user.getDisplayName());
|
||||
}
|
||||
|
||||
private void run_debug(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
// Toggles debug mode.
|
||||
private void runDebug(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
ess.getSettings().setDebug(!ess.getSettings().isDebug());
|
||||
sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
|
||||
}
|
||||
|
||||
private void run_reload(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
// Reloads all reloadable configs.
|
||||
private void runReload(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
ess.reload();
|
||||
sender.sendMessage(tl("essentialsReload", ess.getDescription().getVersion()));
|
||||
}
|
||||
|
||||
private void run_nya(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
final Map<String, Float> noteMap = new HashMap<String, Float>();
|
||||
noteMap.put("1F#", 0.5f);
|
||||
noteMap.put("1G", 0.53f);
|
||||
noteMap.put("1G#", 0.56f);
|
||||
noteMap.put("1A", 0.6f);
|
||||
noteMap.put("1A#", 0.63f);
|
||||
noteMap.put("1B", 0.67f);
|
||||
noteMap.put("1C", 0.7f);
|
||||
noteMap.put("1C#", 0.76f);
|
||||
noteMap.put("1D", 0.8f);
|
||||
noteMap.put("1D#", 0.84f);
|
||||
noteMap.put("1E", 0.9f);
|
||||
noteMap.put("1F", 0.94f);
|
||||
noteMap.put("2F#", 1.0f);
|
||||
noteMap.put("2G", 1.06f);
|
||||
noteMap.put("2G#", 1.12f);
|
||||
noteMap.put("2A", 1.18f);
|
||||
noteMap.put("2A#", 1.26f);
|
||||
noteMap.put("2B", 1.34f);
|
||||
noteMap.put("2C", 1.42f);
|
||||
noteMap.put("2C#", 1.5f);
|
||||
noteMap.put("2D", 1.6f);
|
||||
noteMap.put("2D#", 1.68f);
|
||||
noteMap.put("2E", 1.78f);
|
||||
noteMap.put("2F", 1.88f);
|
||||
final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1B,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,";
|
||||
final String[] tune = tuneStr.split(",");
|
||||
taskid = ess.scheduleSyncRepeatingTask(new Runnable() {
|
||||
int i = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final String note = tune[i];
|
||||
i++;
|
||||
if (i >= tune.length) {
|
||||
Commandessentials.this.stopTune();
|
||||
}
|
||||
if (note == null || note.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Sound noteHarp;
|
||||
try {
|
||||
noteHarp = Sound.valueOf("NOTE_PIANO"); // pre-1.9, referenced internally as note.harp
|
||||
} catch (IllegalArgumentException e) {
|
||||
noteHarp = Sound.valueOf("BLOCK_NOTE_HARP"); // 1.9
|
||||
}
|
||||
|
||||
for (Player onlinePlayer : ess.getOnlinePlayers()) {
|
||||
onlinePlayer.playSound(onlinePlayer.getLocation(), noteHarp, 1, noteMap.get(note));
|
||||
}
|
||||
}
|
||||
}, 20, 2);
|
||||
}
|
||||
|
||||
private void stopTune() {
|
||||
ess.getScheduler().cancelTask(taskid);
|
||||
for (Block block : noteBlocks.values()) {
|
||||
if (block.getType() == Material.NOTE_BLOCK) {
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
// Pop tarts.
|
||||
private void runNya(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (currentTune != null) {
|
||||
currentTune.cancel();
|
||||
}
|
||||
noteBlocks.clear();
|
||||
|
||||
currentTune = new TuneRunnable(NYAN_TUNE, NOTE_HARP, ess::getOnlinePlayers);
|
||||
currentTune.runTaskTimer(ess, 20, 2);
|
||||
}
|
||||
|
||||
private final String[] consoleMoo = new String[]{" (__)", " (oo)", " /------\\/", " / | ||", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..."};
|
||||
private final String[] playerMoo = new String[]{" (__)", " (oo)", " /------\\/", " / | | |", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..."};
|
||||
|
||||
private void run_moo(final Server server, final CommandSource sender, final String command, final String args[]) {
|
||||
Sound moo = EnumUtil.valueOf(Sound.class, "COW_IDLE", "ENTITY_COW_MILK");
|
||||
|
||||
// Cow farts.
|
||||
private void runMoo(final Server server, final CommandSource sender, final String command, final String args[]) {
|
||||
if (args.length == 2 && args[1].equals("moo")) {
|
||||
for (String s : consoleMoo) {
|
||||
for (String s : CONSOLE_MOO) {
|
||||
logger.info(s);
|
||||
}
|
||||
for (Player player : ess.getOnlinePlayers()) {
|
||||
player.sendMessage(playerMoo);
|
||||
player.playSound(player.getLocation(), moo, 1, 1.0f);
|
||||
player.sendMessage(PLAYER_MOO);
|
||||
player.playSound(player.getLocation(), MOO_SOUND, 1, 1.0f);
|
||||
}
|
||||
} else {
|
||||
if (sender.isPlayer()) {
|
||||
sender.getSender().sendMessage(playerMoo);
|
||||
sender.getSender().sendMessage(PLAYER_MOO);
|
||||
final Player player = sender.getPlayer();
|
||||
player.playSound(player.getLocation(), moo, 1, 1.0f);
|
||||
player.playSound(player.getLocation(), MOO_SOUND, 1, 1.0f);
|
||||
|
||||
} else {
|
||||
sender.getSender().sendMessage(consoleMoo);
|
||||
sender.getSender().sendMessage(CONSOLE_MOO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void run_cleanup(final Server server, final CommandSource sender, final String command, final String args[]) throws Exception {
|
||||
// Cleans up inactive users.
|
||||
private void runCleanup(final Server server, final CommandSource sender, final String command, final String args[]) throws Exception {
|
||||
if (args.length < 2 || !NumberUtil.isInt(args[1])) {
|
||||
sender.sendMessage("This sub-command will delete users who havent logged in in the last <days> days.");
|
||||
sender.sendMessage("Optional parameters define the minium amount required to prevent deletion.");
|
||||
sender.sendMessage("Unless you define larger default values, this command wil ignore people who have more than 0 money/homes.");
|
||||
sender.sendMessage("This sub-command will delete users who haven't logged in in the last <days> days.");
|
||||
sender.sendMessage("Optional parameters define the minimum amount required to prevent deletion.");
|
||||
sender.sendMessage("Unless you define larger default values, this command will ignore people who have more than 0 money/homes.");
|
||||
throw new Exception("/<command> cleanup <days> [money] [homes]");
|
||||
}
|
||||
|
||||
sender.sendMessage(tl("cleaning"));
|
||||
|
||||
final long daysArg = Long.parseLong(args[1]);
|
||||
@@ -218,59 +212,58 @@ public class Commandessentials extends EssentialsCommand {
|
||||
final int homesArg = args.length >= 4 && NumberUtil.isInt(args[3]) ? Integer.parseInt(args[3]) : 0;
|
||||
final UserMap userMap = ess.getUserMap();
|
||||
|
||||
ess.runTaskAsynchronously(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Long currTime = System.currentTimeMillis();
|
||||
for (UUID u : userMap.getAllUniqueUsers()) {
|
||||
final User user = ess.getUserMap().getUser(u);
|
||||
if (user == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
long lastLog = user.getLastLogout();
|
||||
if (lastLog == 0) {
|
||||
lastLog = user.getLastLogin();
|
||||
}
|
||||
if (lastLog == 0) {
|
||||
user.setLastLogin(currTime);
|
||||
}
|
||||
|
||||
if (user.isNPC()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
long timeDiff = currTime - lastLog;
|
||||
long milliDays = daysArg * 24L * 60L * 60L * 1000L;
|
||||
int homeCount = user.getHomes().size();
|
||||
double moneyCount = user.getMoney().doubleValue();
|
||||
|
||||
if ((lastLog == 0) || (timeDiff < milliDays) || (homeCount > homesArg) || (moneyCount > moneyArg)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().info("Deleting user: " + user.getName() + " Money: " + moneyCount + " Homes: " + homeCount + " Last seen: " + DateUtil.formatDateDiff(lastLog));
|
||||
}
|
||||
|
||||
user.reset();
|
||||
ess.runTaskAsynchronously(() -> {
|
||||
Long currTime = System.currentTimeMillis();
|
||||
for (UUID u : userMap.getAllUniqueUsers()) {
|
||||
final User user = ess.getUserMap().getUser(u);
|
||||
if (user == null) {
|
||||
continue;
|
||||
}
|
||||
sender.sendMessage(tl("cleaned"));
|
||||
|
||||
long lastLog = user.getLastLogout();
|
||||
if (lastLog == 0) {
|
||||
lastLog = user.getLastLogin();
|
||||
}
|
||||
if (lastLog == 0) {
|
||||
user.setLastLogin(currTime);
|
||||
}
|
||||
|
||||
if (user.isNPC()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
long timeDiff = currTime - lastLog;
|
||||
long milliDays = daysArg * 24L * 60L * 60L * 1000L;
|
||||
int homeCount = user.getHomes().size();
|
||||
double moneyCount = user.getMoney().doubleValue();
|
||||
|
||||
if ((lastLog == 0) || (timeDiff < milliDays) || (homeCount > homesArg) || (moneyCount > moneyArg)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().info("Deleting user: " + user.getName() + " Money: " + moneyCount + " Homes: " + homeCount + " Last seen: " + DateUtil.formatDateDiff(lastLog));
|
||||
}
|
||||
|
||||
user.reset();
|
||||
}
|
||||
sender.sendMessage(tl("cleaned"));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void run_uuidconvert(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
sender.sendMessage("Starting Essentials UUID userdata conversion, this may lag the server.");
|
||||
// Forces a rerun of userdata UUID conversion.
|
||||
private void runUUIDConvert(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
sender.sendMessage("Starting Essentials UUID userdata conversion; this may lag the server.");
|
||||
|
||||
Boolean ignoreUFCache = (args.length > 2 && args[1].toLowerCase(Locale.ENGLISH).contains("ignore"));
|
||||
EssentialsUpgrade.uuidFileConvert(ess, ignoreUFCache);
|
||||
|
||||
sender.sendMessage("UUID conversion complete, check your server log for more information.");
|
||||
sender.sendMessage("UUID conversion complete. Check your server log for more information.");
|
||||
}
|
||||
|
||||
private void run_uuidtest(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
// Looks up various UUIDs for a user.
|
||||
private void runUUIDTest(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (args.length < 2) {
|
||||
throw new Exception("/<command> uuidtest <name>");
|
||||
}
|
||||
@@ -307,7 +300,8 @@ public class Commandessentials extends EssentialsCommand {
|
||||
sender.sendMessage("Offline Mode UUID: " + offlineuuid.toString());
|
||||
}
|
||||
|
||||
private void run_version(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
// Displays versions of EssentialsX and related plugins.
|
||||
private void runVersion(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.version")) return;
|
||||
|
||||
boolean isMismatched = false;
|
||||
@@ -374,47 +368,101 @@ public class Commandessentials extends EssentialsCommand {
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
List<String> options = Lists.newArrayList();
|
||||
options.add("reload");
|
||||
options.add("debug");
|
||||
//options.add("nya");
|
||||
//options.add("moo");
|
||||
options.add("commands");
|
||||
options.add("version");
|
||||
options.add("reload");
|
||||
options.add("reset");
|
||||
options.add("cleanup");
|
||||
//options.add("uuidconvert");
|
||||
//options.add("uuidtest");
|
||||
options.add("version");
|
||||
//options.add("nya");
|
||||
//options.add("moo");
|
||||
return options;
|
||||
} else if (args[0].equalsIgnoreCase("debug")) {
|
||||
// No args
|
||||
} else if (args[0].equalsIgnoreCase("nya")) {
|
||||
// No args
|
||||
} else if (args[0].equalsIgnoreCase("moo")) {
|
||||
if (args.length == 2) {
|
||||
return Lists.newArrayList("moo");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("reset")) {
|
||||
if (args.length == 2) {
|
||||
return getPlayers(server, sender);
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("cleanup")) {
|
||||
if (args.length == 2) {
|
||||
return COMMON_DURATIONS;
|
||||
} else if (args.length == 3 || args.length == 4) {
|
||||
return Lists.newArrayList("-1", "0");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("uuidconvert")) {
|
||||
if (args.length == 2) {
|
||||
return Lists.newArrayList("ignoreUFCache");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("uuidtest")) {
|
||||
if (args.length == 2) {
|
||||
return getPlayers(server, sender);
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("version")) {
|
||||
// No args
|
||||
} else {
|
||||
// No args
|
||||
}
|
||||
|
||||
switch (args[0]) {
|
||||
case "moo":
|
||||
if (args.length == 2) {
|
||||
return Lists.newArrayList("moo");
|
||||
}
|
||||
break;
|
||||
case "reset":
|
||||
case "uuidtest":
|
||||
if (args.length == 2) {
|
||||
return getPlayers(server, sender);
|
||||
}
|
||||
break;
|
||||
case "cleanup":
|
||||
if (args.length == 2) {
|
||||
return COMMON_DURATIONS;
|
||||
} else if (args.length == 3 || args.length == 4) {
|
||||
return Lists.newArrayList("-1", "0");
|
||||
}
|
||||
break;
|
||||
case "uuidconvert":
|
||||
if (args.length == 2) {
|
||||
return Lists.newArrayList("ignoreUFCache");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private static class TuneRunnable extends BukkitRunnable {
|
||||
private static final Map<String, Float> noteMap = ImmutableMap.<String, Float>builder()
|
||||
.put("1F#", 0.5f)
|
||||
.put("1G", 0.53f)
|
||||
.put("1G#", 0.56f)
|
||||
.put("1A", 0.6f)
|
||||
.put("1A#", 0.63f)
|
||||
.put("1B", 0.67f)
|
||||
.put("1C", 0.7f)
|
||||
.put("1C#", 0.76f)
|
||||
.put("1D", 0.8f)
|
||||
.put("1D#", 0.84f)
|
||||
.put("1E", 0.9f)
|
||||
.put("1F", 0.94f)
|
||||
.put("2F#", 1.0f)
|
||||
.put("2G", 1.06f)
|
||||
.put("2G#", 1.12f)
|
||||
.put("2A", 1.18f)
|
||||
.put("2A#", 1.26f)
|
||||
.put("2B", 1.34f)
|
||||
.put("2C", 1.42f)
|
||||
.put("2C#", 1.5f)
|
||||
.put("2D", 1.6f)
|
||||
.put("2D#", 1.68f)
|
||||
.put("2E", 1.78f)
|
||||
.put("2F", 1.88f)
|
||||
.build();
|
||||
|
||||
private final String[] tune;
|
||||
private final Sound sound;
|
||||
private final Supplier<Collection<Player>> players;
|
||||
private int i = 0;
|
||||
|
||||
TuneRunnable(final String tuneStr, final Sound sound, final Supplier<Collection<Player>> players) {
|
||||
this.tune = tuneStr.split(",");
|
||||
this.sound = sound;
|
||||
this.players = players;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final String note = tune[i];
|
||||
i++;
|
||||
if (i >= tune.length) {
|
||||
cancel();
|
||||
}
|
||||
if (note == null || note.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player onlinePlayer : players.get()) {
|
||||
onlinePlayer.playSound(onlinePlayer.getLocation(), sound, 1, noteMap.get(note));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,18 @@ public class Commandexp extends EssentialsCommand {
|
||||
} else {
|
||||
setExp(user.getSource(), user, args[1], true);
|
||||
}
|
||||
} else if (args.length > 1 && args[0].equalsIgnoreCase("take") && user.isAuthorized("essentials.exp.take")) {
|
||||
if (args.length == 3 && user.isAuthorized("essentials.exp.take.others")) {
|
||||
expMatch(server, user.getSource(), args[1], "-" + args[2], true);
|
||||
} else {
|
||||
setExp(user.getSource(), user, "-" + args[1], true);
|
||||
}
|
||||
} else if (args.length < 3 && args[0].equalsIgnoreCase("reset") && user.isAuthorized("essentials.exp.reset")) {
|
||||
if (args.length == 2 && user.isAuthorized("essentials.exp.reset.others")) {
|
||||
expMatch(server, user.getSource(), args[1], "0", false);
|
||||
} else {
|
||||
setExp(user.getSource(), user, "0", false);
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("show")) {
|
||||
if (args.length >= 2 && user.isAuthorized("essentials.exp.others")) {
|
||||
String match = args[1].trim();
|
||||
@@ -159,6 +171,12 @@ public class Commandexp extends EssentialsCommand {
|
||||
if (user.isAuthorized("essentials.exp.give")) {
|
||||
options.add("give");
|
||||
}
|
||||
if (user.isAuthorized("essentials.exp.take")) {
|
||||
options.add("take");
|
||||
}
|
||||
if (user.isAuthorized("essentials.exp.reset")) {
|
||||
options.add("reset");
|
||||
}
|
||||
return options;
|
||||
} else if (args.length == 2) {
|
||||
if ((args[0].equalsIgnoreCase("set") && user.isAuthorized("essentials.exp.set")) || (args[0].equalsIgnoreCase("give") && user.isAuthorized("essentials.exp.give"))) {
|
||||
@@ -184,7 +202,7 @@ public class Commandexp extends EssentialsCommand {
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
// TODO: This seems somewhat buggy, both setting and showing - right now, ignoring that
|
||||
return Lists.newArrayList("set", "give", "show");
|
||||
return Lists.newArrayList("set", "give", "show", "take", "reset");
|
||||
} else if (args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase("set") || args[0].equalsIgnoreCase("give")) {
|
||||
String levellessArg = args[1].toLowerCase(Locale.ENGLISH).replace("l", "");
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FloatUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.*;
|
||||
@@ -8,44 +11,86 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandfireball extends EssentialsCommand {
|
||||
private static final Map<String, Class<? extends Projectile>> types;
|
||||
|
||||
static {
|
||||
ImmutableMap.Builder<String, Class<? extends Projectile>> builder = ImmutableMap.<String, Class<? extends Projectile>>builder()
|
||||
.put("fireball", Fireball.class)
|
||||
.put("small", SmallFireball.class)
|
||||
.put("large", LargeFireball.class)
|
||||
.put("arrow", Arrow.class)
|
||||
.put("skull", WitherSkull.class)
|
||||
.put("egg", Egg.class)
|
||||
.put("snowball", Snowball.class)
|
||||
.put("expbottle", ThrownExpBottle.class)
|
||||
.put("splashpotion", SplashPotion.class)
|
||||
.put("lingeringpotion", LingeringPotion.class);
|
||||
|
||||
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_9_R01)) {
|
||||
builder.put("dragon", DragonFireball.class);
|
||||
}
|
||||
|
||||
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_13_0_R01)) {
|
||||
builder.put("trident", Trident.class);
|
||||
}
|
||||
|
||||
types = builder.build();
|
||||
}
|
||||
|
||||
public Commandfireball() {
|
||||
super("fireball");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
Class<? extends Entity> type = Fireball.class;
|
||||
Projectile projectile;
|
||||
int speed = 2;
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("small")) {
|
||||
type = SmallFireball.class;
|
||||
} else if (args[0].equalsIgnoreCase("arrow")) {
|
||||
type = Arrow.class;
|
||||
} else if (args[0].equalsIgnoreCase("skull")) {
|
||||
type = WitherSkull.class;
|
||||
} else if (args[0].equalsIgnoreCase("egg")) {
|
||||
type = Egg.class;
|
||||
} else if (args[0].equalsIgnoreCase("snowball")) {
|
||||
type = Snowball.class;
|
||||
} else if (args[0].equalsIgnoreCase("expbottle")) {
|
||||
type = ThrownExpBottle.class;
|
||||
} else if (args[0].equalsIgnoreCase("large")) {
|
||||
type = LargeFireball.class;
|
||||
String type = "fireball";
|
||||
double speed = 2;
|
||||
boolean ride = false;
|
||||
|
||||
if (args.length > 0 && types.containsKey(args[0])) {
|
||||
type = args[0];
|
||||
}
|
||||
|
||||
if (args.length > 1) {
|
||||
try {
|
||||
speed = FloatUtil.parseDouble(args[1]);
|
||||
speed = Double.max(0, Double.min(speed, ess.getSettings().getMaxProjectileSpeed()));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length > 2 && args[2].equalsIgnoreCase("ride") && user.isAuthorized("essentials.fireball.ride")) {
|
||||
ride = true;
|
||||
}
|
||||
|
||||
if (!user.isAuthorized("essentials.fireball." + type)) {
|
||||
throw new Exception(tl("noPerm", "essentials.fireball." + type));
|
||||
}
|
||||
|
||||
final Vector direction = user.getBase().getEyeLocation().getDirection().multiply(speed);
|
||||
projectile = (Projectile) user.getWorld().spawn(user.getBase().getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), type);
|
||||
Projectile projectile = user.getWorld().spawn(user.getBase().getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), types.get(type));
|
||||
projectile.setShooter(user.getBase());
|
||||
projectile.setVelocity(direction);
|
||||
|
||||
if (ride) {
|
||||
projectile.addPassenger(user.getBase());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final User user, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
return Lists.newArrayList("small", "arrow", "skull", "egg", "snowball", "expbottle", "large");
|
||||
return types.keySet().stream()
|
||||
.filter(type -> user.isAuthorized("essentials.fireball." + type))
|
||||
.collect(Collectors.toList());
|
||||
} else if (args.length == 2) {
|
||||
return Lists.newArrayList("1", "2", "3", "4", "5");
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.MetaItemStack;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.DyeColor;
|
||||
@@ -43,8 +44,8 @@ public class Commandfirework extends EssentialsCommand {
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
final ItemStack stack = user.getBase().getInventory().getItemInMainHand();
|
||||
if (stack.getType() == Material.FIREWORK_ROCKET || stack.getType() == Material.FIREWORK_STAR) {
|
||||
final ItemStack stack = user.getItemInHand();
|
||||
if (MaterialUtil.isFirework(stack.getType())) {
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("clear")) {
|
||||
FireworkMeta fmeta = (FireworkMeta) stack.getItemMeta();
|
||||
|
||||
@@ -31,9 +31,9 @@ public class Commandgive extends EssentialsCommand {
|
||||
}
|
||||
|
||||
ItemStack stack = ess.getItemDb().get(args[1]);
|
||||
|
||||
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
if (sender.isPlayer() && (ess.getSettings().permissionBasedItemSpawn() ? (!ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.item-all") && !ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.item-" + itemname)) : (!ess.getUser(sender.getPlayer()).isAuthorized("essentials.itemspawn.exempt") && !ess.getUser(sender.getPlayer()).canSpawnItem(stack.getType())))) {
|
||||
|
||||
if (sender.isPlayer() && !ess.getUser(sender.getPlayer()).canSpawnItem(stack.getType())) {
|
||||
throw new Exception(tl("cantSpawnItem", itemname));
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,12 @@ public class Commandhat extends EssentialsCommand {
|
||||
user.sendMessage(tl("hatRemoved"));
|
||||
}
|
||||
} else {
|
||||
if (user.getBase().getInventory().getItemInMainHand().getType() != Material.AIR) {
|
||||
final ItemStack hand = user.getBase().getInventory().getItemInMainHand();
|
||||
final ItemStack hand = user.getItemInHand();
|
||||
if (hand != null && hand.getType() != Material.AIR) {
|
||||
if (user.isAuthorized("essentials.hat.prevent-type." + hand.getType().name().toLowerCase())) {
|
||||
user.sendMessage(tl("hatFail"));
|
||||
return;
|
||||
}
|
||||
if (hand.getType().getMaxDurability() == 0) {
|
||||
final PlayerInventory inv = user.getBase().getInventory();
|
||||
final ItemStack head = inv.getHelmet();
|
||||
|
||||
@@ -53,7 +53,11 @@ public class Commandhome extends EssentialsCommand {
|
||||
Location bed = player.getBase().getBedSpawnLocation();
|
||||
final List<String> homes = player.getHomes();
|
||||
if (homes.isEmpty() && player.equals(user)) {
|
||||
user.getTeleport().respawn(charge, TeleportCause.COMMAND);
|
||||
if (ess.getSettings().isSpawnIfNoHome()) {
|
||||
user.getTeleport().respawn(charge, TeleportCause.COMMAND);
|
||||
} else {
|
||||
throw new Exception(tl("noHomeSetPlayer"));
|
||||
}
|
||||
} else if (homes.isEmpty()) {
|
||||
throw new Exception(tl("noHomeSetPlayer"));
|
||||
} else if (homes.size() == 1 && player.equals(user)) {
|
||||
@@ -95,6 +99,7 @@ public class Commandhome extends EssentialsCommand {
|
||||
throw new Exception(tl("noPerm", "essentials.worlds." + loc.getWorld().getName()));
|
||||
}
|
||||
user.getTeleport().teleport(loc, charge, TeleportCause.COMMAND);
|
||||
user.sendMessage(tl("teleportHome", home));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,9 +29,10 @@ public class Commanditem extends EssentialsCommand {
|
||||
ItemStack stack = ess.getItemDb().get(args[0]);
|
||||
|
||||
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
if (ess.getSettings().permissionBasedItemSpawn() ? (!user.isAuthorized("essentials.itemspawn.item-all") && !user.isAuthorized("essentials.itemspawn.item-" + itemname)) : (!user.isAuthorized("essentials.itemspawn.exempt") && !user.canSpawnItem(stack.getType()))) {
|
||||
if (!user.canSpawnItem(stack.getType())) {
|
||||
throw new Exception(tl("cantSpawnItem", itemname));
|
||||
}
|
||||
|
||||
try {
|
||||
if (args.length > 1 && Integer.parseInt(args[1]) > 0) {
|
||||
stack.setAmount(Integer.parseInt(args[1]));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -23,7 +24,7 @@ public class Commanditemdb extends EssentialsCommand {
|
||||
if (args.length < 1) {
|
||||
if (sender.isPlayer() && sender.getPlayer() != null) {
|
||||
itemHeld = true;
|
||||
itemStack = sender.getPlayer().getInventory().getItemInMainHand();
|
||||
itemStack = ess.getUser(sender.getPlayer()).getItemInHand();
|
||||
}
|
||||
if (itemStack == null) {
|
||||
throw new NotEnoughArgumentsException();
|
||||
@@ -32,7 +33,18 @@ public class Commanditemdb extends EssentialsCommand {
|
||||
itemStack = ess.getItemDb().get(args[0]);
|
||||
}
|
||||
|
||||
sender.sendMessage(tl("itemType", itemStack.getType().toString()));
|
||||
String itemId = "none";
|
||||
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_13_0_R01)) {
|
||||
itemId = itemStack.getType().getId() + ":" + itemStack.getDurability();
|
||||
}
|
||||
|
||||
sender.sendMessage(tl("itemType", itemStack.getType().toString(), itemId));
|
||||
|
||||
// Don't send IDs twice
|
||||
if (!tl("itemType").contains("{1}") && !itemId.equals("none")) {
|
||||
sender.sendMessage(tl("itemId", itemId));
|
||||
}
|
||||
|
||||
if (itemHeld && itemStack.getType() != Material.AIR) {
|
||||
int maxuses = itemStack.getType().getMaxDurability();
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.I18n;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class Commanditemname extends EssentialsCommand {
|
||||
|
||||
public Commanditemname() {
|
||||
super("itemname");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception {
|
||||
ItemStack item = user.getBase().getItemInHand();
|
||||
if (item.getType().name().contains("AIR")) {
|
||||
user.sendMessage(tl("itemnameInvalidItem", item.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ')));
|
||||
return;
|
||||
}
|
||||
|
||||
String name = FormatUtil.formatString(user, "essentials.itemname", getFinalArg(args, 0)).trim();
|
||||
if (name.isEmpty()) name = null;
|
||||
|
||||
ItemMeta im = item.getItemMeta();
|
||||
im.setDisplayName(name);
|
||||
item.setItemMeta(im);
|
||||
user.sendMessage(name == null ? tl("itemnameClear") : tl("itemnameSuccess", name));
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,11 @@ import com.earth2me.essentials.Mob;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Cat;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Tameable;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -18,16 +22,7 @@ public class Commandkittycannon extends EssentialsCommand {
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
final Mob cat = Mob.OCELOT;
|
||||
final Ocelot ocelot = (Ocelot) cat.spawn(user.getWorld(), server, user.getBase().getEyeLocation());
|
||||
if (ocelot == null) {
|
||||
return;
|
||||
}
|
||||
final int i = random.nextInt(Ocelot.Type.values().length);
|
||||
ocelot.setCatType(Ocelot.Type.values()[i]);
|
||||
ocelot.setTamed(true);
|
||||
ocelot.setBaby();
|
||||
ocelot.setVelocity(user.getBase().getEyeLocation().getDirection().multiply(2));
|
||||
final Entity ocelot = Mob.CAT.getType() == null ? spawnOcelot(user.getWorld(), server, user) : spawnCat(user.getWorld(), server, user);
|
||||
|
||||
class KittyCannonExplodeTask implements Runnable {
|
||||
@Override
|
||||
@@ -40,4 +35,32 @@ public class Commandkittycannon extends EssentialsCommand {
|
||||
ess.scheduleSyncDelayedTask(new KittyCannonExplodeTask(), 20);
|
||||
|
||||
}
|
||||
|
||||
private static Ocelot spawnOcelot(World world, Server server, User user) throws Mob.MobException {
|
||||
final Ocelot ocelot = (Ocelot) Mob.OCELOT.spawn(user.getWorld(), server, user.getBase().getEyeLocation());
|
||||
if (ocelot == null) {
|
||||
return null;
|
||||
}
|
||||
final int i = random.nextInt(Ocelot.Type.values().length);
|
||||
ocelot.setCatType(Ocelot.Type.values()[i]);
|
||||
((Tameable) ocelot).setTamed(true);
|
||||
ocelot.setBaby();
|
||||
ocelot.setVelocity(user.getBase().getEyeLocation().getDirection().multiply(2));
|
||||
|
||||
return ocelot;
|
||||
}
|
||||
|
||||
private static Entity spawnCat(World world, Server server, User user) throws Mob.MobException {
|
||||
final Cat cat = (Cat) Mob.CAT.spawn(user.getWorld(), server, user.getBase().getEyeLocation());
|
||||
if (cat == null) {
|
||||
return null;
|
||||
}
|
||||
final int i = random.nextInt(Cat.Type.values().length);
|
||||
cat.setCatType(Cat.Type.values()[i]);
|
||||
cat.setTamed(true);
|
||||
cat.setBaby();
|
||||
cat.setVelocity(user.getBase().getEyeLocation().getDirection().multiply(2));
|
||||
|
||||
return cat;
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class Commandmail extends EssentialsCommand {
|
||||
}
|
||||
|
||||
if (user.isMuted()) {
|
||||
throw new Exception(tl("voiceSilenced"));
|
||||
throw new Exception(user.hasMuteReason() ? tl("voiceSilencedReason", user.getMuteReason()) : tl("voiceSilenced"));
|
||||
}
|
||||
|
||||
User u = getPlayer(server, args[1], true, true);
|
||||
@@ -87,6 +87,11 @@ public class Commandmail extends EssentialsCommand {
|
||||
return;
|
||||
}
|
||||
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0])) {
|
||||
if (user.getMails() == null || user.getMails().isEmpty()) {
|
||||
user.sendMessage(tl("noMail"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
user.setMails(null);
|
||||
user.sendMessage(tl("mailCleared"));
|
||||
return;
|
||||
@@ -105,11 +110,11 @@ public class Commandmail extends EssentialsCommand {
|
||||
if (u == null) {
|
||||
throw new Exception(tl("playerNeverOnServer", args[1]));
|
||||
}
|
||||
u.addMail(tl("mailFormat", "Server", getFinalArg(args, 2)));
|
||||
u.addMail(tl("mailFormat", "Server", FormatUtil.replaceFormat(getFinalArg(args, 2))));
|
||||
sender.sendMessage(tl("mailSent"));
|
||||
return;
|
||||
} else if (args.length >= 2 && "sendall".equalsIgnoreCase(args[0])) {
|
||||
ess.runTaskAsynchronously(new SendAll(tl("mailFormat", "Server", getFinalArg(args, 1))));
|
||||
ess.runTaskAsynchronously(new SendAll(tl("mailFormat", "Server", FormatUtil.replaceFormat(getFinalArg(args, 1)))));
|
||||
sender.sendMessage(tl("mailSent"));
|
||||
return;
|
||||
} else if (args.length >= 2) {
|
||||
@@ -118,7 +123,7 @@ public class Commandmail extends EssentialsCommand {
|
||||
if (u == null) {
|
||||
throw new Exception(tl("playerNeverOnServer", args[0]));
|
||||
}
|
||||
u.addMail(tl("mailFormat", "Server", getFinalArg(args, 1)));
|
||||
u.addMail(tl("mailFormat", "Server", FormatUtil.replaceFormat(getFinalArg(args, 1))));
|
||||
sender.sendMessage(tl("mailSent"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Commandme extends EssentialsCommand {
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception {
|
||||
if (user.isMuted()) {
|
||||
throw new Exception(tl("voiceSilenced"));
|
||||
throw new Exception(user.hasMuteReason() ? tl("voiceSilencedReason", user.getMuteReason()) : tl("voiceSilenced"));
|
||||
}
|
||||
|
||||
if (args.length < 1) {
|
||||
|
||||
@@ -16,7 +16,7 @@ public class Commandmore extends EssentialsCommand {
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
final ItemStack stack = user.getBase().getInventory().getItemInMainHand();
|
||||
final ItemStack stack = user.getItemInHand();
|
||||
if (stack == null) {
|
||||
throw new Exception(tl("cantSpawnItem", "Air"));
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class Commandmore extends EssentialsCommand {
|
||||
throw new Exception(tl("fullStack"));
|
||||
}
|
||||
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
|
||||
if (ess.getSettings().permissionBasedItemSpawn() ? (!user.isAuthorized("essentials.itemspawn.item-all") && !user.isAuthorized("essentials.itemspawn.item-" + itemname)) : (!user.isAuthorized("essentials.itemspawn.exempt") && !user.canSpawnItem(stack.getType()))) {
|
||||
if (!user.canSpawnItem(stack.getType())) {
|
||||
throw new Exception(tl("cantSpawnItem", itemname));
|
||||
}
|
||||
if (user.isAuthorized("essentials.oversizedstacks")) {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Commandmsg extends EssentialsLoopCommand {
|
||||
if (sender.isPlayer()) {
|
||||
User user = ess.getUser(sender.getPlayer());
|
||||
if (user.isMuted()) {
|
||||
throw new Exception(tl("voiceSilenced"));
|
||||
throw new Exception(user.hasMuteReason() ? tl("voiceSilencedReason", user.getMuteReason()) : tl("voiceSilenced"));
|
||||
}
|
||||
message = FormatUtil.formatMessage(user, "essentials.msg", message);
|
||||
canWildcard = user.isAuthorized("essentials.msg.multiple");
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Commandmute extends EssentialsCommand {
|
||||
}
|
||||
}
|
||||
|
||||
final boolean willMute = (args.length > 1) ? true : !user.getMuted();
|
||||
final boolean willMute = (args.length > 1) || !user.getMuted();
|
||||
final User controller = sender.isPlayer() ? ess.getUser(sender.getPlayer()) : null;
|
||||
final MuteStatusChangeEvent event = new MuteStatusChangeEvent(user, controller, willMute);
|
||||
ess.getServer().getPluginManager().callEvent(event);
|
||||
@@ -50,11 +50,22 @@ public class Commandmute extends EssentialsCommand {
|
||||
long muteTimestamp = 0;
|
||||
|
||||
if (args.length > 1) {
|
||||
final String time = getFinalArg(args, 1);
|
||||
muteTimestamp = DateUtil.parseDateDiff(time, true);
|
||||
final String time = args[1];
|
||||
String muteReason;
|
||||
try {
|
||||
muteTimestamp = DateUtil.parseDateDiff(time, true);
|
||||
muteReason = getFinalArg(args, 2);
|
||||
} catch (Exception e) {
|
||||
muteReason = getFinalArg(args, 1);
|
||||
}
|
||||
|
||||
user.setMuteReason(muteReason.isEmpty() ? null : muteReason);
|
||||
user.setMuted(true);
|
||||
} else {
|
||||
user.setMuted(!user.getMuted());
|
||||
if (!user.getMuted()) {
|
||||
user.setMuteReason(null);
|
||||
}
|
||||
}
|
||||
user.setMuteTimeout(muteTimestamp);
|
||||
final boolean muted = user.getMuted();
|
||||
@@ -66,17 +77,35 @@ public class Commandmute extends EssentialsCommand {
|
||||
|
||||
if (muted) {
|
||||
if (muteTimestamp > 0) {
|
||||
sender.sendMessage(tl("mutedPlayerFor", user.getDisplayName(), muteTime));
|
||||
user.sendMessage(tl("playerMutedFor", muteTime));
|
||||
if (!user.hasMuteReason()) {
|
||||
sender.sendMessage(tl("mutedPlayerFor", user.getDisplayName(), muteTime));
|
||||
user.sendMessage(tl("playerMutedFor", muteTime));
|
||||
} else {
|
||||
sender.sendMessage(tl("mutedPlayerForReason", user.getDisplayName(), muteTime, user.getMuteReason()));
|
||||
user.sendMessage(tl("playerMutedForReason", muteTime, user.getMuteReason()));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(tl("mutedPlayer", user.getDisplayName()));
|
||||
user.sendMessage(tl("playerMuted"));
|
||||
if (!user.hasMuteReason()) {
|
||||
sender.sendMessage(tl("mutedPlayer", user.getDisplayName()));
|
||||
user.sendMessage(tl("playerMuted"));
|
||||
} else {
|
||||
sender.sendMessage(tl("mutedPlayerReason", user.getDisplayName(), user.getMuteReason()));
|
||||
user.sendMessage(tl("playerMutedReason", user.getMuteReason()));
|
||||
}
|
||||
}
|
||||
final String message;
|
||||
if (muteTimestamp > 0) {
|
||||
message = tl("muteNotifyFor", sender.getSender().getName(), user.getName(), muteTime);
|
||||
if (!user.hasMuteReason()) {
|
||||
message = tl("muteNotifyFor", sender.getSender().getName(), user.getName(), muteTime);
|
||||
} else {
|
||||
message = tl("muteNotifyForReason", sender.getSender().getName(), user.getName(), muteTime, user.getMuteReason());
|
||||
}
|
||||
} else {
|
||||
message = tl("muteNotify", sender.getSender().getName(), user.getName());
|
||||
if (!user.hasMuteReason()) {
|
||||
message = tl("muteNotify", sender.getSender().getName(), user.getName());
|
||||
} else {
|
||||
message = tl("muteNotifyReason", sender.getSender().getName(), user.getName(), user.getMuteReason());
|
||||
}
|
||||
}
|
||||
server.getLogger().log(Level.INFO, message);
|
||||
ess.broadcastMessage("essentials.mute.notify", message);
|
||||
|
||||
@@ -9,6 +9,8 @@ import org.bukkit.World;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.Queue;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
@@ -83,6 +85,8 @@ public class Commandnear extends EssentialsCommand {
|
||||
final long radiusSquared = radius * radius;
|
||||
boolean showHidden = user.canInteractVanished();
|
||||
|
||||
Queue<User> nearbyPlayers = new PriorityQueue<>((o1, o2) -> (int) (o1.getLocation().distanceSquared(loc) - o2.getLocation().distanceSquared(loc)));
|
||||
|
||||
for (User player : ess.getOnlineUsers()) {
|
||||
if (!player.equals(user) && (!player.isHidden(user.getBase()) || showHidden || user.getBase().canSee(player.getBase()))) {
|
||||
final Location playerLoc = player.getLocation();
|
||||
@@ -92,13 +96,19 @@ public class Commandnear extends EssentialsCommand {
|
||||
|
||||
final long delta = (long) playerLoc.distanceSquared(loc);
|
||||
if (delta < radiusSquared) {
|
||||
if (output.length() > 0) {
|
||||
output.append(", ");
|
||||
}
|
||||
output.append(player.getDisplayName()).append("§f(§4").append((long) Math.sqrt(delta)).append("m§f)");
|
||||
nearbyPlayers.offer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (!nearbyPlayers.isEmpty()) {
|
||||
if (output.length() > 0) {
|
||||
output.append(", ");
|
||||
}
|
||||
User nearbyPlayer = nearbyPlayers.poll();
|
||||
output.append(nearbyPlayer.getDisplayName()).append("§f(§4").append((long) nearbyPlayer.getLocation().distance(loc)).append("m§f)");
|
||||
}
|
||||
|
||||
return output.length() > 1 ? output.toString() : tl("none");
|
||||
}
|
||||
|
||||
|
||||
@@ -83,10 +83,17 @@ public class Commandnick extends EssentialsLoopCommand {
|
||||
throw new Exception(tl("nickNamesAlpha"));
|
||||
} else if (user != null && (user.isAuthorized("essentials.nick.changecolors") && !user.isAuthorized("essentials.nick.changecolors.bypass")) && !FormatUtil.stripFormat(newNick).equals(user.getName())) {
|
||||
throw new Exception(tl("nickNamesOnlyColorChanges"));
|
||||
} else if (user != null && !user.isAuthorized("essentials.nick.blacklist.bypass") && isNickBanned(newNick)) {
|
||||
throw new Exception(tl("nickNameBlacklist", nick));
|
||||
}
|
||||
return newNick;
|
||||
}
|
||||
|
||||
private boolean isNickBanned(String newNick) {
|
||||
return ess.getSettings().getNickBlacklist().stream()
|
||||
.anyMatch(entry -> entry.test(newNick));
|
||||
}
|
||||
|
||||
private int getNickLength(final String nick) {
|
||||
return ess.getSettings().ignoreColorsInMaxLength() ? ChatColor.stripColor(nick).length() : nick.length();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.earth2me.essentials.utils.StringUtil;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import net.ess3.api.events.UserBalanceUpdateEvent;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -73,7 +74,7 @@ public class Commandpay extends EssentialsLoopCommand {
|
||||
user.getConfirmingPayments().put(player, amount);
|
||||
return;
|
||||
}
|
||||
user.payUser(player, amount);
|
||||
user.payUser(player, amount, UserBalanceUpdateEvent.Cause.COMMAND_PAY);
|
||||
user.getConfirmingPayments().remove(player);
|
||||
Trade.log("Command", "Pay", "Player", user.getName(), new Trade(amount, ess), player.getName(), new Trade(amount, ess), user.getLocation(), ess);
|
||||
} catch (MaxMoneyException ex) {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Commandr extends EssentialsCommand {
|
||||
User user = ess.getUser(sender.getPlayer());
|
||||
|
||||
if (user.isMuted()) {
|
||||
throw new Exception(tl("voiceSilenced"));
|
||||
throw new Exception(user.hasMuteReason() ? tl("voiceSilencedReason", user.getMuteReason()) : tl("voiceSilenced"));
|
||||
}
|
||||
|
||||
message = FormatUtil.formatMessage(user, "essentials.msg", message);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import org.bukkit.Material;
|
||||
@@ -20,6 +21,11 @@ import net.ess3.nms.refl.ReflUtil;
|
||||
|
||||
|
||||
public class Commandrecipe extends EssentialsCommand {
|
||||
|
||||
private static final Material FIREWORK_ROCKET = EnumUtil.getMaterial("FIREWORK_ROCKET", "FIREWORK");
|
||||
private static final Material FIREWORK_STAR = EnumUtil.getMaterial("FIREWORK_STAR", "FIREWORK_CHARGE");
|
||||
private static final Material GUNPOWDER = EnumUtil.getMaterial("GUNPOWDER", "SULPHUR");
|
||||
|
||||
public Commandrecipe() {
|
||||
super("recipe");
|
||||
}
|
||||
@@ -67,11 +73,11 @@ public class Commandrecipe extends EssentialsCommand {
|
||||
} else if (selectedRecipe instanceof ShapedRecipe) {
|
||||
shapedRecipe(sender, (ShapedRecipe) selectedRecipe, sender.isPlayer());
|
||||
} else if (selectedRecipe instanceof ShapelessRecipe) {
|
||||
if (recipesOfType.size() == 1 && (itemType.getType() == Material.FIREWORK_ROCKET || itemType.getType() == Material.FIREWORK_STAR)) {
|
||||
if (recipesOfType.size() == 1 && (itemType.getType() == FIREWORK_ROCKET)) {
|
||||
ShapelessRecipe shapelessRecipe = new ShapelessRecipe(itemType);
|
||||
shapelessRecipe.addIngredient(Material.LEGACY_SULPHUR);
|
||||
shapelessRecipe.addIngredient(GUNPOWDER);
|
||||
shapelessRecipe.addIngredient(Material.PAPER);
|
||||
shapelessRecipe.addIngredient(Material.FIREWORK_ROCKET);
|
||||
shapelessRecipe.addIngredient(FIREWORK_STAR);
|
||||
shapelessRecipe(sender, shapelessRecipe, sender.isPlayer());
|
||||
} else {
|
||||
shapelessRecipe(sender, (ShapelessRecipe) selectedRecipe, sender.isPlayer());
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.Material;
|
||||
@@ -38,7 +39,7 @@ public class Commandrepair extends EssentialsCommand {
|
||||
}
|
||||
|
||||
public void repairHand(User user) throws Exception {
|
||||
final ItemStack item = user.getBase().getInventory().getItemInMainHand();
|
||||
final ItemStack item = user.getItemInHand();
|
||||
if (item == null || item.getType().isBlock() || item.getDurability() == 0) {
|
||||
throw new Exception(tl("repairInvalidType"));
|
||||
}
|
||||
@@ -48,7 +49,7 @@ public class Commandrepair extends EssentialsCommand {
|
||||
}
|
||||
|
||||
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-item", ess), ess);
|
||||
final Trade charge = getCharge(item.getType());
|
||||
|
||||
charge.isAffordableFor(user);
|
||||
|
||||
@@ -95,7 +96,8 @@ public class Commandrepair extends EssentialsCommand {
|
||||
}
|
||||
|
||||
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-item", ess), ess);
|
||||
final Trade charge = getCharge(item.getType());
|
||||
|
||||
try {
|
||||
charge.isAffordableFor(user);
|
||||
} catch (ChargeException ex) {
|
||||
@@ -120,6 +122,16 @@ public class Commandrepair extends EssentialsCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private Trade getCharge(final Material material) {
|
||||
final String itemName = material.toString().toLowerCase(Locale.ENGLISH);
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_13_0_R01)) {
|
||||
final int itemId = material.getId();
|
||||
return new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-" + itemId, new Trade("repair-item", ess), ess), ess);
|
||||
} else {
|
||||
return new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-item", ess), ess);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(Server server, User user, String commandLabel, String[] args) {
|
||||
if (args.length == 1) {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandrtoggle extends EssentialsToggleCommand {
|
||||
public Commandrtoggle() {
|
||||
super("rtoggle", "essentials.rtoggle.others");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception {
|
||||
handleToggleWithArgs(server, user, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSource sender, String commandLabel, String[] args) throws Exception {
|
||||
toggleOtherPlayers(server, sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
void togglePlayer(CommandSource sender, User user, Boolean enabled) throws NotEnoughArgumentsException {
|
||||
if (enabled == null) {
|
||||
enabled = !user.isLastMessageReplyRecipient();
|
||||
}
|
||||
|
||||
user.setLastMessageReplyRecipient(enabled);
|
||||
|
||||
user.sendMessage(!enabled ? tl("replyLastRecipientDisabled") : tl("replyLastRecipientEnabled"));
|
||||
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
|
||||
sender.sendMessage(!enabled ? tl("replyLastRecipientDisabledFor", user.getDisplayName()) : tl("replyLastRecipientEnabledFor", user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,12 @@ public class Commandseen extends EssentialsCommand {
|
||||
sender.sendMessage(tl("whoisJail", (user.getJailTimeout() > 0 ? DateUtil.formatDateDiff(user.getJailTimeout()) : tl("true"))));
|
||||
}
|
||||
if (user.isMuted()) {
|
||||
sender.sendMessage(tl("whoisMuted", (user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true"))));
|
||||
long muteTimeout = user.getMuteTimeout();
|
||||
if (!user.hasMuteReason()) {
|
||||
sender.sendMessage(tl("whoisMuted", (muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true"))));
|
||||
} else {
|
||||
sender.sendMessage(tl("whoisMutedReason", (muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true")), user.getMuteReason()));
|
||||
}
|
||||
}
|
||||
final String location = user.getGeoLocation();
|
||||
if (location != null && (!(sender.isPlayer()) || ess.getUser(sender.getPlayer()).isAuthorized("essentials.geoip.show"))) {
|
||||
@@ -159,6 +164,15 @@ public class Commandseen extends EssentialsCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (user.isMuted()) {
|
||||
long muteTimeout = user.getMuteTimeout();
|
||||
if (!user.hasMuteReason()) {
|
||||
sender.sendMessage(tl("whoisMuted", (muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true"))));
|
||||
} else {
|
||||
sender.sendMessage(tl("whoisMutedReason", (muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true")), user.getMuteReason()));
|
||||
}
|
||||
}
|
||||
|
||||
final String location = user.getGeoLocation();
|
||||
if (location != null && (!(sender.isPlayer()) || ess.getUser(sender.getPlayer()).isAuthorized("essentials.geoip.show"))) {
|
||||
sender.sendMessage(tl("whoisGeoLocation", location));
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.ess3.api.events.UserBalanceUpdateEvent;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -94,7 +95,7 @@ public class Commandsell extends EssentialsCommand {
|
||||
user.getBase().getInventory().removeItem(ris);
|
||||
user.getBase().updateInventory();
|
||||
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(result, ess), user.getLocation(), ess);
|
||||
user.giveMoney(result);
|
||||
user.giveMoney(result, null, UserBalanceUpdateEvent.Cause.COMMAND_SELL);
|
||||
user.sendMessage(tl("itemSold", NumberUtil.displayCurrency(result, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), NumberUtil.displayCurrency(worth, ess)));
|
||||
logger.log(Level.INFO, tl("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), NumberUtil.displayCurrency(result, ess), amount, NumberUtil.displayCurrency(worth, ess)));
|
||||
return result;
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
@@ -14,6 +16,9 @@ import java.util.List;
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandskull extends EssentialsCommand {
|
||||
|
||||
private static final Material SKULL_ITEM = EnumUtil.getMaterial("PLAYER_HEAD", "SKULL_ITEM");
|
||||
|
||||
public Commandskull() {
|
||||
super("skull");
|
||||
}
|
||||
@@ -31,14 +36,14 @@ public class Commandskull extends EssentialsCommand {
|
||||
owner = user.getName();
|
||||
}
|
||||
|
||||
ItemStack itemSkull = user.getBase().getInventory().getItemInMainHand();
|
||||
ItemStack itemSkull = user.getItemInHand();
|
||||
SkullMeta metaSkull = null;
|
||||
boolean spawn = false;
|
||||
|
||||
if (itemSkull != null && itemSkull.getType() == Material.LEGACY_SKULL_ITEM && itemSkull.getDurability() == 3) {
|
||||
if (itemSkull != null && MaterialUtil.isPlayerHead(itemSkull.getType(), itemSkull.getDurability())) {
|
||||
metaSkull = (SkullMeta) itemSkull.getItemMeta();
|
||||
} else if (user.isAuthorized("essentials.skull.spawn")) {
|
||||
itemSkull = new ItemStack(Material.LEGACY_SKULL_ITEM, 1, (byte) 3);
|
||||
itemSkull = new ItemStack(SKULL_ITEM, 1, (byte) 3);
|
||||
metaSkull = (SkullMeta) itemSkull.getItemMeta();
|
||||
spawn = true;
|
||||
} else {
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Commandsudo extends EssentialsLoopCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
ess.getServer().dispatchCommand(user.getBase(), command);
|
||||
user.getBase().chat("/" + command);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(tl("errorCallingCommand", command));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Teleport;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.ess3.api.events.TPARequestEvent;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -32,11 +36,25 @@ public class Commandtpa extends EssentialsCommand {
|
||||
}
|
||||
// Don't let sender request teleport twice to the same player.
|
||||
if (user.getConfigUUID().equals(player.getTeleportRequest()) && player.hasOutstandingTeleportRequest() // Check timeout
|
||||
&& player.isTpRequestHere() == false) { // Make sure the last teleport request was actually tpa and not tpahere
|
||||
&& !player.isTpRequestHere()) { // Make sure the last teleport request was actually tpa and not tpahere
|
||||
throw new Exception(tl("requestSentAlready", player.getDisplayName()));
|
||||
}
|
||||
if (player.isAutoTeleportEnabled() && !player.isIgnoredPlayer(user)) {
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
Teleport teleport = user.getTeleport();
|
||||
teleport.setTpType(Teleport.TeleportType.TPA);
|
||||
teleport.teleport(player.getBase(), charge, PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||
player.sendMessage(tl("requestAcceptedAuto", user.getDisplayName()));
|
||||
user.sendMessage(tl("requestAcceptedFromAuto", player.getDisplayName()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.isIgnoredPlayer(user)) {
|
||||
TPARequestEvent tpaEvent = new TPARequestEvent(user.getSource(), player, false);
|
||||
ess.getServer().getPluginManager().callEvent(tpaEvent);
|
||||
if (tpaEvent.isCancelled()) {
|
||||
throw new Exception(tl("teleportRequestCancelled", player.getDisplayName()));
|
||||
}
|
||||
player.requestTeleport(user, false);
|
||||
player.sendMessage(tl("teleportRequest", user.getDisplayName()));
|
||||
player.sendMessage(tl("typeTpaccept"));
|
||||
@@ -46,7 +64,9 @@ public class Commandtpa extends EssentialsCommand {
|
||||
}
|
||||
}
|
||||
user.sendMessage(tl("requestSent", player.getDisplayName()));
|
||||
user.sendMessage(tl("typeTpacancel"));
|
||||
if (user.isAuthorized("essentials.tpacancel")) {
|
||||
user.sendMessage(tl("typeTpacancel"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.ess3.api.events.TPARequestEvent;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -42,6 +43,12 @@ public class Commandtpaall extends EssentialsCommand {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
TPARequestEvent tpaEvent = new TPARequestEvent(sender, player, true);
|
||||
ess.getServer().getPluginManager().callEvent(tpaEvent);
|
||||
if (tpaEvent.isCancelled()) {
|
||||
sender.sendMessage(tl("teleportRequestCancelled", player.getDisplayName()));
|
||||
continue;
|
||||
}
|
||||
player.requestTeleport(target, true);
|
||||
player.sendMessage(tl("teleportHereRequest", target.getDisplayName()));
|
||||
player.sendMessage(tl("typeTpaccept"));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import net.ess3.api.events.TPARequestEvent;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -32,10 +33,15 @@ public class Commandtpahere extends EssentialsCommand {
|
||||
}
|
||||
// Don't let sender request teleport twice to the same player.
|
||||
if (user.getConfigUUID().equals(player.getTeleportRequest()) && player.hasOutstandingTeleportRequest() // Check timeout
|
||||
&& player.isTpRequestHere() == true) { // Make sure the last teleport request was actually tpahere and not tpa
|
||||
&& player.isTpRequestHere()) { // Make sure the last teleport request was actually tpahere and not tpa
|
||||
throw new Exception(tl("requestSentAlready", player.getDisplayName()));
|
||||
}
|
||||
if (!player.isIgnoredPlayer(user)) {
|
||||
TPARequestEvent tpaEvent = new TPARequestEvent(user.getSource(), player, true);
|
||||
ess.getServer().getPluginManager().callEvent(tpaEvent);
|
||||
if (tpaEvent.isCancelled()) {
|
||||
throw new Exception(tl("teleportRequestCancelled", player.getDisplayName()));
|
||||
}
|
||||
player.requestTeleport(user, true);
|
||||
player.sendMessage(tl("teleportHereRequest", user.getDisplayName()));
|
||||
player.sendMessage(tl("typeTpaccept"));
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
|
||||
public class Commandtpauto extends EssentialsToggleCommand {
|
||||
public Commandtpauto() {
|
||||
super("tpauto", "essentials.tpauto.others");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
||||
toggleOtherPlayers(server, sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
handleToggleWithArgs(server, user, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
void togglePlayer(CommandSource sender, User user, Boolean enabled) {
|
||||
if (enabled == null) {
|
||||
enabled = !user.isAutoTeleportEnabled();
|
||||
}
|
||||
|
||||
user.setAutoTeleportEnabled(enabled);
|
||||
|
||||
user.sendMessage(enabled ? tl("autoTeleportEnabled") : tl("autoTeleportDisabled"));
|
||||
if (enabled && !user.isTeleportEnabled()) {
|
||||
user.sendMessage(tl("teleportationDisabledWarning"));
|
||||
}
|
||||
if (!sender.isPlayer() || !user.getBase().equals(sender.getPlayer())) {
|
||||
sender.sendMessage(enabled ? tl("autoTeleportEnabledFor", user.getDisplayName()) : tl("autoTeleportDisabledFor", user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,6 @@ public class Commandunbanip extends EssentialsCommand {
|
||||
final String senderName = sender.isPlayer() ? sender.getPlayer().getDisplayName() : Console.NAME;
|
||||
server.getLogger().log(Level.INFO, tl("playerUnbanIpAddress", senderName, ipAddress));
|
||||
|
||||
ess.broadcastMessage("essentials.ban.notify", tl("playerUnbanIpAddress", senderName, ipAddress));
|
||||
ess.broadcastMessage("essentials.banip.notify", tl("playerUnbanIpAddress", senderName, ipAddress));
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,10 @@ import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
@@ -32,14 +34,10 @@ public class Commandunlimited extends EssentialsCommand {
|
||||
final String list = getList(target);
|
||||
user.sendMessage(list);
|
||||
} else if (args[0].equalsIgnoreCase("clear")) {
|
||||
final List<Material> itemList = target.getUnlimited();
|
||||
final Set<Material> itemList = new HashSet<>(target.getUnlimited());
|
||||
|
||||
int index = 0;
|
||||
while (itemList.size() > index) {
|
||||
final Material item = itemList.get(index);
|
||||
if (!toggleUnlimited(user, target, item.toString())) {
|
||||
index++;
|
||||
}
|
||||
for (Material m : itemList) {
|
||||
toggleUnlimited(user, target, m.toString());
|
||||
}
|
||||
} else {
|
||||
toggleUnlimited(user, target, args[0]);
|
||||
@@ -50,7 +48,7 @@ public class Commandunlimited extends EssentialsCommand {
|
||||
final StringBuilder output = new StringBuilder();
|
||||
output.append(tl("unlimitedItems")).append(" ");
|
||||
boolean first = true;
|
||||
final List<Material> items = target.getUnlimited();
|
||||
final Set<Material> items = target.getUnlimited();
|
||||
if (items.isEmpty()) {
|
||||
output.append(tl("none"));
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
@@ -64,17 +64,8 @@ public class Commandwarp extends EssentialsCommand {
|
||||
//TODO: Use one of the new text classes, like /help ?
|
||||
private void warpList(final CommandSource sender, final String[] args, final IUser user) throws Exception {
|
||||
final IWarps warps = ess.getWarps();
|
||||
final List<String> warpNameList = new ArrayList<>(warps.getList());
|
||||
final List<String> warpNameList = getAvailableWarpsFor(user);
|
||||
|
||||
if (user != null) {
|
||||
final Iterator<String> iterator = warpNameList.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final String warpName = iterator.next();
|
||||
if (ess.getSettings().getPerWarpPermission() && !user.isAuthorized("essentials.warps." + warpName)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (warpNameList.isEmpty()) {
|
||||
throw new Exception(tl("noWarpsDefined"));
|
||||
}
|
||||
@@ -112,10 +103,20 @@ public class Commandwarp extends EssentialsCommand {
|
||||
owner.getTeleport().warp(user, name, charge, TeleportCause.COMMAND);
|
||||
}
|
||||
|
||||
private List<String> getAvailableWarpsFor(final IUser user) {
|
||||
if (ess.getSettings().getPerWarpPermission() && user != null) {
|
||||
return ess.getWarps().getList().stream()
|
||||
.filter(warpName -> user.isAuthorized("essentials.warps." + warpName))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return new ArrayList<>(ess.getWarps().getList());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final User user, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1 && user.isAuthorized("essentials.warp.list")) {
|
||||
return new ArrayList<>(ess.getWarps().getList());
|
||||
return getAvailableWarpsFor(user);
|
||||
} else if (args.length == 2 && (user.isAuthorized("essentials.warp.otherplayers") || user.isAuthorized("essentials.warp.others"))) {
|
||||
//TODO: Remove 'otherplayers' permission.
|
||||
return getPlayers(server, user);
|
||||
|
||||
@@ -17,13 +17,12 @@ import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
|
||||
public class Commandwhois extends EssentialsCommand {
|
||||
private final Statistic playOneTick;
|
||||
// For some reason, in 1.13 PLAY_ONE_MINUTE = ticks played = what used to be PLAY_ONE_TICK
|
||||
// https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/b848d8ce633871b52115247b089029749c02f579
|
||||
private static final Statistic PLAY_ONE_TICK = EnumUtil.getStatistic("PLAY_ONE_MINUTE", "PLAY_ONE_TICK");
|
||||
|
||||
public Commandwhois() {
|
||||
super("whois");
|
||||
// For some reason, in 1.13 PLAY_ONE_MINUTE = ticks played
|
||||
// https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/b848d8ce633871b52115247b089029749c02f579
|
||||
playOneTick = EnumUtil.getStatistic("PLAY_ONE_MINUTE", "PLAY_ONE_TICK");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,7 +41,7 @@ public class Commandwhois extends EssentialsCommand {
|
||||
sender.sendMessage(tl("whoisHunger", user.getBase().getFoodLevel(), user.getBase().getSaturation()));
|
||||
sender.sendMessage(tl("whoisExp", SetExpFix.getTotalExperience(user.getBase()), user.getBase().getLevel()));
|
||||
sender.sendMessage(tl("whoisLocation", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));
|
||||
long playtimeMs = System.currentTimeMillis() - (user.getBase().getStatistic(playOneTick) * 50);
|
||||
long playtimeMs = System.currentTimeMillis() - (user.getBase().getStatistic(PLAY_ONE_TICK) * 50);
|
||||
sender.sendMessage(tl("whoisPlaytime", DateUtil.formatDateDiff(playtimeMs)));
|
||||
if (!ess.getSettings().isEcoDisabled()) {
|
||||
sender.sendMessage(tl("whoisMoney", NumberUtil.displayCurrency(user.getMoney(), ess)));
|
||||
@@ -64,8 +63,14 @@ public class Commandwhois extends EssentialsCommand {
|
||||
sender.sendMessage(tl("whoisAFK", tl("false")));
|
||||
}
|
||||
sender.sendMessage(tl("whoisJail", (user.isJailed() ? user.getJailTimeout() > 0 ? DateUtil.formatDateDiff(user.getJailTimeout()) : tl("true") : tl("false"))));
|
||||
sender.sendMessage(tl("whoisMuted", (user.isMuted() ? user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : tl("true") : tl("false"))));
|
||||
|
||||
long muteTimeout = user.getMuteTimeout();
|
||||
if (!user.hasMuteReason()) {
|
||||
sender.sendMessage(tl("whoisMuted", (user.isMuted() ? (muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true")) : tl("false"))));
|
||||
} else {
|
||||
sender.sendMessage(tl("whoisMutedReason", (user.isMuted() ? (muteTimeout > 0 ? DateUtil.formatDateDiff(muteTimeout) : tl("true")) : tl("false")),
|
||||
user.getMuteReason()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -104,7 +104,11 @@ public abstract class EssentialsCommand implements IEssentialsCommand {
|
||||
try {
|
||||
exPlayer = server.getPlayer(UUID.fromString(searchTerm));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
exPlayer = server.getPlayer(searchTerm);
|
||||
if (getOffline) {
|
||||
exPlayer = server.getPlayerExact(searchTerm);
|
||||
} else {
|
||||
exPlayer = server.getPlayer(searchTerm);
|
||||
}
|
||||
}
|
||||
|
||||
if (exPlayer != null) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.CommandSource;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import net.ess3.api.MaxMoneyException;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -23,7 +24,11 @@ public abstract class EssentialsLoopCommand extends EssentialsCommand {
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
|
||||
if (matchWildcards && searchTerm.contentEquals("**")) {
|
||||
final UUID uuid = StringUtil.toUUID(searchTerm);
|
||||
if (uuid != null) {
|
||||
final User matchedUser = ess.getUser(uuid);
|
||||
updatePlayer(server, sender, matchedUser, commandArgs);
|
||||
} else if (matchWildcards && searchTerm.contentEquals("**")) {
|
||||
for (UUID sUser : ess.getUserMap().getAllUniqueUsers()) {
|
||||
final User matchedUser = ess.getUser(sUser);
|
||||
updatePlayer(server, sender, matchedUser, commandArgs);
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.bukkit.util.Vector;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
@@ -112,7 +113,7 @@ public class FakeWorld implements World {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
//@Override
|
||||
public boolean unloadChunk(int i, int i1, boolean bln, boolean bln1) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
@@ -122,7 +123,7 @@ public class FakeWorld implements World {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
//@Override
|
||||
public boolean unloadChunkRequest(int i, int i1, boolean bln) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
@@ -137,6 +138,46 @@ public class FakeWorld implements World {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkForceLoaded(int x, int z) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChunkForceLoaded(int x, int z, boolean forced) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Chunk> getForceLoadedChunks() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPluginChunkTicket(int i, int i1, Plugin plugin) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePluginChunkTicket(int i, int i1, Plugin plugin) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePluginChunkTickets(Plugin plugin) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Plugin> getPluginChunkTickets(int i, int i1) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Plugin, Collection<Chunk>> getPluginChunkTickets() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item dropItem(Location lctn, ItemStack is) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
@@ -153,7 +194,7 @@ public class FakeWorld implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Arrow> T spawnArrow(Location location, Vector vector, float v, float v1, Class<T> aClass) {
|
||||
public <T extends AbstractArrow> T spawnArrow(Location location, Vector direction, float speed, float spread, Class<T> clazz) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@@ -164,7 +205,7 @@ public class FakeWorld implements World {
|
||||
|
||||
@Override
|
||||
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
|
||||
return false;
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -336,6 +377,21 @@ public class FakeWorld implements World {
|
||||
public boolean createExplosion(Location lctn, float f, boolean bln) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createExplosion(double d, double d1, double d2, float f, boolean bln, boolean bln1, Entity entity) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createExplosion(Location lctn, float f, boolean bln, boolean bln1) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createExplosion(Location lctn, float f, boolean bln, boolean bln1, Entity entity) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Entity> T spawn(Location lctn, Class<T> type) throws IllegalArgumentException {
|
||||
@@ -392,21 +448,56 @@ public class FakeWorld implements World {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHighestBlockYAt(int i, int i1, HeightMap heightMap) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHighestBlockYAt(Location location, HeightMap heightMap) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getHighestBlockAt(int i, int i1, HeightMap heightMap) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getHighestBlockAt(Location location, HeightMap heightMap) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int i, int i1) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int i, int i1, int i2) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTemperature(int i, int i1) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTemperature(int i, int i1, int i2) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHumidity(int i, int i1) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHumidity(int i, int i1, int i2) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unloadChunk(Chunk chunk) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
@@ -482,6 +573,16 @@ public class FakeWorld implements World {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHardcore() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHardcore(boolean hardcore) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTicksPerAnimalSpawns() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
@@ -547,6 +648,11 @@ public class FakeWorld implements World {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int i, int i1, int i2, Biome biome) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMonsterSpawnLimit() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
@@ -727,6 +833,16 @@ public class FakeWorld implements World {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Raid locateNearestRaid(Location location, int radius) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Raid> getRaids() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Entity> getNearbyEntities(Location loc, double x, double y, double z) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
|
||||
@@ -2,32 +2,111 @@ package com.earth2me.essentials.items;
|
||||
|
||||
import com.earth2me.essentials.IConf;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import com.earth2me.essentials.utils.VersionUtil;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.PluginKey;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Banner;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.*;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public abstract class AbstractItemDb implements IConf, net.ess3.api.IItemDb {
|
||||
|
||||
protected final IEssentials ess;
|
||||
protected boolean ready = false;
|
||||
|
||||
private Map<PluginKey, ItemResolver> resolverMap = new HashMap<>();
|
||||
|
||||
AbstractItemDb(IEssentials ess) {
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack get(final String id, final int quantity) throws Exception {
|
||||
final ItemStack retval = get(id.toLowerCase(Locale.ENGLISH));
|
||||
retval.setAmount(quantity);
|
||||
return retval;
|
||||
public void registerResolver(Plugin plugin, String name, ItemResolver resolver) throws Exception {
|
||||
PluginKey key = PluginKey.fromKey(plugin, name);
|
||||
if (resolverMap.containsKey(key)) {
|
||||
throw new Exception("Tried to add a duplicate resolver with name " + key.toString());
|
||||
}
|
||||
|
||||
resolverMap.put(key, resolver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterResolver(Plugin plugin, String name) throws Exception {
|
||||
PluginKey key = PluginKey.fromKey(plugin, name);
|
||||
if (!resolverMap.containsKey(key)) {
|
||||
throw new Exception("Tried to remove nonexistent resolver with name " + key.toString());
|
||||
}
|
||||
|
||||
resolverMap.remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResolverPresent(Plugin plugin, String name) {
|
||||
return resolverMap.containsKey(PluginKey.fromKey(plugin, name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<PluginKey, ItemResolver> getResolvers() {
|
||||
return new HashMap<>(resolverMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<PluginKey, ItemResolver> getResolvers(Plugin plugin) {
|
||||
Map<PluginKey, ItemResolver> matchingResolvers = new HashMap<>();
|
||||
for (PluginKey key : resolverMap.keySet()) {
|
||||
if (key.getPlugin().equals(plugin)) {
|
||||
matchingResolvers.put(key, resolverMap.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
return matchingResolvers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemResolver getResolver(Plugin plugin, String name) {
|
||||
return resolverMap.get(PluginKey.fromKey(plugin, name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack get(String id) throws Exception {
|
||||
return get(id, true);
|
||||
}
|
||||
|
||||
ItemStack tryResolvers(String id) {
|
||||
for (PluginKey key : resolverMap.keySet()) {
|
||||
if (ess.getSettings().isDebug()) {
|
||||
ess.getLogger().info(String.format("Trying resolver '%s' for item '%s'...", key, id));
|
||||
}
|
||||
|
||||
Function<String, ItemStack> resolver = resolverMap.get(key);
|
||||
ItemStack stack = resolver.apply(id);
|
||||
|
||||
if (stack != null) {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Collection<String> getResolverNames() {
|
||||
return resolverMap.values().stream()
|
||||
.map(ItemResolver::getNames)
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,20 +142,10 @@ public abstract class AbstractItemDb implements IConf, net.ess3.api.IItemDb {
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String names(ItemStack item) {
|
||||
List<String> nameList = nameList(item);
|
||||
|
||||
if (nameList.size() > 15) {
|
||||
nameList = nameList.subList(0, 14);
|
||||
}
|
||||
return StringUtil.joinList(", ", nameList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize(ItemStack is) {
|
||||
String mat = is.getType().name();
|
||||
if (is.getData().getData() != 0) {
|
||||
String mat = name(is);
|
||||
if (VersionUtil.getServerBukkitVersion().isLowerThanOrEqualTo(VersionUtil.v1_12_2_R01) && is.getData().getData() != 0) {
|
||||
mat = mat + ":" + is.getData().getData();
|
||||
}
|
||||
int quantity = is.getAmount();
|
||||
@@ -125,7 +194,9 @@ public abstract class AbstractItemDb implements IConf, net.ess3.api.IItemDb {
|
||||
}
|
||||
}
|
||||
|
||||
switch (is.getType()) {
|
||||
final Material material = is.getType();
|
||||
|
||||
switch (material) {
|
||||
case WRITTEN_BOOK:
|
||||
// Everything from http://wiki.ess3.net/wiki/Item_Meta#Books in that order.
|
||||
// Interesting as I didn't see a way to do pages or chapters.
|
||||
@@ -144,106 +215,100 @@ public abstract class AbstractItemDb implements IConf, net.ess3.api.IItemDb {
|
||||
sb.append(e.getName().toLowerCase()).append(":").append(enchantmentStorageMeta.getStoredEnchantLevel(e)).append(" ");
|
||||
}
|
||||
break;
|
||||
case FIREWORK_ROCKET:
|
||||
case FIREWORK_STAR:
|
||||
// Everything from http://wiki.ess3.net/wiki/Item_Meta#Fireworks in that order.
|
||||
FireworkMeta fireworkMeta = (FireworkMeta) is.getItemMeta();
|
||||
if (fireworkMeta.hasEffects()) {
|
||||
for (FireworkEffect effect : fireworkMeta.getEffects()) {
|
||||
if (effect.getColors() != null && !effect.getColors().isEmpty()) {
|
||||
sb.append("color:");
|
||||
boolean first = true;
|
||||
for (Color c : effect.getColors()) {
|
||||
if (!first) {
|
||||
sb.append(","); // same thing as above.
|
||||
}
|
||||
sb.append(c.toString());
|
||||
first = false;
|
||||
}
|
||||
sb.append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
sb.append("shape: ").append(effect.getType().name()).append(" ");
|
||||
if (effect.getFadeColors() != null && !effect.getFadeColors().isEmpty()) {
|
||||
sb.append("fade:");
|
||||
boolean first = true;
|
||||
for (Color c : effect.getFadeColors()) {
|
||||
if (!first) {
|
||||
sb.append(","); // same thing as above.
|
||||
}
|
||||
sb.append(c.toString());
|
||||
first = false;
|
||||
if (MaterialUtil.isFirework(material)) {
|
||||
// Everything from http://wiki.ess3.net/wiki/Item_Meta#Fireworks in that order.
|
||||
FireworkMeta fireworkMeta = (FireworkMeta) is.getItemMeta();
|
||||
if (fireworkMeta.hasEffects()) {
|
||||
for (FireworkEffect effect : fireworkMeta.getEffects()) {
|
||||
if (effect.getColors() != null && !effect.getColors().isEmpty()) {
|
||||
sb.append("color:");
|
||||
boolean first = true;
|
||||
for (Color c : effect.getColors()) {
|
||||
if (!first) {
|
||||
sb.append(","); // same thing as above.
|
||||
}
|
||||
sb.append(" ");
|
||||
sb.append(c.toString());
|
||||
first = false;
|
||||
}
|
||||
sb.append(" ");
|
||||
}
|
||||
|
||||
sb.append("shape:").append(effect.getType().name()).append(" ");
|
||||
if (effect.getFadeColors() != null && !effect.getFadeColors().isEmpty()) {
|
||||
sb.append("fade:");
|
||||
boolean first = true;
|
||||
for (Color c : effect.getFadeColors()) {
|
||||
if (!first) {
|
||||
sb.append(","); // same thing as above.
|
||||
}
|
||||
sb.append(c.toString());
|
||||
first = false;
|
||||
}
|
||||
sb.append(" ");
|
||||
}
|
||||
sb.append("power: ").append(fireworkMeta.getPower()).append(" ");
|
||||
}
|
||||
break;
|
||||
case POTION:
|
||||
Potion potion = Potion.fromItemStack(is);
|
||||
for (PotionEffect e : potion.getEffects()) {
|
||||
// long but needs to be effect:speed power:2 duration:120 in that order.
|
||||
sb.append("splash:").append(potion.isSplash()).append(" ").append("effect:").append(e.getType().getName().toLowerCase()).append(" ").append("power:").append(e.getAmplifier()).append(" ").append("duration:").append(e.getDuration() / 20).append(" ");
|
||||
sb.append("power:").append(fireworkMeta.getPower()).append(" ");
|
||||
}
|
||||
} else if (MaterialUtil.isPotion(material)) {
|
||||
Potion potion = Potion.fromItemStack(is);
|
||||
for (PotionEffect e : potion.getEffects()) {
|
||||
// long but needs to be effect:speed power:2 duration:120 in that order.
|
||||
sb.append("splash:").append(potion.isSplash()).append(" ").append("effect:").append(e.getType().getName().toLowerCase()).append(" ").append("power:").append(e.getAmplifier()).append(" ").append("duration:").append(e.getDuration() / 20).append(" ");
|
||||
}
|
||||
} else if (MaterialUtil.isPlayerHead(material, is.getData().getData())) {
|
||||
// item stack with meta
|
||||
SkullMeta skullMeta = (SkullMeta) is.getItemMeta();
|
||||
if (skullMeta != null && skullMeta.hasOwner()) {
|
||||
sb.append("player:").append(skullMeta.getOwner()).append(" ");
|
||||
}
|
||||
} else if (MaterialUtil.isBanner(material)) {
|
||||
if (material.toString().contains("SHIELD")) {
|
||||
// Hacky fix for accessing Shield meta - https://github.com/drtshock/Essentials/pull/745#issuecomment-234843795
|
||||
BlockStateMeta shieldMeta = (BlockStateMeta) is.getItemMeta();
|
||||
Banner shieldBannerMeta = (Banner) shieldMeta.getBlockState();
|
||||
DyeColor baseDyeColor = shieldBannerMeta.getBaseColor();
|
||||
if (baseDyeColor != null) {
|
||||
int basecolor = baseDyeColor.getColor().asRGB();
|
||||
sb.append("basecolor:").append(basecolor).append(" ");
|
||||
}
|
||||
break;
|
||||
case SKELETON_SKULL:
|
||||
case WITHER_SKELETON_SKULL:
|
||||
// item stack with meta
|
||||
SkullMeta skullMeta = (SkullMeta) is.getItemMeta();
|
||||
if (skullMeta != null && skullMeta.hasOwner()) {
|
||||
sb.append("player:").append(skullMeta.getOwner()).append(" ");
|
||||
for (org.bukkit.block.banner.Pattern p : shieldBannerMeta.getPatterns()) {
|
||||
String type = p.getPattern().getIdentifier();
|
||||
int color = p.getColor().getColor().asRGB();
|
||||
sb.append(type).append(",").append(color).append(" ");
|
||||
}
|
||||
break;
|
||||
case LEATHER_HELMET:
|
||||
case LEATHER_CHESTPLATE:
|
||||
case LEATHER_LEGGINGS:
|
||||
case LEATHER_BOOTS:
|
||||
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) is.getItemMeta();
|
||||
int rgb = leatherArmorMeta.getColor().asRGB();
|
||||
sb.append("color:").append(rgb).append(" ");
|
||||
break;
|
||||
case BLACK_BANNER:
|
||||
case BLUE_BANNER:
|
||||
case BROWN_BANNER:
|
||||
case CYAN_BANNER:
|
||||
case GRAY_BANNER:
|
||||
case GREEN_BANNER:
|
||||
case LIGHT_BLUE_BANNER:
|
||||
case LIGHT_GRAY_BANNER:
|
||||
case LIME_BANNER:
|
||||
case MAGENTA_BANNER:
|
||||
case ORANGE_BANNER:
|
||||
case PINK_BANNER:
|
||||
case PURPLE_BANNER:
|
||||
case RED_BANNER:
|
||||
case WHITE_BANNER:
|
||||
case YELLOW_BANNER:
|
||||
} else {
|
||||
BannerMeta bannerMeta = (BannerMeta) is.getItemMeta();
|
||||
if (bannerMeta != null) {
|
||||
int basecolor = bannerMeta.getBaseColor().getColor().asRGB();
|
||||
sb.append("basecolor:").append(basecolor).append(" ");
|
||||
DyeColor baseDyeColor = bannerMeta.getBaseColor();
|
||||
if (baseDyeColor == null) {
|
||||
baseDyeColor = MaterialUtil.getColorOf(material);
|
||||
}
|
||||
if (baseDyeColor != null) {
|
||||
int basecolor = baseDyeColor
|
||||
.getColor()
|
||||
.asRGB();
|
||||
sb.append("basecolor:").append(basecolor).append(" ");
|
||||
}
|
||||
for (org.bukkit.block.banner.Pattern p : bannerMeta.getPatterns()) {
|
||||
String type = p.getPattern().getIdentifier();
|
||||
int color = p.getColor().getColor().asRGB();
|
||||
sb.append(type).append(",").append(color).append(" ");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SHIELD:
|
||||
// Hacky fix for accessing Shield meta - https://github.com/drtshock/Essentials/pull/745#issuecomment-234843795
|
||||
BlockStateMeta shieldMeta = (BlockStateMeta) is.getItemMeta();
|
||||
Banner shieldBannerMeta = (Banner) shieldMeta.getBlockState();
|
||||
int basecolor = shieldBannerMeta.getBaseColor().getColor().asRGB();
|
||||
sb.append("basecolor:").append(basecolor).append(" ");
|
||||
for (org.bukkit.block.banner.Pattern p : shieldBannerMeta.getPatterns()) {
|
||||
String type = p.getPattern().getIdentifier();
|
||||
int color = p.getColor().getColor().asRGB();
|
||||
sb.append(type).append(",").append(color).append(" ");
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (MaterialUtil.isLeatherArmor(material)) {
|
||||
LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) is.getItemMeta();
|
||||
int rgb = leatherArmorMeta.getColor().asRGB();
|
||||
sb.append("color:").append(rgb).append(" ");
|
||||
}
|
||||
|
||||
return sb.toString().trim().replaceAll("§", "&");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return ready;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.earth2me.essentials.items;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.EssentialsConf;
|
||||
import com.earth2me.essentials.IConf;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import net.ess3.api.IItemDb;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CustomItemResolver implements IItemDb.ItemResolver, IConf {
|
||||
private final EssentialsConf config;
|
||||
private final Essentials ess;
|
||||
private final HashMap<String, String> map = new HashMap<>();
|
||||
|
||||
public CustomItemResolver(Essentials ess) {
|
||||
config = new EssentialsConf(new File(ess.getDataFolder(), "custom_items.yml"));
|
||||
this.ess = ess;
|
||||
config.setTemplateName("/custom_items.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack apply(String item) {
|
||||
if (map.containsKey(item)) {
|
||||
try {
|
||||
return ess.getItemDb().get(map.get(item));
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getNames() {
|
||||
return map.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
map.clear();
|
||||
config.load();
|
||||
|
||||
ConfigurationSection section = config.getConfigurationSection("aliases");
|
||||
if (section == null || section.getKeys(false).isEmpty()) {
|
||||
ess.getLogger().warning("No aliases found in custom_items.yml.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (String alias : section.getKeys(false)) {
|
||||
if (!section.isString(alias)) continue;
|
||||
String target = section.getString(alias);
|
||||
|
||||
if (target != null && !section.contains(target) && existsInItemDb(target)) {
|
||||
map.put(alias, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setAlias(String alias, String target) {
|
||||
if (map.containsKey(alias) && map.get(alias).equalsIgnoreCase(target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
map.put(alias, target);
|
||||
save();
|
||||
}
|
||||
|
||||
public void removeAlias(String alias) {
|
||||
if (map.remove(alias) != null) {
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
private void save() {
|
||||
config.setProperty("aliases", map);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private boolean existsInItemDb(String item) {
|
||||
try {
|
||||
ess.getItemDb().get(item);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,19 @@
|
||||
package com.earth2me.essentials.items;
|
||||
|
||||
import com.earth2me.essentials.ManagedFile;
|
||||
import com.earth2me.essentials.utils.EnumUtil;
|
||||
import com.earth2me.essentials.utils.MaterialUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.inventory.meta.Repairable;
|
||||
import org.bukkit.potion.PotionData;
|
||||
|
||||
import java.util.*;
|
||||
@@ -23,8 +25,6 @@ import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class FlatItemDb extends AbstractItemDb {
|
||||
protected static final Logger LOGGER = Logger.getLogger("Essentials");
|
||||
private final transient IEssentials ess;
|
||||
|
||||
private static Gson gson = new Gson();
|
||||
|
||||
// Maps primary name to ItemData
|
||||
@@ -39,7 +39,7 @@ public class FlatItemDb extends AbstractItemDb {
|
||||
private transient ManagedFile file = null;
|
||||
|
||||
public FlatItemDb(final IEssentials ess) {
|
||||
this.ess = ess;
|
||||
super(ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,19 +56,22 @@ public class FlatItemDb extends AbstractItemDb {
|
||||
this.reset();
|
||||
|
||||
String json = file.getLines().stream()
|
||||
.filter(line -> !line.startsWith("#"))
|
||||
.collect(Collectors.joining());
|
||||
|
||||
.filter(line -> !line.startsWith("#"))
|
||||
.collect(Collectors.joining());
|
||||
|
||||
this.loadJSON(String.join("\n", json));
|
||||
|
||||
ready = true;
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
ready = false;
|
||||
items.clear();
|
||||
itemAliases.clear();
|
||||
allAliases.clear();
|
||||
}
|
||||
|
||||
public void loadJSON(String source) {
|
||||
private void loadJSON(String source) {
|
||||
JsonObject map = (new JsonParser()).parse(source).getAsJsonObject();
|
||||
|
||||
for (Map.Entry<String, JsonElement> entry : map.entrySet()) {
|
||||
@@ -97,7 +100,15 @@ public class FlatItemDb extends AbstractItemDb {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack get(final String id) throws Exception {
|
||||
public ItemStack get(String id, boolean useResolvers) throws Exception {
|
||||
if (useResolvers) {
|
||||
ItemStack resolved = tryResolvers(id);
|
||||
if (resolved != null) {
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
|
||||
id = id.toLowerCase();
|
||||
final String[] split = id.split(":");
|
||||
|
||||
ItemData data = getByName(split[0]);
|
||||
@@ -106,12 +117,14 @@ public class FlatItemDb extends AbstractItemDb {
|
||||
throw new Exception(tl("unknownItemName", id));
|
||||
}
|
||||
|
||||
PotionData potionData = data.getPotionData();
|
||||
Material material = data.getMaterial();
|
||||
|
||||
if (!material.isItem()) throw new Exception(tl("unableToSpawnItem", id));
|
||||
|
||||
ItemStack stack = new ItemStack(material);
|
||||
stack.setAmount(material.getMaxStackSize());
|
||||
|
||||
PotionData potionData = data.getPotionData();
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
|
||||
if (potionData != null && meta instanceof PotionMeta) {
|
||||
@@ -128,6 +141,13 @@ public class FlatItemDb extends AbstractItemDb {
|
||||
|
||||
stack.setItemMeta(meta);
|
||||
|
||||
// The spawner provider will update the meta again, so we need to call it after
|
||||
// setItemMeta to prevent a race condition
|
||||
EntityType entity = data.getEntity();
|
||||
if (entity != null && material.toString().contains("SPAWNER")) {
|
||||
ess.getSpawnerProvider().setEntityType(stack, entity);
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@@ -159,14 +179,7 @@ public class FlatItemDb extends AbstractItemDb {
|
||||
|
||||
@Override
|
||||
public String name(ItemStack item) {
|
||||
Material type = item.getType();
|
||||
PotionData potion = null;
|
||||
|
||||
if ((type.name().contains("POTION") || type.name().equals("TIPPED_ARROW")) && item.getItemMeta() instanceof PotionMeta) {
|
||||
potion = ((PotionMeta) item.getItemMeta()).getBasePotionData();
|
||||
}
|
||||
|
||||
ItemData data = new ItemData(type, potion);
|
||||
ItemData data = lookup(item);
|
||||
|
||||
for (Map.Entry<String, ItemData> entry : items.entrySet()) {
|
||||
if (entry.getValue().equals(data)) {
|
||||
@@ -179,31 +192,51 @@ public class FlatItemDb extends AbstractItemDb {
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Material getFromLegacyId(int id) {
|
||||
throw new UnsupportedOperationException("Legacy IDs aren't supported on this version of EssentialsX.");
|
||||
public int getLegacyId(Material material) {
|
||||
throw new UnsupportedOperationException("Legacy IDs aren't supported on this version.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getLegacyId(Material material) throws Exception {
|
||||
throw new UnsupportedOperationException("Legacy IDs aren't supported on this version of EssentialsX.");
|
||||
private ItemData lookup(ItemStack item) {
|
||||
Material type = item.getType();
|
||||
|
||||
if (MaterialUtil.isPotion(type) && item.getItemMeta() instanceof PotionMeta) {
|
||||
PotionData potion = ((PotionMeta) item.getItemMeta()).getBasePotionData();
|
||||
return new ItemData(type, potion);
|
||||
} else if (type.toString().contains("SPAWNER")) {
|
||||
EntityType entity = ess.getSpawnerProvider().getEntityType(item);
|
||||
return new ItemData(type, entity);
|
||||
} else {
|
||||
return new ItemData(type);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> listNames() {
|
||||
return Collections.unmodifiableSet(allAliases);
|
||||
Set<String> names = new HashSet<>(allAliases);
|
||||
names.addAll(getResolverNames());
|
||||
return names;
|
||||
}
|
||||
|
||||
public static class ItemData {
|
||||
private String itemName;
|
||||
private Material material;
|
||||
private PotionData potionData;
|
||||
private String[] fallbacks = null;
|
||||
private PotionData potionData = null;
|
||||
private EntityType entity = null;
|
||||
|
||||
public ItemData(Material material, PotionData potionData) {
|
||||
ItemData(Material material) {
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
ItemData(Material material, PotionData potionData) {
|
||||
this.material = material;
|
||||
this.potionData = potionData;
|
||||
}
|
||||
|
||||
ItemData(Material material, EntityType entity) {
|
||||
this.material = material;
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (31 * material.hashCode()) ^ potionData.hashCode();
|
||||
@@ -218,14 +251,15 @@ public class FlatItemDb extends AbstractItemDb {
|
||||
return false;
|
||||
}
|
||||
ItemData that = (ItemData) o;
|
||||
return this.material == that.getMaterial() && potionDataEquals(that);
|
||||
}
|
||||
|
||||
public String getItemName() {
|
||||
return itemName;
|
||||
return this.getMaterial() == that.getMaterial() && potionDataEquals(that) && entityEquals(that);
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
if (material == null && fallbacks != null) {
|
||||
material = EnumUtil.getMaterial(fallbacks);
|
||||
fallbacks = null; // If fallback fails, don't keep trying to look up fallbacks
|
||||
}
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
@@ -233,6 +267,10 @@ public class FlatItemDb extends AbstractItemDb {
|
||||
return this.potionData;
|
||||
}
|
||||
|
||||
public EntityType getEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
private boolean potionDataEquals(ItemData o) {
|
||||
if (this.potionData == null && o.getPotionData() == null) {
|
||||
return true;
|
||||
@@ -242,5 +280,15 @@ public class FlatItemDb extends AbstractItemDb {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean entityEquals(ItemData o) {
|
||||
if (this.entity == null && o.getEntity() == null) { // neither have an entity
|
||||
return true;
|
||||
} else if (this.entity != null && o.getEntity() != null) { // both have an entity; check if it's the same one
|
||||
return this.entity.equals(o.getEntity());
|
||||
} else { // one has an entity but the other doesn't, so they can't be equal
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class LegacyItemDb extends AbstractItemDb {
|
||||
protected static final Logger LOGGER = Logger.getLogger("Essentials");
|
||||
private final transient IEssentials ess;
|
||||
private final transient Map<String, Integer> items = new HashMap<>();
|
||||
private final transient Map<ItemData, List<String>> names = new HashMap<>();
|
||||
private final transient Map<ItemData, String> primaryName = new HashMap<>();
|
||||
@@ -32,7 +31,7 @@ public class LegacyItemDb extends AbstractItemDb {
|
||||
private final transient Pattern csvSplitPattern = Pattern.compile("(\"([^\"]*)\"|[^,]*)(,|$)");
|
||||
|
||||
public LegacyItemDb(final IEssentials ess) {
|
||||
this.ess = ess;
|
||||
super(ess);
|
||||
file = new ManagedFile("items.csv", ess);
|
||||
}
|
||||
|
||||
@@ -44,6 +43,7 @@ public class LegacyItemDb extends AbstractItemDb {
|
||||
return;
|
||||
}
|
||||
|
||||
ready = false;
|
||||
durabilities.clear();
|
||||
items.clear();
|
||||
names.clear();
|
||||
@@ -90,18 +90,13 @@ public class LegacyItemDb extends AbstractItemDb {
|
||||
continue;
|
||||
}
|
||||
|
||||
Material material = Material.matchMaterial(itemName);
|
||||
if (material == null) {
|
||||
LOGGER.warning(String.format("Failed to find material for %s", itemName));
|
||||
continue;
|
||||
}
|
||||
durabilities.put(itemName, data);
|
||||
items.put(itemName, numeric);
|
||||
if (nbt != null) {
|
||||
nbtData.put(itemName, nbt);
|
||||
}
|
||||
|
||||
ItemData itemData = new ItemData(material, numeric, data);
|
||||
ItemData itemData = new ItemData(numeric, data);
|
||||
if (names.containsKey(itemData)) {
|
||||
List<String> nameList = names.get(itemData);
|
||||
nameList.add(itemName);
|
||||
@@ -120,10 +115,19 @@ public class LegacyItemDb extends AbstractItemDb {
|
||||
}
|
||||
|
||||
LOGGER.info(String.format("Loaded %s items from items.csv.", listNames().size()));
|
||||
|
||||
ready = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack get(final String id) throws Exception {
|
||||
public ItemStack get(final String id, final boolean useResolvers) throws Exception {
|
||||
if (useResolvers) {
|
||||
ItemStack resolved = tryResolvers(id);
|
||||
if (resolved != null) {
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
|
||||
int itemid = 0;
|
||||
String itemname;
|
||||
short metaData = 0;
|
||||
@@ -152,6 +156,13 @@ public class LegacyItemDb extends AbstractItemDb {
|
||||
}
|
||||
}
|
||||
|
||||
if (itemid < 1) {
|
||||
Material matFromName = EnumUtil.getMaterial(itemname.toUpperCase());
|
||||
if (matFromName != null) {
|
||||
itemid = matFromName.getId();
|
||||
}
|
||||
}
|
||||
|
||||
if (itemid < 1) {
|
||||
throw new Exception(tl("unknownItemName", itemname));
|
||||
}
|
||||
@@ -161,7 +172,7 @@ public class LegacyItemDb extends AbstractItemDb {
|
||||
throw new Exception(tl("unknownItemId", itemid));
|
||||
}
|
||||
|
||||
Material mat = data.getMaterial();
|
||||
Material mat = getFromLegacy(itemid, (byte) metaData);
|
||||
ItemStack retval = new ItemStack(mat);
|
||||
if (nbtData.containsKey(itemname)) {
|
||||
String nbt = nbtData.get(itemname);
|
||||
@@ -198,10 +209,10 @@ public class LegacyItemDb extends AbstractItemDb {
|
||||
|
||||
@Override
|
||||
public List<String> nameList(ItemStack item) {
|
||||
ItemData itemData = new ItemData(item.getType(), item.getDurability());
|
||||
ItemData itemData = new ItemData(item.getType().getId(), item.getDurability());
|
||||
List<String> nameList = names.get(itemData);
|
||||
if (nameList == null) {
|
||||
itemData = new ItemData(item.getType(), (short) 0);
|
||||
itemData = new ItemData(item.getType().getId(), (short) 0);
|
||||
nameList = names.get(itemData);
|
||||
if (nameList == null) {
|
||||
return null;
|
||||
@@ -213,10 +224,10 @@ public class LegacyItemDb extends AbstractItemDb {
|
||||
|
||||
@Override
|
||||
public String name(ItemStack item) {
|
||||
ItemData itemData = new ItemData(item.getType(), item.getDurability());
|
||||
ItemData itemData = new ItemData(item.getType().getId(), item.getDurability());
|
||||
String name = primaryName.get(itemData);
|
||||
if (name == null) {
|
||||
itemData = new ItemData(item.getType(), (short) 0);
|
||||
itemData = new ItemData(item.getType().getId(), (short) 0);
|
||||
name = primaryName.get(itemData);
|
||||
if (name == null) {
|
||||
return null;
|
||||
@@ -225,16 +236,6 @@ public class LegacyItemDb extends AbstractItemDb {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getFromLegacyId(int id) {
|
||||
ItemData data = this.legacyIds.get(id);
|
||||
if(data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return data.getMaterial();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLegacyId(Material material) throws Exception {
|
||||
for(Map.Entry<String, Integer> entry : items.entrySet()) {
|
||||
@@ -248,33 +249,22 @@ public class LegacyItemDb extends AbstractItemDb {
|
||||
|
||||
@Override
|
||||
public Collection<String> listNames() {
|
||||
return primaryName.values();
|
||||
Collection<String> values = new ArrayList<>(primaryName.values());
|
||||
values.addAll(getResolverNames());
|
||||
return values;
|
||||
}
|
||||
|
||||
static class ItemData {
|
||||
final private Material material;
|
||||
private int legacyId;
|
||||
private int itemNo;
|
||||
final private short itemData;
|
||||
|
||||
ItemData(Material material, short itemData) {
|
||||
this.material = material;
|
||||
ItemData(final int itemNo, final short itemData) {
|
||||
this.itemNo = itemNo;
|
||||
this.itemData = itemData;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
ItemData(Material material, final int legacyId, final short itemData) {
|
||||
this.material = material;
|
||||
this.legacyId = legacyId;
|
||||
this.itemData = itemData;
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getItemNo() {
|
||||
return legacyId;
|
||||
return itemNo;
|
||||
}
|
||||
|
||||
public short getItemData() {
|
||||
@@ -283,7 +273,7 @@ public class LegacyItemDb extends AbstractItemDb {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (31 * material.hashCode()) ^ itemData;
|
||||
return (31 * itemNo) ^ itemData;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -295,7 +285,7 @@ public class LegacyItemDb extends AbstractItemDb {
|
||||
return false;
|
||||
}
|
||||
ItemData pairo = (ItemData) o;
|
||||
return this.material == pairo.getMaterial() && this.itemData == pairo.getItemData();
|
||||
return this.itemNo == pairo.getItemNo() && this.itemData == pairo.getItemData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package com.earth2me.essentials.messaging;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.IUser;
|
||||
import com.earth2me.essentials.User;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
/**
|
||||
* Represents a simple reusable implementation of {@link IMessageRecipient}. This class provides functionality for the following methods:
|
||||
* <ul>
|
||||
@@ -120,11 +119,13 @@ public class SimpleMessageRecipient implements IMessageRecipient {
|
||||
|
||||
User user = getUser(this);
|
||||
boolean afk = false;
|
||||
boolean isLastMessageReplyRecipient = ess.getSettings().isLastMessageReplyRecipient();
|
||||
if (user != null) {
|
||||
if (user.isIgnoreMsg() && sender instanceof IUser && !((IUser) sender).isAuthorized("essentials.msgtoggle.bypass")) { // Don't ignore console and senders with permission
|
||||
return MessageResponse.MESSAGES_IGNORED;
|
||||
if (user.isIgnoreMsg() && sender instanceof IUser && !((IUser) sender).isAuthorized("essentials.msgtoggle.bypass")) { // Don't ignore console and senders with permission
|
||||
return MessageResponse.MESSAGES_IGNORED;
|
||||
}
|
||||
afk = user.isAfk();
|
||||
isLastMessageReplyRecipient = user.isLastMessageReplyRecipient();
|
||||
// Check whether this recipient ignores the sender, only if the sender is not the console.
|
||||
if (sender instanceof IUser && user.isIgnoredPlayer((IUser) sender)) {
|
||||
return MessageResponse.SENDER_IGNORED;
|
||||
@@ -133,7 +134,7 @@ public class SimpleMessageRecipient implements IMessageRecipient {
|
||||
// Display the formatted message to this recipient.
|
||||
sendMessage(tl("msgFormat", sender.getDisplayName(), tl("me"), message));
|
||||
|
||||
if (ess.getSettings().isLastMessageReplyRecipient()) {
|
||||
if (isLastMessageReplyRecipient) {
|
||||
// If this recipient doesn't have a reply recipient, initiate by setting the first
|
||||
// message sender to this recipient's replyRecipient.
|
||||
long timeout = ess.getSettings().getLastMessageReplyRecipientTimeout() * 1000;
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package com.earth2me.essentials.metrics;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.*;
|
||||
@@ -186,24 +187,24 @@ public class Metrics {
|
||||
*
|
||||
* @return The plugin specific data.
|
||||
*/
|
||||
public JSONObject getPluginData() {
|
||||
JSONObject data = new JSONObject();
|
||||
public JsonObject getPluginData() {
|
||||
JsonObject data = new JsonObject();
|
||||
|
||||
String pluginName = "EssentialsX";
|
||||
String pluginName = plugin.getDescription().getName().replace("Essentials", "EssentialsX");
|
||||
String pluginVersion = plugin.getDescription().getVersion();
|
||||
|
||||
data.put("pluginName", pluginName); // Append the name of the plugin
|
||||
data.put("pluginVersion", pluginVersion); // Append the version of the plugin
|
||||
JSONArray customCharts = new JSONArray();
|
||||
data.addProperty("pluginName", pluginName); // Append the name of the plugin
|
||||
data.addProperty("pluginVersion", pluginVersion); // Append the version of the plugin
|
||||
JsonArray customCharts = new JsonArray();
|
||||
for (CustomChart customChart : charts) {
|
||||
// Add the data of the custom charts
|
||||
JSONObject chart = customChart.getRequestJsonObject();
|
||||
JsonObject chart = customChart.getRequestJsonObject();
|
||||
if (chart == null) { // If the chart is null, we skip it
|
||||
continue;
|
||||
}
|
||||
customCharts.add(chart);
|
||||
}
|
||||
data.put("customCharts", customCharts);
|
||||
data.add("customCharts", customCharts);
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -213,7 +214,7 @@ public class Metrics {
|
||||
*
|
||||
* @return The server specific data.
|
||||
*/
|
||||
private JSONObject getServerData() {
|
||||
private JsonObject getServerData() {
|
||||
// Minecraft specific data
|
||||
int playerAmount;
|
||||
try {
|
||||
@@ -228,6 +229,7 @@ public class Metrics {
|
||||
}
|
||||
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
|
||||
String bukkitVersion = Bukkit.getVersion();
|
||||
String bukkitName = Bukkit.getName();
|
||||
|
||||
// OS/Java specific data
|
||||
String javaVersion = System.getProperty("java.version");
|
||||
@@ -236,19 +238,20 @@ public class Metrics {
|
||||
String osVersion = System.getProperty("os.version");
|
||||
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
JsonObject data = new JsonObject();
|
||||
|
||||
data.put("serverUUID", serverUUID);
|
||||
data.addProperty("serverUUID", serverUUID);
|
||||
|
||||
data.put("playerAmount", playerAmount);
|
||||
data.put("onlineMode", onlineMode);
|
||||
data.put("bukkitVersion", bukkitVersion);
|
||||
data.addProperty("playerAmount", playerAmount);
|
||||
data.addProperty("onlineMode", onlineMode);
|
||||
data.addProperty("bukkitVersion", bukkitVersion);
|
||||
data.addProperty("bukkitName", bukkitName);
|
||||
|
||||
data.put("javaVersion", javaVersion);
|
||||
data.put("osName", osName);
|
||||
data.put("osArch", osArch);
|
||||
data.put("osVersion", osVersion);
|
||||
data.put("coreCount", coreCount);
|
||||
data.addProperty("javaVersion", javaVersion);
|
||||
data.addProperty("osName", osName);
|
||||
data.addProperty("osArch", osArch);
|
||||
data.addProperty("osVersion", osVersion);
|
||||
data.addProperty("coreCount", coreCount);
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -257,9 +260,9 @@ public class Metrics {
|
||||
* Collects the data and sends it afterwards.
|
||||
*/
|
||||
private void submitData() {
|
||||
final JSONObject data = getServerData();
|
||||
final JsonObject data = getServerData();
|
||||
|
||||
JSONArray pluginData = new JSONArray();
|
||||
JsonArray pluginData = new JsonArray();
|
||||
// Search for all other bStats Metrics classes to get their plugin data
|
||||
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
||||
try {
|
||||
@@ -267,26 +270,43 @@ public class Metrics {
|
||||
|
||||
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
|
||||
try {
|
||||
pluginData.add(provider.getService().getMethod("getPluginData").invoke(provider.getProvider()));
|
||||
Object plugin = provider.getService().getMethod("getPluginData").invoke(provider.getProvider());
|
||||
if (plugin instanceof JsonObject) {
|
||||
pluginData.add((JsonObject) plugin);
|
||||
} else { // old bstats version compatibility
|
||||
try {
|
||||
Class<?> jsonObjectJsonSimple = Class.forName("org.json.simple.JSONObject");
|
||||
if (plugin.getClass().isAssignableFrom(jsonObjectJsonSimple)) {
|
||||
Method jsonStringGetter = jsonObjectJsonSimple.getDeclaredMethod("toJSONString");
|
||||
jsonStringGetter.setAccessible(true);
|
||||
String jsonString = (String) jsonStringGetter.invoke(plugin);
|
||||
JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject();
|
||||
pluginData.add(object);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
// minecraft version 1.14+
|
||||
if (logFailedRequests) {
|
||||
this.plugin.getLogger().log(Level.SEVERE, "Encountered unexpected exception", e);
|
||||
}
|
||||
continue; // continue looping since we cannot do any other thing.
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { }
|
||||
}
|
||||
} catch (NoSuchFieldException ignored) { }
|
||||
}
|
||||
|
||||
data.put("plugins", pluginData);
|
||||
data.add("plugins", pluginData);
|
||||
|
||||
// Create a new thread for the connection to the bStats server
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// Send the data
|
||||
sendData(plugin, data);
|
||||
} catch (Exception e) {
|
||||
// Something went wrong! :(
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
|
||||
}
|
||||
new Thread(() -> {
|
||||
try {
|
||||
// Send the data
|
||||
sendData(plugin, data);
|
||||
} catch (Exception e) {
|
||||
// Something went wrong! :(
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
@@ -299,7 +319,7 @@ public class Metrics {
|
||||
* @param data The data to send.
|
||||
* @throws Exception If the request failed.
|
||||
*/
|
||||
private static void sendData(Plugin plugin, JSONObject data) throws Exception {
|
||||
private static void sendData(Plugin plugin, JsonObject data) throws Exception {
|
||||
if (data == null) {
|
||||
throw new IllegalArgumentException("Data cannot be null!");
|
||||
}
|
||||
@@ -382,16 +402,16 @@ public class Metrics {
|
||||
this.chartId = chartId;
|
||||
}
|
||||
|
||||
private JSONObject getRequestJsonObject() {
|
||||
JSONObject chart = new JSONObject();
|
||||
chart.put("chartId", chartId);
|
||||
private JsonObject getRequestJsonObject() {
|
||||
JsonObject chart = new JsonObject();
|
||||
chart.addProperty("chartId", chartId);
|
||||
try {
|
||||
JSONObject data = getChartData();
|
||||
JsonObject data = getChartData();
|
||||
if (data == null) {
|
||||
// If the data is null we don't send the chart.
|
||||
return null;
|
||||
}
|
||||
chart.put("data", data);
|
||||
chart.add("data", data);
|
||||
} catch (Throwable t) {
|
||||
if (logFailedRequests) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
|
||||
@@ -401,7 +421,7 @@ public class Metrics {
|
||||
return chart;
|
||||
}
|
||||
|
||||
protected abstract JSONObject getChartData() throws Exception;
|
||||
protected abstract JsonObject getChartData() throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -424,14 +444,14 @@ public class Metrics {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
String value = callable.call();
|
||||
if (value == null || value.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("value", value);
|
||||
data.addProperty("value", value);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -455,9 +475,9 @@ public class Metrics {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject values = new JSONObject();
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
@@ -469,13 +489,13 @@ public class Metrics {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
values.addProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("values", values);
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -499,9 +519,9 @@ public class Metrics {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject values = new JSONObject();
|
||||
public JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Map<String, Integer>> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
@@ -509,22 +529,22 @@ public class Metrics {
|
||||
}
|
||||
boolean reallyAllSkipped = true;
|
||||
for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
|
||||
JSONObject value = new JSONObject();
|
||||
JsonObject value = new JsonObject();
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
|
||||
value.put(valueEntry.getKey(), valueEntry.getValue());
|
||||
value.addProperty(valueEntry.getKey(), valueEntry.getValue());
|
||||
allSkipped = false;
|
||||
}
|
||||
if (!allSkipped) {
|
||||
reallyAllSkipped = false;
|
||||
values.put(entryValues.getKey(), value);
|
||||
values.add(entryValues.getKey(), value);
|
||||
}
|
||||
}
|
||||
if (reallyAllSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("values", values);
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -548,14 +568,14 @@ public class Metrics {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
int value = callable.call();
|
||||
if (value == 0) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("value", value);
|
||||
data.addProperty("value", value);
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -580,9 +600,9 @@ public class Metrics {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject values = new JSONObject();
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
@@ -594,13 +614,13 @@ public class Metrics {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
values.addProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("values", values);
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -625,20 +645,20 @@ public class Metrics {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject values = new JSONObject();
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
JSONArray categoryValues = new JSONArray();
|
||||
JsonArray categoryValues = new JsonArray();
|
||||
categoryValues.add(entry.getValue());
|
||||
values.put(entry.getKey(), categoryValues);
|
||||
values.add(entry.getKey(), categoryValues);
|
||||
}
|
||||
data.put("values", values);
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -663,9 +683,9 @@ public class Metrics {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JSONObject getChartData() throws Exception {
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject values = new JSONObject();
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, int[]> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
@@ -677,17 +697,17 @@ public class Metrics {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
JSONArray categoryValues = new JSONArray();
|
||||
JsonArray categoryValues = new JsonArray();
|
||||
for (int categoryValue : entry.getValue()) {
|
||||
categoryValues.add(categoryValue);
|
||||
}
|
||||
values.put(entry.getKey(), categoryValues);
|
||||
values.add(entry.getKey(), categoryValues);
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.put("values", values);
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ public interface IPermissionsHandler {
|
||||
|
||||
boolean hasPermission(Player base, String node);
|
||||
|
||||
// Does not check for * permissions
|
||||
boolean isPermissionSet(Player base, String node);
|
||||
|
||||
String getPrefix(Player base);
|
||||
|
||||
String getSuffix(Player base);
|
||||
|
||||
@@ -13,7 +13,7 @@ public class PermissionsHandler implements IPermissionsHandler {
|
||||
private transient IPermissionsHandler handler = null;
|
||||
private transient String defaultGroup = "default";
|
||||
private final transient Essentials ess;
|
||||
private transient boolean useSuperperms = false;
|
||||
private transient boolean useSuperperms;
|
||||
|
||||
private Class<?> lastHandler = null;
|
||||
|
||||
@@ -62,6 +62,11 @@ public class PermissionsHandler implements IPermissionsHandler {
|
||||
return handler.hasPermission(base, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(final Player base, final String node) {
|
||||
return handler.isPermissionSet(base, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(final Player base) {
|
||||
final long start = System.nanoTime();
|
||||
@@ -92,10 +97,7 @@ public class PermissionsHandler implements IPermissionsHandler {
|
||||
public void checkPermissions() {
|
||||
// load and assign a handler
|
||||
List<Class<? extends SuperpermsHandler>> providerClazz = Arrays.asList(
|
||||
BPermissions2Handler.class,
|
||||
PermissionsExHandler.class,
|
||||
PrivilegesHandler.class,
|
||||
SimplyPermsHandler.class,
|
||||
ModernVaultHandler.class,
|
||||
GenericVaultHandler.class,
|
||||
SuperpermsHandler.class
|
||||
);
|
||||
@@ -158,7 +160,4 @@ public class PermissionsHandler implements IPermissionsHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPermLag(long start) {
|
||||
checkPermLag(start, "not defined");
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ public abstract class AbstractVaultHandler extends SuperpermsHandler {
|
||||
protected static Permission perms = null;
|
||||
protected static Chat chat = null;
|
||||
|
||||
public boolean setupProviders() {
|
||||
private boolean setupProviders() {
|
||||
try {
|
||||
Class.forName("net.milkbowl.vault.permission.Permission");
|
||||
Class.forName("net.milkbowl.vault.chat.Chat");
|
||||
@@ -46,26 +46,34 @@ public abstract class AbstractVaultHandler extends SuperpermsHandler {
|
||||
@Override
|
||||
public String getPrefix(final Player base) {
|
||||
String playerPrefix = chat.getPlayerPrefix(base);
|
||||
if (playerPrefix == null) {
|
||||
String playerGroup = perms.getPrimaryGroup(base);
|
||||
return chat.getGroupPrefix(base.getWorld().getName(), playerGroup);
|
||||
} else {
|
||||
if (playerPrefix != null) {
|
||||
return playerPrefix;
|
||||
}
|
||||
|
||||
String playerGroup = perms.getPrimaryGroup(base);
|
||||
if (playerGroup != null) {
|
||||
return chat.getGroupPrefix(base.getWorld().getName(), playerGroup);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuffix(final Player base) {
|
||||
String playerSuffix = chat.getPlayerSuffix(base);
|
||||
if (playerSuffix == null) {
|
||||
String playerGroup = perms.getPrimaryGroup(base);
|
||||
return chat.getGroupSuffix(base.getWorld().getName(), playerGroup);
|
||||
} else {
|
||||
if (playerSuffix != null) {
|
||||
return playerSuffix;
|
||||
}
|
||||
|
||||
String playerGroup = perms.getPrimaryGroup(base);
|
||||
if (playerGroup != null) {
|
||||
return chat.getGroupSuffix(base.getWorld().getName(), playerGroup);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean canLoad() {
|
||||
boolean canLoad() {
|
||||
if (Bukkit.getPluginManager().getPlugin("Vault") == null) return false;
|
||||
try {
|
||||
return setupProviders();
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.earth2me.essentials.perm.impl;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class BPermissions2Handler extends AbstractVaultHandler {
|
||||
@Override
|
||||
public boolean canBuild(final Player base, final String group) {
|
||||
return hasPermission(base, "bPermissions.build");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryProvider() {
|
||||
return super.canLoad() && Bukkit.getPluginManager().getPlugin("bPermissions") != null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.earth2me.essentials.perm.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ModernVaultHandler extends AbstractVaultHandler {
|
||||
private final List<String> supportedPlugins = Arrays.asList("PermissionsEx", "LuckPerms");
|
||||
|
||||
@Override
|
||||
protected boolean emulateWildcards() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(final Player base, final String group) {
|
||||
Objects.requireNonNull(base, "Can't check build override for nonexistent player!");
|
||||
return super.canBuild(base, group) || chat.getPlayerInfoBoolean(base.getWorld().getName(), base, "build", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryProvider() {
|
||||
return super.canLoad() && supportedPlugins.contains(getEnabledPermsPlugin());
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.earth2me.essentials.perm.impl;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PermissionsExHandler extends AbstractVaultHandler {
|
||||
@Override
|
||||
public boolean canBuild(final Player base, final String group) {
|
||||
return base != null && chat.getPlayerInfoBoolean(base.getWorld().getName(), base, "build", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryProvider() {
|
||||
return super.canLoad() && Bukkit.getPluginManager().getPlugin("PermissionsEx") != null;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.earth2me.essentials.perm.impl;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PrivilegesHandler extends AbstractVaultHandler {
|
||||
@Override
|
||||
public boolean canBuild(Player base, String group) {
|
||||
return hasPermission(base, "privileges.build");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryProvider() {
|
||||
return super.canLoad() && Bukkit.getPluginManager().getPlugin("Privileges") != null;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.earth2me.essentials.perm.impl;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SimplyPermsHandler extends AbstractVaultHandler {
|
||||
@Override
|
||||
public boolean canBuild(Player base, String group) {
|
||||
return hasPermission(base, "permissions.allow.build");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryProvider() {
|
||||
return super.canLoad() && Bukkit.getPluginManager().getPlugin("SimplyPerms") != null;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,10 @@ import java.util.List;
|
||||
|
||||
|
||||
public class SuperpermsHandler implements IPermissionsHandler {
|
||||
protected boolean emulateWildcards() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup(final Player base) {
|
||||
return null;
|
||||
@@ -22,7 +26,7 @@ public class SuperpermsHandler implements IPermissionsHandler {
|
||||
|
||||
@Override
|
||||
public boolean canBuild(final Player base, final String group) {
|
||||
return false;
|
||||
return hasPermission(base, "essentials.build");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,6 +36,10 @@ public class SuperpermsHandler implements IPermissionsHandler {
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final Player base, String node) {
|
||||
if (!emulateWildcards()) {
|
||||
return base.hasPermission(node);
|
||||
}
|
||||
|
||||
String permCheck = node;
|
||||
int index;
|
||||
while (true) {
|
||||
@@ -49,6 +57,11 @@ public class SuperpermsHandler implements IPermissionsHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(final Player base, final String node) {
|
||||
return base.isPermissionSet(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(final Player base) {
|
||||
return null;
|
||||
|
||||
@@ -5,10 +5,10 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by a payment method.
|
||||
* Copyright (C) 2011
|
||||
* AOL license <http://aol.nexua.org>
|
||||
*
|
||||
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
|
||||
* @copyright Copyright (C) 2011
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public interface Method {
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.Set;
|
||||
* preferred: "iConomy"
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* @author: Nijikokun <nijikokun@shortmail.com> (@nijikokun) @copyright: Copyright (C) 2011 @license: AOL license
|
||||
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun) @copyright: Copyright (C) 2011 @license: AOL license
|
||||
* <http://aol.nexua.org>
|
||||
*/
|
||||
public class Methods {
|
||||
@@ -30,9 +30,9 @@ public class Methods {
|
||||
private static boolean self = false;
|
||||
private static Method Method = null;
|
||||
private static String preferred = "";
|
||||
private static final Set<Method> Methods = new HashSet<Method>();
|
||||
private static final Set<String> Dependencies = new HashSet<String>();
|
||||
private static final Set<Method> Attachables = new HashSet<Method>();
|
||||
private static final Set<Method> Methods = new HashSet<>();
|
||||
private static final Set<String> Dependencies = new HashSet<>();
|
||||
private static final Set<Method> Attachables = new HashSet<>();
|
||||
|
||||
static {
|
||||
_init();
|
||||
@@ -79,7 +79,7 @@ public class Methods {
|
||||
*
|
||||
* @return <code>Set<String></code> - Array of payment methods that are loaded.
|
||||
*
|
||||
* @see #setMethod(org.bukkit.plugin.Plugin)
|
||||
* @see #setMethod(PluginManager)
|
||||
*/
|
||||
public static Set<String> getDependencies() {
|
||||
return Dependencies;
|
||||
@@ -114,8 +114,8 @@ public class Methods {
|
||||
*
|
||||
* @return <code>boolean</code>
|
||||
*
|
||||
* @see #setMethod(org.bukkit.plugin.Plugin)
|
||||
* @see #checkDisabled(org.bukkit.plugin.Plugin)
|
||||
* @see #setMethod(PluginManager)
|
||||
* @see #checkDisabled(Plugin)
|
||||
*/
|
||||
public static boolean hasMethod() {
|
||||
return (Method != null);
|
||||
@@ -124,7 +124,7 @@ public class Methods {
|
||||
/**
|
||||
* Checks Plugin Class against a multitude of checks to verify it's usability as a payment method.
|
||||
*
|
||||
* @param <code>PluginManager</code> the plugin manager for the server
|
||||
* @param manager the plugin manager for the server
|
||||
*
|
||||
* @return <code>boolean</code> True on success, False on failure.
|
||||
*/
|
||||
@@ -140,7 +140,7 @@ public class Methods {
|
||||
|
||||
int count = 0;
|
||||
boolean match = false;
|
||||
Plugin plugin = null;
|
||||
Plugin plugin;
|
||||
|
||||
for (String name : getDependencies()) {
|
||||
if (hasMethod()) {
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package com.earth2me.essentials.register.payment.methods;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
import net.milkbowl.vault.Vault;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
|
||||
public class VaultEco implements Method {
|
||||
private Vault vault;
|
||||
private Plugin vault;
|
||||
private Economy economy;
|
||||
|
||||
@Override
|
||||
public Vault getPlugin() {
|
||||
public Plugin getPlugin() {
|
||||
return this.vault;
|
||||
}
|
||||
|
||||
@@ -108,17 +107,15 @@ public class VaultEco implements Method {
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
try {
|
||||
RegisteredServiceProvider<Economy> ecoPlugin = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
return plugin instanceof Vault && ecoPlugin != null && !ecoPlugin.getProvider().getName().equals("Essentials Economy");
|
||||
} catch (LinkageError e) {
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
return plugin.getName().equals("Vault") && ecoPlugin != null && !ecoPlugin.getProvider().getName().equals("Essentials Economy");
|
||||
} catch (LinkageError | Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlugin(Plugin plugin) {
|
||||
this.vault = (Vault) plugin;
|
||||
this.vault = plugin;
|
||||
RegisteredServiceProvider<Economy> economyProvider = this.vault.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if (economyProvider != null) {
|
||||
this.economy = economyProvider.getProvider();
|
||||
@@ -130,7 +127,7 @@ public class VaultEco implements Method {
|
||||
private final String name;
|
||||
private final Economy economy;
|
||||
|
||||
public VaultAccount(String name, Economy economy) {
|
||||
VaultAccount(String name, Economy economy) {
|
||||
this.name = name;
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@@ -2,15 +2,39 @@ package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.MapValueType;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@Data @EqualsAndHashCode(callSuper = false) public class Jails implements StorageObject {
|
||||
public class Jails implements StorageObject {
|
||||
@MapValueType(Location.class)
|
||||
private Map<String, Location> jails = new HashMap<String, Location>();
|
||||
private Map<String, Location> jails = new HashMap<>();
|
||||
|
||||
public Map<String, Location> getJails() {
|
||||
return jails;
|
||||
}
|
||||
|
||||
public void setJails(Map<String, Location> jails) {
|
||||
this.jails = jails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Jails jails1 = (Jails) o;
|
||||
return Objects.equals(jails, jails1.jails);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(jails);
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,38 @@ package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.MapValueType;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@Data @EqualsAndHashCode(callSuper = false) public class Spawns implements StorageObject {
|
||||
public class Spawns implements StorageObject {
|
||||
@MapValueType(Location.class)
|
||||
private Map<String, Location> spawns = new HashMap<>();
|
||||
|
||||
public Map<String, Location> getSpawns() {
|
||||
return spawns;
|
||||
}
|
||||
|
||||
public void setSpawns(Map<String, Location> spawns) {
|
||||
this.spawns = spawns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Spawns spawns1 = (Spawns) o;
|
||||
return Objects.equals(spawns, spawns1.spawns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(spawns);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 244 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user