1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-09-07 21:20:47 +02:00

Compare commits

..

510 Commits

Author SHA1 Message Date
KHobbits
d522a4230f Make /god and /god <player> behave the same. 2013-02-09 19:31:31 +00:00
Chris Ward
f17485b112 Merge remote-tracking branch 'origin/groupmanager' into 2.9 2013-02-09 21:55:20 +11:00
ElgarL
1f932434c2 Fix bad Git Merge 2013-02-09 10:51:16 +00:00
Chris Ward
92b0178ca7 Merge pull request #312 from necrodoom/patch-44
update kit link to the new one
2013-02-09 02:48:48 -08:00
Necrodoom
d30c3ca2a6 update kit link to the new one 2013-02-09 12:47:36 +02:00
Chris Ward
fb60272439 Merge pull request #311 from necrodoom/patch-43
fix itemmeta link on kit section
2013-02-09 02:41:01 -08:00
Necrodoom
80ad075f02 fix itemmeta link on kit section 2013-02-09 11:57:32 +02:00
snowleo
3f31dc179b Fix /seen command 2013-02-08 22:26:21 +01:00
snowleo
5b975672e8 Don't overwrite last location on logout
Logout position is saved as logoutlocation now in users yml
2013-02-08 21:22:35 +01:00
snowleo
335d8b7f20 Check if player is still online 2013-02-08 21:18:00 +01:00
snowleo
379e75f3e6 Fix async access to bukkit code 2013-02-08 21:16:21 +01:00
Chris Ward
2ca171a3f4 Merge pull request #304 from necrodoom/patch-40
pull messages.properties changes to messages_en
2013-02-06 22:54:27 -08:00
Necrodoom
8036cc9924 pull messages.properties changes to messages_en 2013-02-06 16:15:18 +02:00
Chris Ward
6442e793a9 Merge pull request #300 from necrodoom/patch-39
add missing puncuation
2013-02-06 02:49:04 -08:00
KHobbits
d745b866c0 Don't block food recovery in god mode. 2013-02-05 23:34:08 +00:00
KHobbits
4493d7d00c Merge pull request #302 from GunfighterJ/patch-9
Prevents flying from being disabled on world teleport if player has esse...
2013-02-05 12:07:36 -08:00
GunfighterJ
631692d763 Prevents flying from being disabled on world teleport if player has essentials.fly 2013-02-05 13:16:27 -06:00
Necrodoom
d0e3c1d946 fix a few errors 2013-02-05 16:45:30 +02:00
Necrodoom
82137e0703 add missing puncuation
probably needs extra reading though before pulling.
2013-02-05 13:57:27 +02:00
KHobbits
a3b2ffdeef Merge pull request #297 from necrodoom/patch-36
fix typo at ID 22
2013-02-05 03:26:19 -08:00
Necrodoom
46fc6c192c fix typo at ID 22 2013-02-05 13:11:36 +02:00
ElgarL
6506c290c8 Revert Necro's change to mancheckw 2013-02-04 13:44:58 +00:00
ElgarL
b1bc73f938 Fix Necrodooms errors for not using an IDE!!!!! 2013-02-04 13:33:06 +00:00
ElgarL
09851acd1b Merge pull request #291 from necrodoom/patch-32
display name instead of path for /mancheckw
2013-02-04 05:29:10 -08:00
ElgarL
df42c9051b Merge pull request #290 from necrodoom/patch-30
Derp - revert incorrect modified line
2013-02-04 05:25:10 -08:00
KHobbits
24c93c11c0 Stylize 'bed' in /home list 2013-02-03 17:30:14 +00:00
Chris Ward
5a13e9bbe5 Merge pull request #294 from necrodoom/patch-35
add common cat type name aliases
2013-02-03 05:16:17 -08:00
Necrodoom
05f337c63c add common cat type name aliases 2013-02-03 15:13:36 +02:00
KHobbits
eea0c9682c We don't need move events if afk interact is disabled. 2013-02-03 05:15:25 +00:00
KHobbits
2f567812d2 Merge pull request #292 from GunfighterJ/2.9
Adds toggle to disable AFK cancel on interactions
2013-02-02 21:11:43 -08:00
GunfighterJ
88c1b785af Adds toggle to disable AFK cancel on interactions 2013-02-02 23:06:09 -06:00
KHobbits
5225fb22f8 Minor comment updates. 2013-02-03 04:14:23 +00:00
Necrodoom
fae5780e09 Update EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java 2013-02-01 16:39:18 +02:00
Necrodoom
7ec65bf213 Update EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/UsersDataHolder.java 2013-02-01 16:33:55 +02:00
Necrodoom
d40484d016 Update EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/GroupsDataHolder.java 2013-02-01 16:33:37 +02:00
Necrodoom
971902ae38 Update EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/UsersDataHolder.java 2013-02-01 16:31:58 +02:00
Necrodoom
844be04d75 Derp - revert incorrect modified line 2013-02-01 14:14:46 +02:00
KHobbits
ef01332114 Fix missing 'bed' from home list. 2013-02-01 05:26:17 +00:00
KHobbits
705b193450 Let Bukkit decide if a bedspawn is valid or not.
Bukkit's bed fix forces minimum bukkit change.
2013-02-01 02:59:40 +00:00
KHobbits
20b9111495 [GM] Catch all of the null. 2013-02-01 02:52:41 +00:00
KHobbits
1661eddc02 Make gm API lookup respect offlineperms toggle properly. 2013-02-01 00:01:57 +00:00
KHobbits
15be319d3e Updating groups example 2013-01-31 21:02:38 +00:00
KHobbits
fddbd7a52a Merge branch 'groupmanager' of github.com:essentials/Essentials into 2.9
Conflicts:
	EssentialsGroupManager/src/Changelog.txt
2013-01-31 20:38:36 +00:00
Iaccidentally
360e3e8801 cleanup :: fix build 2013-01-31 14:40:33 -05:00
Iaccidentally
4edc39360a Refactor name of ScheduleAsyncDelayedTask to RunTaskAsynchronously 2013-01-31 14:16:09 -05:00
Iaccidentally
cd126264e0 Update to 1.4.7 R1 :: remove calls to ScheduleAsyncDelayedTask, as it is deprecated :: cleanup :: WARNING: This commit may or may not be stable 2013-01-31 14:03:27 -05:00
ElgarL
df0ccb5832 Fix Necrodooms broken code. 2013-01-30 19:55:38 +00:00
ElgarL
8afcd41ab2 Merge pull request #288 from necrodoom/patch-29
config option to allow GM commands in commandblocks
2013-01-30 11:45:27 -08:00
Necrodoom
b8a71761ec update changelog 2013-01-30 19:26:46 +02:00
Necrodoom
738ded7ae5 update commandblock usage deny message 2013-01-30 19:25:35 +02:00
Necrodoom
5535435215 update config description of allow_commmandblocks 2013-01-30 19:14:57 +02:00
Necrodoom
4167dd2590 add allow commandblock check 2013-01-30 18:53:40 +02:00
Necrodoom
623ff0f629 register new config setting 2013-01-30 18:47:19 +02:00
Necrodoom
6e4ba4302f update config.yml to include commandblock change 2013-01-30 18:15:58 +02:00
KHobbits
3d4d616414 What is less than less than one. 2013-01-29 23:59:31 +00:00
KHobbits
d6c91d2d04 Might as well make it all safe. 2013-01-29 23:51:42 +00:00
snowleo
cef8cf7b75 Don't run calls against bucket api in async login thread 2013-01-30 00:26:50 +01:00
snowleo
12786a260e Update /sell command to newer bukkit api 2013-01-29 20:29:03 +01:00
ElgarL
6ea956b11c Doh, actually find what world we want to check properly with mancheckw. 2013-01-29 16:56:03 +00:00
ElgarL
132aa0cc1d Update plugin.yml with the new command 2013-01-29 16:45:23 +00:00
ElgarL
b5733d6597 grammaaahhhh!!! 2013-01-29 16:35:15 +00:00
ElgarL
7fc4a75d4d Added '/mancheckw <world>' to inspect what permission files a world is
referencing.
2013-01-29 16:33:20 +00:00
ElgarL
e9e9efd2d7 Missed an S 2013-01-29 16:15:45 +00:00
ElgarL
9e4493fbb4 Prevent '*' permissions granting the 'groupmanager.noofflineperm'
permission.
2013-01-29 16:14:24 +00:00
ementalo
a64cb31211 Revert "Merge pull request #286 from GunfighterJ/2.9"
This reverts commit 57de3f3ed2, reversing
changes made to 76d1ea5cab.
2013-01-29 10:25:01 +00:00
Iaccidentally
57de3f3ed2 Merge pull request #286 from GunfighterJ/2.9
Ignore itemmeta on selling
2013-01-28 21:13:41 -08:00
GunfighterJ
74b63a6f2d Ignore itemmeta on sell 2013-01-28 23:11:43 -06:00
ElgarL
faad91849d Add support for BukkitForge using 'overworld' as the main world name. 2013-01-28 04:13:16 +00:00
GunfighterJ
ce7d83adb6 Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2013-01-27 14:20:59 -06:00
KHobbits
76d1ea5cab Minor /ci tweak. 2013-01-27 17:22:43 +00:00
KHobbits
9fb42375b8 Cleanup /ci addition. 2013-01-27 17:10:07 +00:00
GunfighterJ
2a7f3c6525 Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2013-01-27 10:44:13 -06:00
KHobbits
c65353350f Merge pull request #278 from GunfighterJ/2.9
Adds vanilla syntax for /clearinventory
2013-01-27 08:40:39 -08:00
KHobbits
1ae58d05b4 Fix vanish status when switching worlds.
This fixes the potion effect being cleared on world change.
2013-01-27 16:39:50 +00:00
KHobbits
4f35a72174 Add command syntax comment, for clarification.
Merge branch '2.9' of github.com:essentials/Essentials into 2.9
2013-01-27 15:26:46 +00:00
KHobbits
addd55228b Don't try and charge a user if we don't have the chat data stored. 2013-01-27 15:26:42 +00:00
Iaccidentally
bb29d48268 Make heal remove fire from players. 2013-01-26 17:16:48 -05:00
Iaccidentally
d9ee9b036c Update heal to account for the fact that 20 is not always the max health 2013-01-26 17:12:17 -05:00
GunfighterJ
95e630de92 Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2013-01-24 21:16:13 -06:00
KHobbits
2836c0862d Revert "Prevent replacement of { and } characters in chat.format"
This reverts commit 8fde5102b9.
2013-01-25 03:12:13 +00:00
KHobbits
286091cd32 Try command fallback 2013-01-25 03:06:53 +00:00
KHobbits
20786654a4 Merge pull request #284 from phrstbrn/chat-braces-fix
Prevent replacement of { and } characters in chat.format
2013-01-24 08:53:32 -08:00
Zak Ford
8fde5102b9 Prevent replacement of { and } characters in chat.format 2013-01-24 11:43:10 -05:00
GunfighterJ
133fdac343 Update /ci to support vanilla syntax 2013-01-23 16:47:21 -06:00
Chris Ward
2361b9e724 Add debug option to XMPP 2013-01-23 19:41:36 +11:00
Chris Ward
972d831d0d Remove references to earth2me in plugin.ymls 2013-01-23 02:56:18 +11:00
Chris Ward
bfa34130a0 Merge pull request #280 from necrodoom/patch-28
update documation reference in config.yml
2013-01-22 00:13:07 -08:00
Necrodoom
befe1fb39e Update Essentials/src/config.yml 2013-01-22 09:54:48 +02:00
KHobbits
378eaaaf1f Small patch to allow multiple firework effects to be defined in kits. 2013-01-21 23:38:03 +00:00
KHobbits
51a55318d0 Revert /gc change.
Simplify firework syntax, and add help
Merge branch 'patch-26' of git://github.com/necrodoom/Essentials into 2.9
2013-01-21 20:07:02 +00:00
KHobbits
4663c89dd6 Merge pull request #276 from necrodoom/patch-26
Update Essentials/src/plugin.yml
2013-01-21 06:41:32 -08:00
Necrodoom
2a1c3fb8e0 Update Essentials/src/plugin.yml 2013-01-21 16:40:45 +02:00
Necrodoom
0ac1a90b93 Update Essentials/src/messages_en.properties 2013-01-21 16:37:12 +02:00
Necrodoom
ab6b3bff90 fix message 2013-01-21 16:35:40 +02:00
Necrodoom
2d00fd0c1e try make error message more informative 2013-01-21 16:32:49 +02:00
Necrodoom
e5f4cb9a4d Update Essentials/src/plugin.yml 2013-01-21 16:29:26 +02:00
KHobbits
91701e8c2f Allow negative exp to be given 2013-01-21 14:15:53 +00:00
KHobbits
9cef107bc3 Fix a couple of param issues. 2013-01-21 13:40:45 +00:00
KHobbits
76fd829e8c Merge pull request #275 from DMarby/patch-1
Update Essentials/src/messages_se.properties
2013-01-20 15:31:34 -08:00
David Marby
6ea422015c Update Essentials/src/messages_se.properties 2013-01-21 00:26:38 +01:00
KHobbits
443a317184 Show afk warning when pm'ing afk players.
Fix vanished leak on player matching.
2013-01-20 22:05:44 +00:00
KHobbits
50dca9abf5 Add optional 2nd arg to broadcast format. 2013-01-20 20:58:05 +00:00
KHobbits
f1e3d48248 Fix book meta error message. 2013-01-20 20:41:15 +00:00
KHobbits
63ce4a99b9 Trim long /gc output, add /gc all 2013-01-20 20:35:41 +00:00
KHobbits
1ccda52e9f Fix minor /book bug (Null author) 2013-01-20 20:06:27 +00:00
KHobbits
1679790157 Fix eco take derp. 2013-01-20 19:43:59 +00:00
KHobbits
6170540a24 Fix colour syntax message on coloured leather. 2013-01-20 01:44:03 +00:00
KHobbits
987b2ff4d5 Minor cleanup on /eco command. 2013-01-20 01:24:09 +00:00
KHobbits
23a15cb11a Merge pull request #274 from GunfighterJ/2.9
Cleanup /eco, fix reset broadcast
2013-01-19 17:12:07 -08:00
KHobbits
41547e3243 Cleanup /exp command, and fix vanilla syntax issues.
Needs double checking with commandblocks with vanilla syntax.
2013-01-20 01:10:41 +00:00
GunfighterJ
a586edfd0b Cleanup /eco, fix reset broadcast 2013-01-19 17:58:12 -06:00
KHobbits
762bb65677 Add example firework kit, and cleanup debug messages. 2013-01-19 23:43:40 +00:00
KHobbits
73c92bf742 Move firework meta handling into MetaItemStack
Allow firework meta to be applied to item spawning and kit commands.
2013-01-19 23:35:59 +00:00
ElgarL
2b8435342d Negate 'groupmanager.noofflineperms' by default in the owner group. 2013-01-19 22:22:42 +00:00
KHobbits
9566499a2f Merge pull request #272 from GunfighterJ/2.9
/eco overhaul, adds /eco set
2013-01-19 10:54:11 -08:00
GunfighterJ
343c3a1bdd /eco overhaul, adds /eco set 2013-01-19 12:50:35 -06:00
KHobbits
9aeb49f6c3 Reduce chance of self repeating powertool actions. 2013-01-19 15:19:39 +00:00
Chris Ward
7dae04759f Merge pull request #271 from necrodoom/patch-25
update /book description
2013-01-19 06:21:47 -08:00
Necrodoom
e2f6e5a7fd update /book description 2013-01-19 16:16:35 +02:00
ElgarL
d26fa6c5b8 Negate 'groupmanager.noofflineperms' by default in the owner group. 2013-01-19 12:40:40 +00:00
Chris Ward
82f9505a2e Touch of cleanup to Gunfighter's addition to exp 2013-01-19 18:22:22 +11:00
GunfighterJ
f8ce80c18a Adds vanilla syntax to /exp command 2013-01-18 18:20:05 -06:00
Alexander Schepp
313fd30ce9 Fix bug with empty motd 2013-01-18 23:36:59 +01:00
Iaccidentally
da216b05d9 Merge pull request #266 from GunfighterJ/2.9
Duplicate alias removed
2013-01-17 17:30:04 -08:00
GunfighterJ
d8132548f6 Duplicate alias removed 2013-01-17 19:27:21 -06:00
snowleo
6fdeddd96b Merge remote-tracking branch 'origin/groupmanager' into 2.9 2013-01-18 01:01:23 +01:00
Iaccidentally
8082508db9 Merge pull request #265 from GunfighterJ/2.9
Adds essentials.mute.notify
2013-01-17 15:53:37 -08:00
GunfighterJ
78e6da9504 Adds essentials.mute.notify 2013-01-17 17:42:32 -06:00
Iaccidentally
0014d5cfcb Merge pull request #263 from GunfighterJ/2.9
Added /firework command
2013-01-17 14:59:01 -08:00
Iaccidentally
6aeba173b9 Update libs 2013-01-17 14:36:03 -05:00
Iaccidentally
a2813358af Update Bukkit to 1.4.7-R0.1 2013-01-17 14:25:19 -05:00
GunfighterJ
8e663b53ce Now it adds the right firework command 2013-01-16 20:40:29 -06:00
GunfighterJ
214d9414da Adds the actual /firework command 2013-01-16 20:39:09 -06:00
GunfighterJ
6d7881f876 Added /firework command 2013-01-16 20:36:33 -06:00
Iaccidentally
19ccdf2193 Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2013-01-16 21:23:17 -05:00
KHobbits
35036ecc18 Fix null args on /book 2013-01-16 16:56:27 +00:00
KHobbits
b3cc4dbe09 Remove logger. 2013-01-16 16:30:30 +00:00
KHobbits
04bd9e8baf Remove broken firework meta. 2013-01-15 00:37:08 +00:00
KHobbits
fdc262a205 Start work on firework effect - syntax in flux 2013-01-14 23:11:19 +00:00
Iaccidentally
32ea86bfd3 Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2013-01-14 17:25:32 -05:00
KHobbits
4807fb39e5 Couple of extra /helpop aliases. 2013-01-14 21:40:25 +00:00
KHobbits
4ffe61a505 Add colour support to item meta. 2013-01-14 21:34:35 +00:00
KHobbits
d74952927a Only show ban reason in the in-game display, not full banFormat. 2013-01-14 11:59:31 +00:00
KHobbits
f8cf3be87f Better handle initial book.txt creation. 2013-01-14 08:21:03 +00:00
KHobbits
ada266a0f9 Switch book meta, to use 'book.txt', and 'book:<section>'.
Should make things clearer and easier to understand.
2013-01-14 08:14:42 +00:00
KHobbits
115c4fa1d0 Merge remote-tracking branch 'remotes/origin/groupmanager' into 2.9 2013-01-14 07:37:11 +00:00
KHobbits
0c19b2feed All the better to kick you with
(Pipe format for linebreak)
2013-01-14 07:36:45 +00:00
ElgarL
04c833f648 Fix recursive loop when used on offline servers. 2013-01-14 06:47:50 +00:00
ElgarL
4533d09fc9 Update GlobalGroups (removing old permissions) as Towny handles it's own
perms now.
2013-01-14 05:48:48 +00:00
KHobbits
7337b86a16 Cleanup /book command. 2013-01-13 23:11:15 +00:00
Iaccidentally
3db015b1c1 Merge pull request #260 from GunfighterJ/patch-3
Fixes /top command not carrying pitch and yaw
2013-01-13 15:09:05 -08:00
GunfighterJ
659d602b57 Fixes /top command not carrying pitch and yaw 2013-01-13 17:02:46 -06:00
KHobbits
f82d7e806f Merge pull request #259 from GunfighterJ/patch-2
Added more book commands for editing author and title
2013-01-13 14:57:35 -08:00
GunfighterJ
a8088fb8c8 Merge branch 'patch-2' of https://github.com/GunfighterJ/Essentials into patch-2
Conflicts:
	Essentials/src/com/earth2me/essentials/commands/Commandbook.java
2013-01-13 16:31:29 -06:00
GunfighterJ
84c06fb746 Added more book arguments for editing author and title amend 2013-01-13 16:19:37 -06:00
KHobbits
ffe2a283d2 Cleanup of book meta. 2013-01-13 22:18:08 +00:00
GunfighterJ
7e3fd48956 Added more book commands for editing author and title 2013-01-13 15:54:11 -06:00
KHobbits
bd22aec38a Adding support for books made from /einfo 2013-01-13 21:08:24 +00:00
ElgarL
675c4b7897 typo in changelog. 2013-01-13 16:40:53 +00:00
ElgarL
ad7009c77e Do not grant any permissions (nort update Bukkit) if the server is in
offline mode and the player has the permission node
'groupmanager.noofflineperms'.
2013-01-13 16:39:53 +00:00
KHobbits
3f783bb43b Merge branch '2.9' of github.com:essentials/Essentials into 2.9 2013-01-13 16:30:43 +00:00
KHobbits
9fe7712bd6 Clean up TextPager 2013-01-13 16:30:22 +00:00
ElgarL
24f56892ad Fix the logger so errors are reported again. 2013-01-13 16:20:38 +00:00
ElgarL
b860e943f6 Synchronize pushing to Bukkit perms to prevent any
ConcurrentModificationException.
2013-01-13 16:20:09 +00:00
Chris Ward
5dc2665377 Merge pull request #258 from necrodoom/patch-22
update ID 397:3
2013-01-13 05:03:05 -08:00
Necrodoom
dd9b7e0d3c update ID 397:3 2013-01-13 15:01:10 +02:00
KHobbits
18a15ca63c Add provisional support for basic item Meta
Adds /book command to allow reediting of signed books.
2013-01-13 04:44:28 +00:00
KHobbits
ef1492a2a2 Clean up userdata saving, to prevent CMI
Also update config section code to use newer bukkit methods
2013-01-12 19:30:06 +00:00
KHobbits
298ab846c1 Don't extend ItemStack 2013-01-12 17:05:05 +00:00
KHobbits
7fdb2ad7d3 Pull item meta from itemdb class 2013-01-12 14:12:12 +00:00
Iaccidentally
3afe8d18f4 Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2013-01-11 12:56:18 -05:00
Iaccidentally
0b581580c7 Merge pull request #251 from necrodoom/patch-19
/me shakes fist at Khobbits
2013-01-11 09:17:44 -08:00
Necrodoom
01e78cd666 /me shakes fist at Khobbits
fixes e6aeefb12d whitespace
2013-01-11 19:10:32 +02:00
Chris Ward
29d28456aa Merge remote-tracking branch 'origin/groupmanager' into 2.9 2013-01-11 21:59:39 +11:00
Chris Ward
f3812786d0 Fixes Item Frames being linked to Paintings when breaking 2013-01-11 21:54:52 +11:00
ElgarL
999d922fb9 Store a plugin and server reference. 2013-01-11 00:53:48 +00:00
KHobbits
2d4a07b95b New permission: essentials.sethome.bed
Players with this permission will force a bed home updating if daytime beds are enabled.
2013-01-10 22:36:38 +00:00
Chris Ward
5c99eee0c0 Implement abstract methods 2013-01-10 22:57:08 +11:00
Chris Ward
1fc502a4ff Update bukkit/craftbukkit libs. Force latest beta version 2013-01-10 22:51:48 +11:00
KHobbits
e73983649f Ban cleanup 2013-01-09 21:31:56 +00:00
KHobbits
465cdae989 Util commenting 2013-01-09 21:18:46 +00:00
KHobbits
341cb89bb7 Multiline kick messages and tempban countdown. 2013-01-09 21:04:58 +00:00
Chris Ward
79004c7098 Merge branch 'groupmanager' into 2.9 2013-01-10 04:57:10 +11:00
Joseph
2988db08ca Formatting 2013-01-10 03:25:58 +11:00
GunfighterJ
b04fa82be2 Add more items to Fireball command. Add delay option to /spawner 2013-01-10 03:25:57 +11:00
Chris Ward
5d210d81dc Merge pull request #247 from necrodoom/patch-18
rewrite ID 43:6, 44:6, 113, 114
2013-01-09 06:50:31 -08:00
Necrodoom
c14b32123f rewrite ID 43:6, 44:6, 113, 114 2013-01-09 16:46:37 +02:00
ElgarL
f256930269 Synchronize the raising of GroupManager events to Bukkit.getServer()
(should prevent deadlocks).
2013-01-09 14:38:00 +00:00
ElgarL
cde95d832e Merge pull request #241 from necrodoom/patch-15
fix typo
2013-01-09 02:50:30 -08:00
ElgarL
b9af4fb35c Remove attachments BEFORE we clear them. 2013-01-09 04:27:10 +00:00
ElgarL
5056210a38 code tidy. 2013-01-09 04:13:40 +00:00
ElgarL
eacb847305 Remove attachments before clearing 2013-01-09 04:04:59 +00:00
ElgarL
27ff43c0ac Clear our attachment map upon a manload so we correctly reconfigure a
players new permissions.
2013-01-09 03:55:26 +00:00
KHobbits
368c33a843 Expand plugin.yml fireball aliases. 2013-01-09 01:00:13 +00:00
KHobbits
c210e8730b Fire a few extra entities from /fireball 2013-01-09 00:58:29 +00:00
KHobbits
6c48e02c14 Add a couple of extra entities to spawnmob 2013-01-09 00:41:24 +00:00
KHobbits
c54d68a660 Cleanup 2013-01-08 23:59:31 +00:00
KHobbits
33d3123104 Pull and clean up book enchant pullreq.
Removed 1 enchant per book limit, anvils seem to handle multiple enchants fine, even if the result can only be one enchant.
2013-01-08 23:51:46 +00:00
Chasing Code
df0b1cedd8 Add missing import for EnchantmentStorageMeta 2013-01-08 11:46:08 -08:00
Chasing Code
2b57381fb8 Store enchanments in Enchanted Books
Change enchant command to store the enchantment instead of applying it when used on an Enchanted Book.  If an enchantment is already present, replace it (only one allowed on Enchanted Books).
2013-01-08 11:37:46 -08:00
oggehej
67b9a82e51 Update Swedish translation with new messages. 2013-01-08 19:45:51 +11:00
Chris Ward
c4e10da646 Store regex, use util method instead of another regex. Store variable 2013-01-08 02:26:09 +11:00
Chris Ward
fbb1c1278c Fix multiple enchantments in kits 2013-01-08 02:25:35 +11:00
Chris Ward
9b49c5e0f4 Merge pull request #242 from necrodoom/patch-17
update ID 127
2013-01-07 07:00:41 -08:00
Necrodoom
186d4e2fd1 update ID 127 2013-01-07 16:52:51 +02:00
Chris Ward
437b01e371 Unnecessary RegEx is unnecessary. 2013-01-08 00:08:11 +11:00
KHobbits
3bf36fecf9 Enchantment and item spawning cleanup
Should make it a little easier to add itemmeta.
2013-01-06 18:28:24 +00:00
KHobbits
c57332be63 Tell user that /mail sendall succeeded when used in console. 2013-01-06 16:27:20 +00:00
Necrodoom
292fb0cea1 fix typo 2013-01-05 19:05:02 +02:00
Necrodoom
3c4388f8be update IDs 368, 381, 399, 402 2013-01-05 19:27:56 +11:00
KHobbits
f930ff48a2 Throw an error if user doesn't have permission to use kit sign. 2013-01-05 07:39:32 +00:00
KHobbits
ef7b940e96 More user feedback on enchant sign. 2013-01-05 07:24:02 +00:00
KHobbits
6497db837d Allow unsafe enchants to be placed by [enchant] signs if enabled in the config file. 2013-01-05 07:05:25 +00:00
KHobbits
87cb6190eb Couple of extra enchant aliases 2013-01-05 06:59:37 +00:00
KHobbits
74c4c604da Merge branch 'release' into 2.9 2013-01-04 21:40:02 +00:00
KHobbits
0937a35470 Fix sign break bug 2013-01-04 13:05:57 +00:00
md_5
121f09caf0 Might be worth catching other occurances of the event too. 2013-01-04 13:53:01 +11:00
md_5
ef8bd3422a ArrayList, I choose you! (Fixes CraftBook erroring when the killall command is used and custom drops are enabled in that plugin) 2013-01-04 13:49:45 +11:00
Alexander Schepp
2232d859fd Fix nl translation 2013-01-03 11:50:19 +01:00
Iaccidentally
0258abee29 Update AntiBuild to use HangingBreakByEntityEvent instead of deprecated PaintingBreakByEntityEvent 2013-01-02 18:25:40 -05:00
Iaccidentally
9b8991788b Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2013-01-02 18:24:34 -05:00
KHobbits
9a91c99391 Merge pull request #236 from gravypod/patch-1
Store ingredient map and recipe shape
2013-01-01 15:20:26 -08:00
KHobbits
c6dd921f0c New permission: essentials.fly.safelogin - Players with this command will automatically switch to fly mode if they login whilst floating in the air. 2013-01-01 22:00:53 +00:00
KHobbits
63e622374d New perm: essentials.vanish.effect - People with this effect will get the potion effect applied while vanished. 2013-01-01 21:12:26 +00:00
KHobbits
ca25c71010 Cleanup cleanup. 2013-01-01 19:48:08 +00:00
KHobbits
b5e559ff66 More cleanup 2013-01-01 19:34:32 +00:00
KHobbits
555bb76428 Cleanup 2013-01-01 18:39:23 +00:00
ElgarL
f210f8e20b Merge pull request #235 from necrodoom/patch-10
fix isOpOverride checks
2012-12-31 07:59:27 -08:00
gravypod
e572e7c94c Store ingredient map and recipe shape 2012-12-31 10:44:28 -05:00
Chris Ward
5c9d3c6b1a Fix recipe NPE/failed display in game 2013-01-01 02:26:04 +11:00
Necrodoom
ccfc23d629 fix isOpOverride checks 2012-12-31 15:35:58 +02:00
KHobbits
b5dd0fc671 Don't unregister all listeners. 2012-12-31 12:15:51 +00:00
KHobbits
8e3ee8576e Unregister unused events. 2012-12-31 05:44:20 +00:00
KHobbits
4cec7fe5c1 Use bukkit api for chat user list 2012-12-31 05:43:05 +00:00
KHobbits
6c3b2076ff Allow unbanning players who do not have valid userdata 2012-12-31 01:08:39 +00:00
KHobbits
cbc1aeacbe Implement event toggle. 2012-12-30 04:32:43 +00:00
KHobbits
a1b2773bf5 Reorganize entity listener 2012-12-30 03:32:32 +00:00
Alexander Schepp
9ecb501e00 Use the right formatter in XMPP 2012-12-30 00:23:04 +01:00
KHobbits
3dcdad2233 Hide a few more duplicate enchantments from /enchant 2012-12-29 09:00:42 +00:00
KHobbits
3725a5e6d4 Set default tpa timeout to 2 minutes. 2012-12-29 08:40:03 +00:00
KHobbits
ed88f8aa06 Allow unsafe enchantments in /item /give /kit and /enchant
Needs enabled in config file manually.
2012-12-29 08:36:24 +00:00
KHobbits
d551e8c6d2 Make /enchant only show valid enchantments for the item. 2012-12-29 07:58:28 +00:00
KHobbits
69ad186839 Add aliases for new thorns enchantment. 2012-12-29 07:47:07 +00:00
KHobbits
fc89867e4a Ignore self damage in teleport entity protection. 2012-12-29 07:35:26 +00:00
KHobbits
bbb478c51f Lets clean up the recipe window on player quit, just in case. 2012-12-29 06:55:48 +00:00
KHobbits
03445e5b9b Fix home functionality bugs:
/home not using bed when enabled
/home not giving teleport warning
2012-12-29 06:43:26 +00:00
KHobbits
0755fbf089 Update bukkit to 1.4.6-R0.1
bukkit: 1652 cb: 2561
2012-12-29 06:37:52 +00:00
KHobbits
3a789bdcfe Fix string match error on none existing user (/ban). 2012-12-29 02:00:48 +00:00
Chris Ward
93db8bc7c1 Add SimplyPerms to classpath 2012-12-29 11:26:44 +11:00
Xefir
62832ad43a Added SimplyPerms Handler 2012-12-29 10:41:15 +11:00
Alexander Schepp
52b104aca5 Merge pull request #229 from necrodoom/patch-9
fix tempban permission check
2012-12-28 09:37:40 -08:00
Necrodoom
1f98fe710f derp - fix tempban permission check 2012-12-28 19:05:54 +02:00
ElgarL
a73986a358 Fix missing + from Necrodoom's pull request. 2012-12-28 13:46:22 +00:00
ElgarL
257165584e Merge pull request #228 from necrodoom/patch-8
Update EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManage...
2012-12-28 05:43:54 -08:00
Iaccidentally
8e92150cb7 Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2012-12-26 09:48:38 -05:00
Chris Ward
4bb275e1b7 Revert 6b18259af6 - Adding permission node to speak, with config option to enable the node 2012-12-27 01:41:32 +11:00
Chris Ward
e5fc579071 Add tpdeny message to /tpahere 2012-12-27 01:10:57 +11:00
Iaccidentally
26306f6fa3 Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2012-12-25 18:12:42 -05:00
Necrodoom
0bfb079cbb Update EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java 2012-12-25 18:11:10 +02:00
Chris Ward
6b18259af6 Adding permission node to speak, with config option to enable the node 2012-12-24 01:55:53 +11:00
Chris Ward
99c750d18b Move max-tempban-time in config 2012-12-24 01:04:02 +11:00
Chris Ward
bb64fa468a Fixing IUser 2012-12-23 21:29:26 +11:00
Chris Ward
66db3c6cfb Adding isAfk and setAfk to IUser API 2012-12-23 21:25:29 +11:00
KHobbits
c97763c3c8 Make seen status's only show when true. 2012-12-22 03:36:56 +00:00
Chris Ward
ad3e8a3aba Merge pull request #215 from necrodoom/patch-5
update items.csv to minecraft 1.4.6
2012-12-21 04:33:14 -08:00
KHobbits
617959a11b Log target plugin in debug mode for altcmd 2012-12-21 06:38:51 +00:00
KHobbits
a480091617 Final all the things - Recipe 2012-12-21 03:48:54 +00:00
KHobbits
13a847e0ab Fix recipe layout for small shapes 2012-12-21 03:35:48 +00:00
KHobbits
a8a8b52977 Swap method order on recipe 2012-12-21 03:21:35 +00:00
KHobbits
226a75472c Adjust section matching. 2012-12-20 23:37:37 +00:00
KHobbits
a1c88a140e Merge pull request #227 from Elvaron/2.9
FallBack for missing config property
2012-12-20 15:36:01 -08:00
Elvaron
2c3218b056 FallBack for missing config property 2012-12-21 00:16:18 +01:00
KHobbits
27db9e8c3b Merge branch '2.9' of github.com:essentials/Essentials into 2.9 2012-12-20 22:58:00 +00:00
KHobbits
cf0e36c973 Add support for whitelisting commands in /help by permission: essentials.help.<plugin>.<command> 2012-12-20 22:57:38 +00:00
KHobbits
1218a0b217 Reduce permissions checking when generating /help 2012-12-20 22:54:36 +00:00
KHobbits
adb75b69c2 Allow certain commands while in jail, but only if the user normally has access to that command. 2012-12-20 22:53:52 +00:00
KHobbits
010df964a1 Merge pull request #226 from Elvaron/2.9
Made socialspy commands list configurable
2012-12-20 14:16:45 -08:00
Elvaron
0e2e8e16af Made socialspy commands list configurable 2012-12-20 23:07:22 +01:00
KHobbits
6f28540d59 Merge branch 'release' of github.com:essentials/Essentials into 2.9 2012-12-20 20:37:42 +00:00
KHobbits
ce78125028 Add a little bit of extra information to /seen, this will show when user is online. 2012-12-20 20:37:04 +00:00
KHobbits
10b972bd07 Warn other party when teleport fails after tpaccept. 2012-12-20 20:24:07 +00:00
KHobbits
371a6437ae Redundant tpaccept cost check. 2012-12-20 20:23:51 +00:00
KHobbits
78666ade2b Fix max tempban length option. 2012-12-20 20:11:45 +00:00
KHobbits
8f00aa5542 Warn other party when teleport fails after tpaccept. 2012-12-20 20:01:43 +00:00
KHobbits
b2d68fe213 Redundant tpaccept cost check. 2012-12-20 19:50:59 +00:00
KHobbits
a6c13974c4 Merge branch 'release' of github.com:essentials/Essentials into 2.9 2012-12-20 17:03:48 +00:00
KHobbits
fb0cd8fbf0 Remove command cost warnings from plugin matching. 2012-12-20 15:51:49 +00:00
Chris Ward
01d1ae442e Fix currency display in MOTD - display currency character, trim decimal places 2012-12-20 15:45:32 +00:00
snowleo
dc13f46ff1 Don't use broken CB methods ... 2012-12-20 15:45:22 +00:00
snowleo
f125ac3b4a Don't use broken CB methods ... 2012-12-20 16:07:40 +01:00
Chris Ward
be29a373ab Useless import 2012-12-20 23:10:38 +11:00
Chris Ward
b28db7e435 Fix currency display in MOTD - display currency character, trim decimal places 2012-12-20 23:07:49 +11:00
md_5
3ac6cc11e3 Fix nagging for overriden commands. 2012-12-20 09:56:30 +01:00
snowleo
9097bef728 Merge branch 'refs/heads/groupmanager' into 2.9 2012-12-20 09:55:26 +01:00
snowleo
68e401821f Fix gm builds
Change craftbukkit.jar -> bukkit,jar
2012-12-20 09:36:35 +01:00
md_5
7f9a52c3f7 Lets leave numeric homes as is for now, looping through all files on server startup is not the place to do this (reverse-merged from commit 79a44b919c) 2012-12-20 17:24:14 +11:00
md_5
79671d08e4 Fix nagging for overriden commands. 2012-12-20 17:11:05 +11:00
Chris Ward
d01d6bcd1b Fix NPE in update (sorry again :P) 2012-12-20 15:45:09 +11:00
Chris Ward
79a44b919c Update home names to prepend "home" to numeric home names 2012-12-20 13:11:05 +11:00
snowleo
477e1a4f58 Force people to use latest CB version 2012-12-20 00:46:03 +01:00
snowleo
c028c385b6 Fix Spawns / Jail loading 2012-12-20 00:46:03 +01:00
snowleo
f9bcc3100c Update Inventory Workaround to the latest version
Still bugged in CB: maxAmount of items
2012-12-20 00:46:03 +01:00
snowleo
3ea3d18922 Force people to use latest CB version 2012-12-19 23:28:18 +01:00
snowleo
3faedec602 Fix Spawns / Jail loading 2012-12-19 23:26:29 +01:00
snowleo
2a88a314ce Update Inventory Workaround to the latest version
Still bugged in CB: maxAmount of items
2012-12-19 22:07:03 +01:00
ElgarL
38293560d7 Update Bukkit to version #2543 (1.4.5-R1.0) To ensure we are all
compatible with current recommended build.
2012-12-19 15:10:37 +00:00
Chris Ward
f57b3595ed Fix recipe command 2012-12-20 01:35:55 +11:00
md_5
e2e6bb3876 Simply using the SnakeYaml default (which in turn defaults to Class.forName) appears to be enough to get the classes for our custom configuration. This avoid Bukkit depreciation. 2012-12-19 12:57:05 +00:00
KHobbits
4e399778b4 Merge branch '2.9' of github.com:essentials/Essentials into 2.9 2012-12-19 12:54:00 +00:00
KHobbits
9ba5f43315 Updating Bukkit to 1.4.5 RB
Bukkit: 1643 CB: 2543
2012-12-19 12:52:05 +00:00
Chris Ward
0bde364125 Merge pull request #223 from chrisgward/patch-1
Add /recipe command
2012-12-19 00:28:27 -08:00
md_5
87f5ec491e Simply using the SnakeYaml default (which in turn defaults to Class.forName) appears to be enough to get the classes for our custom configuration. This avoid Bukkit depreciation. 2012-12-19 19:10:02 +11:00
Chris Ward
1f8a0a811f Add /recipe command 2012-12-19 14:57:12 +11:00
KHobbits
74d5590d3b Remove CB from EssCore libs. 2012-12-18 22:58:55 +00:00
KHobbits
258fbdb0e8 Merge pull request #216 from chrisgward/patch-1
Add tempban limit (with override node)
2012-12-18 02:24:45 -08:00
KHobbits
bd4a48c441 Fix command costs warnings. 2012-12-17 18:32:42 +00:00
KHobbits
00bd6a3e02 Support new skeleton and zombie types.
Also fix baby sheep colours.
2012-12-16 21:39:31 +00:00
KHobbits
28ad7b96d2 Log a few extra metrics. 2012-12-16 21:02:02 +00:00
KHobbits
97204c0e8c Merge pull request #217 from necrodoom/patch-7
add "w" alias
2012-12-16 11:07:10 -08:00
Necrodoom
46645cb39f Update Essentials/src/plugin.yml 2012-12-16 18:05:07 +02:00
Necrodoom
dfd6fc78f0 add "w" alias 2012-12-16 18:03:04 +02:00
Chris Ward
ecf5d47e97 Add tempban limit (with override node) and console override to exempt node. 2012-12-17 02:12:38 +11:00
Alexander Schepp
77df82eaff derp
That's why switch statements are bad.
2012-12-16 13:59:25 +01:00
Alexander Schepp
020f2c3ea5 Fix order of messages 2012-12-16 13:48:02 +01:00
KHobbits
5a855eede5 Update bukkit
Bukkit 1608 CraftBukkit 2488
2012-12-16 12:28:49 +00:00
KHobbits
8b4273cbd1 Merge branch 'groupmanager' of github.com:essentials/Essentials into 2.9 2012-12-16 12:12:23 +00:00
Necrodoom
30bc597851 update items.csv to minecraft 1.4.6 2012-12-16 12:52:16 +02:00
Alexander Schepp
13efadbb65 Merge pull request #214 from necrodoom/patch-4
change add-prefix-suffix description
2012-12-15 06:17:22 -08:00
snowleo
6bc3d7f0f4 Fix the gap 2012-12-15 14:22:52 +01:00
snowleo
e706614a3b Align /tp syntax with Minecraft /tp command 2012-12-15 14:12:34 +01:00
Necrodoom
cf68031110 change add-prefix-suffic description
hopefully will keep newbies from changing it for no reason
2012-12-15 12:58:57 +02:00
Iaccidentally
5741cea3f5 Merge pull request #210 from Echo4190/patch-1
Update Essentials/src/config.yml
2012-12-11 04:06:10 -08:00
Echo419
7b879331db Update Essentials/src/config.yml
trillions => trillion
english => English
2012-12-11 12:03:21 +00:00
KHobbits
0a27a631e3 Merge pull request #209 from necrodoom/patch-2
update config.yml to reference wiki more
2012-12-10 09:46:31 -08:00
KHobbits
d8c6587532 Add missing import. 2012-12-10 17:45:32 +00:00
KHobbits
d600f160fe Update metrics to r6 2012-12-10 17:43:06 +00:00
KHobbits
d23c324035 Metrics Diff 2012-12-10 17:40:15 +00:00
Necrodoom
52bfeff5b4 update config.yml to reference wiki more
also changed locale setting to be less confusing
2012-12-10 09:39:22 +02:00
KHobbits
3dcb2a828e Delay sending respawn event until we actually try to respawn user. 2012-12-09 17:32:02 +00:00
KHobbits
0b95a691a6 Revert "Bukkit should have fixed this issue, so we can now get a better first join player experience by teleporting them at once with no delay."
This reverts commit f7daa20be8.

This breaks compatibility with multiverse, and Essentials core.
2012-12-09 17:14:57 +00:00
KHobbits
eba2bad113 Merge branch '2.9' of github.com:essentials/Essentials into 2.9 2012-12-09 17:10:31 +00:00
KHobbits
4f21490ec8 Move null bed check to teleport code 2012-12-09 17:10:12 +00:00
md_5
f7daa20be8 Bukkit should have fixed this issue, so we can now get a better first join player experience by teleporting them at once with no delay. 2012-12-09 16:03:00 +11:00
KHobbits
a9ace1163f Shorten local chat format. 2012-12-08 18:51:18 +00:00
KHobbits
ba380e61ee Some nice friendly messages to help debugging command costs. 2012-12-08 15:51:33 +00:00
KHobbits
bbc306970f Throw error when using /more on full stack 2012-12-07 00:46:13 +00:00
KHobbits
7b997634ef Remove unused variable 2012-12-06 23:27:43 +00:00
KHobbits
1efbc3856c Make BPerms sign group checking behave similarly to same as GM and PEX 2012-12-06 23:26:48 +00:00
KHobbits
f769f96f74 Merge pull request #208 from kukelekuuk00/2.9
Added a total profit message for /sell all|blocks
2012-12-05 09:14:07 -08:00
kukelekuuk00
3f69473072 Added a total profit message for /sell all|blocks 2012-12-05 15:40:17 +01:00
KHobbits
d7bcf6508d Merge branch '2.9' of github.com:essentials/Essentials into 2.9 2012-12-03 09:09:17 +00:00
KHobbits
61c4d8cb5e Update afk status on block interact 2012-12-03 09:08:56 +00:00
Iaccidentally
f7361eed98 Merge pull request #205 from evonuts/patch-1
Spelling/Grammar fixes.
2012-12-01 02:43:20 -08:00
evonuts
deaa72b05d Spelling/Grammar fixes. 2012-12-01 21:51:24 +13:00
Iaccidentally
92bdd51cd4 Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2012-11-27 14:54:18 -05:00
snowleo
0ed29c029d Add log color removal.
(This could already be done with the bukkit setting "log-strip-color")
2012-11-27 19:54:32 +01:00
KHobbits
61903355cd Fix kit timers, kit times more than 25 years will be treated as single use. 2012-11-27 18:27:23 +00:00
KHobbits
889f60e58e Userdata cleanup 2012-11-27 17:47:08 +00:00
KHobbits
c4f292f4ef Merge branch 'release' of github.com:essentials/Essentials into 2.9 2012-11-27 15:24:34 +00:00
Iaccidentally
36687e2659 Merge pull request #204 from necrodoom/patch-23
fix typo at config.yml
2012-11-25 09:30:13 -08:00
Necrodoom
948647926d fix typo at config.yml 2012-11-25 15:07:25 +02:00
Iaccidentally
4a4f443fee Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2012-11-24 14:55:54 -05:00
KHobbits
18d52821b7 Merge pull request #201 from necrodoom/patch-22
fix spacing at disabled-commands
2012-11-20 11:16:00 -08:00
Necrodoom
ad7d751856 fix spacing at disabled-commands 2012-11-20 19:38:21 +02:00
ElgarL
1151f1a29c Fix recursive error detection when partial mirroring the main world 2012-11-20 14:55:06 +00:00
snowleo
0b1625f4c1 Better fix for last commit 2012-11-19 22:03:25 +01:00
snowleo
1363406b84 Fix for the plugin conflict with any plugin that contains a log4j library 2012-11-19 20:28:12 +01:00
KHobbits
4b875ed4d9 Merge branch 'release' of github.com:essentials/Essentials into 2.9 2012-11-19 14:28:28 +00:00
KHobbits
42872650d2 Add tptoggle others Essentials style. 2012-11-16 01:37:47 +00:00
Iaccidentally
fd87933aa9 Merge remote-tracking branch 'remotes/origin/release' into 2.9 2012-11-13 22:57:14 -05:00
ElgarL
269cf85457 Update bukkit.jar to #1593 in lib so we can reference the new
interfaces.
2012-11-13 10:17:15 +00:00
Iaccidentally
5728f964a5 Merge pull request #195 from evonuts/2.9
Update fly command to allow for /fly on|*ena*|1 and inversely, /fly off|...
2012-11-11 14:21:18 -08:00
ElgarL
a7aa8be37a Prevent GM commands from being used on CommandBlocks. 2012-11-11 20:56:07 +00:00
ElgarL
237c896fff Add support for Rcon. 2012-11-11 20:39:03 +00:00
Iaccidentally
fbb3d7344f update tptoggle to allow toggling other players :: new permission: essentials.tptoggle.others 2012-11-11 14:34:56 -05:00
KHobbits
8b660d32ac Cleanup spawnmob classes
Spawnmob sign nolonger calls Command
Spawnmob other, now spawns at targets feet, rather than where the target is looking
Console can now spawnmob other
2012-11-11 18:55:02 +00:00
Iaccidentally
98bccf6cec Merge pull request #197 from necrodoom/patch-21
Update Essentials/src/com/earth2me/essentials/Mob.java
2012-11-11 09:10:33 -08:00
KHobbits
936606ce7c Mob comment. 2012-11-11 17:04:16 +00:00
Necrodoom
a63748ca3a Update Essentials/src/com/earth2me/essentials/Mob.java 2012-11-11 18:58:05 +02:00
Iaccidentally
a1ce340ce0 Make playerFishEvent cancel AFK :: fixes #3192 2012-11-11 11:43:10 -05:00
KHobbits
a8df79661a Merge branch '2.9' of github.com:essentials/Essentials into release 2012-11-11 14:55:00 +00:00
KHobbits
f52e0ae7a8 Merge branch 'groupmanager' of github.com:essentials/Essentials into 2.9 2012-11-11 14:54:19 +00:00
KHobbits
648a5ef8dd Merge branch '2.9' of github.com:essentials/Essentials into release 2012-11-11 14:53:42 +00:00
Iaccidentally
0d610f761b Merge pull request #196 from necrodoom/patch-20
update ID 101, by andrewkm request
2012-11-10 09:53:16 -08:00
Necrodoom
e7afe4109e update ID 101, by andrewkm request 2012-11-10 19:12:25 +02:00
evonuts
b11a1a7cf2 Fix fly specific settings for other players (eg. /fly evonuts on) 2012-11-10 22:17:39 +13:00
evonuts
6a8a2dd28b Update fly command to allow for /fly on|*ena*|1 and inversely, /fly off|*dis*|0. 2012-11-10 13:40:48 +13:00
ElgarL
a370a8e01c Merge pull request #194 from necrodoom/patch-19
correct spaces at plugin.yml
2012-11-09 05:51:52 -08:00
ElgarL
5e38a2180c Merge pull request #193 from necrodoom/patch-18
GroupManager typo fix
2012-11-09 05:51:15 -08:00
ElgarL
f3bc94a547 Merge pull request #190 from necrodoom/patch-16
fix typos and update ingame error message
2012-11-09 05:50:39 -08:00
Necrodoom
ba0db53c44 correct spaces at plugin.yml 2012-11-08 16:35:57 +02:00
Necrodoom
ef98a6b54c GroupManager typo fix 2012-11-08 16:31:49 +02:00
KHobbits
8c9b755671 Extra perm check in /home 2012-11-08 11:53:26 +00:00
md_5
6c1da1d552 Set a players sleeping ignored status synchronously, just in case! Thanks for the hint mbaxter & Wolvereness. Closes ticket 3179. 2012-11-08 18:57:44 +11:00
Iaccidentally
0df0be5762 Merge pull request #192 from evonuts/2.9
Allow for console based gamemode shortcuts. Fixes ticket #3173
2012-11-07 18:39:39 -08:00
evonuts
83120f707f Allow for console based gamemode shortcuts. Fixes ticket #3173 2012-11-08 15:19:07 +13:00
Iaccidentally
9d98edb4ee fix build 2012-11-04 19:04:10 -05:00
Iaccidentally
a50b0ac71d CB 2455 :: Bukkit 1593 2012-11-04 17:52:35 -05:00
KHobbits
d674e65c11 Allow the 'userIsNotAway' and 'userIsAway' translation messages to be empty. 2012-11-04 22:41:35 +00:00
Alexander Schepp
4967279b8c Allow the noNewMail translation to be empty 2012-11-04 22:34:47 +01:00
KHobbits
4722e687fa Code comments. 2012-11-04 21:31:23 +00:00
Iaccidentally
332a59f3fc allow money to be put in kits using the currency symbol before the amount 2012-11-04 16:25:09 -05:00
KHobbits
587f532991 Use durability instead of itemdata for antibuild checks.
Fixes potion blocking using antibuild.
2012-11-04 18:02:36 +00:00
KHobbits
10244d5f90 Fix godmode pvp protection not blocking thrown pots and arrows. 2012-11-04 17:31:57 +00:00
KHobbits
6f1a70dc8b Fix missing mob target block 2012-11-04 16:45:02 +00:00
KHobbits
7369155166 Fix a few more errors in plugin.yml 2012-11-04 13:29:39 +00:00
KHobbits
28d4609c8c Fix plugin.yml typo. 2012-11-04 13:16:05 +00:00
KHobbits
d2966b64eb Code comments 2012-11-04 02:24:54 +00:00
KHobbits
c8f8680ce9 Limit tnt disable on /nuke to 10s 2012-11-04 02:18:51 +00:00
md_5
9fcb412774 Update Spanish translations thanks to nikooo14. 2012-11-03 11:47:39 +11:00
Necrodoom
296af1069e Update EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java 2012-11-02 18:21:26 +02:00
Alexander Schepp
b22e97b3cf remove all L 2012-10-31 21:30:57 +01:00
Iaccidentally
dcf90cbf5a Make /exp accept L before or after the amount, add extra checks 2012-10-31 16:25:13 -04:00
Alexander Schepp
4dc2e2e3fd Handle int overflow in SetExpFix 2012-10-31 21:06:30 +01:00
Alexander Schepp
4d4779ecdc Use the class, not the interface
This code will be changed later, once Elgarl updates the gm branch to 1.4
2012-10-31 20:06:32 +01:00
Alexander Schepp
1c25d317dd Quickfix to prevent GM commands from being called by BlockCommandSender. 2012-10-31 19:44:13 +01:00
Iaccidentally
651a62890a fix minimum required bukkit version. 2012-10-29 14:26:51 -03:00
Iaccidentally
39b38f0619 CB 2420 :: Bukkit 1570 :: Update FakeServer and OfflinePlayer 2012-10-29 13:17:56 -04:00
KHobbits
4a194e8758 Merge pull request #185 from evonuts/patch-5
Update Essentials/src/config.yml
2012-10-29 02:21:24 -07:00
evonuts
5a35da53a0 Update Essentials/src/config.yml
'flase' typo in wither-spawnexplosion
2012-10-29 22:06:23 +13:00
ementalo
8d64c7c81b Fix mail 2012-10-28 20:09:25 +00:00
ementalo
bea3583192 Fix mail 2012-10-28 20:00:15 +00:00
Iaccidentally
618d115233 typo fix 2012-10-28 15:03:45 -03:00
Iaccidentally
5e476f4d61 Update Essentials/src/com/earth2me/essentials/commands/Commandtppos.java
2.9 too
2012-10-28 15:01:54 -03:00
Iaccidentally
5bc1b8df70 nothing to see here, move along (typo fix) 2012-10-28 13:09:19 -04:00
Iaccidentally
72e0ab2cb2 NOW with complete wither protection! 2012-10-28 13:05:08 -04:00
Iaccidentally
e0d189a5e0 oops! :: fix wither spawn explosion blocking 2012-10-28 12:58:01 -04:00
Iaccidentally
91c193b773 Fully support wither blocking in protect 2012-10-28 12:53:12 -04:00
Iaccidentally
4a18130354 CB #2415 2012-10-28 12:23:47 -04:00
Iaccidentally
7c6268fe20 Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2012-10-28 11:10:17 -04:00
Iaccidentally
6f213c23e2 update tppos to not accept coords over 30000000 2012-10-28 11:09:49 -04:00
Iaccidentally
cc606fe1aa Merge pull request #184 from necrodoom/patch-15
add bat egg and witch egg
2012-10-28 07:40:52 -07:00
Necrodoom
ee8638841d add bat egg and witch egg
enderdragon and wither have no useable eggs, so not added
2012-10-28 16:37:23 +02:00
Iaccidentally
9864a75c32 Protect updates :: ability to prevent wither damage :: block spawning of new mobs 2012-10-28 09:39:54 -04:00
Iaccidentally
520427239f CB #2406 Bukkit #1568 2012-10-28 09:11:50 -04:00
md-5
614a229ea7 Merge pull request #183 from evonuts/patch-4
Update Essentials/src/config.yml
2012-10-28 03:22:55 -07:00
evonuts
2a4d40020e Update Essentials/src/config.yml 2012-10-28 22:37:00 +13:00
md_5
d6efae202a Why the f*** do we depend on Bukkit too? 2012-10-28 20:09:26 +11:00
md-5
7b9c711486 Merge pull request #182 from evonuts/patch-3
Update Essentials/src/config.yml
2012-10-28 02:02:24 -07:00
md_5
e2bd22d984 No idea why this still refuses to compile locally. Stupid ant. 2012-10-28 20:01:27 +11:00
evonuts
2310b41b21 Update Essentials/src/config.yml 2012-10-28 21:55:20 +13:00
md-5
2ae9c577db Merge pull request #180 from Glyca/2.9
Added, fixed and improved French translations
2012-10-28 01:38:51 -07:00
md-5
7c9375ce2e Merge pull request #176 from necrodoom/patch-14
update files to minecraft 1.4
2012-10-28 01:37:22 -07:00
Glyca
9addc2ccd5 Added, fixed and improved French translations 2012-10-27 21:47:55 +02:00
Necrodoom
e180f6e6b3 update ID 137 2012-10-27 10:41:50 +03:00
KHobbits
f0e29552bc Merge branch '2.9' of github.com:essentials/Essentials into release 2012-10-26 21:41:49 +01:00
KHobbits
48d04216a7 Reduce calls to bukkit getPlayer(); 2012-10-26 21:34:36 +01:00
ementalo
ff6221f1a8 2.9 Release 2012-10-26 09:48:45 +01:00
KHobbits
0bc33554f3 Fix tp delay message 2012-10-23 00:00:55 +01:00
KHobbits
7c480e88d6 Update EssentialsAntiBuild/src/com/earth2me/essentials/antibuild/EssentialsAntiBuildListener.java 2012-10-22 14:55:52 +02:00
KHobbits
c357d19c56 Update listener comment 2012-10-22 12:27:01 +02:00
Alexander Schepp
86124b2705 Fix NPE in UserData on login
if no address is available
2012-10-21 23:17:08 +03:00
KHobbits
99cefb2d74 Fix perm check in /kill 2012-10-20 19:24:33 +01:00
KHobbits
600f99eb6b If the player is still alive, make sure he dies. (/kill) 2012-10-20 19:18:04 +01:00
KHobbits
8ba7a24fd2 Block explicit /home bed, unless user has "essentials.home.bed" permission.
This does not effect the '/home' command when used with no arguments.
In this case, a player will still be sent to the bed home, if they have no Ess home set.
2012-10-20 16:15:43 +01:00
KHobbits
ef608c7595 Remove extra home check. 2012-10-20 16:09:54 +01:00
Necrodoom
2ea453110a update mob.java to 1.4 2012-10-20 12:24:18 +03:00
Necrodoom
a86efb5ebe update items.csv to 1.4
items.csv version 2.2_01
2012-10-20 12:11:27 +03:00
ementalo
e61fa58d2b Fix test 2012-10-17 13:14:59 +01:00
ementalo
ec5edf7bd2 CB #2396 B #1566 2012-10-17 13:09:03 +01:00
snowleo
8dbcebda53 Don't call plugin manager in Settings. 2012-10-15 20:30:52 +02:00
KHobbits
28d2a9ed2e Merge pull request #174 from necrodoom/patch-13
fix sandstone slab aliases
2012-10-14 09:44:26 -07:00
Necrodoom
d47e9145f3 fix sandstone slab aliases 2012-10-14 19:40:57 +03:00
KHobbits
ae7c64619c Allow kicking of hidden players 2012-10-14 13:04:00 +01:00
KHobbits
bdef1780ac Warn when banning a player who has never connected to the server. 2012-10-14 13:03:54 +01:00
Iaccidentally
ced192e8fd Update Essentials/src/items.csv
quick items.csv fix
2012-10-09 05:19:27 -03:00
KHobbits
0a9e9ca41d Merge branch '2.9' of github.com:essentials/Essentials into 2.9 2012-10-07 22:40:18 +01:00
KHobbits
4982cc950e Add alt warp perm for others 2012-10-07 22:40:04 +01:00
snowleo
140a9100b7 Update AntiBuild for NB7.2 2012-10-07 23:00:09 +02:00
snowleo
0097f961b4 Prevent massive amount of mails being send.
Added new config: mails-per-minute, default 1000
2012-10-07 22:46:15 +02:00
KHobbits
98d657ec4b New permission: essentials.vanish.pvp
If you don't have this permission you cannot PVP while vanished.
2012-10-07 18:10:50 +01:00
KHobbits
63149d0b50 Change default action colour to be different to /say 2012-10-06 22:26:51 +01:00
KHobbits
7a410919a0 Code comments 2012-10-06 03:49:36 +01:00
KHobbits
aa7a39d0b0 Comment for future sanity. 2012-10-05 02:06:23 +01:00
KHobbits
9b88107897 Fix gamemode other perm check 2012-10-02 21:06:28 +01:00
KHobbits
147a2fc227 Better handle invalid warp names 2012-10-02 00:19:42 +01:00
KHobbits
732dc3bf34 Cleanup sethome 2012-10-01 20:32:10 +01:00
Alexander Schepp
227cde75a7 Merge pull request #171 from chrisgward/patch-5
Adding console override to sudo chat
2012-10-01 10:31:48 -07:00
Chris Ward
e670d0af45 Adding console override to sudo chat, changing say to c: 2012-10-02 03:30:13 +10:00
ElgarL
cd0fde05b7 Merge remote-tracking branch 'remotes/origin/2.9' into groupmanager 2012-10-01 17:51:56 +01:00
ElgarL
8cf2ce7b73 Merge branch '2.9' of https://ElgarL@github.com/essentials/Essentials.git into 2.9 2012-10-01 17:50:08 +01:00
ElgarL
1ecf592893 Move Event to LOW so permissions get updated before this event is
triggered.

With LOWEST it would only randomly work with most perm systems,
depending on the loading order.
2012-10-01 17:49:42 +01:00
Alexander Schepp
0dd0dba338 Merge pull request #165 from chrisgward/patch-2
Adding say command to sudo to fake chat
2012-10-01 09:34:49 -07:00
Alexander Schepp
678ae78767 Merge pull request #166 from chrisgward/patch-3
Blocking numeric home names, changing invalid home message
2012-10-01 09:34:09 -07:00
Chris Ward
d8b6742543 Blocking numeric home names, changing invalid home message 2012-10-02 02:32:52 +10:00
Chris Ward
2671f39951 Adding -c switch to sudo to fake chat 2012-10-02 02:31:15 +10:00
Alexander Schepp
d7ddf3c828 Merge pull request #169 from chrisgward/patch-5
Adding console only overrides to exempts
2012-10-01 09:15:18 -07:00
Alexander Schepp
2b7cba936d Merge pull request #170 from chrisgward/2.9
Fixing storage of compiled regex
2012-10-01 09:12:35 -07:00
Chris Ward
2757c707bb Fixing storage of compiled regex 2012-10-02 02:11:05 +10:00
Chris Ward
f50c5276e4 Adding console overrides to exempts 2012-10-02 01:57:29 +10:00
Iaccidentally
a7e692fe37 Merge pull request #164 from chrisgward/patch-1
Fixing bad file names in Windows (Fixes #2924)
2012-10-01 07:16:22 -07:00
Chris Ward
02d273f15e Fixing bad file names in Windows (Fixes #2924) 2012-10-01 21:20:17 +10:00
ElgarL
778f5649c8 allWorldsDataList now returns fully mirrored worlds whihc are not
identical mirrors (fixes the /manselect list).
2012-10-01 12:05:49 +01:00
KHobbits
d7829bef28 Merge pull request #163 from chrisgward/patch-1
Fixes #2933
2012-10-01 03:27:37 -07:00
Chris Ward
d436d10b00 Typo (Ticket 2933) 2012-10-01 20:12:13 +10:00
KHobbits
2d9254eb28 Merge pull request #158 from necrodoom/patch-10
update potion aliases- add all unused potions
2012-09-30 13:55:20 -07:00
KHobbits
23393aea5f Merge pull request #162 from necrodoom/patch-12
small fixes to items.csv
2012-09-30 13:55:09 -07:00
KHobbits
e1562e38bf Restore removed tp method, it is used in other plugins. 2012-09-30 18:15:46 +01:00
Necrodoom
29fa2f0f19 small fixes to items.csv 2012-09-30 19:22:14 +03:00
KHobbits
b850ae93e9 Merge branch 'release' of github.com:essentials/Essentials into 2.9 2012-09-30 17:21:09 +01:00
KHobbits
872bc4df4c New permission: essentials.teleport.timer.move - allow players to move during tp delay 2012-09-29 23:48:59 +01:00
KHobbits
3083ba2627 Little bit DRYer 2012-09-29 23:41:12 +01:00
KHobbits
35259892b8 Merge branch '2.9' of github.com:essentials/Essentials into 2.9 2012-09-29 23:35:09 +01:00
KHobbits
fbc0f13b2b Properly handle tphere requests so the right user is in control/charged. 2012-09-29 23:34:46 +01:00
KHobbits
aa7f49cb85 Tidy Teleport file 2012-09-29 23:33:32 +01:00
KHobbits
720676542e Merge pull request #161 from necrodoom/patch-11
update signs permission check
2012-09-29 13:52:07 -07:00
Necrodoom
1d7eb77f27 update kit sign permission check 2012-09-29 15:57:31 +03:00
Necrodoom
895f6269fc update warp sign permission check 2012-09-29 15:55:47 +03:00
KHobbits
4bf0d3ab24 Should fix tpaccept charge bug - needs testing 2012-09-29 03:59:31 +01:00
Necrodoom
838d7dd8f9 update potion aliases- add all unused potions
items.csv version 2.1_13
2012-09-28 17:02:43 +03:00
178 changed files with 7152 additions and 2706 deletions

4
.gitignore vendored
View File

@@ -42,4 +42,6 @@
/EssentialsGroupManager/.externalToolBuilders
/EssentialsAntiBuild/nbproject/private/
/EssentialsAntiBuild/dist/
/EssentialsAntiBuild/build/
/EssentialsAntiBuild/build/
/jars
/out

View File

@@ -12,9 +12,9 @@ is divided into following sections:
- execution
- debugging
- javadoc
- junit compilation
- junit execution
- junit debugging
- test compilation
- test execution
- test debugging
- applet
- cleanup
@@ -181,6 +181,7 @@ is divided into following sections:
</and>
</condition>
<property name="run.jvmargs" value=""/>
<property name="run.jvmargs.ide" value=""/>
<property name="javac.compilerargs" value=""/>
<property name="work.dir" value="${basedir}"/>
<condition property="no.deps">
@@ -225,6 +226,27 @@ is divided into following sections:
<property name="jar.index.metainf" value="${jar.index}"/>
<property name="copylibs.rebase" value="true"/>
<available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
<condition property="junit.available">
<or>
<available classname="org.junit.Test" classpath="${run.test.classpath}"/>
<available classname="junit.framework.Test" classpath="${run.test.classpath}"/>
</or>
</condition>
<condition property="testng.available">
<available classname="org.testng.annotations.Test" classpath="${run.test.classpath}"/>
</condition>
<condition property="junit+testng.available">
<and>
<istrue value="${junit.available}"/>
<istrue value="${testng.available}"/>
</and>
</condition>
<condition else="testng" property="testng.mode" value="mixed">
<istrue value="${junit+testng.available}"/>
</condition>
<condition else="" property="testng.debug.mode" value="-mixed">
<istrue value="${junit+testng.available}"/>
</condition>
</target>
<target name="-post-init">
<!-- Empty placeholder for easier customization. -->
@@ -357,11 +379,52 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target name="-init-macrodef-junit">
<target if="${junit.available}" name="-init-macrodef-junit-init">
<condition else="false" property="nb.junit.batch" value="true">
<and>
<istrue value="${junit.available}"/>
<not>
<isset property="test.method"/>
</not>
</and>
</condition>
<condition else="false" property="nb.junit.single" value="true">
<and>
<istrue value="${junit.available}"/>
<isset property="test.method"/>
</and>
</condition>
</target>
<target if="${nb.junit.single}" name="-init-macrodef-junit-single" unless="${nb.junit.batch}">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<element name="customize" optional="true"/>
<sequential>
<property name="junit.forkmode" value="perTest"/>
<junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
<test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
<mapper from="test-sys-prop.*" to="*" type="glob"/>
</syspropertyset>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<jvmarg value="-ea"/>
<customize/>
</junit>
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<element name="customize" optional="true"/>
<sequential>
<property name="junit.forkmode" value="perTest"/>
<junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
@@ -370,32 +433,270 @@ is divided into following sections:
<filename name="@{testincludes}"/>
</fileset>
</batchtest>
<classpath>
<path path="${run.test.classpath}"/>
</classpath>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
<mapper from="test-sys-prop.*" to="*" type="glob"/>
</syspropertyset>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg value="-ea"/>
<jvmarg line="${run.jvmargs}"/>
<customize/>
</junit>
</sequential>
</macrodef>
</target>
<target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" name="profile-init"/>
<target name="-profile-pre-init">
<target depends="-init-macrodef-junit-init,-init-macrodef-junit-single, -init-macrodef-junit-batch" if="${junit.available}" name="-init-macrodef-junit"/>
<target if="${testng.available}" name="-init-macrodef-testng">
<macrodef name="testng" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<element name="customize" optional="true"/>
<sequential>
<condition else="" property="testng.methods.arg" value="@{testincludes}.@{testmethods}">
<isset property="test.method"/>
</condition>
<union id="test.set">
<fileset dir="${test.src.dir}" excludes="@{excludes},**/*.xml,${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
</union>
<taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/>
<testng classfilesetref="test.set" failureProperty="tests.failed" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="BuildAll" testname="TestNG tests" workingDir="${work.dir}">
<xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/>
<propertyset>
<propertyref prefix="test-sys-prop."/>
<mapper from="test-sys-prop.*" to="*" type="glob"/>
</propertyset>
<customize/>
</testng>
</sequential>
</macrodef>
</target>
<target name="-init-macrodef-test-impl">
<macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<element implicit="true" name="customize" optional="true"/>
<sequential>
<echo>No tests executed.</echo>
</sequential>
</macrodef>
</target>
<target depends="-init-macrodef-junit" if="${junit.available}" name="-init-macrodef-junit-impl">
<macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<element implicit="true" name="customize" optional="true"/>
<sequential>
<j2seproject3:junit excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
<customize/>
</j2seproject3:junit>
</sequential>
</macrodef>
</target>
<target depends="-init-macrodef-testng" if="${testng.available}" name="-init-macrodef-testng-impl">
<macrodef name="test-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<element implicit="true" name="customize" optional="true"/>
<sequential>
<j2seproject3:testng excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
<customize/>
</j2seproject3:testng>
</sequential>
</macrodef>
</target>
<target depends="-init-macrodef-test-impl,-init-macrodef-junit-impl,-init-macrodef-testng-impl" name="-init-macrodef-test">
<macrodef name="test" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<sequential>
<j2seproject3:test-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
<customize>
<classpath>
<path path="${run.test.classpath}"/>
</classpath>
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg line="${run.jvmargs}"/>
<jvmarg line="${run.jvmargs.ide}"/>
</customize>
</j2seproject3:test-impl>
</sequential>
</macrodef>
</target>
<target if="${junit.available}" name="-init-macrodef-junit-debug" unless="${nb.junit.batch}">
<macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<element name="customize" optional="true"/>
<sequential>
<property name="junit.forkmode" value="perTest"/>
<junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
<test methods="@{testmethods}" name="@{testincludes}" todir="${build.test.results.dir}"/>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
<mapper from="test-sys-prop.*" to="*" type="glob"/>
</syspropertyset>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<jvmarg value="-ea"/>
<jvmarg line="${debug-args-line}"/>
<jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
<customize/>
</junit>
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
<macrodef name="junit-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<element name="customize" optional="true"/>
<sequential>
<property name="junit.forkmode" value="perTest"/>
<junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
<batchtest todir="${build.test.results.dir}">
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
<mapper from="test-sys-prop.*" to="*" type="glob"/>
</syspropertyset>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<jvmarg value="-ea"/>
<jvmarg line="${debug-args-line}"/>
<jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
<customize/>
</junit>
</sequential>
</macrodef>
</target>
<target depends="-init-macrodef-junit-debug,-init-macrodef-junit-debug-batch" if="${junit.available}" name="-init-macrodef-junit-debug-impl">
<macrodef name="test-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<element implicit="true" name="customize" optional="true"/>
<sequential>
<j2seproject3:junit-debug excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
<customize/>
</j2seproject3:junit-debug>
</sequential>
</macrodef>
</target>
<target if="${testng.available}" name="-init-macrodef-testng-debug">
<macrodef name="testng-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${main.class}" name="testClass"/>
<attribute default="" name="testMethod"/>
<element name="customize2" optional="true"/>
<sequential>
<condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}">
<isset property="test.method"/>
</condition>
<condition else="-suitename BuildAll -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
<matches pattern=".*\.xml" string="@{testClass}"/>
</condition>
<delete dir="${build.test.results.dir}" quiet="true"/>
<mkdir dir="${build.test.results.dir}"/>
<j2seproject3:debug classname="org.testng.TestNG" classpath="${debug.test.classpath}">
<customize>
<customize2/>
<jvmarg value="-ea"/>
<arg line="${testng.debug.mode}"/>
<arg line="-d ${build.test.results.dir}"/>
<arg line="-listener org.testng.reporters.VerboseReporter"/>
<arg line="${testng.cmd.args}"/>
</customize>
</j2seproject3:debug>
</sequential>
</macrodef>
</target>
<target depends="-init-macrodef-testng-debug" if="${testng.available}" name="-init-macrodef-testng-debug-impl">
<macrodef name="testng-debug-impl" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${main.class}" name="testClass"/>
<attribute default="" name="testMethod"/>
<element implicit="true" name="customize2" optional="true"/>
<sequential>
<j2seproject3:testng-debug testClass="@{testClass}" testMethod="@{testMethod}">
<customize2/>
</j2seproject3:testng-debug>
</sequential>
</macrodef>
</target>
<target depends="-init-macrodef-junit-debug-impl" if="${junit.available}" name="-init-macrodef-test-debug-junit">
<macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<attribute default="${main.class}" name="testClass"/>
<attribute default="" name="testMethod"/>
<sequential>
<j2seproject3:test-debug-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
<customize>
<classpath>
<path path="${run.test.classpath}"/>
</classpath>
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg line="${run.jvmargs}"/>
<jvmarg line="${run.jvmargs.ide}"/>
</customize>
</j2seproject3:test-debug-impl>
</sequential>
</macrodef>
</target>
<target depends="-init-macrodef-testng-debug-impl" if="${testng.available}" name="-init-macrodef-test-debug-testng">
<macrodef name="test-debug" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<attribute default="${main.class}" name="testClass"/>
<attribute default="" name="testMethod"/>
<sequential>
<j2seproject3:testng-debug-impl testClass="@{testClass}" testMethod="@{testMethod}">
<customize2>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
<mapper from="test-sys-prop.*" to="*" type="glob"/>
</syspropertyset>
</customize2>
</j2seproject3:testng-debug-impl>
</sequential>
</macrodef>
</target>
<target depends="-init-macrodef-test-debug-junit,-init-macrodef-test-debug-testng" name="-init-macrodef-test-debug"/>
<!--
pre NB7.2 profiling section; consider it deprecated
-->
<target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" if="profiler.info.jvmargs.agent" name="profile-init"/>
<target if="profiler.info.jvmargs.agent" name="-profile-pre-init">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-profile-post-init">
<target if="profiler.info.jvmargs.agent" name="-profile-post-init">
<!-- Empty placeholder for easier customization. -->
<!-- You can override this target in the ../build.xml file. -->
</target>
<target name="-profile-init-macrodef-profile">
<target if="profiler.info.jvmargs.agent" name="-profile-init-macrodef-profile">
<macrodef name="resolve">
<attribute name="name"/>
<attribute name="value"/>
@@ -427,10 +728,13 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" name="-profile-init-check">
<target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" if="profiler.info.jvmargs.agent" name="-profile-init-check">
<fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>
<fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
</target>
<!--
end of pre NB7.2 profiling section
-->
<target depends="-init-debug-args" name="-init-macrodef-nbjpda">
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
<attribute default="${main.class}" name="name"/>
@@ -488,6 +792,7 @@ is divided into following sections:
<jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
<redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
<jvmarg line="${run.jvmargs}"/>
<jvmarg line="${run.jvmargs.ide}"/>
<classpath>
<path path="@{classpath}"/>
</classpath>
@@ -504,6 +809,7 @@ is divided into following sections:
<macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
<attribute default="${main.class}" name="classname"/>
<attribute default="${run.classpath}" name="classpath"/>
<attribute default="jvm" name="jvm"/>
<element name="customize" optional="true"/>
<sequential>
<java classname="@{classname}" dir="${work.dir}" fork="true">
@@ -511,6 +817,7 @@ is divided into following sections:
<jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
<redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
<jvmarg line="${run.jvmargs}"/>
<jvmarg line="${run.jvmargs.ide}"/>
<classpath>
<path path="@{classpath}"/>
</classpath>
@@ -537,6 +844,9 @@ is divided into following sections:
<path path="${run.classpath.without.build.classes.dir}"/>
<chainedmapper>
<flattenmapper/>
<filtermapper>
<replacestring from=" " to="%20"/>
</filtermapper>
<globmapper from="*" to="lib/*"/>
</chainedmapper>
</pathconvert>
@@ -582,7 +892,7 @@ is divided into following sections:
<target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
<property name="ap.cmd.line.internal" value=""/>
</target>
<target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
<target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-test,-init-macrodef-test-debug,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
<!--
===================
COMPILATION SECTION
@@ -861,7 +1171,11 @@ is divided into following sections:
PROFILING SECTION
=================
-->
<target depends="profile-init,compile" description="Profile a project in the IDE." if="netbeans.home" name="profile">
<!--
pre NB7.2 profiler integration
-->
<target depends="profile-init,compile" description="Profile a project in the IDE." if="profiler.info.jvmargs.agent" name="-profile-pre72">
<fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
<nbprofiledirect>
<classpath>
<path path="${run.classpath}"/>
@@ -869,8 +1183,9 @@ is divided into following sections:
</nbprofiledirect>
<profile/>
</target>
<target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="netbeans.home" name="profile-single">
<target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="profiler.info.jvmargs.agent" name="-profile-single-pre72">
<fail unless="profile.class">Must select one file in the IDE or set profile.class</fail>
<fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
<nbprofiledirect>
<classpath>
<path path="${run.classpath}"/>
@@ -878,12 +1193,8 @@ is divided into following sections:
</nbprofiledirect>
<profile classname="${profile.class}"/>
</target>
<!--
=========================
APPLET PROFILING SECTION
=========================
-->
<target depends="profile-init,compile-single" if="netbeans.home" name="profile-applet">
<target depends="profile-init,compile-single" if="profiler.info.jvmargs.agent" name="-profile-applet-pre72">
<fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
<nbprofiledirect>
<classpath>
<path path="${run.classpath}"/>
@@ -895,12 +1206,8 @@ is divided into following sections:
</customize>
</profile>
</target>
<!--
=========================
TESTS PROFILING SECTION
=========================
-->
<target depends="profile-init,compile-test-single" if="netbeans.home" name="profile-test-single">
<target depends="profile-init,compile-test-single" if="profiler.info.jvmargs.agent" name="-profile-test-single-pre72">
<fail unless="netbeans.home">This target only works when run from inside the NetBeans IDE.</fail>
<nbprofiledirect>
<classpath>
<path path="${run.test.classpath}"/>
@@ -922,6 +1229,42 @@ is divided into following sections:
<formatter type="xml"/>
</junit>
</target>
<!--
end of pre NB72 profiling section
-->
<target if="netbeans.home" name="-profile-check">
<condition property="profiler.configured">
<or>
<contains casesensitive="true" string="${run.jvmargs.ide}" substring="-agentpath:"/>
<contains casesensitive="true" string="${run.jvmargs.ide}" substring="-javaagent:"/>
</or>
</condition>
</target>
<target depends="-profile-check,-profile-pre72" description="Profile a project in the IDE." if="profiler.configured" name="profile" unless="profiler.info.jvmargs.agent">
<startprofiler/>
<antcall target="run"/>
</target>
<target depends="-profile-check,-profile-single-pre72" description="Profile a selected class in the IDE." if="profiler.configured" name="profile-single" unless="profiler.info.jvmargs.agent">
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
<startprofiler/>
<antcall target="run-single"/>
</target>
<target depends="-profile-test-single-pre72" description="Profile a selected test in the IDE." name="profile-test-single"/>
<target depends="-profile-check" description="Profile a selected test in the IDE." if="profiler.configured" name="profile-test" unless="profiler.info.jvmargs">
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
<startprofiler/>
<antcall target="test-single"/>
</target>
<target depends="-profile-check" description="Profile a selected class in the IDE." if="profiler.configured" name="profile-test-with-main">
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
<startprofiler/>
<antcal target="run-test-with-main"/>
</target>
<target depends="-profile-check,-profile-applet-pre72" if="profiler.configured" name="profile-applet" unless="profiler.info.jvmargs.agent">
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
<startprofiler/>
<antcall target="run-applet"/>
</target>
<!--
===============
JAVADOC SECTION
@@ -965,7 +1308,7 @@ is divided into following sections:
<target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
<!--
=========================
JUNIT COMPILATION SECTION
TEST COMPILATION SECTION
=========================
-->
<target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
@@ -1008,14 +1351,14 @@ is divided into following sections:
<target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
<!--
=======================
JUNIT EXECUTION SECTION
TEST EXECUTION SECTION
=======================
-->
<target depends="init" if="have.tests" name="-pre-test-run">
<mkdir dir="${build.test.results.dir}"/>
</target>
<target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
<j2seproject3:junit testincludes="**/*Test.java"/>
<j2seproject3:test testincludes="**/*Test.java"/>
</target>
<target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
<fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
@@ -1028,39 +1371,40 @@ is divided into following sections:
</target>
<target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
<j2seproject3:junit excludes="" includes="${test.includes}"/>
<j2seproject3:test excludes="" includes="${test.includes}" testincludes="${test.includes}"/>
</target>
<target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
<fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
</target>
<target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
<target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single-method">
<fail unless="test.class">Must select some files in the IDE or set test.class</fail>
<fail unless="test.method">Must select some method in the IDE or set test.method</fail>
<j2seproject3:test excludes="" includes="${javac.includes}" testincludes="${test.class}" testmethods="${test.method}"/>
</target>
<target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method" if="have.tests" name="-post-test-run-single-method">
<fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
</target>
<target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single-method,-post-test-run-single-method" description="Run single unit test." name="test-single-method"/>
<!--
=======================
JUNIT DEBUGGING SECTION
TEST DEBUGGING SECTION
=======================
-->
<target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
<target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test">
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
<property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
<delete file="${test.report.file}"/>
<mkdir dir="${build.test.results.dir}"/>
<j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
<customize>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
<mapper from="test-sys-prop.*" to="*" type="glob"/>
</syspropertyset>
<arg value="${test.class}"/>
<arg value="showoutput=true"/>
<arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
<arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
</customize>
</j2seproject3:debug>
<j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testincludes="${javac.includes}"/>
</target>
<target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-debug-start-debuggee-test-method">
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
<fail unless="test.method">Must select some method in the IDE or set test.method</fail>
<j2seproject3:test-debug excludes="" includes="${javac.includes}" testClass="${test.class}" testMethod="${test.method}" testincludes="${test.class}" testmethods="${test.method}"/>
</target>
<target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
<j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
</target>
<target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
<target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test-method" name="debug-test-method"/>
<target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
<j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
</target>
@@ -1188,9 +1532,12 @@ is divided into following sections:
<target name="-check-call-dep">
<property file="${call.built.properties}" prefix="already.built."/>
<condition property="should.call.dep">
<not>
<isset property="already.built.${call.subproject}"/>
</not>
<and>
<not>
<isset property="already.built.${call.subproject}"/>
</not>
<available file="${call.script}"/>
</and>
</condition>
</target>
<target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">

View File

@@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.50.3.46
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=b4df970c
nbproject/build-impl.xml.script.CRC32=1fd6d3cc
nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.3.46
nbproject/build-impl.xml.script.CRC32=8905537e
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46

View File

@@ -68,7 +68,6 @@ file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
file.reference.bPermissions.jar=../lib/bPermissions.jar
file.reference.bpermissions2.jar=../lib/bpermissions2.jar
file.reference.bukkit.jar=../lib/bukkit.jar
file.reference.craftbukkit.jar=../lib/craftbukkit.jar
file.reference.iCo4.jar=../lib/iCo4.jar
file.reference.iCo5.jar=../lib/iCo5.jar
file.reference.iCo6.jar=../lib/iCo6.jar
@@ -79,6 +78,7 @@ file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
file.reference.Privileges.jar=..\\lib\\Privileges.jar
file.reference.Vault.jar=../lib/Vault.jar
file.reference.SimplyPerms.jar=../lib/SimplyPerms.jar
includes=**
jar.archive.disabled=${jnlp.enabled}
jar.compress=true
@@ -96,12 +96,12 @@ javac.classpath=\
${file.reference.lombok.jar}:\
${reference.EssentialsGroupManager.jar}:\
${file.reference.bukkit.jar}:\
${file.reference.craftbukkit.jar}:\
${file.reference.Vault.jar}:\
${file.reference.Privileges.jar}:\
${file.reference.bpermissions2.jar}
${file.reference.bpermissions2.jar}:\
${file.reference.SimplyPerms.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.compilerargs=-Xlint:unchecked
javac.deprecation=false
javac.processorpath=\
${javac.classpath}

18
Essentials/src/book.txt Normal file
View File

@@ -0,0 +1,18 @@
This is the book file.
This file format works similar to the info.txt, motd.txt and rules.txt
Place content in here that you would like to be used by books ingame.
You can use this content by using the book:<section> meta option in kits or item spawning.
#Colors
Minecraft colors:
&0 &&0 &1 &&1 &2 &&2 &3 &&3
&4 &&4 &5 &&5 &6 &&6 &7 &&7
&8 &&8 &9 &&9 &a &&a &b &&b
&c &&c &d &&d &e &&e &f &&f
&0
&&k &kMagic&r &&l &lBold
&&m &mStrike&r &&n &nUline
&&o &oItalic&r &&r &rReset

View File

@@ -121,13 +121,14 @@ public class AlternativeCommandsHandler
return commands.get(0);
}
public void executed(final String label, final String otherLabel)
public void executed(final String label, final PluginCommand pc)
{
final String altString = pc.getPlugin().getName() + ":" + pc.getLabel();
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + otherLabel);
LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + altString);
}
disabledList.put(label, otherLabel);
disabledList.put(label, altString);
}
public Map<String, String> disabledCommands()

View File

@@ -72,7 +72,7 @@ public class Backup implements Runnable
server.dispatchCommand(cs, "save-all");
server.dispatchCommand(cs, "save-off");
ess.scheduleAsyncDelayedTask(
ess.runTaskAsynchronously(
new Runnable()
{
@Override

View File

@@ -5,13 +5,11 @@ import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.regex.Pattern;
import org.bukkit.enchantments.Enchantment;
public class Enchantments
{
private static final transient Pattern NUMPATTERN = Pattern.compile("\\d+");
private static final Map<String, Enchantment> ENCHANTMENTS = new HashMap<String, Enchantment>();
private static final Map<String, Enchantment> ALIASENCHANTMENTS = new HashMap<String, Enchantment>();
@@ -20,7 +18,7 @@ public class Enchantments
ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL);
ALIASENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL);
ENCHANTMENTS.put("sharpness", Enchantment.DAMAGE_ALL);
ENCHANTMENTS.put("sharp", Enchantment.DAMAGE_ALL);
ALIASENCHANTMENTS.put("sharp", Enchantment.DAMAGE_ALL);
ALIASENCHANTMENTS.put("dal", Enchantment.DAMAGE_ALL);
ENCHANTMENTS.put("ardmg", Enchantment.DAMAGE_ARTHROPODS);
@@ -38,12 +36,19 @@ public class Enchantments
ALIASENCHANTMENTS.put("minespeed", Enchantment.DIG_SPEED);
ALIASENCHANTMENTS.put("cutspeed", Enchantment.DIG_SPEED);
ALIASENCHANTMENTS.put("ds", Enchantment.DIG_SPEED);
ALIASENCHANTMENTS.put("eff", Enchantment.DIG_SPEED);
ENCHANTMENTS.put("durability", Enchantment.DURABILITY);
ENCHANTMENTS.put("dura", Enchantment.DURABILITY);
ALIASENCHANTMENTS.put("dura", Enchantment.DURABILITY);
ENCHANTMENTS.put("unbreaking", Enchantment.DURABILITY);
ALIASENCHANTMENTS.put("d", Enchantment.DURABILITY);
ENCHANTMENTS.put("thorns", Enchantment.THORNS);
ENCHANTMENTS.put("highcrit", Enchantment.THORNS);
ALIASENCHANTMENTS.put("thorn", Enchantment.THORNS);
ALIASENCHANTMENTS.put("highercrit", Enchantment.THORNS);
ALIASENCHANTMENTS.put("t", Enchantment.THORNS);
ENCHANTMENTS.put("fireaspect", Enchantment.FIRE_ASPECT);
ENCHANTMENTS.put("fire", Enchantment.FIRE_ASPECT);
ALIASENCHANTMENTS.put("meleefire", Enchantment.FIRE_ASPECT);
@@ -51,10 +56,13 @@ public class Enchantments
ALIASENCHANTMENTS.put("fa", Enchantment.FIRE_ASPECT);
ENCHANTMENTS.put("knockback", Enchantment.KNOCKBACK);
ALIASENCHANTMENTS.put("kback", Enchantment.KNOCKBACK);
ALIASENCHANTMENTS.put("kb", Enchantment.KNOCKBACK);
ALIASENCHANTMENTS.put("k", Enchantment.KNOCKBACK);
ALIASENCHANTMENTS.put("blockslootbonus", Enchantment.LOOT_BONUS_BLOCKS);
ENCHANTMENTS.put("fortune", Enchantment.LOOT_BONUS_BLOCKS);
ALIASENCHANTMENTS.put("fort", Enchantment.LOOT_BONUS_BLOCKS);
ALIASENCHANTMENTS.put("lbb", Enchantment.LOOT_BONUS_BLOCKS);
ALIASENCHANTMENTS.put("mobslootbonus", Enchantment.LOOT_BONUS_MOBS);
@@ -83,7 +91,7 @@ public class Enchantments
ALIASENCHANTMENTS.put("fallprotection", Enchantment.PROTECTION_FALL);
ENCHANTMENTS.put("fallprot", Enchantment.PROTECTION_FALL);
ENCHANTMENTS.put("featherfall", Enchantment.PROTECTION_FALL);
ENCHANTMENTS.put("featherfalling", Enchantment.PROTECTION_FALL);
ALIASENCHANTMENTS.put("featherfalling", Enchantment.PROTECTION_FALL);
ALIASENCHANTMENTS.put("pfa", Enchantment.PROTECTION_FALL);
ALIASENCHANTMENTS.put("fireprotection", Enchantment.PROTECTION_FIRE);
@@ -129,12 +137,12 @@ public class Enchantments
ALIASENCHANTMENTS.put("infinite", Enchantment.ARROW_INFINITE);
ALIASENCHANTMENTS.put("unlimited", Enchantment.ARROW_INFINITE);
ALIASENCHANTMENTS.put("unlimitedarrows", Enchantment.ARROW_INFINITE);
ALIASENCHANTMENTS.put("ai", Enchantment.ARROW_INFINITE);
ALIASENCHANTMENTS.put("ai", Enchantment.ARROW_INFINITE);
}
public static Enchantment getByName(String name) {
Enchantment enchantment;
if (NUMPATTERN.matcher(name).matches()) {
if (Util.isInt(name)) {
enchantment = Enchantment.getById(Integer.parseInt(name));
} else {
enchantment = Enchantment.getByName(name.toUpperCase(Locale.ENGLISH));

View File

@@ -47,9 +47,12 @@ import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.command.defaults.VanillaCommand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.world.WorldLoadEvent;
@@ -60,12 +63,13 @@ import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitTask;
import org.yaml.snakeyaml.error.YAMLException;
public class Essentials extends JavaPlugin implements IEssentials
{
public static final int BUKKIT_VERSION = 2352;
public static final int BUKKIT_VERSION = 2624;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
@@ -84,6 +88,7 @@ public class Essentials extends JavaPlugin implements IEssentials
private transient Metrics metrics;
private transient EssentialsTimer timer;
private transient List<String> vanishedPlayers = new ArrayList<String>();
private transient SimpleCommandMap scm;
@Override
public ISettings getSettings()
@@ -122,6 +127,7 @@ public class Essentials extends JavaPlugin implements IEssentials
i18n = new I18n(this);
i18n.onEnable();
execTimer.mark("I18n1");
scm = new SimpleCommandMap(this.getServer());
final PluginManager pm = getServer().getPluginManager();
for (Plugin plugin : pm.getPlugins())
{
@@ -176,6 +182,8 @@ public class Essentials extends JavaPlugin implements IEssentials
itemDb = new ItemDb(this);
confList.add(itemDb);
execTimer.mark("Init(Worth/ItemDB)");
jails = new Jails(this);
confList.add(jails);
reload();
}
catch (YAMLException exception)
@@ -207,6 +215,40 @@ public class Essentials extends JavaPlugin implements IEssentials
backup = new Backup(this);
permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions());
alternativeCommandsHandler = new AlternativeCommandsHandler(this);
timer = new EssentialsTimer(this);
getScheduler().scheduleSyncRepeatingTask(this, timer, 100, 100);
Economy.setEss(this);
execTimer.mark("RegHandler");
final MetricsStarter metricsStarter = new MetricsStarter(this);
if (metricsStarter.getStart() != null && metricsStarter.getStart() == true)
{
getScheduler().runTaskLaterAsynchronously(this, metricsStarter, 1);
}
else if (metricsStarter.getStart() != null && metricsStarter.getStart() == false)
{
final MetricsListener metricsListener = new MetricsListener(this, metricsStarter);
pm.registerEvents(metricsListener, this);
}
final String timeroutput = execTimer.end();
if (getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Essentials load " + timeroutput);
}
}
private void registerListeners(PluginManager pm)
{
HandlerList.unregisterAll(this);
if (getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Registering Listeners");
}
final EssentialsPluginListener serverListener = new EssentialsPluginListener(this);
pm.registerEvents(serverListener, this);
confList.add(serverListener);
@@ -232,34 +274,9 @@ public class Essentials extends JavaPlugin implements IEssentials
final EssentialsWorldListener worldListener = new EssentialsWorldListener(this);
pm.registerEvents(worldListener, this);
//TODO: Check if this should be here, and not above before reload()
jails = new Jails(this);
confList.add(jails);
pm.registerEvents(tntListener, this);
timer = new EssentialsTimer(this);
getScheduler().scheduleSyncRepeatingTask(this, timer, 100, 100);
Economy.setEss(this);
execTimer.mark("RegListeners");
final MetricsStarter metricsStarter = new MetricsStarter(this);
if (metricsStarter.getStart() != null && metricsStarter.getStart() == true)
{
getScheduler().scheduleAsyncDelayedTask(this, metricsStarter, 1);
}
else if (metricsStarter.getStart() != null && metricsStarter.getStart() == false)
{
final MetricsListener metricsListener = new MetricsListener(this, metricsStarter);
pm.registerEvents(metricsListener, this);
}
final String timeroutput = execTimer.end();
if (getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Essentials load " + timeroutput);
}
jails.resetListener();
}
@Override
@@ -291,6 +308,9 @@ public class Essentials extends JavaPlugin implements IEssentials
}
i18n.updateLocale(settings.getLocale());
final PluginManager pm = getServer().getPluginManager();
registerListeners(pm);
}
@Override
@@ -308,7 +328,7 @@ public class Essentials extends JavaPlugin implements IEssentials
final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel);
if (pc != null)
{
alternativeCommandsHandler.executed(commandLabel, pc.getLabel());
alternativeCommandsHandler.executed(commandLabel, pc);
try
{
return pc.execute(sender, commandLabel, args);
@@ -343,6 +363,16 @@ public class Essentials extends JavaPlugin implements IEssentials
// Check for disabled commands
if (getSettings().isCommandDisabled(commandLabel))
{
if (scm != null)
{
for (VanillaCommand cmd : scm.getFallbackCommands())
{
if (cmd.matches(commandLabel))
{
cmd.execute(sender, commandLabel, args);
}
}
}
return true;
}
@@ -368,6 +398,19 @@ public class Essentials extends JavaPlugin implements IEssentials
return true;
}
if (user != null && user.isJailed() && !user.isAuthorized(cmd, "essentials.jail.allow."))
{
if (user.getJailTimeout() > 0)
{
user.sendMessage(_("playerJailedFor", user.getName(), Util.formatDateDiff(user.getJailTimeout())));
}
else
{
user.sendMessage(_("jailMessage"));
}
return true;
}
// Run the command
try
{
@@ -467,16 +510,22 @@ public class Essentials extends JavaPlugin implements IEssentials
}
if (base instanceof String)
{
final User user = userMap.getUser((String)base);
if (user != null && user.getBase() instanceof OfflinePlayer)
{
((OfflinePlayer)user.getBase()).setName((String)base);
}
return user;
return getOfflineUser((String)base);
}
return null;
}
@Override
public User getOfflineUser(final String name)
{
final User user = userMap.getUser(name);
if (user != null && user.getBase() instanceof OfflinePlayer)
{
((OfflinePlayer)user.getBase()).setName(name);
}
return user;
}
private <T extends Player> User getUser(final T base)
{
if (base == null)
@@ -508,17 +557,6 @@ public class Essentials extends JavaPlugin implements IEssentials
return user;
}
@Override
public User getOfflineUser(final String name)
{
final User user = userMap.getUser(name);
if (user != null && user.getBase() instanceof OfflinePlayer)
{
((OfflinePlayer)user.getBase()).setName(name);
}
return user;
}
@Override
public World getWorld(final String name)
{
@@ -571,9 +609,14 @@ public class Essentials extends JavaPlugin implements IEssentials
}
@Override
public int scheduleAsyncDelayedTask(final Runnable run)
public BukkitTask runTaskAsynchronously(final Runnable run)
{
return this.getScheduler().scheduleAsyncDelayedTask(this, run);
return this.getScheduler().runTaskAsynchronously(this, run);
}
@Override
public BukkitTask runTaskLaterAsynchronously(final Runnable run, final long delay)
{
return this.getScheduler().runTaskLaterAsynchronously(this, run, delay);
}
@Override

View File

@@ -28,8 +28,7 @@ public class EssentialsBlockListener implements Listener
return;
}
final User user = ess.getUser(event.getPlayer());
final boolean unlimitedForUser = user.hasUnlimited(is);
if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL)
if (user.hasUnlimited(is) && user.getGameMode() == GameMode.SURVIVAL)
{
ess.scheduleSyncDelayedTask(
new Runnable()

View File

@@ -221,6 +221,69 @@ public class EssentialsConf extends YamlConfiguration
this.resourceClass = resClass;
}
public void save()
{
try
{
save(configFile);
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
}
}
public void saveWithError() throws IOException
{
save(configFile);
}
@Override
public synchronized void save(final File file) throws IOException
{
if (file == null)
{
throw new IllegalArgumentException("File cannot be null");
}
Files.createParentDirs(file);
final String data = saveToString();
if (data.length() == 0)
{
return;
}
if (!configFile.exists())
{
try
{
LOGGER.log(Level.INFO, _("creatingEmptyConfig", configFile.toString()));
if (!configFile.createNewFile())
{
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
}
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()), ex);
}
}
final OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), UTF8);
try
{
writer.write(data);
}
finally
{
writer.close();
}
}
public boolean hasProperty(final String path)
{
return isSet(path);
@@ -305,89 +368,14 @@ public class EssentialsConf extends YamlConfiguration
set(path, map);
}
public long getLong(final String path, final long def)
public void setProperty(String path, List object)
{
try
{
final Number num = (Number)get(path);
return num == null ? def : num.longValue();
}
catch (ClassCastException ex)
{
return def;
}
set(path, new ArrayList(object));
}
@Override
public double getDouble(final String path, final double def)
public void setProperty(String path, Map object)
{
try
{
Number num = (Number)get(path);
return num == null ? def : num.doubleValue();
}
catch (ClassCastException ex)
{
return def;
}
}
public void save()
{
try
{
save(configFile);
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
}
}
@Override
public synchronized void save(final File file) throws IOException
{
if (file == null)
{
throw new IllegalArgumentException("File cannot be null");
}
Files.createParentDirs(file);
final String data = saveToString();
if (data.length() == 0)
{
return;
}
if (!configFile.exists())
{
try
{
LOGGER.log(Level.INFO, _("creatingEmptyConfig", configFile.toString()));
if (!configFile.createNewFile())
{
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
}
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()), ex);
}
}
final OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), UTF8);
try
{
writer.write(data);
}
finally
{
writer.close();
}
set(path, new LinkedHashMap(object));
}
public Object getProperty(String path)
@@ -459,6 +447,12 @@ public class EssentialsConf extends YamlConfiguration
return super.getDouble(path);
}
@Override
public synchronized double getDouble(final String path, final double def)
{
return super.getDouble(path, def);
}
@Override
public synchronized List<Double> getDoubleList(String path)
{
@@ -519,6 +513,12 @@ public class EssentialsConf extends YamlConfiguration
return super.getLong(path);
}
@Override
public synchronized long getLong(final String path, final long def)
{
return super.getLong(path, def);
}
@Override
public synchronized List<Long> getLongList(String path)
{

View File

@@ -5,15 +5,12 @@ import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Material;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.inventory.ItemStack;
@@ -27,73 +24,96 @@ public class EssentialsEntityListener implements Listener
this.ess = ess;
}
// This method does something undocumented reguarding certain bucket types #EasterEgg
@EventHandler(priority = EventPriority.LOW)
public void onEntityDamage(final EntityDamageByEntityEvent event)
{
final Entity eAttack = event.getDamager();
final Entity eDefend = event.getEntity();
if (eDefend instanceof Player && eAttack instanceof Player)
if (eAttack instanceof Player)
{
final User defender = ess.getUser(eDefend);
final User attacker = ess.getUser(eAttack);
if (ess.getSettings().getLoginAttackDelay() > 0 && !attacker.isAuthorized("essentials.pvpdelay.exempt")
&& (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay())))
if (eDefend instanceof Player)
{
event.setCancelled(true);
onPlayerVsPlayerDamage(event, (Player)eDefend, attacker);
}
if (attacker.hasInvulnerabilityAfterTeleport() || defender.hasInvulnerabilityAfterTeleport())
else if (eDefend instanceof Ageable)
{
event.setCancelled(true);
}
if (attacker.isGodModeEnabled() && !attacker.isAuthorized("essentials.god.pvp"))
{
event.setCancelled(true);
}
attacker.updateActivity(true);
final List<String> commandList = attacker.getPowertool(attacker.getItemInHand());
if (commandList != null && !commandList.isEmpty())
{
for (final String command : commandList)
{
if (command != null && !command.isEmpty())
{
ess.scheduleSyncDelayedTask(
new Runnable()
{
@Override
public void run()
{
attacker.getServer().dispatchCommand(attacker.getBase(), command.replaceAll("\\{player\\}", defender.getName()));
LOGGER.log(Level.INFO, String.format("[PT] %s issued server command: /%s", attacker.getName(), command));
}
});
event.setCancelled(true);
return;
}
}
}
}
else if (eAttack instanceof Player)
{
final User player = ess.getUser(eAttack);
player.updateActivity(true);
if (eDefend instanceof Ageable)
{
final ItemStack hand = player.getItemInHand();
final ItemStack hand = attacker.getItemInHand();
if (hand != null && hand.getType() == Material.MILK_BUCKET)
{
((Ageable)eDefend).setBaby();
hand.setType(Material.BUCKET);
player.setItemInHand(hand);
player.updateInventory();
attacker.setItemInHand(hand);
attacker.updateInventory();
event.setCancelled(true);
}
}
attacker.updateActivity(true);
}
else if (eAttack instanceof Projectile && eDefend instanceof Player)
{
Entity shooter = ((Projectile)event.getDamager()).getShooter();
if (shooter instanceof Player)
{
final User attacker = ess.getUser(shooter);
onPlayerVsPlayerDamage(event, (Player)eDefend, attacker);
attacker.updateActivity(true);
}
}
}
private void onPlayerVsPlayerDamage(final EntityDamageByEntityEvent event, final Player defender, final User attacker)
{
if (ess.getSettings().getLoginAttackDelay() > 0 && !attacker.isAuthorized("essentials.pvpdelay.exempt")
&& (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay())))
{
event.setCancelled(true);
}
if (!defender.equals(attacker.getBase()) && (attacker.hasInvulnerabilityAfterTeleport() || ess.getUser(defender).hasInvulnerabilityAfterTeleport()))
{
event.setCancelled(true);
}
if (attacker.isGodModeEnabled() && !attacker.isAuthorized("essentials.god.pvp"))
{
event.setCancelled(true);
}
if (attacker.isHidden() && !attacker.isAuthorized("essentials.vanish.pvp"))
{
event.setCancelled(true);
}
onPlayerVsPlayerPowertool(event, defender, attacker);
}
private void onPlayerVsPlayerPowertool(final EntityDamageByEntityEvent event, final Player defender, final User attacker)
{
final List<String> commandList = attacker.getPowertool(attacker.getItemInHand());
if (commandList != null && !commandList.isEmpty())
{
for (final String tempCommand : commandList)
{
final String command = tempCommand.replaceAll("\\{player\\}", defender.getName());
if (command != null && !command.isEmpty() && !command.equals(tempCommand))
{
ess.scheduleSyncDelayedTask(
new Runnable()
{
@Override
public void run()
{
attacker.getServer().dispatchCommand(attacker.getBase(), command);
LOGGER.log(Level.INFO, String.format("[PT] %s issued server command: /%s", attacker.getName(), command));
}
});
event.setCancelled(true);
return;
}
}
}
}
@@ -149,6 +169,9 @@ public class EssentialsEntityListener implements Listener
{
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{
final Player player = (Player)event.getEntity();
player.setFoodLevel(20);
player.setSaturation(10);
event.setCancelled(true);
}
}

View File

@@ -6,7 +6,6 @@ import com.earth2me.essentials.textreader.KeywordReplacer;
import com.earth2me.essentials.textreader.TextInput;
import com.earth2me.essentials.textreader.TextPager;
import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@@ -15,6 +14,7 @@ import java.util.logging.Logger;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -23,9 +23,10 @@ import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
@@ -76,10 +77,20 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerMove(final PlayerMoveEvent event)
{
if ((!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers())
|| event.getFrom().getBlockX() == event.getTo().getBlockX()
&& event.getFrom().getBlockZ() == event.getTo().getBlockZ()
&& event.getFrom().getBlockY() == event.getTo().getBlockY())
if (!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers())
{
event.getHandlers().unregister(this);
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Unregistering move listener");
}
return;
}
if (event.getFrom().getBlockX() == event.getTo().getBlockX()
&& event.getFrom().getBlockZ() == event.getTo().getBlockZ()
&& event.getFrom().getBlockY() == event.getTo().getBlockY())
{
return;
}
@@ -127,9 +138,10 @@ public class EssentialsPlayerListener implements Listener
{
user.toggleVanished();
}
if (!user.isJailed())
user.setLogoutLocation();
if (user.isRecipeSee())
{
user.setLastLocation();
user.getPlayer().getOpenInventory().getTopInventory().clear();
}
user.updateActivity(false);
user.dispose();
@@ -138,7 +150,7 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(final PlayerJoinEvent event)
{
ess.scheduleAsyncDelayedTask(new Runnable()
ess.runTaskAsynchronously(new Runnable()
{
@Override
public void run()
@@ -156,63 +168,96 @@ public class EssentialsPlayerListener implements Listener
}
ess.getBackup().onPlayerJoin();
final User user = ess.getUser(player);
user.setDisplayNick();
updateCompass(user);
user.setLastLogin(System.currentTimeMillis());
user.updateActivity(false);
if (!ess.getVanishedPlayers().isEmpty() && !user.isAuthorized("essentials.vanish.see"))
ess.scheduleSyncDelayedTask(new Runnable()
{
for (String p : ess.getVanishedPlayers())
@Override
public void run()
{
Player toVanish = ess.getUser(p).getBase();
if (toVanish.isOnline()) {
user.hidePlayer(toVanish);
}
}
}
user.setDisplayNick();
updateCompass(user);
if (user.isAuthorized("essentials.sleepingignored"))
{
user.setSleepingIgnored(true);
}
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
{
try
{
final IText input = new TextInput(user, "motd", true, ess);
final IText output = new KeywordReplacer(input, user, ess);
final TextPager pager = new TextPager(output, true);
pager.showPage("1", null, "motd", user);
}
catch (IOException ex)
{
if (ess.getSettings().isDebug())
if (!ess.getVanishedPlayers().isEmpty() && !user.isAuthorized("essentials.vanish.see"))
{
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
for (String p : ess.getVanishedPlayers())
{
Player toVanish = ess.getServer().getPlayerExact(p);
if (toVanish != null && toVanish.isOnline())
{
user.hidePlayer(toVanish);
}
}
}
else
{
LOGGER.log(Level.WARNING, ex.getMessage());
}
}
}
if (!ess.getSettings().isCommandDisabled("mail") && user.isAuthorized("essentials.mail"))
{
final List<String> mail = user.getMails();
if (mail.isEmpty())
{
user.sendMessage(_("noNewMail"));
if (user.isAuthorized("essentials.sleepingignored"))
{
user.setSleepingIgnored(true);
}
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
{
try
{
final IText input = new TextInput(user, "motd", true, ess);
final IText output = new KeywordReplacer(input, user, ess);
final TextPager pager = new TextPager(output, true);
pager.showPage("1", null, "motd", user);
}
catch (IOException ex)
{
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
}
else
{
LOGGER.log(Level.WARNING, ex.getMessage());
}
}
}
if (!ess.getSettings().isCommandDisabled("mail") && user.isAuthorized("essentials.mail"))
{
final List<String> mail = user.getMails();
if (mail.isEmpty())
{
final String msg = _("noNewMail");
if (!msg.isEmpty())
{
user.sendMessage(msg);
}
}
else
{
user.sendMessage(_("youHaveNewMail", mail.size()));
}
}
if (user.isAuthorized("essentials.fly.safelogin"))
{
final World world = user.getLocation().getWorld();
final int x = user.getLocation().getBlockX();
int y = user.getLocation().getBlockY();
final int z = user.getLocation().getBlockZ();
while (Util.isBlockUnsafe(world, x, y, z) && y > -1)
{
y--;
}
if (user.getLocation().getBlockY() - y > 1 || y < 0)
{
user.setAllowFlight(true);
user.setFlying(true);
user.sendMessage(_("flyMode", _("enabled"), user.getDisplayName()));
}
}
}
else
{
user.sendMessage(_("youHaveNewMail", mail.size()));
}
}
});
}
// Makes the compass item ingame always point to the first essentials home. #EasterEgg
private void updateCompass(final User user)
{
Location loc = user.getHome(user.getLocation());
@@ -223,14 +268,7 @@ public class EssentialsPlayerListener implements Listener
if (loc != null)
{
final Location updateLoc = loc;
ess.scheduleSyncDelayedTask(new Runnable()
{
@Override
public void run()
{
user.setCompassTarget(updateLoc);
}
});
user.setCompassTarget(updateLoc);
}
}
@@ -260,8 +298,17 @@ public class EssentialsPlayerListener implements Listener
if (!banExpired && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
{
final String banReason = user.getBanReason();
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : _("defaultBanReason"));
String banReason = user.getBanReason();
if (banReason == null || banReason.isEmpty() || banReason.equalsIgnoreCase("ban"))
{
banReason = _("defaultBanReason");
}
if (user.getBanTimeout() > 0)
{
//TODO: TL This
banReason += "\n\n" + "Expires in " + Util.formatDateDiff(user.getBanTimeout());
}
event.disallow(Result.KICK_BANNED, banReason);
return;
}
@@ -322,14 +369,13 @@ public class EssentialsPlayerListener implements Listener
});
}
}
private final static List<String> COMMANDS = Arrays.asList("msg", "r", "mail", "m", "t", "whisper", "emsg", "tell", "er", "reply", "ereply", "email", "action", "describe", "eme", "eaction", "edescribe", "etell", "ewhisper", "pm");
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
{
final Player player = event.getPlayer();
final String cmd = event.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "").toLowerCase(Locale.ENGLISH);
if (COMMANDS.contains(cmd))
if (ess.getSettings().getSocialSpyCommands().contains(cmd))
{
for (Player onlinePlayer : ess.getServer().getOnlinePlayers())
{
@@ -347,13 +393,14 @@ public class EssentialsPlayerListener implements Listener
}
}
@EventHandler(priority = EventPriority.LOWEST)
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerChangedWorldHack(final PlayerChangedWorldEvent event)
{
final Player user = event.getPlayer();
if (user.getGameMode() != GameMode.CREATIVE) {
user.setAllowFlight(false);
}
final User user = ess.getUser(event.getPlayer());
if (user.getGameMode() != GameMode.CREATIVE && !user.isAuthorized("essentials.fly"))
{
user.setAllowFlight(false);
}
user.setFlySpeed(0.1f);
user.setWalkSpeed(0.2f);
}
@@ -370,10 +417,14 @@ public class EssentialsPlayerListener implements Listener
user.sendMessage(_("noGodWorldWarning"));
}
if (!event.getPlayer().getWorld().getName().equals(newWorld))
if (!user.getWorld().getName().equals(newWorld))
{
user.sendMessage(_("currentWorld", newWorld));
}
if (user.isVanished())
{
user.setVanished(user.isAuthorized("essentials.vanish"));
}
}
@EventHandler(priority = EventPriority.NORMAL)
@@ -384,9 +435,12 @@ public class EssentialsPlayerListener implements Listener
case RIGHT_CLICK_BLOCK:
if (!event.isCancelled() && event.getClickedBlock().getTypeId() == BED && ess.getSettings().getUpdateBedAtDaytime())
{
Player player = event.getPlayer();
player.setBedSpawnLocation(event.getClickedBlock().getLocation());
player.sendMessage(_("homeSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
User player = ess.getUser(event.getPlayer());
if (player.isAuthorized("essentials.sethome.bed"))
{
player.setBedSpawnLocation(event.getClickedBlock().getLocation());
player.sendMessage(_("homeSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
}
}
break;
case LEFT_CLICK_AIR:
@@ -403,6 +457,7 @@ public class EssentialsPlayerListener implements Listener
if (event.getItem() != null && event.getItem().getTypeId() != AIR)
{
final User user = ess.getUser(event.getPlayer());
user.updateActivity(true);
if (user.hasPowerTools() && user.arePowerToolsEnabled() && usePowertools(user, event.getItem().getTypeId()))
{
event.setCancelled(true);
@@ -414,6 +469,7 @@ public class EssentialsPlayerListener implements Listener
}
}
// This method allows the /jump lock feature to work, allows teleporting while flying #EasterEgg
private void useFlyClickJump(final User user)
{
try
@@ -499,10 +555,13 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onInventoryClickEvent(final InventoryClickEvent event)
{
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
final Inventory top = event.getView().getTopInventory();
final InventoryType type = top.getType();
if (type == InventoryType.PLAYER)
{
final User user = ess.getUser(event.getWhoClicked());
final InventoryHolder invHolder = event.getView().getTopInventory().getHolder();
final InventoryHolder invHolder = top.getHolder();
if (invHolder != null && invHolder instanceof HumanEntity)
{
final User invOwner = ess.getUser((HumanEntity)invHolder);
@@ -511,10 +570,11 @@ public class EssentialsPlayerListener implements Listener
|| !invOwner.isOnline()))
{
event.setCancelled(true);
user.updateInventory();
}
}
}
else if (event.getView().getTopInventory().getType() == InventoryType.ENDER_CHEST)
else if (type == InventoryType.ENDER_CHEST)
{
final User user = ess.getUser(event.getWhoClicked());
if (user.isEnderSee() && (!user.isAuthorized("essentials.enderchest.modify")))
@@ -522,20 +582,64 @@ public class EssentialsPlayerListener implements Listener
event.setCancelled(true);
}
}
else if (type == InventoryType.WORKBENCH)
{
User user = ess.getUser(event.getWhoClicked());
if (user.isRecipeSee())
{
event.setCancelled(true);
}
}
else if (type == InventoryType.CHEST && top.getSize() == 9)
{
final User user = ess.getUser(event.getWhoClicked());
final InventoryHolder invHolder = top.getHolder();
if (invHolder != null && invHolder instanceof HumanEntity && user.isInvSee())
{
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onInventoryCloseEvent(final InventoryCloseEvent event)
{
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
final Inventory top = event.getView().getTopInventory();
final InventoryType type = top.getType();
if (type == InventoryType.PLAYER)
{
final User user = ess.getUser(event.getPlayer());
user.setInvSee(false);
}
else if (event.getView().getTopInventory().getType() == InventoryType.ENDER_CHEST)
else if (type == InventoryType.ENDER_CHEST)
{
final User user = ess.getUser(event.getPlayer());
user.setEnderSee(false);
}
else if (type == InventoryType.WORKBENCH)
{
final User user = ess.getUser(event.getPlayer());
if (user.isRecipeSee())
{
user.setRecipeSee(false);
event.getView().getTopInventory().clear();
}
}
else if (type == InventoryType.CHEST && top.getSize() == 9)
{
final InventoryHolder invHolder = top.getHolder();
if (invHolder != null && invHolder instanceof HumanEntity)
{
final User user = ess.getUser(event.getPlayer());
user.setInvSee(false);
}
}
}
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerFishEvent(final PlayerFishEvent event)
{
final User user = ess.getUser(event.getPlayer());
user.updateActivity(true);
}
}

View File

@@ -20,6 +20,9 @@ public class EssentialsPluginListener implements Listener, IConf
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(final PluginEnableEvent event)
{
if (event.getPlugin().getName().equals("EssentialsChat")) {
ess.getSettings().setEssentialsChatActive(true);
}
ess.getPermissionsHandler().checkPermissions();
ess.getAlternativeCommandsHandler().addPlugin(event.getPlugin());
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager()))
@@ -31,6 +34,9 @@ public class EssentialsPluginListener implements Listener, IConf
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(final PluginDisableEvent event)
{
if (event.getPlugin().getName().equals("EssentialsChat")) {
ess.getSettings().setEssentialsChatActive(false);
}
ess.getPermissionsHandler().checkPermissions();
ess.getAlternativeCommandsHandler().removePlugin(event.getPlugin());
// Check to see if the plugin thats being disabled is the one we are using

View File

@@ -10,6 +10,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitTask;
public interface IEssentials extends Plugin
@@ -44,7 +45,9 @@ public interface IEssentials extends Plugin
Methods getPaymentMethod();
int scheduleAsyncDelayedTask(Runnable run);
BukkitTask runTaskAsynchronously(Runnable run);
BukkitTask runTaskLaterAsynchronously(Runnable run, long delay);
int scheduleSyncDelayedTask(Runnable run);

View File

@@ -42,6 +42,8 @@ public interface ISettings extends IConf
double getHealCooldown();
Set<String> getSocialSpyCommands();
Map<String, Object> getKit(String name);
ConfigurationSection getKits();
@@ -141,6 +143,8 @@ public interface ISettings extends IConf
boolean getFreezeAfkPlayers();
boolean cancelAfkOnMove();
boolean cancelAfkOnInteract();
boolean areDeathMessagesEnabled();
@@ -149,6 +153,8 @@ public interface ISettings extends IConf
Set<String> getNoGodWorlds();
boolean getUpdateBedAtDaytime();
boolean allowUnsafeEnchantments();
boolean getRepairEnchanted();
@@ -179,4 +185,10 @@ public interface ISettings extends IConf
double getMaxFlySpeed();
double getMaxWalkSpeed();
public int getMailsPerMinute();
public void setEssentialsChatActive(boolean b);
long getMaxTempban();
}

View File

@@ -42,4 +42,14 @@ public interface IUser extends Player
Teleport getTeleport();
void setJail(String jail);
boolean isIgnoreExempt();
boolean isAfk();
void setAfk(final boolean set);
void setLogoutLocation();
Location getLogoutLocation();
}

View File

@@ -3,6 +3,7 @@ package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IItemDb;
import java.util.*;
import java.util.regex.Pattern;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@@ -20,6 +21,7 @@ public class ItemDb implements IConf, IItemDb
private final transient Map<ItemData, List<String>> names = new HashMap<ItemData, List<String>>();
private final transient Map<String, Short> durabilities = new HashMap<String, Short>();
private final transient ManagedFile file;
private final transient Pattern splitPattern = Pattern.compile("[:+',;.]");
@Override
public void reloadConfig()
@@ -84,19 +86,20 @@ public class ItemDb implements IConf, IItemDb
int itemid = 0;
String itemname = null;
short metaData = 0;
String[] parts = splitPattern.split(id);;
if (id.matches("^\\d+[:+',;.]\\d+$"))
{
itemid = Integer.parseInt(id.split("[:+',;.]")[0]);
metaData = Short.parseShort(id.split("[:+',;.]")[1]);
itemid = Integer.parseInt(parts[0]);
metaData = Short.parseShort(parts[1]);
}
else if (id.matches("^\\d+$"))
else if (Util.isInt(id))
{
itemid = Integer.parseInt(id);
}
else if (id.matches("^[^:+',;.]+[:+',;.]\\d+$"))
{
itemname = id.split("[:+',;.]")[0].toLowerCase(Locale.ENGLISH);
metaData = Short.parseShort(id.split("[:+',;.]")[1]);
itemname = parts[0].toLowerCase(Locale.ENGLISH);
metaData = Short.parseShort(parts[1]);
}
else
{
@@ -134,19 +137,21 @@ public class ItemDb implements IConf, IItemDb
retval.setDurability(metaData);
return retval;
}
public String names(ItemStack item)
{
ItemData itemData = new ItemData(item.getTypeId(), item.getDurability());
List<String> nameList = names.get(itemData);
if (nameList == null) {
itemData = new ItemData(item.getTypeId(), (short) 0);
if (nameList == null)
{
itemData = new ItemData(item.getTypeId(), (short)0);
nameList = names.get(itemData);
if (nameList == null) {
if (nameList == null)
{
return null;
}
}
if (nameList.size() > 15)
{
nameList = nameList.subList(0, 14);
@@ -154,6 +159,7 @@ public class ItemDb implements IConf, IItemDb
return Util.joinList(", ", nameList);
}
class ItemData
{
final private int itemNo;
@@ -198,6 +204,7 @@ public class ItemDb implements IConf, IItemDb
}
}
class LengthCompare implements java.util.Comparator<String>
{
public LengthCompare()

View File

@@ -44,6 +44,10 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
final PluginManager pluginManager = ess.getServer().getPluginManager();
final JailListener blockListener = new JailListener();
pluginManager.registerEvents(blockListener, ess);
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Registering Jail listener");
}
}
@Override
@@ -55,16 +59,24 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
@Override
public void finishRead()
{
if (enabled == false && getCount() > 0)
{
registerListeners();
}
checkRegister();
}
@Override
public void finishWrite()
{
if (enabled == false)
checkRegister();
}
public void resetListener()
{
enabled = false;
checkRegister();
}
private void checkRegister()
{
if (enabled == false && getCount() > 0)
{
registerListeners();
}

View File

@@ -6,9 +6,7 @@ import com.earth2me.essentials.commands.NoChargeException;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import java.util.*;
import java.util.logging.Level;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
@@ -37,16 +35,17 @@ public class Kit
}
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws NoChargeException
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws Exception
{
if (user.isAuthorized("essentials.kit.exemptdelay")) {
if (user.isAuthorized("essentials.kit.exemptdelay"))
{
return;
}
final Calendar time = new GregorianCalendar();
// Take the current time, and remove the delay from it.
final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L;
final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0.0d;
final Calendar earliestTime = new GregorianCalendar();
earliestTime.add(Calendar.SECOND, -(int)delay);
earliestTime.add(Calendar.MILLISECOND, -(int)((delay * 1000.0) % 1000.0));
@@ -56,7 +55,7 @@ public class Kit
// When was the last kit used?
final long lastTime = user.getKitTimestamp(kitName);
if (lastTime < earliestLong)
if (lastTime < earliestLong || lastTime == 0L)
{
user.setKitTimestamp(kitName, time.getTimeInMillis());
}
@@ -66,6 +65,11 @@ public class Kit
// If this happens, let's give the user the benifit of the doubt.
user.setKitTimestamp(kitName, time.getTimeInMillis());
}
else if (earliestLong < 0L)
{
user.sendMessage(_("kitOnce"));
throw new NoChargeException();
}
else
{
time.setTimeInMillis(lastTime);
@@ -82,7 +86,6 @@ public class Kit
{
throw new Exception(_("kitError2"));
}
try
{
@@ -100,57 +103,34 @@ public class Kit
try
{
boolean spew = false;
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
for (String d : items)
{
final String[] parts = d.split(" ");
final String[] item = parts[0].split("[:+',;.]", 2);
final int id = Material.getMaterial(Integer.parseInt(item[0])).getId();
final short data = item.length > 1 ? Short.parseShort(item[1]) : 0;
final int amount = parts.length > 1 ? Integer.parseInt(parts[1]) : 1;
if (d.startsWith(ess.getSettings().getCurrencySymbol()))
{
Double value = Double.parseDouble(d.substring(ess.getSettings().getCurrencySymbol().length()).trim());
Trade t = new Trade(value, ess);
t.pay(user);
continue;
}
final String[] parts = d.split(" ");
final ItemStack parseStack = ess.getItemDb().get(parts[0], parts.length > 1 ? Integer.parseInt(parts[1]) : 1);
final MetaItemStack metaStack = new MetaItemStack(parseStack);
final ItemStack stack = new ItemStack(id, amount, data);
if (parts.length > 2)
{
for (int i = 2; i < parts.length; i++)
{
final String[] split = parts[i].split("[:+',;.]", 2);
if (split.length < 1)
{
continue;
}
final Enchantment enchantment = Enchantments.getByName(split[0]);
if (enchantment == null)
{
throw new Exception("Enchantment not found: " + split[0]);
}
int level;
if (split.length > 1)
{
level = Integer.parseInt(split[1]);
}
else
{
level = enchantment.getMaxLevel();
}
try
{
stack.addEnchantment(enchantment, level);
}
catch (Exception ex)
{
throw new Exception("Enchantment " + enchantment.getName() + ": " + ex.getMessage(), ex);
}
}
metaStack.parseStringMeta(user, allowUnsafe, parts, 2, ess);
}
final Map<Integer, ItemStack> overfilled;
if (user.isAuthorized("essentials.oversizedstacks"))
{
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
overfilled = InventoryWorkaround.addOversizedItems(user.getInventory(), ess.getSettings().getOversizedStackSize(), metaStack.getItemStack());
}
else
{
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, 0, stack);
overfilled = InventoryWorkaround.addItems(user.getInventory(), metaStack.getItemStack());
}
for (ItemStack itemStack : overfilled.values())
{

View File

@@ -0,0 +1,361 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.textreader.*;
import java.util.*;
import java.util.regex.Pattern;
import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.*;
public class MetaItemStack
{
private final transient Pattern splitPattern = Pattern.compile("[:+',;.]");
private final ItemStack stack;
private final static Map<String, DyeColor> colorMap = new HashMap<String, DyeColor>();
private final static Map<String, FireworkEffect.Type> fireworkShape = new HashMap<String, FireworkEffect.Type>();
private FireworkEffect.Builder builder = FireworkEffect.builder();
private boolean validFirework = false;
static
{
for (DyeColor color : DyeColor.values())
{
colorMap.put(color.name(), color);
}
for (FireworkEffect.Type type : FireworkEffect.Type.values())
{
fireworkShape.put(type.name(), type);
}
}
public MetaItemStack(final ItemStack stack)
{
this.stack = stack.clone();
}
public ItemStack getItemStack()
{
return stack;
}
public boolean isValidFirework()
{
return validFirework;
}
public FireworkEffect.Builder getFireworkBuilder()
{
return builder;
}
public void parseStringMeta(final CommandSender user, final boolean allowUnsafe, String[] string, int fromArg, final IEssentials ess) throws Exception
{
for (int i = fromArg; i < string.length; i++)
{
addStringMeta(user, allowUnsafe, string[i], ess);
}
if (validFirework)
{
FireworkEffect effect = builder.build();
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
fmeta.addEffect(effect);
stack.setItemMeta(fmeta);
}
}
//TODO: TL this
private void addStringMeta(final CommandSender user, final boolean allowUnsafe, final String string, final IEssentials ess) throws Exception
{
final String[] split = splitPattern.split(string, 2);
if (split.length < 1)
{
return;
}
if (split.length > 1 && split[0].equalsIgnoreCase("name"))
{
final String displayName = Util.replaceFormat(split[1].replace('_', ' '));
final ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(displayName);
stack.setItemMeta(meta);
}
else if (split.length > 1 && (split[0].equalsIgnoreCase("lore") || split[0].equalsIgnoreCase("desc")))
{
final List<String> lore = new ArrayList<String>();
for (String line : split[1].split("\\|"))
{
lore.add(Util.replaceFormat(line.replace('_', ' ')));
}
final ItemMeta meta = stack.getItemMeta();
meta.setLore(lore);
stack.setItemMeta(meta);
}
else if (split.length > 1 && (split[0].equalsIgnoreCase("player") || split[0].equalsIgnoreCase("owner")) && stack.getType() == Material.SKULL_ITEM)
{
if (stack.getDurability() == 3)
{
final String owner = split[1];
final SkullMeta meta = (SkullMeta)stack.getItemMeta();
boolean result = meta.setOwner(owner);
stack.setItemMeta(meta);
}
else
{
throw new Exception("You can only set the owner of player skulls (397:3)");
}
}
else if (split.length > 1 && split[0].equalsIgnoreCase("book") && stack.getType() == Material.WRITTEN_BOOK)
{
final BookMeta meta = (BookMeta)stack.getItemMeta();
final IText input = new BookInput("book", true, ess);
final BookPager pager = new BookPager(input);
List<String> pages = pager.getPages(split[1]);
meta.setPages(pages);
stack.setItemMeta(meta);
}
else if (split.length > 1 && split[0].equalsIgnoreCase("author") && stack.getType() == Material.WRITTEN_BOOK)
{
final String author = split[1];
final BookMeta meta = (BookMeta)stack.getItemMeta();
meta.setAuthor(author);
stack.setItemMeta(meta);
}
else if (split.length > 1 && split[0].equalsIgnoreCase("title") && stack.getType() == Material.WRITTEN_BOOK)
{
final String title = Util.replaceFormat(split[1].replace('_', ' '));
final BookMeta meta = (BookMeta)stack.getItemMeta();
meta.setTitle(title);
stack.setItemMeta(meta);
}
else if (split.length > 1 && split[0].equalsIgnoreCase("power") && stack.getType() == Material.FIREWORK)
{
final int power = Util.isInt(split[1]) ? Integer.parseInt(split[1]) : 0;
final FireworkMeta meta = (FireworkMeta)stack.getItemMeta();
meta.setPower(power > 3 ? 4 : power);
stack.setItemMeta(meta);
}
else if (stack.getType() == Material.FIREWORK) //WARNING - Meta for fireworks will be ignored after this point.
{
addFireworkMeta(user, false, string, ess);
}
else if (split.length > 1 && (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour"))
&& (stack.getType() == Material.LEATHER_BOOTS
|| stack.getType() == Material.LEATHER_CHESTPLATE
|| stack.getType() == Material.LEATHER_HELMET
|| stack.getType() == Material.LEATHER_LEGGINGS))
{
final String[] color = split[1].split("(\\||,)");
if (color.length == 3)
{
final int red = Util.isInt(color[0]) ? Integer.parseInt(color[0]) : 0;
final int green = Util.isInt(color[1]) ? Integer.parseInt(color[1]) : 0;
final int blue = Util.isInt(color[2]) ? Integer.parseInt(color[2]) : 0;
final LeatherArmorMeta meta = (LeatherArmorMeta)stack.getItemMeta();
meta.setColor(Color.fromRGB(red, green, blue));
stack.setItemMeta(meta);
}
else
{
throw new Exception("Leather Color Syntax: color:<red>,<green>,<blue> eg: color:255,0,0");
}
}
else
{
parseEnchantmentStrings(user, allowUnsafe, split);
}
}
public void addFireworkMeta(final CommandSender user, final boolean allowShortName, final String string, final IEssentials ess) throws Exception
{
if (stack.getType() == Material.FIREWORK)
{
final String[] split = splitPattern.split(string, 2);
if (split.length < 2)
{
return;
}
if (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour") || (allowShortName && split[0].equalsIgnoreCase("c")))
{
if (validFirework)
{
FireworkEffect effect = builder.build();
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
fmeta.addEffect(effect);
stack.setItemMeta(fmeta);
builder = FireworkEffect.builder();
}
List<Color> primaryColors = new ArrayList<Color>();
String[] colors = split[1].split(",");
for (String color : colors)
{
if (colorMap.containsKey(color.toUpperCase()))
{
validFirework = true;
primaryColors.add(colorMap.get(color.toUpperCase()).getFireworkColor());
}
else
{
user.sendMessage(_("fireworkSyntax"));
throw new Exception(_("invalidFireworkFormat", split[1], split[0]));
}
}
builder.withColor(primaryColors);
}
else if (split[0].equalsIgnoreCase("shape") || split[0].equalsIgnoreCase("type") || (allowShortName && (split[0].equalsIgnoreCase("s") || split[0].equalsIgnoreCase("t"))))
{
FireworkEffect.Type finalEffect = null;
split[1] = (split[1].equalsIgnoreCase("large") ? "BALL_LARGE" : split[1]);
if (fireworkShape.containsKey(split[1].toUpperCase()))
{
finalEffect = fireworkShape.get(split[1].toUpperCase());
}
else
{
user.sendMessage(_("fireworkSyntax"));
throw new Exception(_("invalidFireworkFormat", split[1], split[0]));
}
if (finalEffect != null)
{
builder.with(finalEffect);
}
}
else if (split[0].equalsIgnoreCase("fade") || (allowShortName && split[0].equalsIgnoreCase("f")))
{
List<Color> fadeColors = new ArrayList<Color>();
String[] colors = split[1].split(",");
for (String color : colors)
{
if (colorMap.containsKey(color.toUpperCase()))
{
fadeColors.add(colorMap.get(color.toUpperCase()).getFireworkColor());
}
else
{
user.sendMessage(_("fireworkSyntax"));
throw new Exception(_("invalidFireworkFormat", split[1], split[0]));
}
}
if (!fadeColors.isEmpty())
{
builder.withFade(fadeColors);
}
}
else if (split[0].equalsIgnoreCase("effect") || (allowShortName && split[0].equalsIgnoreCase("e")))
{
String[] effects = split[1].split(",");
for (String effect : effects)
{
if (effect.equalsIgnoreCase("twinkle"))
{
builder.flicker(true);
}
else if (effect.equalsIgnoreCase("trail"))
{
builder.trail(true);
}
else
{
user.sendMessage(_("fireworkSyntax"));
throw new Exception(_("invalidFireworkFormat", split[1], split[0]));
}
}
}
}
}
private void parseEnchantmentStrings(final CommandSender user, final boolean allowUnsafe, final String[] split) throws Exception
{
Enchantment enchantment = getEnchantment(null, split[0]);
int level = -1;
if (split.length > 1)
{
try
{
level = Integer.parseInt(split[1]);
}
catch (NumberFormatException ex)
{
level = -1;
}
}
if (level < 0 || (!allowUnsafe && level > enchantment.getMaxLevel()))
{
level = enchantment.getMaxLevel();
}
addEnchantment(user, allowUnsafe, enchantment, level);
}
public void addEnchantment(final CommandSender user, final boolean allowUnsafe, final Enchantment enchantment, final int level) throws Exception
{
try
{
if (stack.getType().equals(Material.ENCHANTED_BOOK))
{
EnchantmentStorageMeta meta = (EnchantmentStorageMeta)stack.getItemMeta();
if (level == 0)
{
meta.removeStoredEnchant(enchantment);
}
else
{
meta.addStoredEnchant(enchantment, level, allowUnsafe);
}
stack.setItemMeta(meta);
}
else // all other material types besides ENCHANTED_BOOK
{
if (level == 0)
{
stack.removeEnchantment(enchantment);
}
else
{
if (allowUnsafe)
{
stack.addUnsafeEnchantment(enchantment, level);
}
else
{
stack.addEnchantment(enchantment, level);
}
}
}
}
catch (Exception ex)
{
throw new Exception("Enchantment " + enchantment.getName() + ": " + ex.getMessage(), ex);
}
}
//TODO: Properly TL this
public Enchantment getEnchantment(final User user, final String name) throws Exception
{
final Enchantment enchantment = Enchantments.getByName(name);
if (enchantment == null)
{
throw new Exception(_("enchantmentNotFound") + ": " + name);
}
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
if (user != null && !user.isAuthorized("essentials.enchant." + enchantmentName))
{
throw new Exception(_("enchantmentPerm", enchantmentName));
}
return enchantment;
}
}

View File

@@ -6,11 +6,14 @@ import java.util.logging.Level;
import java.util.logging.Logger;
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.LivingEntity;
import org.bukkit.entity.Player;
// Suffixes can be appended on the end of a mob name to make it plural
// Entities without a suffix, will default to 's'
public enum Mob
{
CHICKEN("Chicken", Enemies.FRIENDLY, EntityType.CHICKEN),
@@ -37,8 +40,14 @@ public enum Mob
MAGMACUBE("MagmaCube", Enemies.ENEMY, EntityType.MAGMA_CUBE),
SNOWMAN("Snowman", Enemies.FRIENDLY, "", EntityType.SNOWMAN),
OCELOT("Ocelot", Enemies.NEUTRAL, EntityType.OCELOT),
IRONGOLEM("IronGolem", Enemies.NEUTRAL, EntityType.IRON_GOLEM);
IRONGOLEM("IronGolem", Enemies.NEUTRAL, EntityType.IRON_GOLEM),
WITHER("Wither", Enemies.ENEMY, EntityType.WITHER),
BAT("Bat", Enemies.FRIENDLY, EntityType.BAT),
WITCH("Witch", Enemies.ENEMY, EntityType.WITCH),
BOAT("Boat", Enemies.NEUTRAL, EntityType.BOAT),
MINECART("Minecart", Enemies.NEUTRAL, EntityType.MINECART),
ENDERCRYSTAL("EnderCrystal", Enemies.NEUTRAL, EntityType.ENDER_CRYSTAL),
EXPERIENCEORB("ExperienceOrb", Enemies.NEUTRAL, EntityType.EXPERIENCE_ORB);
public static final Logger logger = Logger.getLogger("Minecraft");
private Mob(String n, Enemies en, String s, EntityType type)
@@ -68,14 +77,20 @@ public enum Mob
hashMap.put(mob.name.toLowerCase(Locale.ENGLISH), mob);
}
}
public static Set<String> getMobList() {
public static Set<String> getMobList()
{
return Collections.unmodifiableSet(hashMap.keySet());
}
public LivingEntity spawn(final Player player, final Server server, final Location loc) throws MobException
public Entity spawn(final Player player, final Server server, final Location loc) throws MobException
{
final LivingEntity entity = player.getWorld().spawn(loc, (Class<? extends LivingEntity>)this.bukkitType.getEntityClass());
return spawn(player.getWorld(), server, loc);
}
public Entity spawn(final World world, final Server server, final Location loc) throws MobException
{
final Entity entity = world.spawn(loc, (Class<? extends Entity>)this.bukkitType.getEntityClass());
if (entity == null)
{
logger.log(Level.WARNING, _("unableToSpawnMob"));

View File

@@ -11,11 +11,8 @@ import org.bukkit.conversations.ConversationAbandonedEvent;
import org.bukkit.entity.*;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.*;
import org.bukkit.inventory.InventoryView.Property;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.map.MapView;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.permissions.Permission;
@@ -841,6 +838,12 @@ public class OfflinePlayer implements Player
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setBedSpawnLocation(Location lctn, boolean force)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void playEffect(EntityEffect ee)
{
@@ -1105,4 +1108,64 @@ public class OfflinePlayer implements Player
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void giveExpLevels(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean getRemoveWhenFarAway()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setRemoveWhenFarAway(boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public EntityEquipment getEquipment()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setCanPickupItems(boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean getCanPickupItems()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Location getLocation(Location lctn)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setTexturePack(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setMaxHealth(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void resetMaxHealth()
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -12,6 +12,7 @@ import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.command.PluginCommand;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.MemoryConfiguration;
import org.bukkit.event.EventPriority;
@@ -189,6 +190,11 @@ public class Settings implements ISettings
final ConfigurationSection newSection = new MemoryConfiguration();
for (String command : section.getKeys(false))
{
PluginCommand cmd = ess.getServer().getPluginCommand(command);
if (command.charAt(0) == '/')
{
ess.getLogger().warning("Invalid command cost. '" + command + "' should not start with '/'.");
}
if (section.isDouble(command))
{
newSection.set(command.toLowerCase(Locale.ENGLISH), section.getDouble(command));
@@ -197,6 +203,24 @@ public class Settings implements ISettings
{
newSection.set(command.toLowerCase(Locale.ENGLISH), (double)section.getInt(command));
}
else if (section.isString(command))
{
String costString = section.getString(command);
try
{
double cost = Double.parseDouble(costString.trim().replace(getCurrencySymbol(), "").replaceAll("\\W", ""));
newSection.set(command.toLowerCase(Locale.ENGLISH), cost);
}
catch (NumberFormatException ex)
{
ess.getLogger().warning("Invalid command cost for: " + command + " (" + costString + ")");
}
}
else
{
ess.getLogger().warning("Invalid command cost for: " + command);
}
}
return newSection;
}
@@ -213,6 +237,31 @@ public class Settings implements ISettings
}
return 0.0;
}
private Set<String> socialSpyCommands = new HashSet<String>();
public Set<String> _getSocialSpyCommands()
{
Set<String> socialspyCommands = new HashSet<String>();
if (config.isConfigurationSection("socialspy-commands"))
{
for (String c : config.getStringList("socialspy-commands"))
{
socialspyCommands.add(c.toLowerCase(Locale.ENGLISH));
}
}
else
{
socialspyCommands.addAll(Arrays.asList("msg", "r", "mail", "m", "whisper", "emsg", "t", "tell", "er", "reply", "ereply", "email", "action", "describe", "eme", "eaction", "edescribe", "etell", "ewhisper", "pm"));
}
return socialspyCommands;
}
public Set<String> getSocialSpyCommands()
{
return socialSpyCommands;
}
private String nicknamePrefix = "~";
private String _getNicknamePrefix()
@@ -419,7 +468,8 @@ public class Settings implements ISettings
teleportInvulnerability = _isTeleportInvulnerability();
disableItemPickupWhileAfk = _getDisableItemPickupWhileAfk();
registerBackInListener = _registerBackInListener();
cancelAfkOnMove = _cancelAfkOnMove();
cancelAfkOnInteract = _cancelAfkOnInteract();
cancelAfkOnMove = _cancelAfkOnMove() && cancelAfkOnInteract;
getFreezeAfkPlayers = _getFreezeAfkPlayers();
itemSpawnBl = _getItemSpawnBlacklist();
loginAttackDelay = _getLoginAttackDelay();
@@ -438,7 +488,9 @@ public class Settings implements ISettings
disableSuffix = _disableSuffix();
chatRadius = _getChatRadius();
commandCosts = _getCommandCosts();
socialSpyCommands = _getSocialSpyCommands();
warnOnBuildDisallow = _warnOnBuildDisallow();
mailsPerMinute = _getMailsPerMinute();
}
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
@@ -557,6 +609,8 @@ public class Settings implements ISettings
return config.getString("locale", "");
}
//This method should always only return one character due to the implementation of the calling methods
//If you need to use a string currency, for example "coins", use the translation key 'currency'.
@Override
public String getCurrencySymbol()
{
@@ -695,6 +749,7 @@ public class Settings implements ISettings
}
private boolean prefixsuffixconfigured = false;
private boolean addprefixsuffix = false;
private boolean essentialsChatActive = false;
private boolean _addPrefixSuffix()
{
@@ -706,10 +761,16 @@ public class Settings implements ISettings
return config.hasProperty("add-prefix-suffix");
}
@Override
public void setEssentialsChatActive(boolean essentialsChatActive)
{
this.essentialsChatActive = essentialsChatActive;
}
@Override
public boolean addPrefixSuffix()
{
return prefixsuffixconfigured ? addprefixsuffix : ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat");
return prefixsuffixconfigured ? addprefixsuffix : essentialsChatActive;
}
private boolean disablePrefix = false;
@@ -771,6 +832,18 @@ public class Settings implements ISettings
{
return config.getBoolean("cancel-afk-on-move", true);
}
private boolean cancelAfkOnInteract;
@Override
public boolean cancelAfkOnInteract()
{
return cancelAfkOnInteract;
}
private boolean _cancelAfkOnInteract()
{
return config.getBoolean("cancel-afk-on-interact", true);
}
@Override
public boolean areDeathMessagesEnabled()
@@ -797,6 +870,12 @@ public class Settings implements ISettings
return config.getBoolean("repair-enchanted", true);
}
@Override
public boolean allowUnsafeEnchantments()
{
return config.getBoolean("unsafe-enchantments", false);
}
@Override
public boolean isWorldTeleportPermissions()
{
@@ -863,7 +942,7 @@ public class Settings implements ISettings
@Override
public long getTpaAcceptCancellation()
{
return config.getLong("tpa-accept-cancellation", 0);
return config.getLong("tpa-accept-cancellation", 120);
}
@Override
@@ -928,10 +1007,30 @@ public class Settings implements ISettings
return maxSpeed > 1.0 ? 1.0 : Math.abs(maxSpeed);
}
//This option does not exist in the config.yml because it wasn't yet implemented in bukkit
//The code was commented out in the /speed command
@Override
public double getMaxWalkSpeed()
{
double maxSpeed = config.getDouble("max-walk-speed", 0.8);
return maxSpeed > 1.0 ? 1.0 : Math.abs(maxSpeed);
}
private int mailsPerMinute;
private int _getMailsPerMinute()
{
return config.getInt("mails-per-minute", 1000);
}
@Override
public int getMailsPerMinute()
{
return mailsPerMinute;
}
@Override
public long getMaxTempban()
{
return config.getLong("max-tempban-time", -1);
}
}

View File

@@ -0,0 +1,295 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Mob.MobException;
import java.util.HashSet;
import java.util.Locale;
import java.util.Random;
import java.util.Set;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.*;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.material.Colorable;
public class SpawnMob
{
public static String mobList(final User user)
{
final Set<String> mobList = Mob.getMobList();
final Set<String> availableList = new HashSet<String>();
for (String mob : mobList)
{
if (user.isAuthorized("essentials.spawnmob." + mob.toLowerCase()))
{
availableList.add(mob);
}
}
if (availableList.isEmpty())
{
availableList.add(_("none"));
}
return Util.joinList(availableList);
}
public static String[] mobData(final String mobString)
{
String[] returnString = new String[4];
final String[] parts = mobString.split(",");
String[] mobParts = parts[0].split(":");
returnString[0] = mobParts[0];
if (mobParts.length == 2)
{
returnString[1] = mobParts[1];
}
if (parts.length > 1)
{
String[] mountParts = parts[1].split(":");
returnString[2] = mountParts[0];
if (mountParts.length == 2)
{
returnString[3] = mountParts[1];
}
}
return returnString;
}
// This method spawns a mob where the user is looking, owned by user
public static void spawnmob(final IEssentials ess, final Server server, final User user, final String[] Data, int mobCount) throws Exception
{
final Block block = Util.getTarget(user).getBlock();
if (block == null)
{
throw new Exception(_("unableToSpawnMob"));
}
spawnmob(ess, server, user, user, block.getLocation(), Data, mobCount);
}
// This method spawns a mob at loc, owned by noone
public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final Location loc, final String[] Data, int mobCount) throws Exception
{
spawnmob(ess, server, sender, null, loc, Data, mobCount);
}
// This method spawns a mob at target, owned by target
public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final User target, final String[] Data, int mobCount) throws Exception
{
spawnmob(ess, server, sender, target, target.getLocation(), Data, mobCount);
}
// This method spawns a mob at loc, owned by target
public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final User target, final Location loc, final String[] Data, int mobCount) throws Exception
{
final Location sloc = Util.getSafeDestination(loc);
final String mobType = Data[0];
final String mobData = Data[1];
final String mountType = Data[2];
final String mountData = Data[3];
Mob mob = Mob.fromName(mobType);
Mob mobMount = null;
checkSpawnable(ess, sender, mob);
if (mountType != null)
{
mobMount = Mob.fromName(mountType);
checkSpawnable(ess, sender, mobMount);
}
int serverLimit = ess.getSettings().getSpawnMobLimit();
if (mobCount > serverLimit)
{
mobCount = serverLimit;
sender.sendMessage(_("mobSpawnLimit"));
}
try
{
for (int i = 0; i < mobCount; i++)
{
spawnMob(ess, server, sender, target, sloc, mob, mobData, mobMount, mountData);
}
sender.sendMessage(mobCount + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned"));
}
catch (MobException e1)
{
throw new Exception(_("unableToSpawnMob"), e1);
}
catch (NumberFormatException e2)
{
throw new Exception(_("numberRequired"), e2);
}
catch (NullPointerException np)
{
throw new Exception(_("soloMob"), np);
}
}
private static void spawnMob(final IEssentials ess, final Server server, final CommandSender sender, final User target, final Location sloc, Mob mob, String mobData, Mob mobMount, String mountData) throws Exception
{
Entity spawnedMob = mob.spawn(sloc.getWorld(), server, sloc);
Entity spawnedMount = null;
if (mobMount != null)
{
spawnedMount = mobMount.spawn(sloc.getWorld(), server, sloc);
spawnedMob.setPassenger(spawnedMount);
}
if (mobData != null)
{
changeMobData(mob.getType(), spawnedMob, mobData, target);
}
if (spawnedMount != null && mountData != null)
{
changeMobData(mobMount.getType(), spawnedMount, mountData, target);
}
}
private static void checkSpawnable(IEssentials ess, CommandSender sender, Mob mob) throws Exception
{
if (mob == null)
{
throw new Exception(_("invalidMob"));
}
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
{
throw new Exception(_("disabledToSpawnMob"));
}
if (sender instanceof User && !((User)sender).isAuthorized("essentials.spawnmob." + mob.name.toLowerCase()))
{
throw new Exception(_("noPermToSpawnMob"));
}
}
private static void changeMobData(final EntityType type, final Entity spawned, String data, final User target) throws Exception
{
data = data.toLowerCase(Locale.ENGLISH);
if (spawned instanceof Slime)
{
try
{
((Slime)spawned).setSize(Integer.parseInt(data));
}
catch (Exception e)
{
throw new Exception(_("slimeMalformedSize"), e);
}
}
if ((spawned instanceof Ageable) && data.contains("baby"))
{
((Ageable)spawned).setBaby();
data = data.replace("baby", "");
}
if (spawned instanceof Colorable)
{
final String color = data.toUpperCase(Locale.ENGLISH);
try
{
if (color.equals("RANDOM"))
{
final Random rand = new Random();
((Colorable)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
}
else if (color.length() > 1)
{
((Colorable)spawned).setColor(DyeColor.valueOf(color));
}
}
catch (Exception e)
{
throw new Exception(_("sheepMalformedColor"), e);
}
}
if (spawned instanceof Tameable && data.contains("tamed") && target != null)
{
final Tameable tameable = ((Tameable)spawned);
tameable.setTamed(true);
tameable.setOwner(target.getBase());
data = data.replace("tamed", "");
}
if (type == EntityType.WOLF)
{
if (data.contains("angry"))
{
((Wolf)spawned).setAngry(true);
}
}
if (type == EntityType.CREEPER && data.contains("powered"))
{
((Creeper)spawned).setPowered(true);
}
if (type == EntityType.OCELOT)
{
if (data.contains("siamese") || data.contains("white"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.SIAMESE_CAT);
}
else if (data.contains("red") || data.contains("orange") || data.contains("tabby"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.RED_CAT);
}
else if (data.contains("black") || data.contains("tuxedo"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.BLACK_CAT);
}
}
if (type == EntityType.VILLAGER)
{
for (Villager.Profession prof : Villager.Profession.values())
{
if (data.contains(prof.toString().toLowerCase(Locale.ENGLISH)))
{
((Villager)spawned).setProfession(prof);
}
}
}
if (spawned instanceof Zombie)
{
if (data.contains("villager"))
{
((Zombie)spawned).setVillager(true);
}
if (data.contains("baby"))
{
((Zombie)spawned).setBaby(true);
}
}
if (type == EntityType.SKELETON)
{
if (data.contains("wither"))
{
((Skeleton)spawned).setSkeletonType(SkeletonType.WITHER);
}
}
if (type == EntityType.EXPERIENCE_ORB)
{
if (Util.isInt(data))
{
((ExperienceOrb)spawned).setExperience(Integer.parseInt(data));
}
}
}
}

View File

@@ -24,13 +24,13 @@ public class TNTExplodeListener implements Listener, Runnable
if (!enabled)
{
enabled = true;
timer = ess.scheduleSyncDelayedTask(this, 1000);
timer = ess.scheduleSyncDelayedTask(this, 200);
return;
}
if (timer != -1)
{
ess.getScheduler().cancelTask(timer);
timer = ess.scheduleSyncDelayedTask(this, 1000);
timer = ess.scheduleSyncDelayedTask(this, 200);
}
}

View File

@@ -6,6 +6,7 @@ import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@@ -14,25 +15,25 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Teleport implements Runnable, ITeleport
{
private static final double MOVE_CONSTANT = 0.3;
private class Target
{
private final Location location;
private final String name;
Target(Location location)
{
this.location = location;
this.name = null;
}
Target(Player entity)
{
this.name = entity.getName();
this.location = null;
}
public Location getLocation()
{
if (this.name != null)
@@ -44,9 +45,10 @@ public class Teleport implements Runnable, ITeleport
}
}
private IUser user;
private IUser teleportUser;
private int teleTimer = -1;
private long started; // time this task was initiated
private long delay; // how long to delay the teleport
private long tpdelay; // how long to delay the teleport
private int 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)
@@ -55,55 +57,76 @@ public class Teleport implements Runnable, ITeleport
private long initY;
private long initZ;
private Target teleportTarget;
private boolean respawn;
private Trade chargeFor;
private final IEssentials ess;
private static final Logger logger = Logger.getLogger("Minecraft");
private TeleportCause cause;
private void initTimer(long delay, Target target, Trade chargeFor, TeleportCause cause)
{
initTimer(delay, user, target, chargeFor, cause, false);
}
private void initTimer(long delay, IUser teleportUser, Target target, Trade chargeFor, TeleportCause cause, boolean respawn)
{
this.started = System.currentTimeMillis();
this.delay = delay;
this.health = user.getHealth();
this.initX = Math.round(user.getLocation().getX() * MOVE_CONSTANT);
this.initY = Math.round(user.getLocation().getY() * MOVE_CONSTANT);
this.initZ = Math.round(user.getLocation().getZ() * MOVE_CONSTANT);
this.tpdelay = delay;
this.health = teleportUser.getHealth();
this.initX = Math.round(teleportUser.getLocation().getX() * MOVE_CONSTANT);
this.initY = Math.round(teleportUser.getLocation().getY() * MOVE_CONSTANT);
this.initZ = Math.round(teleportUser.getLocation().getZ() * MOVE_CONSTANT);
this.teleportUser = teleportUser;
this.teleportTarget = target;
this.chargeFor = chargeFor;
this.cause = cause;
this.respawn = respawn;
}
@Override
public void run()
{
if (user == null || !user.isOnline() || user.getLocation() == null)
{
cancel();
cancel(false);
return;
}
if (Math.round(user.getLocation().getX() * MOVE_CONSTANT) != initX
|| Math.round(user.getLocation().getY() * MOVE_CONSTANT) != initY
|| Math.round(user.getLocation().getZ() * MOVE_CONSTANT) != initZ
|| user.getHealth() < health)
{ // user moved, cancel teleport
if (teleportUser == null || !teleportUser.isOnline() || teleportUser.getLocation() == null)
{
cancel(false);
return;
}
if (!user.isAuthorized("essentials.teleport.timer.move")
&& (Math.round(teleportUser.getLocation().getX() * MOVE_CONSTANT) != initX
|| Math.round(teleportUser.getLocation().getY() * MOVE_CONSTANT) != initY
|| Math.round(teleportUser.getLocation().getZ() * MOVE_CONSTANT) != initZ
|| teleportUser.getHealth() < health))
{
// user moved, cancel teleport
cancel(true);
return;
}
health = user.getHealth(); // in case user healed, then later gets injured
health = teleportUser.getHealth(); // in case user healed, then later gets injured
long now = System.currentTimeMillis();
if (now > started + delay)
if (now > started + tpdelay)
{
try
{
cooldown(false);
user.sendMessage(_("teleportationCommencing"));
teleportUser.sendMessage(_("teleportationCommencing"));
try
{
now(teleportTarget, cause);
if (respawn)
{
teleportUser.getTeleport().respawn(cause);
}
else
{
teleportUser.getTeleport().now(teleportTarget, cause);
}
cancel(false);
if (chargeFor != null)
{
chargeFor.charge(user);
@@ -117,32 +140,20 @@ public class Teleport implements Runnable, ITeleport
catch (Exception ex)
{
user.sendMessage(_("cooldownWithMessage", ex.getMessage()));
if (user != teleportUser)
{
teleportUser.sendMessage(_("cooldownWithMessage", ex.getMessage()));
}
}
}
}
public Teleport(IUser user, IEssentials ess)
{
this.user = user;
this.ess = ess;
}
public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception
{
final Player player = user.getBase();
final Location bed = player.getBedSpawnLocation();
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, bed == null ? player.getWorld().getSpawnLocation() : bed, bed != null);
ess.getServer().getPluginManager().callEvent(pre);
teleport(new Target(pre.getRespawnLocation()), chargeFor, cause);
}
public void warp(String warp, Trade chargeFor, TeleportCause cause) throws Exception
{
Location loc = ess.getWarps().getWarp(warp);
teleport(new Target(loc), chargeFor, cause);
user.sendMessage(_("warpingTo", warp));
}
public void cooldown(boolean check) throws Exception
{
final Calendar time = new GregorianCalendar();
@@ -158,7 +169,7 @@ public class Teleport implements Runnable, ITeleport
// When was the last teleport used?
final Long lastTime = user.getLastTeleportTimestamp();
if (lastTime > time.getTimeInMillis())
{
// This is to make sure time didn't get messed up on last kit use.
@@ -181,6 +192,7 @@ public class Teleport implements Runnable, ITeleport
}
}
//If we need to cancel a pending teleport call this method
public void cancel(boolean notifyUser)
{
if (teleTimer == -1)
@@ -193,6 +205,10 @@ public class Teleport implements Runnable, ITeleport
if (notifyUser)
{
user.sendMessage(_("pendingTeleportCancelled"));
if (teleportUser != user)
{
teleportUser.sendMessage(_("pendingTeleportCancelled"));
}
}
}
finally
@@ -201,30 +217,54 @@ public class Teleport implements Runnable, ITeleport
}
}
public void cancel()
//The now function is used when you want to skip tp delay when teleporting someone to a location or player.
public void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception
{
if (cooldown)
{
cooldown(false);
}
now(new Target(loc), cause);
}
public void now(Player entity, boolean cooldown, TeleportCause cause) throws Exception
{
if (cooldown)
{
cooldown(false);
}
now(new Target(entity), cause);
}
private void now(Target target, TeleportCause cause) throws Exception
{
cancel(false);
user.setLastLocation();
user.getBase().teleport(Util.getSafeDestination(target.getLocation()), cause);
}
//The teleport function is used when you want to normally teleport someone to a location or player.
//This method is nolonger used internally and will be removed.
@Deprecated
public void teleport(Location loc, Trade chargeFor) throws Exception
{
teleport(new Target(loc), chargeFor, TeleportCause.PLUGIN);
teleport(loc, chargeFor, TeleportCause.PLUGIN);
}
public void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
{
teleport(new Target(loc), chargeFor, cause);
}
public void teleport(Player entity, Trade chargeFor, TeleportCause cause) throws Exception
{
teleport(new Target(entity), chargeFor, cause);
}
private void teleport(Target target, Trade chargeFor, TeleportCause cause) throws Exception
{
double delay = ess.getSettings().getTeleportDelay();
if (chargeFor != null)
{
chargeFor.isAffordableFor(user);
@@ -240,59 +280,117 @@ public class Teleport implements Runnable, ITeleport
}
return;
}
cancel(false);
warnUser(user, delay);
initTimer((long)(delay * 1000.0), target, chargeFor, cause);
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
}
cancel();
//The teleportToMe function is a wrapper used to handle teleporting players to them, like /tphere
public void teleportToMe(User otherUser, Trade chargeFor, TeleportCause cause) throws Exception
{
Target target = new Target(user);
double delay = ess.getSettings().getTeleportDelay();
if (chargeFor != null)
{
chargeFor.isAffordableFor(user);
}
cooldown(true);
if (delay <= 0 || user.isAuthorized("essentials.teleport.timer.bypass"))
{
cooldown(false);
otherUser.getTeleport().now(target, cause);
if (chargeFor != null)
{
chargeFor.charge(user);
}
return;
}
cancel(false);
warnUser(otherUser, delay);
initTimer((long)(delay * 1000.0), otherUser, target, chargeFor, cause, false);
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
}
private void warnUser(final IUser user, final double delay)
{
Calendar c = new GregorianCalendar();
c.add(Calendar.SECOND, (int)delay);
c.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
user.sendMessage(_("dontMoveMessage", Util.formatDateDiff(c.getTimeInMillis())));
initTimer((long)(delay * 1000.0), target, chargeFor, cause);
}
//The respawn function is a wrapper used to handle tp fallback, on /jail and /home
public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception
{
double delay = ess.getSettings().getTeleportDelay();
if (chargeFor != null)
{
chargeFor.isAffordableFor(user);
}
cooldown(true);
if (delay <= 0 || user.isAuthorized("essentials.teleport.timer.bypass"))
{
cooldown(false);
respawn(cause);
if (chargeFor != null)
{
chargeFor.charge(user);
}
return;
}
cancel(false);
warnUser(user, delay);
initTimer((long)(delay * 1000.0), user, null, chargeFor, cause, true);
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
}
private void now(Target target, TeleportCause cause) throws Exception
public void respawn(TeleportCause cause) throws Exception
{
cancel();
user.setLastLocation();
user.getBase().teleport(Util.getSafeDestination(target.getLocation()), cause);
}
public void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception
{
if (cooldown)
final Player player = user.getBase();
Location bed = player.getBedSpawnLocation();
if (bed != null)
{
cooldown(false);
now(new Target(bed), cause);
}
now(new Target(loc), cause);
}
public void now(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
{
cooldown(false);
chargeFor.charge(user);
now(new Target(loc), cause);
}
public void now(Player entity, boolean cooldown, TeleportCause cause) throws Exception
{
if (cooldown)
else
{
cooldown(false);
if (ess.getSettings().isDebug())
{
ess.getLogger().info("Could not find bed spawn, forcing respawn event.");
}
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, player.getWorld().getSpawnLocation(), false);
ess.getServer().getPluginManager().callEvent(pre);
now(new Target(pre.getRespawnLocation()), cause);
}
now(new Target(entity), cause);
}
//The warp function is a wrapper used to teleport a player to a /warp
public void warp(String warp, Trade chargeFor, TeleportCause cause) throws Exception
{
Location loc = ess.getWarps().getWarp(warp);
user.sendMessage(_("warpingTo", warp));
teleport(new Target(loc), chargeFor, cause);
}
//The back function is a wrapper used to teleport a player /back to their previous location.
public void back(Trade chargeFor) throws Exception
{
teleport(new Target(user.getLastLocation()), chargeFor, TeleportCause.COMMAND);
}
//This function is used to throw a user back after a jail sentence
public void back() throws Exception
{
now(new Target(user.getLastLocation()), TeleportCause.COMMAND);
}
//This function handles teleporting to /home
public void home(Location loc, Trade chargeFor) throws Exception
{
teleport(new Target(loc), chargeFor, TeleportCause.COMMAND);

View File

@@ -77,7 +77,7 @@ public class Trade
}
if (getItemStack() != null
&& !InventoryWorkaround.containsItem(user.getInventory(), true, true, itemStack))
&& !user.getInventory().containsAtLeast(itemStack, itemStack.getAmount()))
{
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
}
@@ -113,7 +113,7 @@ public class Trade
{
if (dropItems)
{
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItems(user.getInventory(), getItemStack());
final Location loc = user.getLocation();
for (ItemStack itemStack : leftOver.values())
{
@@ -137,7 +137,7 @@ public class Trade
}
else
{
success = InventoryWorkaround.addAllItems(user.getInventory(), true, getItemStack());
success = InventoryWorkaround.addAllItems(user.getInventory(), getItemStack());
}
user.updateInventory();
}
@@ -165,11 +165,11 @@ public class Trade
}
if (getItemStack() != null)
{
if (!InventoryWorkaround.containsItem(user.getInventory(), true, true, itemStack))
if (!user.getInventory().containsAtLeast(itemStack, itemStack.getAmount()))
{
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
}
InventoryWorkaround.removeItem(user.getInventory(), true, true, getItemStack());
user.getInventory().removeItem(getItemStack());
user.updateInventory();
}
if (command != null)
@@ -234,6 +234,9 @@ public class Trade
public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess)
{
//isEcoLogUpdateEnabled() - This refers to log entries with no location, ie API updates #EasterEgg
//isEcoLogEnabled() - This refers to log entries with with location, ie /pay /sell and eco signs.
if ((loc == null && !ess.getSettings().isEcoLogUpdateEnabled())
|| (loc != null && !ess.getSettings().isEcoLogEnabled()))
{

View File

@@ -12,6 +12,8 @@ import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class User extends UserData implements Comparable<User>, IReplyTo, IUser
@@ -29,6 +31,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
private boolean rightClickJump = false;
private transient Location afkPosition = null;
private boolean invSee = false;
private boolean recipeSee = false;
private boolean enderSee = false;
private static final Logger logger = Logger.getLogger("Minecraft");
@@ -70,8 +73,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
return result;
}
private boolean isAuthorizedCheck(final String node)
private boolean isAuthorizedCheck(final String node)
{
if (base instanceof OfflinePlayer)
@@ -79,11 +82,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return false;
}
if (isJailed())
{
return false;
}
try
{
return ess.getPermissionsHandler().hasPermission(base, node);
@@ -255,6 +253,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
setLastLocation(getLocation());
}
@Override
public void setLogoutLocation()
{
setLogoutLocation(getLocation());
}
public void requestTeleport(final User player, final boolean here)
{
@@ -306,6 +310,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
if (ess.getSettings().addPrefixSuffix())
{
//These two extra toggles are not documented, because they are mostly redundant #EasterEgg
if (!ess.getSettings().disablePrefix())
{
final String ptext = ess.getPermissionsHandler().getPrefix(base).replace('&', '§');
@@ -531,13 +536,17 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
public void updateActivity(final boolean broadcast)
{
if (isAfk())
if (isAfk() && ess.getSettings().cancelAfkOnInteract())
{
setAfk(false);
if (broadcast && !isHidden())
{
setDisplayNick();
ess.broadcastMessage(this, _("userIsNotAway", getDisplayName()));
final String msg = _("userIsNotAway", getDisplayName());
if (!msg.isEmpty())
{
ess.broadcastMessage(this, msg);
}
}
}
lastActivity = System.currentTimeMillis();
@@ -570,7 +579,11 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
if (!isHidden())
{
setDisplayNick();
ess.broadcastMessage(this, _("userIsAway", getDisplayName()));
final String msg = _("userIsAway", getDisplayName());
if (!msg.isEmpty())
{
ess.broadcastMessage(this, msg);
}
}
}
}
@@ -680,6 +693,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
setHidden(true);
ess.getVanishedPlayers().add(getName());
if (isAuthorized("essentials.vanish.effect"))
{
this.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false));
}
}
else
{
@@ -689,6 +706,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
setHidden(false);
ess.getVanishedPlayers().remove(getName());
if (isAuthorized("essentials.vanish.effect"))
{
this.removePotionEffect(PotionEffectType.INVISIBILITY);
}
}
}
@@ -728,4 +749,20 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
this.rightClickJump = rightClickJump;
}
@Override
public boolean isIgnoreExempt()
{
return this.isAuthorized("essentials.chat.ignoreexempt");
}
public boolean isRecipeSee()
{
return recipeSee;
}
public void setRecipeSee(boolean recipeSee)
{
this.recipeSee = recipeSee;
}
}

View File

@@ -5,7 +5,6 @@ import java.io.File;
import java.util.*;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.MemoryConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -49,23 +48,24 @@ public abstract class UserData extends PlayerExtension implements IConf
lastHealTimestamp = _getLastHealTimestamp();
jail = _getJail();
mails = _getMails();
teleportEnabled = getTeleportEnabled();
ignoredPlayers = getIgnoredPlayers();
teleportEnabled = _getTeleportEnabled();
godmode = _getGodModeEnabled();
muted = getMuted();
muted = _getMuted();
muteTimeout = _getMuteTimeout();
jailed = getJailed();
jailed = _getJailed();
jailTimeout = _getJailTimeout();
lastLogin = _getLastLogin();
lastLogout = _getLastLogout();
lastLoginAddress = _getLastLoginAddress();
afk = getAfk();
afk = _getAfk();
geolocation = _getGeoLocation();
isSocialSpyEnabled = _isSocialSpyEnabled();
isNPC = _isNPC();
arePowerToolsEnabled = _arePowerToolsEnabled();
kitTimestamps = _getKitTimestamps();
nickname = _getNickname();
setIgnoredPlayers(_getIgnoredPlayers());
logoutLocation = _getLogoutLocation();
}
private double money;
@@ -161,7 +161,7 @@ public abstract class UserData extends PlayerExtension implements IConf
public void setHome(String name, Location loc)
{
//Invalid names will corrupt the yaml
name = Util.sanitizeFileName(name);
name = Util.safeString(name);
homes.put(name, loc);
config.setProperty("homes." + name, loc);
config.save();
@@ -172,7 +172,7 @@ public abstract class UserData extends PlayerExtension implements IConf
String search = getHomeName(name);
if (!homes.containsKey(search))
{
search = Util.sanitizeFileName(search);
search = Util.safeString(search);
}
if (homes.containsKey(search))
{
@@ -319,6 +319,37 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("lastlocation", loc);
config.save();
}
private Location logoutLocation;
private Location _getLogoutLocation()
{
try
{
return config.getLocation("logoutlocation", getServer());
}
catch (Exception e)
{
return null;
}
}
public Location getLogoutLocation()
{
return logoutLocation;
}
public void setLogoutLocation(Location loc)
{
if (loc == null || loc.getWorld() == null)
{
return;
}
logoutLocation = loc;
config.setProperty("logoutlocation", loc);
config.save();
}
private long lastTeleportTimestamp;
private long _getLastTeleportTimestamp()
@@ -415,7 +446,7 @@ public abstract class UserData extends PlayerExtension implements IConf
}
private boolean teleportEnabled;
private boolean getTeleportEnabled()
private boolean _getTeleportEnabled()
{
return config.getBoolean("teleportenabled", true);
}
@@ -447,7 +478,7 @@ public abstract class UserData extends PlayerExtension implements IConf
}
private List<String> ignoredPlayers;
public List<String> getIgnoredPlayers()
public List<String> _getIgnoredPlayers()
{
return Collections.synchronizedList(config.getStringList("ignore"));
}
@@ -480,7 +511,7 @@ public abstract class UserData extends PlayerExtension implements IConf
public boolean isIgnoredPlayer(IUser user)
{
return (ignoredPlayers.contains(user.getName().toLowerCase(Locale.ENGLISH)) && !user.isAuthorized("essentials.chat.ignoreexempt"));
return (ignoredPlayers.contains(user.getName().toLowerCase(Locale.ENGLISH)) && !user.isIgnoreExempt());
}
public void setIgnoredPlayer(IUser user, boolean set)
@@ -515,10 +546,15 @@ public abstract class UserData extends PlayerExtension implements IConf
}
private boolean muted;
public boolean getMuted()
public boolean _getMuted()
{
return config.getBoolean("muted", false);
}
public boolean getMuted()
{
return muted;
}
public boolean isMuted()
{
@@ -551,7 +587,7 @@ public abstract class UserData extends PlayerExtension implements IConf
}
private boolean jailed;
private boolean getJailed()
private boolean _getJailed()
{
return config.getBoolean("jailed", false);
}
@@ -635,7 +671,10 @@ public abstract class UserData extends PlayerExtension implements IConf
public void setLastLogin(long time)
{
_setLastLogin(time);
_setLastLoginAddress(base.getAddress().getAddress().getHostAddress());
if (base.getAddress() != null && base.getAddress().getAddress() != null)
{
_setLastLoginAddress(base.getAddress().getAddress().getHostAddress());
}
config.save();
}
private long lastLogout;
@@ -675,7 +714,7 @@ public abstract class UserData extends PlayerExtension implements IConf
}
private boolean afk;
private boolean getAfk()
private boolean _getAfk()
{
return config.getBoolean("afk", false);
}
@@ -786,44 +825,44 @@ public abstract class UserData extends PlayerExtension implements IConf
{
return config.getBoolean("powertoolsenabled", true);
}
private ConfigurationSection kitTimestamps;
private ConfigurationSection _getKitTimestamps()
private Map<String, Long> kitTimestamps;
private Map<String, Long> _getKitTimestamps()
{
if (config.isConfigurationSection("timestamps.kits"))
{
final ConfigurationSection section = config.getConfigurationSection("timestamps.kits");
final ConfigurationSection newSection = new MemoryConfiguration();
final Map<String, Long> timestamps = new HashMap<String, Long>();
for (String command : section.getKeys(false))
{
if (section.isLong(command))
{
newSection.set(command.toLowerCase(Locale.ENGLISH), section.getLong(command));
timestamps.put(command.toLowerCase(Locale.ENGLISH), section.getLong(command));
}
else if (section.isInt(command))
{
newSection.set(command.toLowerCase(Locale.ENGLISH), (long)section.getInt(command));
timestamps.put(command.toLowerCase(Locale.ENGLISH), (long)section.getInt(command));
}
}
return newSection;
return timestamps;
}
return new MemoryConfiguration();
return new HashMap<String, Long>();
}
public long getKitTimestamp(String name)
{
name = name.replace('.', '_').replace('/', '_');
if (kitTimestamps != null)
if (kitTimestamps != null && kitTimestamps.containsKey(name))
{
return kitTimestamps.getLong(name, 0l);
return kitTimestamps.get(name);
}
return 0l;
}
public void setKitTimestamp(final String name, final long time)
{
kitTimestamps.set(name.toLowerCase(Locale.ENGLISH), time);
kitTimestamps.put(name.toLowerCase(Locale.ENGLISH), time);
config.setProperty("timestamps.kits", kitTimestamps);
config.save();
}

View File

@@ -27,7 +27,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
private void loadAllUsersAsync(final IEssentials ess)
{
ess.scheduleAsyncDelayedTask(new Runnable()
ess.runTaskAsynchronously(new Runnable()
{
@Override
public void run()

View File

@@ -24,12 +24,19 @@ public class Util
private final static Pattern INVALIDFILECHARS = Pattern.compile("[^a-z0-9]");
private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
//Used to clean file names before saving to disk
public static String sanitizeFileName(final String name)
{
final String newName = INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
return newName;
return safeString(name);
}
//Used to clean strings/names before saving as filenames/permissions
public static String safeString(final String string)
{
return INVALIDFILECHARS.matcher(string.toLowerCase(Locale.ENGLISH)).replaceAll("_");
}
//Less restrictive string sanitizing, when not used as perm or filename
public static String sanitizeString(final String string)
{
return INVALIDCHARS.matcher(string).replaceAll("");
@@ -597,7 +604,8 @@ public class Util
return input.substring(pos, pos + 2);
}
private static transient final Pattern URL_PATTERN = Pattern.compile("((?:(?:https?)://)?[\\w-_\\.]{2,})\\.([a-z]{2,3}(?:/\\S+)?)");
private static transient final Pattern VANILLA_PATTERN = Pattern.compile("\u00A7+[0-9A-FK-ORa-fk-or]");
private static transient final Pattern VANILLA_PATTERN = Pattern.compile("\u00A7+[0-9A-FK-ORa-fk-or]?");
private static transient final Pattern LOGCOLOR_PATTERN = Pattern.compile("\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]");
private static transient final Pattern REPLACE_PATTERN = Pattern.compile("&([0-9a-fk-or])");
private static transient final Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-Fa-f]");
private static transient final Pattern VANILLA_MAGIC_PATTERN = Pattern.compile("\u00A7+[Kk]");
@@ -606,6 +614,7 @@ public class Util
private static transient final Pattern REPLACE_MAGIC_PATTERN = Pattern.compile("&(k)");
private static transient final Pattern REPLACE_FORMAT_PATTERN = Pattern.compile("&([l-or])");
//This method is used to simply strip the native minecraft colour codes
public static String stripFormat(final String input)
{
if (input == null)
@@ -615,6 +624,16 @@ public class Util
return VANILLA_PATTERN.matcher(input).replaceAll("");
}
public static String stripLogColorFormat(final String input)
{
if (input == null)
{
return null;
}
return LOGCOLOR_PATTERN.matcher(input).replaceAll("");
}
//This method is used to simply replace the ess colour codes with minecraft ones, ie &c
public static String replaceFormat(final String input)
{
if (input == null)
@@ -624,20 +643,7 @@ public class Util
return REPLACE_PATTERN.matcher(input).replaceAll("\u00a7$1");
}
public static String blockURL(final String input)
{
if (input == null)
{
return null;
}
String text = URL_PATTERN.matcher(input).replaceAll("$1 $2");
while (URL_PATTERN.matcher(text).find())
{
text = URL_PATTERN.matcher(text).replaceAll("$1 $2");
}
return text;
}
//This is the general permission sensitive message format function, does not touch urls.
public static String formatString(final IUser user, final String permBase, final String input)
{
if (input == null)
@@ -672,6 +678,7 @@ public class Util
return message;
}
//This is the general permission sensitive message format function, checks for urls.
public static String formatMessage(final IUser user, final String permBase, final String input)
{
if (input == null)
@@ -685,6 +692,20 @@ public class Util
}
return message;
}
private static String blockURL(final String input)
{
if (input == null)
{
return null;
}
String text = URL_PATTERN.matcher(input).replaceAll("$1 $2");
while (URL_PATTERN.matcher(text).find())
{
text = URL_PATTERN.matcher(text).replaceAll("$1 $2");
}
return text;
}
private static String stripColor(final String input, final Pattern pattern)
{

View File

@@ -3,6 +3,7 @@ package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.commands.WarpNotFoundException;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -70,7 +71,14 @@ public class Warps implements IConf
}
conf.setProperty(null, loc);
conf.setProperty("name", name);
conf.save();
try
{
conf.saveWithError();
}
catch (IOException ex)
{
throw new IOException(_("invalidWarpName"));
}
}
public void delWarp(String name) throws Exception

View File

@@ -8,7 +8,6 @@ import com.earth2me.essentials.Util;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.entity.Player;
/**
@@ -72,17 +71,7 @@ public final class Economy
{
throw new RuntimeException(noCallBeforeLoad);
}
User user;
Player player = ess.getServer().getPlayer(name);
if (player != null)
{
user = ess.getUser(player);
}
else
{
user = ess.getOfflineUser(name);
}
return user;
return ess.getUser(name);
}
/**

View File

@@ -32,12 +32,13 @@ public class Commandafk extends EssentialsCommand
private void toggleAfk(User user)
{
user.setDisplayNick();
String msg = "";
if (!user.toggleAfk())
{
//user.sendMessage(_("markedAsNotAway"));
if (!user.isHidden())
{
ess.broadcastMessage(user, _("userIsNotAway", user.getDisplayName()));
msg = _("userIsNotAway", user.getDisplayName());
}
user.updateActivity(false);
}
@@ -46,8 +47,12 @@ public class Commandafk extends EssentialsCommand
//user.sendMessage(_("markedAsAway"));
if (!user.isHidden())
{
ess.broadcastMessage(user, _("userIsAway", user.getDisplayName()));
msg = _("userIsAway", user.getDisplayName());
}
}
if (!msg.isEmpty())
{
ess.broadcastMessage(user, msg);
}
}
}

View File

@@ -6,7 +6,7 @@ import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.entity.TNTPrimed;
// This command has a in theme message that only shows if you supply a parameter #EasterEgg
public class Commandantioch extends EssentialsCommand
{
public Commandantioch()

View File

@@ -27,6 +27,7 @@ public class Commandbalance extends EssentialsCommand
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
//TODO: Remove 'other' perm
final double bal = (args.length < 1
|| !(user.isAuthorized("essentials.balance.others")
|| user.isAuthorized("essentials.balance.other"))

View File

@@ -12,7 +12,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
//TODO: Remove op and replace with perm
public class Commandbalancetop extends EssentialsCommand
{
public Commandbalancetop()
@@ -63,7 +63,7 @@ public class Commandbalancetop extends EssentialsCommand
{
lock.readLock().unlock();
}
ess.scheduleAsyncDelayedTask(new Viewer(sender, page, force));
ess.runTaskAsynchronously(new Viewer(sender, page, force));
}
else
{
@@ -71,7 +71,7 @@ public class Commandbalancetop extends EssentialsCommand
{
sender.sendMessage(_("orderBalances", ess.getUserMap().getUniqueUsers()));
}
ess.scheduleAsyncDelayedTask(new Viewer(sender, page, force));
ess.runTaskAsynchronously(new Viewer(sender, page, force));
}
}
@@ -82,7 +82,7 @@ public class Commandbalancetop extends EssentialsCommand
cal.setTimeInMillis(cacheage);
final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
sender.sendMessage(_("balanceTop", format.format(cal.getTime())));
new TextPager(cache).showPage(Integer.toString(page), "", "balancetop", sender);
new TextPager(cache).showPage(Integer.toString(page), null, "balancetop", sender);
}
@@ -144,7 +144,7 @@ public class Commandbalancetop extends EssentialsCommand
{
lock.writeLock().unlock();
}
ess.scheduleAsyncDelayedTask(viewer);
ess.runTaskAsynchronously(viewer);
}
}
@@ -178,7 +178,7 @@ public class Commandbalancetop extends EssentialsCommand
{
lock.readLock().unlock();
}
ess.scheduleAsyncDelayedTask(new Calculator(new Viewer(sender, page, force), force));
ess.runTaskAsynchronously(new Calculator(new Viewer(sender, page, force), force));
}
}
}

View File

@@ -4,6 +4,7 @@ import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.logging.Level;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -20,6 +21,7 @@ public class Commandban extends EssentialsCommand
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
boolean nomatch = false;
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
@@ -31,6 +33,7 @@ public class Commandban extends EssentialsCommand
}
catch (NoSuchFieldException e)
{
nomatch = true;
user = ess.getUser(new OfflinePlayer(args[0], ess));
}
if (!user.isOnline())
@@ -44,7 +47,7 @@ public class Commandban extends EssentialsCommand
}
else
{
if (user.isAuthorized("essentials.ban.exempt"))
if (user.isAuthorized("essentials.ban.exempt") && sender instanceof Player)
{
sender.sendMessage(_("banExempt"));
return;
@@ -55,23 +58,28 @@ public class Commandban extends EssentialsCommand
String banReason;
if (args.length > 1)
{
banReason = _("banFormat", getFinalArg(args, 1), senderName);
banReason = Util.replaceFormat(getFinalArg(args, 1).replace("\\n", "\n").replace("|", "\n"));
}
else
{
banReason = _("banFormat", _("defaultBanReason"), senderName);
banReason = _("defaultBanReason");
}
user.setBanReason(banReason);
user.setBanReason(_("banFormat", banReason, senderName));
user.setBanned(true);
user.kickPlayer(banReason);
user.setBanTimeout(0);
user.kickPlayer(_("banFormat", banReason, senderName));
server.getLogger().log(Level.INFO, _("playerBanned", senderName, user.getName(), banReason));
if (nomatch) {
sender.sendMessage(_("userUnknown", args[0]));
}
for (Player onlinePlayer : server.getOnlinePlayers())
{
final User player = ess.getUser(onlinePlayer);
if (player.isAuthorized("essentials.ban.notify"))
if (onlinePlayer == sender || player.isAuthorized("essentials.ban.notify"))
{
onlinePlayer.sendMessage(_("playerBanned", senderName, user.getName(), banReason));
}

View File

@@ -0,0 +1,92 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
public class Commandbook extends EssentialsCommand
{
public Commandbook()
{
super("book");
}
//TODO: Translate this
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
final ItemStack item = user.getItemInHand();
final String player = user.getName();
if (item.getType() == Material.WRITTEN_BOOK)
{
BookMeta bmeta = (BookMeta)item.getItemMeta();
if (args.length > 1 && args[0].equalsIgnoreCase("author"))
{
if (user.isAuthorized("essentals.book.author"))
{
bmeta.setAuthor(args[1]);
item.setItemMeta(bmeta);
user.sendMessage(_("bookAuthorSet", getFinalArg(args, 1)));
}
else
{
throw new Exception(_("denyChangeAuthor"));
}
}
else if (args.length > 1 && args[0].equalsIgnoreCase("title"))
{
if (user.isAuthorized("essentials.book.title") && (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others")))
{
bmeta.setTitle(args[1]);
item.setItemMeta(bmeta);
user.sendMessage(_("bookTitleSet", getFinalArg(args, 1)));
}
else
{
throw new Exception(_("denyChangeTitle"));
}
}
else
{
if (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others"))
{
ItemStack newItem = new ItemStack(Material.BOOK_AND_QUILL, item.getAmount());
newItem.setItemMeta(bmeta);
user.setItemInHand(newItem);
user.sendMessage(_("editBookContents"));
}
else
{
throw new Exception(_("denyBookEdit"));
}
}
}
else if (item.getType() == Material.BOOK_AND_QUILL)
{
BookMeta bmeta = (BookMeta)item.getItemMeta();
if (!user.isAuthorized("essentals.book.author"))
{
bmeta.setAuthor(player);
}
ItemStack newItem = new ItemStack(Material.WRITTEN_BOOK, item.getAmount());
newItem.setItemMeta(bmeta);
user.setItemInHand(newItem);
user.sendMessage(_("bookLocked"));
}
else
{
throw new Exception(_("holdBook"));
}
}
private boolean isAuthor(BookMeta bmeta, String player)
{
String author = bmeta.getAuthor();
return author != null && author.equalsIgnoreCase(player);
}
}

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -13,6 +14,17 @@ public class Commandbroadcast extends EssentialsCommand
super("broadcast");
}
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
ess.broadcastMessage(null, _("broadcast", Util.replaceFormat(getFinalArg(args, 0)), user.getDisplayName()));
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
@@ -21,6 +33,6 @@ public class Commandbroadcast extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
ess.broadcastMessage(null, _("broadcast", Util.replaceFormat(getFinalArg(args, 0))));
ess.broadcastMessage(null, _("broadcast", Util.replaceFormat(getFinalArg(args, 0)), sender.getName()));
}
}

View File

@@ -2,10 +2,12 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class Commandclearinventory extends EssentialsCommand
@@ -21,78 +23,134 @@ public class Commandclearinventory extends EssentialsCommand
{
if (args.length > 0 && user.isAuthorized("essentials.clearinventory.others"))
{
//TODO: Fix fringe user match case.
if (args[0].length() >= 3)
if (args[0].contentEquals("*") && user.isAuthorized("essentials.clearinventory.all"))
{
List<Player> online = server.matchPlayer(args[0]);
if (!online.isEmpty())
{
for (Player p : online)
{
p.getInventory().clear();
user.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
}
return;
}
throw new Exception(_("playerNotFound"));
cleanInventoryAll(server, user, args);
}
else if (args[0].trim().length() < 2)
{
cleanInventorySelf(server, user, args);
}
else
{
Player p = server.getPlayer(args[0]);
if (p != null)
{
p.getInventory().clear();
user.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
}
else
{
throw new Exception(_("playerNotFound"));
}
cleanInventoryOthers(server, user, args);
}
}
else
{
user.getInventory().clear();
user.sendMessage(_("inventoryCleared"));
cleanInventorySelf(server, user, args);
}
}
@Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length < 1)
if (args.length > 0)
{
throw new NotEnoughArgumentsException();
}
if (args[0].length() >= 3)
{
List<Player> online = server.matchPlayer(args[0]);
if (!online.isEmpty())
if (args[0].contentEquals("*"))
{
for (Player p : online)
{
p.getInventory().clear();
sender.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
}
return;
cleanInventoryAll(server, sender, args);
}
throw new Exception(_("playerNotFound"));
}
else
{
Player u = server.getPlayer(args[0]);
if (u != null)
{
u.getInventory().clear();
sender.sendMessage(_("inventoryClearedOthers", u.getDisplayName()));
}
else
else if (args[0].trim().length() < 2)
{
throw new Exception(_("playerNotFound"));
}
else
{
cleanInventoryOthers(server, sender, args);
}
}
else
{
throw new NotEnoughArgumentsException();
}
}
}
private void cleanInventoryAll(Server server, CommandSender sender, String[] args) throws Exception
{
if (args.length > 1)
{
for (Player onlinePlayer : server.getOnlinePlayers())
{
clearInventory(onlinePlayer, args[1]);
}
sender.sendMessage("Cleared everyone's inventory");
}
else
{
throw new NotEnoughArgumentsException();
}
}
private void cleanInventoryOthers(Server server, CommandSender user, String[] args) throws Exception
{
List<Player> online = server.matchPlayer(args[0]);
if (!online.isEmpty())
{
for (Player p : online)
{
if (args.length > 1)
{
clearInventory(p, args[1]);
}
else
{
p.getInventory().clear();
}
user.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
}
}
else
{
throw new Exception(_("playerNotFound"));
}
}
private void cleanInventorySelf(Server server, User user, String[] args) throws Exception
{
if (args.length > 0)
{
clearInventory(user, args[0]);
}
else
{
user.getInventory().clear();
}
user.sendMessage(_("inventoryCleared"));
}
private void clearInventory(Player player, String arg) throws Exception
{
if (arg.equalsIgnoreCase("*"))
{
player.getInventory().clear();
}
else
{
final String[] split = arg.split(":");
final ItemStack item = ess.getItemDb().get(split[0]);
final int type = item.getTypeId();
if (split.length > 1 && Util.isInt(split[1]))
{
player.getInventory().clear(type, Integer.parseInt(split[1]));
}
else if (split.length > 1 && split[1].equalsIgnoreCase("*"))
{
player.getInventory().clear(type, -1);
}
else
{
if (Util.isInt(split[0]))
{
player.getInventory().clear(type, -1);
}
else
{
player.getInventory().clear(type, item.getDurability());
}
}
}
}
}

View File

@@ -50,10 +50,10 @@ public class Commanddelhome extends EssentialsCommand
{
name = expandedArg[0];
}
//TODO: Think up a nice error message
/*
* if (name.equalsIgnoreCase("bed")) { throw new Exception("You cannot remove the vanilla home point"); }
*/
if (name.equalsIgnoreCase("bed")) { throw new Exception(_("invalidHomeName")); }
user.delHome(name.toLowerCase(Locale.ENGLISH));
sender.sendMessage(_("deleteHome", name));
}

View File

@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -18,6 +19,9 @@ public class Commandeco extends EssentialsCommand
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
Double broadcast = null;
Double broadcastAll = null;
final double startingBalance = (double)ess.getSettings().getStartingBalance();
if (args.length < 2)
{
throw new NotEnoughArgumentsException();
@@ -34,6 +38,8 @@ public class Commandeco extends EssentialsCommand
throw new NotEnoughArgumentsException(ex);
}
final double minBalance = ess.getSettings().getMinMoney();
if (args[1].contentEquals("**"))
{
for (String sUser : ess.getUserMap().getAllUniqueUsers())
@@ -49,11 +55,25 @@ public class Commandeco extends EssentialsCommand
if (player.canAfford(amount, false))
{
player.takeMoney(amount);
}
}
else
{
if (player.getMoney() > 0)
{
player.setMoney(0);
}
}
break;
case RESET:
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
player.setMoney(startingBalance);
broadcastAll = startingBalance;
break;
case SET:
boolean underMinimum = (player.getMoney() - amount) < minBalance;
player.setMoney(underMinimum ? minBalance : amount);
broadcastAll = underMinimum ? minBalance : amount;
break;
}
}
@@ -70,15 +90,28 @@ public class Commandeco extends EssentialsCommand
break;
case TAKE:
if (!player.canAfford(amount, false))
if (player.canAfford(amount))
{
throw new Exception(_("notEnoughMoney"));
player.takeMoney(amount);
}
else
{
if (player.getMoney() > 0)
{
player.setMoney(0);
}
}
player.takeMoney(amount);
break;
case RESET:
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
player.setMoney(startingBalance);
broadcast = startingBalance;
break;
case SET:
boolean underMinimum = (player.getMoney() - amount) < minBalance;
player.setMoney(underMinimum ? minBalance : amount);
broadcast = underMinimum ? minBalance : amount;
break;
}
}
@@ -93,23 +126,38 @@ public class Commandeco extends EssentialsCommand
break;
case TAKE:
if (!player.canAfford(amount, false))
if (!player.canAfford(amount))
{
throw new Exception(_("notEnoughMoney"));
}
player.takeMoney(amount, sender);
break;
case RESET:
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
player.setMoney(startingBalance);
break;
case SET:
boolean underMinimum = (player.getMoney() - amount) < minBalance;
player.setMoney(underMinimum ? minBalance : amount);
break;
}
}
if (broadcast != null)
{
server.broadcastMessage(_("resetBal", Util.formatAsCurrency(broadcast)));
}
if (broadcastAll != null)
{
server.broadcastMessage(_("resetBalAll", Util.formatAsCurrency(broadcastAll)));
}
}
private enum EcoCommands
{
GIVE, TAKE, RESET
GIVE, TAKE, RESET, SET
}
}

View File

@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Enchantments;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.MetaItemStack;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale;
@@ -35,7 +36,7 @@ public class Commandenchant extends EssentialsCommand
for (Map.Entry<String, Enchantment> entry : Enchantments.entrySet())
{
final String enchantmentName = entry.getValue().getName().toLowerCase(Locale.ENGLISH);
if (enchantmentslist.contains(enchantmentName) || user.isAuthorized("essentials.enchant." + enchantmentName))
if (enchantmentslist.contains(enchantmentName) || (user.isAuthorized("essentials.enchant." + enchantmentName) && entry.getValue().canEnchantItem(stack)))
{
enchantmentslist.add(entry.getKey());
//enchantmentslist.add(enchantmentName);
@@ -43,6 +44,7 @@ public class Commandenchant extends EssentialsCommand
}
throw new NotEnoughArgumentsException(_("enchantments", Util.joinList(enchantmentslist.toArray())));
}
int level = -1;
if (args.length > 1)
{
@@ -55,20 +57,14 @@ public class Commandenchant extends EssentialsCommand
level = -1;
}
}
final Enchantment enchantment = getEnchantment(args[0], user);
if (level < 0 || level > enchantment.getMaxLevel())
{
level = enchantment.getMaxLevel();
}
if (level == 0)
{
stack.removeEnchantment(enchantment);
}
else
{
stack.addEnchantment(enchantment, level);
}
user.getInventory().setItemInHand(stack);
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments() && user.isAuthorized("essentials.enchant.allowunsafe");
final MetaItemStack metaStack = new MetaItemStack(stack);
final Enchantment enchantment = metaStack.getEnchantment(user, args[0]);
metaStack.addEnchantment(user, allowUnsafe, enchantment, level);
user.getInventory().setItemInHand(metaStack.getItemStack());
user.updateInventory();
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
if (level == 0)
@@ -80,20 +76,4 @@ public class Commandenchant extends EssentialsCommand
user.sendMessage(_("enchantmentApplied", enchantmentName.replace('_', ' ')));
}
}
public static Enchantment getEnchantment(final String name, final User user) throws Exception
{
final Enchantment enchantment = Enchantments.getByName(name);
if (enchantment == null)
{
throw new Exception(_("enchantmentNotFound"));
}
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
if (user != null && !user.isAuthorized("essentials.enchant." + enchantmentName))
{
throw new Exception(_("enchantmentPerm", enchantmentName));
}
return enchantment;
}
}

View File

@@ -14,7 +14,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
// This command has 4 undocumented behaviours #EasterEgg
public class Commandessentials extends EssentialsCommand
{
public Commandessentials()
@@ -55,6 +55,7 @@ public class Commandessentials extends EssentialsCommand
}
}
//If you do not supply an argument this command will list 'overridden' commands.
private void run_disabled(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
sender.sendMessage("Essentials " + ess.getDescription().getVersion());

View File

@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.craftbukkit.SetExpFix;
import java.util.Locale;
import org.bukkit.Server;
@@ -45,21 +46,40 @@ public class Commandexp extends EssentialsCommand
setExp(user, user, args[1], true);
}
}
else
else if (args[0].equalsIgnoreCase("show"))
{
String match = args[0].trim();
if (args.length == 2)
if (args.length >= 2 && user.isAuthorized("essentials.exp.others"))
{
match = args[1].trim();
}
if (match.equalsIgnoreCase("show") || !user.isAuthorized("essentials.exp.others"))
{
showExp(user, user);
String match = args[1].trim();
showMatch(server, user, match);
}
else
{
showExp(user, user);
}
}
else
{
if (args.length >= 1 && Util.isInt(args[0].toLowerCase(Locale.ENGLISH).replace("l", "")) && user.isAuthorized("essentials.exp.give"))
{
if (args.length >= 2 && user.isAuthorized("essentials.exp.give.others"))
{
expMatch(server, user, args[1], args[0], true);
}
else
{
setExp(user, user, args[0], true);
}
}
else if (args.length >= 1 && user.isAuthorized("essentials.exp.others"))
{
String match = args[0].trim();
showMatch(server, user, match);
}
else
{
showExp(user, user);
}
}
}
@@ -81,9 +101,14 @@ public class Commandexp extends EssentialsCommand
else
{
String match = args[0].trim();
if (args.length == 2)
if (args.length >= 2 && Util.isInt(args[0].toLowerCase(Locale.ENGLISH).replace("l", "")))
{
match = args[1].trim();
expMatch(server, sender, match, args[0], true);
}
else if (args.length == 1)
{
match = args[0].trim();
}
showMatch(server, sender, match);
}
@@ -104,13 +129,13 @@ public class Commandexp extends EssentialsCommand
}
}
private void expMatch(final Server server, final CommandSender sender, final String match, String amount, final boolean toggle) throws NotEnoughArgumentsException
private void expMatch(final Server server, final CommandSender sender, final String match, String amount, final boolean give) throws NotEnoughArgumentsException
{
boolean foundUser = false;
for (Player matchPlayer : server.matchPlayer(match))
{
final User target = ess.getUser(matchPlayer);
setExp(sender, target, amount, toggle);
setExp(sender, target, amount, give);
foundUser = true;
}
if (!foundUser)
@@ -121,17 +146,17 @@ public class Commandexp extends EssentialsCommand
private void showExp(final CommandSender sender, final User target)
{
final int totalExp = SetExpFix.getTotalExperience(target);
sender.sendMessage(_("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target), target.getLevel(), SetExpFix.getExpUntilNextLevel(target)));
}
private void setExp(final CommandSender sender, final User target, String strAmount, final boolean give)
//TODO: Limit who can give negative exp?
private void setExp(final CommandSender sender, final User target, String strAmount, final boolean give) throws NotEnoughArgumentsException
{
Long amount;
long amount;
strAmount = strAmount.toLowerCase(Locale.ENGLISH);
if (strAmount.startsWith("l"))
if (strAmount.contains("l"))
{
strAmount = strAmount.substring(1);
strAmount = strAmount.replaceAll("l", "");
int neededLevel = Integer.parseInt(strAmount);
if (give)
{
@@ -140,8 +165,13 @@ public class Commandexp extends EssentialsCommand
amount = (long)SetExpFix.getExpToLevel(neededLevel);
SetExpFix.setTotalExperience(target, 0);
}
else {
else
{
amount = Long.parseLong(strAmount);
if (amount > Integer.MAX_VALUE || amount < Integer.MIN_VALUE)
{
throw new NotEnoughArgumentsException();
}
}
if (give)
@@ -152,7 +182,11 @@ public class Commandexp extends EssentialsCommand
{
amount = (long)Integer.MAX_VALUE;
}
SetExpFix.setTotalExperience(target, amount.intValue());
if (amount < 0l)
{
amount = 0l;
}
SetExpFix.setTotalExperience(target, (int)amount);
sender.sendMessage(_("expSet", target.getDisplayName(), amount));
}
}

View File

@@ -2,8 +2,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.SmallFireball;
import org.bukkit.entity.*;
import org.bukkit.util.Vector;
@@ -18,12 +17,43 @@ public class Commandfireball extends EssentialsCommand
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
boolean small = false;
if (args.length > 0 && args[0].equalsIgnoreCase("small"))
Class<? extends Entity> type = Fireball.class;
Projectile projectile;
int speed = 2;
if (args.length > 0)
{
small = true;
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;
}
}
final Vector direction = user.getEyeLocation().getDirection().multiply(2);
Fireball fireball = user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), small ? SmallFireball.class : Fireball.class);
fireball.setShooter(user.getBase());
final Vector direction = user.getEyeLocation().getDirection().multiply(speed);
projectile = (Projectile)user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), type);
projectile.setShooter(user.getBase());
projectile.setVelocity(direction);
}
}

View File

@@ -0,0 +1,156 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.MetaItemStack;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.util.Vector;
//This command has quite a complicated syntax, in theory it has 4 seperate syntaxes which are all variable:
//
//1: /firework clear - This clears all of the effects on a firework stack
//
//2: /firework power <int> - This changes the base power of a firework
//
//3: /firework fire - This 'fires' a copy of the firework held.
//3: /firework fire <int> - This 'fires' a number of copies of the firework held.
//3: /firework fire <other> - This 'fires' a copy of the firework held, in the direction you are looking, #easteregg
//
//4: /firework [meta] - This will add an effect to the firework stack held
//4: /firework color:<color> - The minimum you need to set an effect is 'color'
//4: Full Syntax: color:<color[,color,..]> [fade:<color[,color,..]>] [shape:<shape>] [effect:<effect[,effect]>]
//4: Possible Shapes: star, ball, large, creeper, burst
//4: Possible Effects trail, twinkle
public class Commandfirework extends EssentialsCommand
{
private final transient Pattern splitPattern = Pattern.compile("[:+',;.]");
private final static Map<String, DyeColor> colorMap = new HashMap<String, DyeColor>();
private final static Map<String, FireworkEffect.Type> fireworkShape = new HashMap<String, FireworkEffect.Type>();
static
{
for (DyeColor color : DyeColor.values())
{
colorMap.put(color.name(), color);
}
for (FireworkEffect.Type type : FireworkEffect.Type.values())
{
fireworkShape.put(type.name(), type);
}
}
public Commandfirework()
{
super("firework");
}
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
final ItemStack stack = user.getItemInHand();
if (stack.getType() == Material.FIREWORK)
{
if (args.length > 0)
{
if (args[0].equalsIgnoreCase("clear"))
{
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
fmeta.clearEffects();
stack.setItemMeta(fmeta);
user.sendMessage(_("fireworkEffectsCleared"));
}
else if (args.length > 1 && (args[0].equalsIgnoreCase("power") || (args[0].equalsIgnoreCase("p"))))
{
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
try
{
int power = Integer.parseInt(args[1]);
fmeta.setPower(power > 3 ? 4 : power);
}
catch (NumberFormatException e)
{
throw new Exception(_("invalidFireworkFormat", args[1], args[0]));
}
stack.setItemMeta(fmeta);
}
else if ((args[0].equalsIgnoreCase("fire") || (args[0].equalsIgnoreCase("p")))
&& user.isAuthorized("essentials.firework.fire"))
{
int amount = 1;
boolean direction = false;
if (Util.isInt(args[1]))
{
final int serverLimit = ess.getSettings().getSpawnMobLimit();
amount = Integer.parseInt(args[1]);
if (amount > serverLimit)
{
amount = serverLimit;
user.sendMessage(_("mobSpawnLimit"));
}
}
else
{
direction = true;
}
for (int i = 0; i < amount; i++)
{
Firework firework = (Firework)user.getWorld().spawnEntity(user.getLocation(), EntityType.FIREWORK);
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
if (direction)
{
final Vector vector = user.getEyeLocation().getDirection().multiply(0.070);
if (fmeta.getPower() > 1)
{
fmeta.setPower(1);
}
firework.setVelocity(vector);
}
firework.setFireworkMeta(fmeta);
}
}
else
{
final MetaItemStack mStack = new MetaItemStack(stack);
for (String arg : args)
{
final String[] split = splitPattern.split(arg, 2);
mStack.addFireworkMeta(user, true, arg, ess);
}
if (mStack.isValidFirework())
{
FireworkMeta fmeta = (FireworkMeta)mStack.getItemStack().getItemMeta();
FireworkEffect effect = mStack.getFireworkBuilder().build();
fmeta.addEffect(effect);
stack.setItemMeta(fmeta);
}
else
{
user.sendMessage(_("fireworkSyntax"));
throw new Exception(_("fireworkColor"));
}
}
}
else
{
throw new NotEnoughArgumentsException();
}
}
else
{
throw new Exception(_("holdFirework"));
}
}
}

View File

@@ -28,15 +28,34 @@ public class Commandfly extends EssentialsCommand
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.fly.others"))
if (args.length == 1)
{
if (args[0].equalsIgnoreCase("on") || args[0].startsWith("ena") || args[0].equalsIgnoreCase("1"))
{
user.setAllowFlight(true);
}
else if (args[0].equalsIgnoreCase("off") || args[0].startsWith("dis") || args[0].equalsIgnoreCase("0"))
{
user.setAllowFlight(false);
}
else if (user.isAuthorized("essentials.fly.others"))
{
flyOtherPlayers(server, user, args);
return;
}
}
else if (args.length == 2 && user.isAuthorized("essentials.fly.others"))
{
flyOtherPlayers(server, user, args);
return;
}
user.setAllowFlight(!user.getAllowFlight());
if (!user.getAllowFlight())
else
{
user.setFlying(false);
user.setAllowFlight(!user.getAllowFlight());
if (!user.getAllowFlight())
{
user.setFlying(false);
}
}
user.sendMessage(_("flyMode", _(user.getAllowFlight() ? "enabled" : "disabled"), user.getDisplayName()));
}

View File

@@ -19,12 +19,22 @@ public class Commandgamemode extends EssentialsCommand
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
GameMode gameMode;
if (args.length == 0)
{
throw new NotEnoughArgumentsException();
}
GameMode gameMode = matchGameMode(args[0].toLowerCase(Locale.ENGLISH));
gamemodeOtherPlayers(server, sender, gameMode, args[1]);
else if (args.length == 1)
{
gameMode = matchGameMode(commandLabel);
gamemodeOtherPlayers(server, sender, gameMode, args[0]);
}
else if (args.length == 2)
{
gameMode = matchGameMode(args[0].toLowerCase(Locale.ENGLISH));
gamemodeOtherPlayers(server, sender, gameMode, args[1]);
}
}
@Override
@@ -43,16 +53,23 @@ public class Commandgamemode extends EssentialsCommand
}
else
{
try {
try
{
gameMode = matchGameMode(args[0].toLowerCase(Locale.ENGLISH));
}
catch (NotEnoughArgumentsException e) {
gameMode = matchGameMode(commandLabel);
gamemodeOtherPlayers(server, user, gameMode, args[0]);
return;
catch (NotEnoughArgumentsException e)
{
if (user.isAuthorized("essentials.gamemode.others"))
{
gameMode = matchGameMode(commandLabel);
gamemodeOtherPlayers(server, user, gameMode, args[0]);
return;
}
throw new NotEnoughArgumentsException();
}
}
if (gameMode == null) {
if (gameMode == null)
{
gameMode = user.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : user.getGameMode() == GameMode.CREATIVE ? GameMode.ADVENTURE : GameMode.SURVIVAL;
}
user.setGameMode(gameMode);
@@ -104,11 +121,12 @@ public class Commandgamemode extends EssentialsCommand
mode = GameMode.ADVENTURE;
}
else if (modeString.equalsIgnoreCase("gmt") || modeString.equalsIgnoreCase("egmt")
|| modeString.contains("toggle") || modeString.contains("cycle") || modeString.equalsIgnoreCase("t"))
|| modeString.contains("toggle") || modeString.contains("cycle") || modeString.equalsIgnoreCase("t"))
{
mode = null;
}
else {
else
{
throw new NotEnoughArgumentsException();
}
return mode;

View File

@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Util;
import java.lang.management.ManagementFactory;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.World;
@@ -33,14 +34,15 @@ public class Commandgc extends EssentialsCommand
{
color = ChatColor.RED;
}
sender.sendMessage(_("uptime", Util.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime())));
sender.sendMessage(_("tps", "" + color + tps));
sender.sendMessage(_("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
sender.sendMessage(_("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
sender.sendMessage(_("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
sender.sendMessage(_("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
for (World w : server.getWorlds())
List<World> worlds = server.getWorlds();
for (World w : worlds)
{
String worldType = "World";
switch (w.getEnvironment())
@@ -55,6 +57,5 @@ public class Commandgc extends EssentialsCommand
sender.sendMessage(_("gcWorld", worldType, w.getName(), w.getLoadedChunks().length, w.getEntities().size()));
}
}
}

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.MetaItemStack;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
@@ -8,7 +9,6 @@ import java.util.Locale;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -28,7 +28,7 @@ public class Commandgive extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final ItemStack stack = ess.getItemDb().get(args[1]);
ItemStack stack = ess.getItemDb().get(args[1]);
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
if (sender instanceof Player
@@ -44,45 +44,43 @@ public class Commandgive extends EssentialsCommand
final User giveTo = getPlayer(server, args, 0);
if (args.length > 3 && Util.isInt(args[2]) && Util.isInt(args[3]))
try
{
stack.setAmount(Integer.parseInt(args[2]));
stack.setDurability(Short.parseShort(args[3]));
if (args.length > 3 && Util.isInt(args[2]) && Util.isInt(args[3]))
{
stack.setAmount(Integer.parseInt(args[2]));
stack.setDurability(Short.parseShort(args[3]));
}
else if (args.length > 2 && Integer.parseInt(args[2]) > 0)
{
stack.setAmount(Integer.parseInt(args[2]));
}
else if (ess.getSettings().getDefaultStackSize() > 0)
{
stack.setAmount(ess.getSettings().getDefaultStackSize());
}
else if (ess.getSettings().getOversizedStackSize() > 0 && giveTo.isAuthorized("essentials.oversizedstacks"))
{
stack.setAmount(ess.getSettings().getOversizedStackSize());
}
}
else if (args.length > 2 && Integer.parseInt(args[2]) > 0)
catch (NumberFormatException e)
{
stack.setAmount(Integer.parseInt(args[2]));
}
else if (ess.getSettings().getDefaultStackSize() > 0)
{
stack.setAmount(ess.getSettings().getDefaultStackSize());
}
else if (ess.getSettings().getOversizedStackSize() > 0 && giveTo.isAuthorized("essentials.oversizedstacks"))
{
stack.setAmount(ess.getSettings().getOversizedStackSize());
throw new NotEnoughArgumentsException();
}
if (args.length > 3)
{
for (int i = Util.isInt(args[3]) ? 4 : 3; i < args.length; i++)
MetaItemStack metaStack = new MetaItemStack(stack);
boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
if (allowUnsafe && sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.enchant.allowunsafe"))
{
final String[] split = args[i].split("[:+',;.]", 2);
if (split.length < 1)
{
continue;
}
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], sender instanceof Player ? ess.getUser(sender) : null);
int level;
if (split.length > 1)
{
level = Integer.parseInt(split[1]);
}
else
{
level = enchantment.getMaxLevel();
}
stack.addEnchantment(enchantment, level);
allowUnsafe = false;
}
metaStack.parseStringMeta(sender, allowUnsafe, args, Util.isInt(args[3]) ? 4 : 3, ess);
stack = metaStack.getItemStack();
}
if (stack.getType() == Material.AIR)
@@ -94,11 +92,11 @@ public class Commandgive extends EssentialsCommand
sender.sendMessage(_("giveSpawn", stack.getAmount(), itemName, giveTo.getDisplayName()));
if (giveTo.isAuthorized("essentials.oversizedstacks"))
{
InventoryWorkaround.addItem(giveTo.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
InventoryWorkaround.addOversizedItems(giveTo.getInventory(), ess.getSettings().getOversizedStackSize(), stack);
}
else
{
InventoryWorkaround.addItem(giveTo.getInventory(), true, stack);
InventoryWorkaround.addItems(giveTo.getInventory(), stack);
}
giveTo.updateInventory();
}

View File

@@ -33,10 +33,20 @@ public class Commandgod extends EssentialsCommand
godOtherPlayers(server, user, args);
return;
}
user.setGodModeEnabled(!user.isGodModeEnabled());
godPlayer(user, !user.isGodModeEnabled());
user.sendMessage(_("godMode", (user.isGodModeEnabled() ? _("enabled") : _("disabled"))));
}
private void godPlayer(User player, boolean enabled)
{
player.setGodModeEnabled(enabled);
if (enabled)
{
player.setHealth(player.getMaxHealth());
player.setFoodLevel(20);
}
}
private void godOtherPlayers(final Server server, final CommandSender sender, final String[] args)
{
for (Player matchPlayer : server.matchPlayer(args[0]))
@@ -47,28 +57,24 @@ public class Commandgod extends EssentialsCommand
continue;
}
boolean enabled;
if (args.length > 1)
{
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
{
player.setGodModeEnabled(true);
enabled = true;
}
else
{
player.setGodModeEnabled(false);
enabled = false;
}
}
else
{
player.setGodModeEnabled(!player.isGodModeEnabled());
}
final boolean enabled = player.isGodModeEnabled();
if (enabled)
{
player.setFoodLevel(20);
enabled = !player.isGodModeEnabled();
}
godPlayer(player, enabled);
player.sendMessage(_("godMode", (enabled ? _("enabled") : _("disabled"))));
sender.sendMessage(_("godMode", _(enabled ? "godEnabledFor" : "godDisabledFor", matchPlayer.getDisplayName())));
}

View File

@@ -31,7 +31,7 @@ public class Commandhat extends EssentialsCommand
{
final ItemStack air = new ItemStack(Material.AIR);
inv.setHelmet(air);
InventoryWorkaround.addItem(user.getInventory(), true, head);
InventoryWorkaround.addItems(user.getInventory(), head);
user.sendMessage(_("hatRemoved"));
}
}

View File

@@ -7,7 +7,6 @@ import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class Commandheal extends EssentialsCommand
@@ -68,14 +67,15 @@ public class Commandheal extends EssentialsCommand
}
}
private void healPlayer(final Player p)
private void healPlayer(final Player player)
{
p.setHealth(20);
p.setFoodLevel(20);
p.sendMessage(_("heal"));
for (PotionEffect effect : p.getActivePotionEffects())
player.setHealth(player.getMaxHealth());
player.setFoodLevel(20);
player.setFireTicks(0);
player.sendMessage(_("heal"));
for (PotionEffect effect : player.getActivePotionEffects())
{
p.removePotionEffect(effect.getType());
player.removePotionEffect(effect.getType());
}
}
}

View File

@@ -23,7 +23,6 @@ public class Commandhome extends EssentialsCommand
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
User player = user;
String homeName = "";
String[] nameParts;
@@ -45,10 +44,10 @@ public class Commandhome extends EssentialsCommand
}
try
{
if ("bed".equalsIgnoreCase(homeName))
if ("bed".equalsIgnoreCase(homeName) && user.isAuthorized("essentials.home.bed"))
{
final Location bed = player.getBedSpawnLocation();
if (bed != null && bed.getBlock().getType() == Material.BED_BLOCK)
if (bed != null)
{
user.getTeleport().teleport(bed, charge, TeleportCause.COMMAND);
throw new NoChargeException();
@@ -59,24 +58,14 @@ public class Commandhome extends EssentialsCommand
catch (NotEnoughArgumentsException e)
{
Location bed = player.getBedSpawnLocation();
if (bed != null && bed.getBlock().getType() != Material.BED_BLOCK)
{
bed = null;
}
final List<String> homes = player.getHomes();
if (homes.isEmpty() && player.equals(user))
{
if (bed != null)
{
user.getTeleport().teleport(bed, charge, TeleportCause.COMMAND);
throw new NoChargeException();
}
user.getTeleport().respawn(charge, TeleportCause.COMMAND);
}
else if (homes.isEmpty())
{
throw new Exception(player == user ? _("noHomeSet") : _("noHomeSetPlayer"));
throw new Exception(_("noHomeSetPlayer"));
}
else if (homes.size() == 1 && player.equals(user))
{
@@ -84,9 +73,9 @@ public class Commandhome extends EssentialsCommand
}
else
{
if (bed != null)
if (bed != null && user.isAuthorized("essentials.home.bed"))
{
homes.add("bed");
homes.add(_("bed"));
}
user.sendMessage(_("homes", Util.joinList(homes)));
}

View File

@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.inventory.Inventory;
public class Commandinvsee extends EssentialsCommand
@@ -10,6 +11,8 @@ public class Commandinvsee extends EssentialsCommand
{
super("invsee");
}
//This method has a hidden param, which if given will display the equip slots. #easteregg
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
@@ -18,8 +21,20 @@ public class Commandinvsee extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
final User invUser = getPlayer(server, args, 0);
Inventory inv;
if (args.length > 1 && user.isAuthorized("essentials.invsee.equip"))
{
inv = server.createInventory(invUser, 9, "Equipped");
inv.setContents(invUser.getInventory().getArmorContents());
}
else
{
inv = invUser.getInventory();
}
user.openInventory(inv);
user.setInvSee(true);
user.openInventory(invUser.getInventory());
}
}

View File

@@ -1,12 +1,12 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.MetaItemStack;
import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import java.util.Locale;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
@@ -24,7 +24,7 @@ public class Commanditem extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
final ItemStack stack = ess.getItemDb().get(args[0]);
ItemStack stack = ess.getItemDb().get(args[0]);
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
if (ess.getSettings().permissionBasedItemSpawn()
@@ -50,33 +50,21 @@ public class Commanditem extends EssentialsCommand
{
stack.setAmount(ess.getSettings().getOversizedStackSize());
}
if (args.length > 2)
{
for (int i = 2; i < args.length; i++)
{
final String[] split = args[i].split("[:+',;.]", 2);
if (split.length < 1)
{
continue;
}
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], user);
int level;
if (split.length > 1)
{
level = Integer.parseInt(split[1]);
}
else
{
level = enchantment.getMaxLevel();
}
stack.addEnchantment(enchantment, level);
}
}
}
catch (NumberFormatException e)
{
throw new NotEnoughArgumentsException();
}
if (args.length > 2)
{
MetaItemStack metaStack = new MetaItemStack(stack);
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments() && user.isAuthorized("essentials.enchant.allowunsafe");
metaStack.parseStringMeta(user, allowUnsafe, args, 2, ess);
stack = metaStack.getItemStack();
}
if (stack.getType() == Material.AIR)
{
@@ -87,11 +75,11 @@ public class Commanditem extends EssentialsCommand
user.sendMessage(_("itemSpawn", stack.getAmount(), displayName));
if (user.isAuthorized("essentials.oversizedstacks"))
{
InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
InventoryWorkaround.addOversizedItems(user.getInventory(), ess.getSettings().getOversizedStackSize(), stack);
}
else
{
InventoryWorkaround.addItem(user.getInventory(), true, stack);
InventoryWorkaround.addItems(user.getInventory(), stack);
}
user.updateInventory();
}

View File

@@ -8,7 +8,7 @@ import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
// This method contains an undocumented sub command #EasterEgg
public class Commandjump extends EssentialsCommand
{
public Commandjump()

View File

@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.logging.Level;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -24,23 +25,34 @@ public class Commandkick extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final User user = getPlayer(server, args, 0);
if (sender instanceof Player && user.isAuthorized("essentials.kick.exempt"))
final User target = getPlayer(server, args, 0, true);
if (sender instanceof Player)
{
throw new Exception(_("kickExempt"));
User user = ess.getUser(sender);
if (target.isHidden() && !user.isAuthorized("essentials.list.hidden"))
{
throw new PlayerNotFoundException();
}
if (target.isAuthorized("essentials.kick.exempt"))
{
throw new Exception(_("kickExempt"));
}
}
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : _("kickDefault");
user.kickPlayer(kickReason);
String kickReason = args.length > 1 ? getFinalArg(args, 1) : _("kickDefault");
kickReason = Util.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n"));
target.kickPlayer(kickReason);
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
server.getLogger().log(Level.INFO, _("playerKicked", senderName, user.getName(), kickReason));
server.getLogger().log(Level.INFO, _("playerKicked", senderName, target.getName(), kickReason));
for (Player onlinePlayer : server.getOnlinePlayers())
{
User player = ess.getUser(onlinePlayer);
if (player.isAuthorized("essentials.kick.notify"))
{
onlinePlayer.sendMessage(_("playerKicked", senderName, user.getName(), kickReason));
onlinePlayer.sendMessage(_("playerKicked", senderName, target.getName(), kickReason));
}
}
}

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -16,6 +17,9 @@ public class Commandkickall extends EssentialsCommand
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
String kickReason = args.length > 0 ? getFinalArg(args, 0) : _("kickDefault");
kickReason = Util.replaceFormat(kickReason.replace("\\n", "\n").replace("|", "\n"));
for (Player onlinePlayer : server.getOnlinePlayers())
{
if (sender instanceof Player && onlinePlayer.getName().equalsIgnoreCase(((Player)sender).getName()))
@@ -24,7 +28,7 @@ public class Commandkickall extends EssentialsCommand
}
else
{
onlinePlayer.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : _("kickDefault"));
onlinePlayer.kickPlayer(kickReason);
}
}
sender.sendMessage(_("kickedAll"));

View File

@@ -21,7 +21,7 @@ public class Commandkill extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
//TODO: TL this
if (args[0].trim().length() < 2)
{
@@ -32,12 +32,18 @@ public class Commandkill extends EssentialsCommand
{
final EntityDamageEvent ede = new EntityDamageEvent(matchPlayer, sender instanceof Player && ((Player)sender).getName().equals(matchPlayer.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, Short.MAX_VALUE);
server.getPluginManager().callEvent(ede);
if (ede.isCancelled() && !sender.hasPermission("essentials.kill.force"))
if (ede.isCancelled() && sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.kill.force"))
{
continue;
}
matchPlayer.damage(Short.MAX_VALUE);
if (matchPlayer.getHealth() > 0)
{
matchPlayer.setHealth(0);
}
sender.sendMessage(_("kill", matchPlayer.getDisplayName()));
}
}

View File

@@ -2,7 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Mob;
import java.util.Collections;
import java.util.ArrayList;
import java.util.Locale;
import org.bukkit.Chunk;
import org.bukkit.Server;
@@ -10,6 +10,7 @@ import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.*;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.inventory.ItemStack;
public class Commandkillall extends EssentialsCommand
@@ -109,7 +110,7 @@ public class Commandkillall extends EssentialsCommand
continue;
}
}
if(entity instanceof Ocelot)
if (entity instanceof Ocelot)
{
if (((Ocelot)entity).isTamed())
{
@@ -120,7 +121,7 @@ public class Commandkillall extends EssentialsCommand
{
if (entity instanceof Animals || entity instanceof NPC || entity instanceof Snowman || entity instanceof WaterMob)
{
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, new ArrayList<ItemStack>(0));
ess.getServer().getPluginManager().callEvent(event);
entity.remove();
numKills++;
@@ -130,7 +131,7 @@ public class Commandkillall extends EssentialsCommand
{
if (entity instanceof Monster || entity instanceof ComplexLivingEntity || entity instanceof Flying || entity instanceof Slime)
{
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, new ArrayList<ItemStack>(0));
ess.getServer().getPluginManager().callEvent(event);
entity.remove();
numKills++;
@@ -138,14 +139,14 @@ public class Commandkillall extends EssentialsCommand
}
else if (all)
{
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, new ArrayList<ItemStack>(0));
ess.getServer().getPluginManager().callEvent(event);
entity.remove();
numKills++;
}
else if (entityClass != null && entityClass.isAssignableFrom(entity.getClass()))
{
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, new ArrayList<ItemStack>(0));
ess.getServer().getPluginManager().callEvent(event);
entity.remove();
numKills++;

View File

@@ -7,7 +7,7 @@ import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.entity.Ocelot;
// This command is not documented on the wiki #EasterEgg
public class Commandkittycannon extends EssentialsCommand
{
private static Random random = new Random();

View File

@@ -6,17 +6,19 @@ import com.earth2me.essentials.Util;
import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandmail extends EssentialsCommand
{
private static int mailsPerMinute = 0;
private static long timestamp = 0;
public Commandmail()
{
super("mail");
}
//TODO: Tidy this up
//TODO: Tidy this up / TL these errors.
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
@@ -42,24 +44,29 @@ public class Commandmail extends EssentialsCommand
throw new Exception(_("noPerm", "essentials.mail.send"));
}
Player player = server.getPlayer(args[1]);
User u;
if (player != null)
{
u = ess.getUser(player);
}
else
{
u = ess.getOfflineUser(args[1]);
}
User u = ess.getUser(args[1]);
if (u == null)
{
throw new Exception(_("playerNeverOnServer", args[1]));
}
if (!u.isIgnoredPlayer(user))
{
final String mail = Util.sanitizeString(Util.stripFormat(getFinalArg(args, 2)));
u.addMail(user.getName() + ": " + mail);
final String mail = user.getName() + ": " + Util.sanitizeString(Util.stripFormat(getFinalArg(args, 2)));
if (mail.length() > 1000)
{
throw new Exception("Mail message too long. Try to keep it below 1000");
}
if (Math.abs(System.currentTimeMillis() - timestamp) > 60000)
{
timestamp = System.currentTimeMillis();
mailsPerMinute = 0;
}
mailsPerMinute++;
if (mailsPerMinute > ess.getSettings().getMailsPerMinute())
{
throw new Exception("Too many mails have been send within the last minute. Maximum: " + ess.getSettings().getMailsPerMinute());
}
u.addMail(mail);
}
user.sendMessage(_("mailSent"));
return;
@@ -70,7 +77,7 @@ public class Commandmail extends EssentialsCommand
{
throw new Exception(_("noPerm", "essentials.mail.sendall"));
}
ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripFormat(getFinalArg(args, 1))));
ess.runTaskAsynchronously(new SendAll(user.getName() + ": " + Util.stripFormat(getFinalArg(args, 1))));
user.sendMessage(_("mailSent"));
return;
}
@@ -96,16 +103,7 @@ public class Commandmail extends EssentialsCommand
}
else if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
{
Player player = server.getPlayer(args[1]);
User u;
if (player != null)
{
u = ess.getUser(player);
}
else
{
u = ess.getOfflineUser(args[1]);
}
User u = ess.getUser(args[1]);
if (u == null)
{
throw new Exception(_("playerNeverOnServer", args[1]));
@@ -116,21 +114,14 @@ public class Commandmail extends EssentialsCommand
}
else if (args.length >= 1 && "sendall".equalsIgnoreCase(args[0]))
{
ess.scheduleAsyncDelayedTask(new SendAll("Server: " + getFinalArg(args, 2)));
ess.runTaskAsynchronously(new SendAll("Server: " + getFinalArg(args, 2)));
sender.sendMessage(_("mailSent"));
return;
}
else if (args.length >= 2)
{
//allow sending from console without "send" argument, since it's the only thing the console can do
Player player = server.getPlayer(args[0]);
User u;
if (player != null)
{
u = ess.getUser(player);
}
else
{
u = ess.getOfflineUser(args[0]);
}
User u = ess.getUser(args[0]);
if (u == null)
{
throw new Exception(_("playerNeverOnServer", args[0]));

View File

@@ -25,7 +25,7 @@ public class Commandmore extends EssentialsCommand
if (stack.getAmount() >= ((user.isAuthorized("essentials.oversizedstacks"))
? ess.getSettings().getOversizedStackSize() : stack.getMaxStackSize()))
{
throw new NoChargeException();
throw new Exception(_("fullStack"));
}
final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
if (ess.getSettings().permissionBasedItemSpawn()

View File

@@ -17,15 +17,15 @@ public class Commandmsg extends EssentialsCommand
{
super("msg");
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length < 2 || args[0].trim().length() < 2 || args[1].trim().isEmpty())
if (args.length < 2 || args[0].trim().length() < 2 || args[1].trim().isEmpty())
{
throw new NotEnoughArgumentsException();
}
String message = getFinalArg(args, 1);
if (sender instanceof Player)
{
@@ -40,12 +40,12 @@ public class Commandmsg extends EssentialsCommand
{
message = Util.replaceFormat(message);
}
final String translatedMe = _("me");
final IReplyTo replyTo = sender instanceof Player ? ess.getUser((Player)sender) : Console.getConsoleReplyTo();
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
if (args[0].equalsIgnoreCase(Console.NAME))
{
sender.sendMessage(_("msgFormat", translatedMe, Console.NAME, message));
@@ -55,14 +55,14 @@ public class Commandmsg extends EssentialsCommand
Console.getConsoleReplyTo().setReplyTo(sender);
return;
}
final List<Player> matchedPlayers = server.matchPlayer(args[0]);
if (matchedPlayers.isEmpty())
{
throw new Exception(_("playerNotFound"));
}
int i = 0;
for (Player matchedPlayer : matchedPlayers)
{
@@ -76,17 +76,28 @@ public class Commandmsg extends EssentialsCommand
{
throw new Exception(_("playerNotFound"));
}
for (Player matchedPlayer : matchedPlayers)
{
sender.sendMessage(_("msgFormat", translatedMe, matchedPlayer.getDisplayName(), message));
{
final User matchedUser = ess.getUser(matchedPlayer);
if (sender instanceof Player && (matchedUser.isIgnoredPlayer(ess.getUser(sender)) || matchedUser.isHidden()))
if (sender instanceof Player && matchedUser.isHidden())
{
continue;
}
if (matchedUser.isAfk())
{
sender.sendMessage(_("userAFK", matchedPlayer.getDisplayName()));
}
sender.sendMessage(_("msgFormat", translatedMe, matchedPlayer.getDisplayName(), message));
if (sender instanceof Player && matchedUser.isIgnoredPlayer(ess.getUser(sender)))
{
continue;
}
matchedPlayer.sendMessage(_("msgFormat", senderName, translatedMe, message));
replyTo.setReplyTo(ess.getUser(matchedPlayer));
replyTo.setReplyTo(matchedUser);
ess.getUser(matchedPlayer).setReplyTo(sender);
}
}

View File

@@ -5,6 +5,7 @@ import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandmute extends EssentialsCommand
@@ -41,17 +42,31 @@ public class Commandmute extends EssentialsCommand
}
player.setMuteTimeout(muteTimestamp);
final boolean muted = player.getMuted();
sender.sendMessage(
muted
? (muteTimestamp > 0
? _("mutedPlayerFor", player.getDisplayName(), Util.formatDateDiff(muteTimestamp))
: _("mutedPlayer", player.getDisplayName()))
: _("unmutedPlayer", player.getDisplayName()));
player.sendMessage(
muted
? (muteTimestamp > 0
? _("playerMutedFor", Util.formatDateDiff(muteTimestamp))
: _("playerMuted"))
: _("playerUnmuted"));
if (muted)
{
if (muteTimestamp > 0)
{
sender.sendMessage(_("mutedPlayerFor", player.getDisplayName(), Util.formatDateDiff(muteTimestamp)));
player.sendMessage(_("playerMutedFor", Util.formatDateDiff(muteTimestamp)));
}
else
{
sender.sendMessage(_("mutedPlayer", player.getDisplayName()));
player.sendMessage(_("playerMuted"));
}
for (Player onlinePlayer : server.getOnlinePlayers())
{
final User user = ess.getUser(onlinePlayer);
if (onlinePlayer != sender && user.isAuthorized("essentials.mute.notify"))
{
onlinePlayer.sendMessage(_("muteNotify", sender.getName(), player.getName()));
}
}
}
else
{
sender.sendMessage(_("unmutedPlayer", player.getDisplayName()));
player.sendMessage(_("playerUnmuted"));
}
}
}
}

View File

@@ -22,7 +22,7 @@ public class Commandpay extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
//TODO: TL this
//TODO: TL this.
if (args[0].trim().length() < 2)
{
throw new NotEnoughArgumentsException("You need to specify a player to pay.");

View File

@@ -5,7 +5,7 @@ import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
// This command can be used to echo messages to the users screen, mostly useless but also an #EasterEgg
public class Commandping extends EssentialsCommand
{
public Commandping()

View File

@@ -0,0 +1,196 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.FurnaceRecipe;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe;
public class Commandrecipe extends EssentialsCommand
{
public Commandrecipe()
{
super("recipe");
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
final ItemStack itemType = ess.getItemDb().get(args[0]);
int recipeNo = 0;
if (args.length > 1)
{
if (Util.isInt(args[1]))
{
recipeNo = Integer.parseInt(args[1]) - 1;
}
else
{
throw new Exception(_("invalidNumber"));
}
}
final List<Recipe> recipesOfType = ess.getServer().getRecipesFor(itemType);
if (recipesOfType.size() < 1)
{
throw new Exception(_("recipeNone", getMaterialName(itemType)));
}
if (recipeNo < 0 || recipeNo >= recipesOfType.size())
{
throw new Exception(_("recipeBadIndex"));
}
final Recipe selectedRecipe = recipesOfType.get(recipeNo);
sender.sendMessage(_("recipe", getMaterialName(itemType), recipeNo + 1, recipesOfType.size()));
if (selectedRecipe instanceof FurnaceRecipe)
{
furnaceRecipe(sender, (FurnaceRecipe)selectedRecipe);
}
else if (selectedRecipe instanceof ShapedRecipe)
{
shapedRecipe(sender, (ShapedRecipe)selectedRecipe);
}
else if (selectedRecipe instanceof ShapelessRecipe)
{
shapelessRecipe(sender, (ShapelessRecipe)selectedRecipe);
}
if (recipesOfType.size() > 1 && args.length == 1)
{
sender.sendMessage(_("recipeMore", commandLabel, args[0], getMaterialName(itemType)));
}
}
public void furnaceRecipe(final CommandSender sender, final FurnaceRecipe recipe)
{
sender.sendMessage(_("recipeFurnace", getMaterialName(recipe.getInput())));
}
public void shapedRecipe(final CommandSender sender, final ShapedRecipe recipe)
{
final Map<Character, ItemStack> recipeMap = recipe.getIngredientMap();
if (sender instanceof Player)
{
final User user = ess.getUser(sender);
user.setRecipeSee(true);
final InventoryView view = user.openWorkbench(null, true);
final String[] recipeShape = recipe.getShape();
final Map<Character, ItemStack> ingredientMap = recipe.getIngredientMap();
for (int j = 0; j < recipeShape.length; j++)
{
for (int k = 0; k < recipeShape[j].length(); k++)
{
final ItemStack item = ingredientMap.get(recipeShape[j].toCharArray()[k]);
if(item == null)
{
continue;
}
item.setAmount(0);
view.getTopInventory().setItem(j * 3 + k + 1, item);
}
}
}
else
{
final HashMap<Material, String> colorMap = new HashMap<Material, String>();
int i = 1;
for (Character c : "abcdefghi".toCharArray())
{
ItemStack item = recipeMap.get(c);
if (!colorMap.containsKey(item == null ? null : item.getType()))
{
colorMap.put(item == null ? null : item.getType(), String.valueOf(i++));
}
}
final Material[][] materials = new Material[3][3];
for (int j = 0; j < recipe.getShape().length; j++)
{
for (int k = 0; k < recipe.getShape()[j].length(); k++)
{
ItemStack item = recipe.getIngredientMap().get(recipe.getShape()[j].toCharArray()[k]);
materials[j][k] = item == null ? null : item.getType();
}
}
sender.sendMessage(_("recipeGrid", colorMap.get(materials[0][0]), colorMap.get(materials[0][1]), colorMap.get(materials[0][2])));
sender.sendMessage(_("recipeGrid", colorMap.get(materials[1][0]), colorMap.get(materials[1][1]), colorMap.get(materials[1][2])));
sender.sendMessage(_("recipeGrid", colorMap.get(materials[2][0]), colorMap.get(materials[2][1]), colorMap.get(materials[2][2])));
StringBuilder s = new StringBuilder();
for (Material items : colorMap.keySet().toArray(new Material[colorMap.size()]))
{
s.append(_("recipeGridItem", colorMap.get(items), getMaterialName(items)));
}
sender.sendMessage(_("recipeWhere", s.toString()));
}
}
public void shapelessRecipe(final CommandSender sender, final ShapelessRecipe recipe)
{
final List<ItemStack> ingredients = recipe.getIngredientList();
if (sender instanceof Player)
{
final User user = ess.getUser(sender);
user.setRecipeSee(true);
final InventoryView view = user.openWorkbench(null, true);
for (int i = 0; i < ingredients.size(); i++)
{
view.setItem(i + 1, ingredients.get(i));
}
}
else
{
StringBuilder s = new StringBuilder();
for (int i = 0; i < ingredients.size(); i++)
{
s.append(getMaterialName(ingredients.get(i)));
if (i != ingredients.size() - 1)
{
s.append(",");
}
s.append(" ");
}
sender.sendMessage(_("recipeShapeless", s.toString()));
}
}
public String getMaterialName(final ItemStack stack)
{
if (stack == null)
{
return _("recipeNothing");
}
return getMaterialName(stack.getType());
}
public String getMaterialName(final Material type)
{
if (type == null)
{
return _("recipeNothing");
}
return type.toString().replace("_", " ").toLowerCase(Locale.ENGLISH);
}
}

View File

@@ -35,12 +35,28 @@ public class Commandseen extends EssentialsCommand
}
try
{
User player = getPlayer(server, args, 0);
player.setDisplayNick();
sender.sendMessage(_("seenOnline", player.getDisplayName(), Util.formatDateDiff(player.getLastLogin())));
User user = getPlayer(server, args, 0);
user.setDisplayNick();
sender.sendMessage(_("seenOnline", user.getDisplayName(), Util.formatDateDiff(user.getLastLogin())));
if (user.isAfk())
{
sender.sendMessage(_("whoisAFK", _("true")));
}
if (user.isJailed())
{
sender.sendMessage(_("whoisJail", (user.getJailTimeout() > 0
? Util.formatDateDiff(user.getJailTimeout())
: _("true"))));
}
if (user.isMuted())
{
sender.sendMessage(_("whoisMuted", (user.getMuteTimeout() > 0
? Util.formatDateDiff(user.getMuteTimeout())
: _("true"))));
}
if (extra)
{
sender.sendMessage(_("whoisIPAddress", player.getAddress().getAddress().toString()));
sender.sendMessage(_("whoisIPAddress", user.getAddress().getAddress().toString()));
}
}
catch (NoSuchFieldException e)
@@ -59,8 +75,9 @@ public class Commandseen extends EssentialsCommand
if (extra)
{
sender.sendMessage(_("whoisIPAddress", player.getLastLoginAddress()));
final Location loc = player.getLastLocation();
if (loc != null) {
final Location loc = player.getLogoutLocation();
if (loc != null)
{
sender.sendMessage(_("whoisLocation", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
}
}

View File

@@ -4,7 +4,6 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import java.util.Locale;
import java.util.logging.Level;
import org.bukkit.Material;
@@ -22,6 +21,8 @@ public class Commandsell extends EssentialsCommand
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
double totalWorth = 0.0;
String type = "";
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
@@ -41,12 +42,16 @@ public class Commandsell extends EssentialsCommand
}
try
{
sellItem(user, stack, args, true);
totalWorth += sellItem(user, stack, args, true);
}
catch (Exception e)
{
}
}
if (totalWorth > 0)
{
user.sendMessage(_("totalWorthAll", type, Util.displayCurrency(totalWorth, ess)));
}
return;
}
else if (args[0].equalsIgnoreCase("blocks"))
@@ -59,12 +64,16 @@ public class Commandsell extends EssentialsCommand
}
try
{
sellItem(user, stack, args, true);
totalWorth += sellItem(user, stack, args, true);
}
catch (Exception e)
{
}
}
if (totalWorth > 0)
{
user.sendMessage(_("totalWorthBlocks", type, Util.displayCurrency(totalWorth, ess)));
}
return;
}
if (is == null)
@@ -74,7 +83,7 @@ public class Commandsell extends EssentialsCommand
sellItem(user, is, args, false);
}
private void sellItem(User user, ItemStack is, String[] args, boolean isBulkSell) throws Exception
private double sellItem(User user, ItemStack is, String[] args, boolean isBulkSell) throws Exception
{
if (is == null || is.getType() == Material.AIR)
{
@@ -107,19 +116,7 @@ public class Commandsell extends EssentialsCommand
int max = 0;
for (ItemStack s : user.getInventory().getContents())
{
if (s == null)
{
continue;
}
if (s.getTypeId() != is.getTypeId())
{
continue;
}
if (s.getDurability() != is.getDurability())
{
continue;
}
if (!s.getEnchantments().equals(is.getEnchantments()))
if (s == null || !s.isSimilar(is))
{
continue;
}
@@ -149,19 +146,23 @@ public class Commandsell extends EssentialsCommand
}
else
{
return;
return worth * amount;
}
}
//TODO: Prices for Enchantments
final ItemStack ris = is.clone();
ris.setAmount(amount);
InventoryWorkaround.removeItem(user.getInventory(), true, true, ris);
if (!user.getInventory().containsAtLeast(ris, amount)) {
// This should never happen.
throw new IllegalStateException("Trying to remove more items than are available.");
}
user.getInventory().removeItem(ris);
user.updateInventory();
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess);
user.giveMoney(worth * amount);
user.sendMessage(_("itemSold", Util.displayCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth, ess)));
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth * amount, ess), amount, Util.displayCurrency(worth, ess)));
return worth * amount;
}
}

View File

@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale;
import org.bukkit.Location;
import org.bukkit.Server;
@@ -38,14 +39,10 @@ public class Commandsethome extends EssentialsCommand
{
if (user.isAuthorized("essentials.sethome.others"))
{
usersHome = ess.getUser(ess.getServer().getPlayer(args[0]));
usersHome = ess.getUser(args[0]);
if (usersHome == null)
{
usersHome = ess.getOfflineUser(args[0]);
}
if (usersHome == null)
{
throw new Exception(_("playerNotFound"));
throw new NoSuchFieldException(_("playerNotFound"));
}
name = args[1].toLowerCase(Locale.ENGLISH);
}
@@ -55,9 +52,9 @@ public class Commandsethome extends EssentialsCommand
{
name = "home";
}
if ("bed".equals(name))
if ("bed".equals(name) || Util.isInt(name))
{
throw new NotEnoughArgumentsException();
throw new NoSuchFieldException(_("invalidHomeName"));
}
usersHome.setHome(name, location);
user.sendMessage(_("homeSet", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));

View File

@@ -22,9 +22,10 @@ public class Commandsetwarp extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
if (args[0].matches("[0-9]+")) {
throw new NotEnoughArgumentsException();
if (Util.isInt(args[0]))
{
throw new NoSuchFieldException(_("invalidWarpName"));
}
final Location loc = user.getLocation();
@@ -39,7 +40,7 @@ public class Commandsetwarp extends EssentialsCommand
{
}
if (warpLoc == null || user.isAuthorized("essentials.warp.overwrite." + Util.sanitizeFileName(args[0])))
if (warpLoc == null || user.isAuthorized("essentials.warp.overwrite." + Util.safeString(args[0])))
{
warps.setWarp(args[0], loc);
}

View File

@@ -34,6 +34,7 @@ public class Commandspawner extends EssentialsCommand
}
String name = args[0];
int delay = 0;
Mob mob = null;
mob = Mob.fromName(name);
@@ -49,11 +50,20 @@ public class Commandspawner extends EssentialsCommand
{
throw new Exception(_("noPermToSpawnMob"));
}
if (args.length > 1)
{
if (Util.isInt(args[1]))
{
delay = Integer.parseInt(args[1]);
}
}
final Trade charge = new Trade("spawner-" + mob.name.toLowerCase(Locale.ENGLISH), ess);
charge.isAffordableFor(user);
try
{
((CreatureSpawner)target.getBlock().getState()).setSpawnedType(mob.getType());
CreatureSpawner spawner = (CreatureSpawner)target.getBlock().getState();
spawner.setSpawnedType(mob.getType());
spawner.setDelay(delay);
}
catch (Throwable ex)
{

View File

@@ -2,20 +2,11 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Mob;
import com.earth2me.essentials.Mob.MobException;
import com.earth2me.essentials.SpawnMob;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.HashSet;
import java.util.Locale;
import java.util.Random;
import java.util.Set;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.entity.Villager.Profession;
import org.bukkit.entity.*;
import org.bukkit.material.Colorable;
import org.bukkit.command.CommandSender;
public class Commandspawnmob extends EssentialsCommand
@@ -30,256 +21,41 @@ public class Commandspawnmob extends EssentialsCommand
{
if (args.length < 1)
{
final Set<String> mobList = Mob.getMobList();
final Set<String> availableList = new HashSet<String>();
for (String mob : mobList)
{
if (user.isAuthorized("essentials.spawnmob." + mob.toLowerCase()))
{
availableList.add(mob);
}
}
if (availableList.isEmpty())
{
availableList.add(_("none"));
}
throw new NotEnoughArgumentsException(_("mobsAvailable", Util.joinList(availableList)));
final String mobList = SpawnMob.mobList(user);
throw new NotEnoughArgumentsException(_("mobsAvailable", mobList));
}
String[] mobData = SpawnMob.mobData(args[0]);
final String[] mountparts = args[0].split(",");
String[] parts = mountparts[0].split(":");
String mobType = parts[0];
String mobData = null;
if (parts.length == 2)
{
mobData = parts[1];
}
String mountType = null;
String mountData = null;
if (mountparts.length > 1)
{
parts = mountparts[1].split(":");
mountType = parts[0];
if (parts.length == 2)
{
mountData = parts[1];
}
}
Entity spawnedMob = null;
Mob mob = null;
Entity spawnedMount = null;
Mob mobMount = null;
mob = Mob.fromName(mobType);
if (mob == null)
{
throw new Exception(_("invalidMob"));
}
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
{
throw new Exception(_("disabledToSpawnMob"));
}
if (!user.isAuthorized("essentials.spawnmob." + mob.name.toLowerCase()))
{
throw new Exception(_("noPermToSpawnMob"));
}
final Block block = Util.getTarget(user).getBlock();
if (block == null)
{
throw new Exception(_("unableToSpawnMob"));
}
User otherUser = null;
if (args.length >= 3)
{
otherUser = getPlayer(ess.getServer(), args, 2);
}
final Location loc = (otherUser == null) ? block.getLocation() : otherUser.getLocation();
final Location sloc = Util.getSafeDestination(loc);
try
{
spawnedMob = mob.spawn(user, server, sloc);
}
catch (MobException e)
{
throw new Exception(_("unableToSpawnMob"), e);
}
if (mountType != null)
{
mobMount = Mob.fromName(mountType);
if (mobMount == null)
{
user.sendMessage(_("invalidMob"));
return;
}
if (ess.getSettings().getProtectPreventSpawn(mobMount.getType().toString().toLowerCase(Locale.ENGLISH)))
{
throw new Exception(_("disabledToSpawnMob"));
}
if (!user.isAuthorized("essentials.spawnmob." + mobMount.name.toLowerCase()))
{
throw new Exception(_("noPermToSpawnMob"));
}
try
{
spawnedMount = mobMount.spawn(user, server, loc);
}
catch (MobException e)
{
throw new Exception(_("unableToSpawnMob"), e);
}
spawnedMob.setPassenger(spawnedMount);
}
if (mobData != null)
{
changeMobData(mob.getType(), spawnedMob, mobData, user);
}
if (spawnedMount != null && mountData != null)
{
changeMobData(mobMount.getType(), spawnedMount, mountData, user);
}
int mobCount = 1;
if (args.length >= 2)
{
int mobCount = Integer.parseInt(args[1]);
int serverLimit = ess.getSettings().getSpawnMobLimit();
if (mobCount > serverLimit)
{
mobCount = serverLimit;
user.sendMessage(_("mobSpawnLimit"));
}
try
{
for (int i = 1; i < mobCount; i++)
{
spawnedMob = mob.spawn(user, server, loc);
if (mobMount != null)
{
try
{
spawnedMount = mobMount.spawn(user, server, loc);
}
catch (MobException e)
{
throw new Exception(_("unableToSpawnMob"), e);
}
spawnedMob.setPassenger(spawnedMount);
}
if (mobData != null)
{
changeMobData(mob.getType(), spawnedMob, mobData, user);
}
if (spawnedMount != null && mountData != null)
{
changeMobData(mobMount.getType(), spawnedMount, mountData, user);
}
}
user.sendMessage(mobCount + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned"));
}
catch (MobException e1)
{
throw new Exception(_("unableToSpawnMob"), e1);
}
catch (NumberFormatException e2)
{
throw new Exception(_("numberRequired"), e2);
}
catch (NullPointerException np)
{
throw new Exception(_("soloMob"), np);
}
mobCount = Integer.parseInt(args[1]);
}
else
{
user.sendMessage(mob.name + " " + _("spawned"));
}
}
private void changeMobData(final EntityType type, final Entity spawned, String data, final User user) throws Exception
{
data = data.toLowerCase(Locale.ENGLISH);
if (spawned instanceof Slime)
if (args.length >= 3)
{
try
{
((Slime)spawned).setSize(Integer.parseInt(data));
}
catch (Exception e)
{
throw new Exception(_("slimeMalformedSize"), e);
}
}
if (spawned instanceof Ageable && data.contains("baby"))
{
((Ageable)spawned).setBaby();
final User target = getPlayer(ess.getServer(), args, 2);
SpawnMob.spawnmob(ess, server, user, target, mobData, mobCount);
return;
}
if (spawned instanceof Colorable)
SpawnMob.spawnmob(ess, server, user, mobData, mobCount);
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 3)
{
final String color = data.toUpperCase(Locale.ENGLISH).replace("BABY", "");
try
{
if (color.equals("RANDOM"))
{
final Random rand = new Random();
((Colorable)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
}
else
{
((Colorable)spawned).setColor(DyeColor.valueOf(color));
}
}
catch (Exception e)
{
throw new Exception(_("sheepMalformedColor"), e);
}
}
if (spawned instanceof Tameable && data.contains("tamed"))
{
final Tameable tameable = ((Tameable)spawned);
tameable.setTamed(true);
tameable.setOwner(user.getBase());
}
if (type == EntityType.WOLF
&& data.contains("angry"))
{
((Wolf)spawned).setAngry(true);
}
if (type == EntityType.CREEPER && data.contains("powered"))
{
((Creeper)spawned).setPowered(true);
}
if (type == EntityType.OCELOT)
{
if (data.contains("siamese"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.SIAMESE_CAT);
}
else if (data.contains("red"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.RED_CAT);
}
else if (data.contains("black"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.BLACK_CAT);
}
}
if (type == EntityType.VILLAGER)
{
for (Profession prof : Villager.Profession.values())
{
if (data.contains(prof.toString().toLowerCase(Locale.ENGLISH)))
{
((Villager)spawned).setProfession(prof);
}
}
final String mobList = Util.joinList(Mob.getMobList());
throw new NotEnoughArgumentsException(_("mobsAvailable", mobList));
}
String[] mobData = SpawnMob.mobData(args[0]);
int mobCount = Integer.parseInt(args[1]);
final User target = getPlayer(ess.getServer(), args, 2);
SpawnMob.spawnmob(ess, server, sender, target, mobData, mobCount);
}
}

View File

@@ -7,6 +7,7 @@ import java.util.logging.Logger;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
public class Commandsudo extends EssentialsCommand
@@ -26,6 +27,15 @@ public class Commandsudo extends EssentialsCommand
}
final User user = getPlayer(server, args, 0, false);
if(args[1].toLowerCase().startsWith("c:"))
{
if (user.isAuthorized("essentials.sudo.exempt") && sender instanceof Player)
{
throw new Exception(_("sudoExempt"));
}
user.chat(getFinalArg(args, 1).substring(2));
return;
}
final String command = args[1];
final String[] arguments = new String[args.length - 2];
if (arguments.length > 0)
@@ -33,7 +43,7 @@ public class Commandsudo extends EssentialsCommand
System.arraycopy(args, 2, arguments, 0, args.length - 2);
}
if (user.isAuthorized("essentials.sudo.exempt"))
if (user.isAuthorized("essentials.sudo.exempt") && sender instanceof Player)
{
throw new Exception(_("sudoExempt"));
}

View File

@@ -4,6 +4,7 @@ import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.GregorianCalendar;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -35,7 +36,7 @@ public class Commandtempban extends EssentialsCommand
}
else
{
if (user.isAuthorized("essentials.tempban.exempt"))
if (user.isAuthorized("essentials.tempban.exempt") && sender instanceof Player)
{
sender.sendMessage(_("tempbanExempt"));
return;
@@ -44,6 +45,13 @@ public class Commandtempban extends EssentialsCommand
final String time = getFinalArg(args, 1);
final long banTimestamp = Util.parseDateDiff(time, true);
final long maxBanLength = ess.getSettings().getMaxTempban() * 1000;
if (maxBanLength > 0 && ((banTimestamp - GregorianCalendar.getInstance().getTimeInMillis()) > maxBanLength) && !(ess.getUser(sender).isAuthorized("essentials.tempban.unlimited")))
{
sender.sendMessage(_("oversizedTempban"));
throw new NoChargeException();
}
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
final String banReason = _("tempBanned", Util.formatDateDiff(banTimestamp), senderName);
user.setBanReason(banReason);

View File

@@ -20,7 +20,9 @@ public class Commandtop extends EssentialsCommand
{
final int topX = user.getLocation().getBlockX();
final int topZ = user.getLocation().getBlockZ();
final Location location = new Location(user.getWorld(), topX, user.getWorld().getMaxHeight(), topZ);
final float pitch = user.getLocation().getPitch();
final float yaw = user.getLocation().getYaw();
final Location location = new Location(user.getWorld(), topX, user.getWorld().getMaxHeight(), topZ, yaw, pitch);
user.getTeleport().teleport(location, new Trade(this.getName(), ess), TeleportCause.COMMAND);
user.sendMessage(_("teleportTop"));
}

View File

@@ -4,6 +4,7 @@ import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@@ -40,13 +41,34 @@ public class Commandtp extends EssentialsCommand
charge.isAffordableFor(user);
user.getTeleport().teleport(player, charge, TeleportCause.COMMAND);
throw new NoChargeException();
case 4:
if (!user.isAuthorized("essentials.tp.others"))
{
throw new Exception(_("noPerm", "essentials.tp.others"));
}
final User target2 = getPlayer(server, args, 0);
final double x = args[1].startsWith("~") ? target2.getLocation().getX() + Integer.parseInt(args[1].substring(1)) : Integer.parseInt(args[1]);
final double y = args[2].startsWith("~") ? target2.getLocation().getY() + Integer.parseInt(args[2].substring(1)) : Integer.parseInt(args[2]);
final double z = args[3].startsWith("~") ? target2.getLocation().getZ() + Integer.parseInt(args[3].substring(1)) : Integer.parseInt(args[3]);
if (x > 30000000 || y > 30000000 || z > 30000000 || x < -30000000 || y < -30000000 || z < -30000000)
{
throw new NotEnoughArgumentsException("Value of coordinates cannot be over 30000000"); //TODO: I18n
}
final Location location = new Location(target2.getWorld(), x, y, z);
if (!target2.isTeleportEnabled())
{
throw new Exception(_("teleportDisabled", target2.getDisplayName()));
}
target2.getTeleport().now(location, false, TeleportCause.COMMAND);
user.sendMessage(_("teleporting"));
target2.sendMessage(_("teleporting"));
break;
case 2:
default:
if (!user.isAuthorized("essentials.tp.others"))
{
throw new Exception(_("noPerm", "essentials.tp.others"));
}
user.sendMessage(_("teleporting"));
final User target = getPlayer(server, args, 0);
final User toPlayer = getPlayer(server, args, 1);
if (!target.isTeleportEnabled())
@@ -63,6 +85,7 @@ public class Commandtp extends EssentialsCommand
throw new Exception(_("noPerm", "essentials.worlds." + toPlayer.getWorld().getName()));
}
target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND);
user.sendMessage(_("teleporting"));
target.sendMessage(_("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
break;
}
@@ -76,10 +99,28 @@ public class Commandtp extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
sender.sendMessage(_("teleporting"));
final User target = getPlayer(server, args, 0);
final User toPlayer = getPlayer(server, args, 1);
target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND);
target.sendMessage(_("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
if (args.length == 2)
{
final User toPlayer = getPlayer(server, args, 1);
target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND);
target.sendMessage(_("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
}
else if (args.length > 3)
{
final double x = args[1].startsWith("~") ? target.getLocation().getX() + Integer.parseInt(args[1].substring(1)) : Integer.parseInt(args[1]);
final double y = args[2].startsWith("~") ? target.getLocation().getY() + Integer.parseInt(args[2].substring(1)) : Integer.parseInt(args[2]);
final double z = args[3].startsWith("~") ? target.getLocation().getZ() + Integer.parseInt(args[3].substring(1)) : Integer.parseInt(args[3]);
if (x > 30000000 || y > 30000000 || z > 30000000 || x < -30000000 || y < -30000000 || z < -30000000)
{
throw new NotEnoughArgumentsException("Value of coordinates cannot be over 30000000"); //TODO: I18n
}
final Location location = new Location(target.getWorld(), x, y, z);
target.getTeleport().now(location, false, TeleportCause.COMMAND);
target.sendMessage(_("teleporting"));
} else {
throw new NotEnoughArgumentsException();
}
sender.sendMessage(_("teleporting"));
}
}

View File

@@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.ChargeException;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
@@ -52,24 +53,24 @@ public class Commandtpaccept extends EssentialsCommand
}
final Trade charge = new Trade(this.getName(), ess);
if (user.isTpRequestHere())
{
charge.isAffordableFor(user);
}
else
{
charge.isAffordableFor(target);
}
user.sendMessage(_("requestAccepted"));
target.sendMessage(_("requestAcceptedFrom", user.getDisplayName()));
if (user.isTpRequestHere())
try
{
user.getTeleport().teleport(target, charge, TeleportCause.COMMAND);
if (user.isTpRequestHere())
{
target.getTeleport().teleportToMe(user, charge, TeleportCause.COMMAND);
}
else
{
target.getTeleport().teleport(user, charge, TeleportCause.COMMAND);
}
}
else
catch (ChargeException ex)
{
target.getTeleport().teleport(user, charge, TeleportCause.COMMAND);
user.sendMessage(_("pendingTeleportCancelled"));
ess.showError(target, ex, commandLabel);
}
user.requestTeleport(null, false);
throw new NoChargeException();

View File

@@ -33,6 +33,7 @@ public class Commandtpahere extends EssentialsCommand
player.requestTeleport(user, true);
player.sendMessage(_("teleportHereRequest", user.getDisplayName()));
player.sendMessage(_("typeTpaccept"));
player.sendMessage(_("typeTpdeny"));
if (ess.getSettings().getTpaAcceptCancellation() != 0)
{
player.sendMessage(_("teleportRequestTimeoutInfo", ess.getSettings().getTpaAcceptCancellation()));

View File

@@ -27,7 +27,7 @@ public class Commandtphere extends EssentialsCommand
{
throw new Exception(_("noPerm", "essentials.worlds." + user.getWorld().getName()));
}
player.getTeleport().teleport(user, new Trade(this.getName(), ess), TeleportCause.COMMAND);
user.getTeleport().teleportToMe(player, new Trade(this.getName(), ess), TeleportCause.COMMAND);
user.sendMessage(_("teleporting"));
player.sendMessage(_("teleporting"));
throw new NoChargeException();

View File

@@ -24,9 +24,9 @@ public class Commandtppos extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final int x = Integer.parseInt(args[0]);
final int y = Integer.parseInt(args[1]);
final int z = Integer.parseInt(args[2]);
final double x = args[0].startsWith("~") ? user.getLocation().getX() + Integer.parseInt(args[0].substring(1)) : Integer.parseInt(args[0]);
final double y = args[1].startsWith("~") ? user.getLocation().getY() + Integer.parseInt(args[1].substring(1)) : Integer.parseInt(args[1]);
final double z = args[2].startsWith("~") ? user.getLocation().getZ() + Integer.parseInt(args[2].substring(1)) : Integer.parseInt(args[2]);
final Location location = new Location(user.getWorld(), x, y, z);
if (args.length > 3)
{
@@ -36,6 +36,10 @@ public class Commandtppos extends EssentialsCommand
{
location.setPitch(Float.parseFloat(args[4]));
}
if (x > 30000000 || y > 30000000 || z > 30000000 || x < -30000000 || y < -30000000 || z < -30000000)
{
throw new NotEnoughArgumentsException("Value of coordinates cannot be over 30000000"); //TODO: I18n
}
final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
user.sendMessage(_("teleporting"));
@@ -52,9 +56,9 @@ public class Commandtppos extends EssentialsCommand
}
User user = ess.getUser(server.getPlayer(args[0]));
final int x = Integer.parseInt(args[1]);
final int y = Integer.parseInt(args[2]);
final int z = Integer.parseInt(args[3]);
final double x = args[1].startsWith("~") ? user.getLocation().getX() + Integer.parseInt(args[1].substring(1)) : Integer.parseInt(args[1]);
final double y = args[2].startsWith("~") ? user.getLocation().getY() + Integer.parseInt(args[2].substring(1)) : Integer.parseInt(args[2]);
final double z = args[3].startsWith("~") ? user.getLocation().getZ() + Integer.parseInt(args[3].substring(1)) : Integer.parseInt(args[3]);
final Location location = new Location(user.getWorld(), x, y, z);
if (args.length > 4)
{
@@ -64,8 +68,13 @@ public class Commandtppos extends EssentialsCommand
{
location.setPitch(Float.parseFloat(args[5]));
}
if (x > 30000000 || y > 30000000 || z > 30000000 || x < -30000000 || y < -30000000 || z < -30000000)
{
throw new NotEnoughArgumentsException("Value of coordinates cannot be over 30000000"); //TODO: I18n
}
sender.sendMessage(_("teleporting"));
user.sendMessage(_("teleporting"));
user.getTeleport().teleport(location, null, TeleportCause.COMMAND);
}
}

View File

@@ -3,6 +3,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandtptoggle extends EssentialsCommand
@@ -12,11 +14,60 @@ public class Commandtptoggle extends EssentialsCommand
super("tptoggle");
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
toggleOtherPlayers(server, sender, args);
}
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
user.sendMessage(user.toggleTeleportEnabled()
? _("teleportationEnabled")
: _("teleportationDisabled"));
if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.tptoggle.others"))
{
toggleOtherPlayers(server, user, args);
return;
}
user.sendMessage(user.toggleTeleportEnabled() ? _("teleportationEnabled") : _("teleportationDisabled"));
}
private void toggleOtherPlayers(final Server server, final CommandSender sender, final String[] args)
{
for (Player matchPlayer : server.matchPlayer(args[0]))
{
final User player = ess.getUser(matchPlayer);
if (player.isHidden())
{
continue;
}
if (args.length > 1)
{
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
{
player.setTeleportEnabled(true);
}
else
{
player.setTeleportEnabled(false);
}
}
else
{
player.toggleTeleportEnabled();
}
final boolean enabled = player.isTeleportEnabled();
player.sendMessage(enabled ? _("teleportationEnabled") : _("teleportationDisabled"));
sender.sendMessage(enabled ? _("teleportationEnabledFor", matchPlayer.getDisplayName()) : _("teleportationDisabledFor", matchPlayer.getDisplayName()));
}
}
}

View File

@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -23,12 +24,21 @@ public class Commandunban extends EssentialsCommand
try
{
final User player = getPlayer(server, args, 0, true);
player.setBanned(false);
final User user = getPlayer(server, args, 0, true);
user.setBanned(false);
user.setBanTimeout(0);
sender.sendMessage(_("unbannedPlayer"));
}
catch (NoSuchFieldException e)
{
final OfflinePlayer player = server.getOfflinePlayer(args[0]);
if (player.isBanned())
{
player.setBanned(false);
sender.sendMessage(_("unbannedPlayer"));
return;
}
throw new Exception(_("playerNotFound"), e);
}
}

View File

@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import java.util.List;
import java.util.Locale;
import org.bukkit.Material;
@@ -103,7 +102,7 @@ public class Commandunlimited extends EssentialsCommand
{
message = "enableUnlimited";
enableUnlimited = true;
if (!InventoryWorkaround.containsItem(target.getInventory(), true, true, stack))
if (!target.getInventory().containsAtLeast(stack, stack.getAmount()))
{
target.getInventory().addItem(stack);
}

View File

@@ -37,8 +37,9 @@ public class Commandwarp extends EssentialsCommand
}
if (args.length > 0)
{
//TODO: Remove 'otherplayers' permission.
User otherUser = null;
if (args.length == 2 && user.isAuthorized("essentials.warp.otherplayers"))
if (args.length == 2 && (user.isAuthorized("essentials.warp.otherplayers") || user.isAuthorized("essentials.warp.others")))
{
otherUser = ess.getUser(server.getPlayer(args[1]));
if (otherUser == null)

View File

@@ -56,14 +56,14 @@ public abstract class EssentialsCommand implements IEssentialsCommand
}
if (args[pos].isEmpty())
{
throw new NoSuchFieldException(_("playerNotFound"));
throw new PlayerNotFoundException();
}
final User user = ess.getUser(args[pos]);
if (user != null)
{
if (!getOffline && (!user.isOnline() || user.isHidden()))
{
throw new NoSuchFieldException(_("playerNotFound"));
throw new PlayerNotFoundException();
}
return user;
}
@@ -85,7 +85,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand
return userMatch;
}
}
throw new NoSuchFieldException(_("playerNotFound"));
throw new PlayerNotFoundException();
}
@Override

View File

@@ -0,0 +1,11 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
public class PlayerNotFoundException extends NoSuchFieldException
{
public PlayerNotFoundException()
{
super(_("playerNotFound"));
}
}

View File

@@ -1,243 +0,0 @@
package com.earth2me.essentials.craftbukkit;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import org.bukkit.Material;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
public class FakeInventory implements Inventory
{
ItemStack[] items;
public FakeInventory(ItemStack[] items)
{
this.items = new ItemStack[items.length];
for (int i = 0; i < items.length; i++)
{
if (items[i] == null)
{
continue;
}
this.items[i] = items[i].clone();
}
}
@Override
public int getSize()
{
return items.length;
}
@Override
public String getName()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ItemStack getItem(int i)
{
return items[i];
}
@Override
public void setItem(int i, ItemStack is)
{
items[i] = is;
}
@Override
public HashMap<Integer, ItemStack> addItem(ItemStack... iss)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public HashMap<Integer, ItemStack> removeItem(ItemStack... iss)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ItemStack[] getContents()
{
return items;
}
@Override
public void setContents(ItemStack[] iss)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(Material mtrl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(ItemStack is)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(int i, int i1)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(Material mtrl, int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(ItemStack is, int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public HashMap<Integer, ? extends ItemStack> all(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public HashMap<Integer, ? extends ItemStack> all(Material mtrl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public HashMap<Integer, ? extends ItemStack> all(ItemStack is)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int first(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int first(Material mtrl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int first(ItemStack is)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int firstEmpty()
{
for (int i = 0; i < items.length; i++)
{
if (items[i] == null || items[i].getTypeId() == 0) {
return i;
}
}
return -1;
}
@Override
public void remove(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void remove(Material mtrl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void remove(ItemStack is)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void clear(int i)
{
items[i] = null;
}
@Override
public void clear()
{
for (int i = 0; i < items.length; i++)
{
items[i] = null;
}
}
@Override
public List<HumanEntity> getViewers()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getTitle()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public InventoryType getType()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public InventoryHolder getHolder()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ListIterator<ItemStack> iterator()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getMaxStackSize()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setMaxStackSize(int size)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ListIterator<ItemStack> iterator(int index)
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -699,4 +699,46 @@ public class FakeWorld implements World
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getAmbientSpawnLimit()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setAmbientSpawnLimit(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String[] getGameRules()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getGameRuleValue(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean setGameRuleValue(String string, String string1)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isGameRule(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean createExplosion(double d, double d1, double d2, float f, boolean bln, boolean bln1)
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -2,6 +2,7 @@ package com.earth2me.essentials.craftbukkit;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@@ -15,49 +16,17 @@ public final class InventoryWorkaround
{
}
public static int first(final Inventory inventory, final ItemStack item, final boolean enforceDurability, final boolean enforceAmount, final boolean enforceEnchantments)
{
return next(inventory, item, 0, enforceDurability, enforceAmount, enforceEnchantments);
}
public static int next(final Inventory cinventory, final ItemStack item, final int start, final boolean enforceDurability, final boolean enforceAmount, final boolean enforceEnchantments)
{
final ItemStack[] inventory = cinventory.getContents();
for (int i = start; i < inventory.length; i++)
{
final ItemStack cItem = inventory[i];
if (cItem == null)
{
continue;
}
if (item.getTypeId() == cItem.getTypeId() && (!enforceAmount || item.getAmount() == cItem.getAmount()) && (!enforceDurability || cItem.getDurability() == item.getDurability()) && (!enforceEnchantments || cItem.getEnchantments().equals(item.getEnchantments())))
{
return i;
}
}
return -1;
}
public static int firstPartial(final Inventory cinventory, final ItemStack item, final boolean enforceDurability)
{
return firstPartial(cinventory, item, enforceDurability, item.getType().getMaxStackSize());
}
public static int firstPartial(final Inventory cinventory, final ItemStack item, final boolean enforceDurability, final int maxAmount)
private static int firstPartial(final Inventory inventory, final ItemStack item, final int maxAmount)
{
if (item == null)
{
return -1;
}
final ItemStack[] inventory = cinventory.getContents();
for (int i = 0; i < inventory.length; i++)
final ItemStack[] stacks = inventory.getContents();
for (int i = 0; i < stacks.length; i++)
{
final ItemStack cItem = inventory[i];
if (cItem == null)
{
continue;
}
if (item.getTypeId() == cItem.getTypeId() && cItem.getAmount() < maxAmount && (!enforceDurability || cItem.getDurability() == item.getDurability()) && cItem.getEnchantments().equals(item.getEnchantments()))
final ItemStack cItem = stacks[i];
if (cItem != null && cItem.getAmount() < maxAmount && cItem.isSimilar(item))
{
return i;
}
@@ -65,26 +34,24 @@ public final class InventoryWorkaround
return -1;
}
public static boolean addAllItems(final Inventory cinventory, final boolean enforceDurability, final ItemStack... items)
public static boolean addAllItems(final Inventory inventory, final ItemStack... items)
{
final Inventory fake = new FakeInventory(cinventory.getContents());
if (addItem(fake, enforceDurability, items).isEmpty())
final Inventory fakeInventory = Bukkit.getServer().createInventory(null, inventory.getType());
fakeInventory.setContents(inventory.getContents());
if (addItems(fakeInventory, items).isEmpty())
{
addItem(cinventory, enforceDurability, items);
addItems(inventory, items);
return true;
}
else
{
return false;
}
return false;
}
public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
public static Map<Integer, ItemStack> addItems(final Inventory inventory, final ItemStack... items)
{
return addItem(cinventory, forceDurability, 0, items);
return addOversizedItems(inventory, 0, items);
}
public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean enforceDurability, final int oversizedStacks, final ItemStack... items)
public static Map<Integer, ItemStack> addOversizedItems(final Inventory inventory, final int oversizedStacks, final ItemStack... items)
{
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
@@ -95,7 +62,7 @@ public final class InventoryWorkaround
// combine items
ItemStack[] combined = new ItemStack[items.length];
final ItemStack[] combined = new ItemStack[items.length];
for (int i = 0; i < items.length; i++)
{
if (items[i] == null || items[i].getAmount() < 1)
@@ -109,7 +76,7 @@ public final class InventoryWorkaround
combined[j] = items[i].clone();
break;
}
if (combined[j].getTypeId() == items[i].getTypeId() && (!enforceDurability || combined[j].getDurability() == items[i].getDurability()) && combined[j].getEnchantments().equals(items[i].getEnchantments()))
if (combined[j].isSimilar(items[i]))
{
combined[j].setAmount(combined[j].getAmount() + items[i].getAmount());
break;
@@ -130,13 +97,13 @@ public final class InventoryWorkaround
{
// Do we already have a stack of it?
final int maxAmount = oversizedStacks > item.getType().getMaxStackSize() ? oversizedStacks : item.getType().getMaxStackSize();
final int firstPartial = firstPartial(cinventory, item, enforceDurability, maxAmount);
final int firstPartial = firstPartial(inventory, item, maxAmount);
// Drat! no partial stack
if (firstPartial == -1)
{
// Find a free spot!
final int firstFree = cinventory.firstEmpty();
final int firstFree = inventory.firstEmpty();
if (firstFree == -1)
{
@@ -151,13 +118,13 @@ public final class InventoryWorkaround
{
final ItemStack stack = item.clone();
stack.setAmount(maxAmount);
cinventory.setItem(firstFree, stack);
inventory.setItem(firstFree, stack);
item.setAmount(item.getAmount() - maxAmount);
}
else
{
// Just store it
cinventory.setItem(firstFree, item);
inventory.setItem(firstFree, item);
break;
}
}
@@ -165,7 +132,7 @@ public final class InventoryWorkaround
else
{
// So, apparently it might only partially fit, well lets do just that
final ItemStack partialItem = cinventory.getItem(firstPartial);
final ItemStack partialItem = inventory.getItem(firstPartial);
final int amount = item.getAmount();
final int partialAmount = partialItem.getAmount();
@@ -185,138 +152,4 @@ public final class InventoryWorkaround
}
return leftover;
}
public static Map<Integer, ItemStack> removeItem(final Inventory cinventory, final boolean enforceDurability, final boolean enforceEnchantments, final ItemStack... items)
{
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
// TODO: optimization
for (int i = 0; i < items.length; i++)
{
final ItemStack item = items[i];
if (item == null)
{
continue;
}
int toDelete = item.getAmount();
while (true)
{
// Bail when done
if (toDelete <= 0)
{
break;
}
// get first Item, ignore the amount
final int first = first(cinventory, item, enforceDurability, false, enforceEnchantments);
// Drat! we don't have this type in the inventory
if (first == -1)
{
item.setAmount(toDelete);
leftover.put(i, item);
break;
}
else
{
final ItemStack itemStack = cinventory.getItem(first);
final int amount = itemStack.getAmount();
if (amount <= toDelete)
{
toDelete -= amount;
// clear the slot, all used up
cinventory.clear(first);
}
else
{
// split the stack and store
itemStack.setAmount(amount - toDelete);
cinventory.setItem(first, itemStack);
toDelete = 0;
}
}
}
}
return leftover;
}
public static boolean containsItem(final Inventory cinventory, final boolean enforceDurability, final boolean enforceEnchantments, final ItemStack... items)
{
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
// TODO: optimization
// combine items
ItemStack[] combined = new ItemStack[items.length];
for (int i = 0; i < items.length; i++)
{
if (items[i] == null)
{
continue;
}
for (int j = 0; j < combined.length; j++)
{
if (combined[j] == null)
{
combined[j] = items[i].clone();
break;
}
if (combined[j].getTypeId() == items[i].getTypeId() && (!enforceDurability || combined[j].getDurability() == items[i].getDurability()) && (!enforceEnchantments || combined[j].getEnchantments().equals(items[i].getEnchantments())))
{
combined[j].setAmount(combined[j].getAmount() + items[i].getAmount());
break;
}
}
}
for (int i = 0; i < combined.length; i++)
{
final ItemStack item = combined[i];
if (item == null)
{
continue;
}
int mustHave = item.getAmount();
int position = 0;
while (true)
{
// Bail when done
if (mustHave <= 0)
{
break;
}
final int slot = next(cinventory, item, position, enforceDurability, false, enforceEnchantments);
// Drat! we don't have this type in the inventory
if (slot == -1)
{
leftover.put(i, item);
break;
}
else
{
final ItemStack itemStack = cinventory.getItem(slot);
final int amount = itemStack.getAmount();
if (amount <= mustHave)
{
mustHave -= amount;
}
else
{
mustHave = 0;
}
position = slot + 1;
}
}
}
return leftover.isEmpty();
}
}

View File

@@ -67,6 +67,10 @@ public class SetExpFix
exp += getExpAtLevel(currentLevel);
currentLevel++;
}
if (exp < 0)
{
exp = Integer.MAX_VALUE;
}
return exp;
}
@@ -82,6 +86,10 @@ public class SetExpFix
currentLevel--;
exp += getExpAtLevel(currentLevel);
}
if (exp < 0)
{
exp = Integer.MAX_VALUE;
}
return exp;
}

View File

@@ -35,6 +35,7 @@ import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.scheduler.BukkitTask;
/**
@@ -51,7 +52,7 @@ public class Metrics
/**
* The current revision number
*/
private final static int REVISION = 5;
private final static int REVISION = 6;
/**
* The base url of the metrics domain
*/
@@ -60,10 +61,6 @@ public class Metrics
* The url used to report a server's status
*/
private static final String REPORT_URL = "/report/%s";
/**
* The file where guid and opt out is stored in
*/
private static final String CONFIG_FILE = "plugins/PluginMetrics/config.yml";
/**
* The separator to use for custom data. This MUST NOT change unless you are hosting your own version of metrics and
* want to change it.
@@ -97,14 +94,18 @@ public class Metrics
* Unique server id
*/
private final String guid;
/**
* Debug mode
*/
private final boolean debug;
/**
* Lock for synchronization
*/
private final Object optOutLock = new Object();
/**
* Id of the scheduled task
* The scheduled task
*/
private volatile int taskId = -1;
private volatile BukkitTask task = null;
public Metrics(final Plugin plugin) throws IOException
{
@@ -116,29 +117,31 @@ public class Metrics
this.plugin = plugin;
// load the config
configurationFile = new File(CONFIG_FILE);
configurationFile = getConfigFile();
configuration = YamlConfiguration.loadConfiguration(configurationFile);
// add some defaults
configuration.addDefault("opt-out", false);
configuration.addDefault("guid", UUID.randomUUID().toString());
configuration.addDefault("debug", false);
// Do we need to create the file?
if (configuration.get("guid", null) == null)
{
configuration.options().header("http://metrics.griefcraft.com").copyDefaults(true);
configuration.options().header("http://mcstats.org").copyDefaults(true);
configuration.save(configurationFile);
}
// Load the guid then
guid = configuration.getString("guid");
debug = configuration.getBoolean("debug", false);
}
/**
* Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics
* website. Plotters can be added to the graph object returned.
*
* @param name
* @param name The name of the graph
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
*/
public Graph createGraph(final String name)
@@ -161,7 +164,7 @@ public class Metrics
/**
* Adds a custom data plotter to the default graph
*
* @param plotter
* @param plotter The plotter to use to plot custom data
*/
public void addCustomData(final Plotter plotter)
{
@@ -193,7 +196,7 @@ public class Metrics
}
// Begin hitting the server with glorious data
taskId = plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable()
task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable()
{
private boolean firstPost = true;
@@ -205,10 +208,15 @@ public class Metrics
synchronized (optOutLock)
{
// Disable Task, if it is running and the server owner decided to opt-out
if (isOptOut() && taskId > 0)
if (isOptOut() && task != null)
{
plugin.getServer().getScheduler().cancelTask(taskId);
taskId = -1;
task.cancel();
task = null;
// Tell all plotters to stop gathering information.
for (Graph graph : graphs)
{
graph.onOptOut();
}
}
}
@@ -223,7 +231,10 @@ public class Metrics
}
catch (IOException e)
{
Bukkit.getLogger().log(Level.FINE, "[Metrics] " + e.getMessage());
if (debug)
{
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
}
}
}
}, 0, PING_INTERVAL * 1200);
@@ -233,7 +244,7 @@ public class Metrics
/**
* Has the server owner denied plugin metrics?
*
* @return
* @return true if metrics should be opted out of it
*/
public boolean isOptOut()
{
@@ -242,16 +253,22 @@ public class Metrics
try
{
// Reload the metrics file
configuration.load(CONFIG_FILE);
configuration.load(getConfigFile());
}
catch (IOException ex)
{
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
if (debug)
{
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
}
return true;
}
catch (InvalidConfigurationException ex)
{
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
if (debug)
{
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
}
return true;
}
return configuration.getBoolean("opt-out", false);
@@ -276,7 +293,7 @@ public class Metrics
}
// Enable Task, if it is not running
if (taskId < 0)
if (task == null)
{
start();
}
@@ -297,35 +314,81 @@ public class Metrics
if (!isOptOut())
{
configuration.set("opt-out", true);
final File file = new File(CONFIG_FILE);
configuration.save(file);
configuration.save(configurationFile);
}
// Disable Task, if it is running
if (taskId >= 0)
if (task != null)
{
this.plugin.getServer().getScheduler().cancelTask(taskId);
taskId = -1;
task.cancel();
task = null;
}
}
}
/**
* Gets the File object of the config file that should be used to store data such as the GUID and opt-out status
*
* @return the File object for the config file
*/
public File getConfigFile()
{
// I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use
// is to abuse the plugin object we already have
// plugin.getDataFolder() => base/plugins/PluginA/
// pluginsFolder => base/plugins/
// The base is not necessarily relative to the startup directory.
File pluginsFolder = plugin.getDataFolder().getParentFile();
// return => base/plugins/PluginMetrics/config.yml
return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml");
}
/**
* Generic method that posts a plugin to the metrics website
*/
private void postPlugin(final boolean isPing) throws IOException
{
// The plugin's description file containg all of the plugin data such as name, version, author, etc
final PluginDescriptionFile description = plugin.getDescription();
// Server software specific section
PluginDescriptionFile description = plugin.getDescription();
String pluginName = description.getName();
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
String pluginVersion = description.getVersion();
String serverVersion = Bukkit.getVersion();
int playersOnline = Bukkit.getServer().getOnlinePlayers().length;
// END server software specific section -- all code below does not use any code outside of this class / Java
// Construct the post data
final StringBuilder data = new StringBuilder();
// The plugin's description file containg all of the plugin data such as name, version, author, etc
data.append(encode("guid")).append('=').append(encode(guid));
encodeDataPair(data, "version", description.getVersion());
encodeDataPair(data, "server", Bukkit.getVersion());
encodeDataPair(data, "players", Integer.toString(Bukkit.getServer().getOnlinePlayers().length));
encodeDataPair(data, "version", pluginVersion);
encodeDataPair(data, "server", serverVersion);
encodeDataPair(data, "players", Integer.toString(playersOnline));
encodeDataPair(data, "revision", String.valueOf(REVISION));
// New data as of R6
String osname = System.getProperty("os.name");
String osarch = System.getProperty("os.arch");
String osversion = System.getProperty("os.version");
String java_version = System.getProperty("java.version");
int coreCount = Runtime.getRuntime().availableProcessors();
// normalize os arch .. amd64 -> x86_64
if (osarch.equals("amd64"))
{
osarch = "x86_64";
}
encodeDataPair(data, "osname", osname);
encodeDataPair(data, "osarch", osarch);
encodeDataPair(data, "osversion", osversion);
encodeDataPair(data, "cores", Integer.toString(coreCount));
encodeDataPair(data, "online-mode", Boolean.toString(onlineMode));
encodeDataPair(data, "java_version", java_version);
// If we're pinging, append it
if (isPing)
{
@@ -342,10 +405,6 @@ public class Metrics
{
final Graph graph = iter.next();
// Because we have a lock on the graphs set already, it is reasonable to assume
// that our lock transcends down to the individual plotters in the graphs also.
// Because our methods are private, no one but us can reasonably access this list
// without reflection so this is a safe assumption without adding more code.
for (Plotter plotter : graph.getPlotters())
{
// The key name to send to the metrics server
@@ -364,7 +423,7 @@ public class Metrics
}
// Create the url
final URL url = new URL(BASE_URL + String.format(REPORT_URL, description.getName()));
URL url = new URL(BASE_URL + String.format(REPORT_URL, encode(pluginName)));
// Connect to the website
URLConnection connection;
@@ -420,13 +479,12 @@ public class Metrics
}
}
}
//if (response.startsWith("OK")) - We should get "OK" followed by an optional description if everything goes right
}
/**
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
*
* @return
* @return true if mineshafter is installed on the server
*/
private boolean isMineshafterPresent()
{
@@ -450,10 +508,9 @@ public class Metrics
* encodeDataPair(data, "version", description.getVersion());
* </code>
*
* @param buffer
* @param key
* @param value
* @return
* @param buffer the stringbuilder to append the data pair onto
* @param key the key value
* @param value the value
*/
private static void encodeDataPair(final StringBuilder buffer, final String key, final String value) throws UnsupportedEncodingException
{
@@ -463,8 +520,8 @@ public class Metrics
/**
* Encode text as UTF-8
*
* @param text
* @return
* @param text the text to encode
* @return the encoded text, as UTF-8
*/
private static String encode(final String text) throws UnsupportedEncodingException
{
@@ -495,7 +552,7 @@ public class Metrics
/**
* Gets the graph's name
*
* @return
* @return the Graph's name
*/
public String getName()
{
@@ -505,7 +562,7 @@ public class Metrics
/**
* Add a plotter to the graph, which will be used to plot entries
*
* @param plotter
* @param plotter the plotter to add to the graph
*/
public void addPlotter(final Plotter plotter)
{
@@ -515,7 +572,7 @@ public class Metrics
/**
* Remove a plotter from the graph
*
* @param plotter
* @param plotter the plotter to remove from the graph
*/
public void removePlotter(final Plotter plotter)
{
@@ -525,7 +582,7 @@ public class Metrics
/**
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
*
* @return
* @return an unmodifiable {@link Set} of the plotter objects
*/
public Set<Plotter> getPlotters()
{
@@ -549,6 +606,13 @@ public class Metrics
final Graph graph = (Graph)object;
return graph.name.equals(name);
}
/**
* Called when the server owner decides to opt-out of Metrics while the server is running.
*/
protected void onOptOut()
{
}
}
@@ -573,7 +637,7 @@ public class Metrics
/**
* Construct a plotter with a specific plot name
*
* @param name
* @param name the name of the plotter to use, which will show up on the website
*/
public Plotter(final String name)
{
@@ -581,9 +645,11 @@ public class Metrics
}
/**
* Get the current value for the plotted point
* Get the current value for the plotted point. Since this function defers to an external function it may or may
* not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called
* from any thread so care should be taken when accessing resources that need to be synchronized.
*
* @return
* @return the current value for the point to be plotted.
*/
public abstract int getValue();
@@ -607,7 +673,7 @@ public class Metrics
@Override
public int hashCode()
{
return getColumnName().hashCode() + getValue();
return getColumnName().hashCode();
}
@Override

View File

@@ -33,7 +33,7 @@ public class MetricsListener implements Listener
player.sendMessage("To opt out, run /essentials opt-out");
ess.getLogger().log(Level.INFO, "[Metrics] Admin join - Starting 5 minute opt-out period.");
ess.getSettings().setMetricsEnabled(true);
ess.getScheduler().scheduleAsyncDelayedTask(ess, starter, 5 * 1200);
ess.getScheduler().runTaskLaterAsynchronously(ess, starter, 5 * 1200);
}
}
}

View File

@@ -134,6 +134,14 @@ public class MetricsStarter implements Runnable
{
enabledGraph.addPlotter(new SimplePlotter("Warps"));
}
if (ess.getSettings().getTeleportCooldown() > 0)
{
enabledGraph.addPlotter(new SimplePlotter("TeleportCooldown"));
}
if (ess.getSettings().getTeleportDelay() > 0)
{
enabledGraph.addPlotter(new SimplePlotter("TeleportDelay"));
}
if (!ess.getSettings().areSignsDisabled())
{
enabledGraph.addPlotter(new SimplePlotter("Signs"));
@@ -142,6 +150,14 @@ public class MetricsStarter implements Runnable
{
enabledGraph.addPlotter(new SimplePlotter("AutoAFK"));
}
if (ess.getSettings().changePlayerListName())
{
enabledGraph.addPlotter(new SimplePlotter("PlayerListName"));
}
if (ess.getSettings().getOperatorColor() != null)
{
enabledGraph.addPlotter(new SimplePlotter("OpColour"));
}
if (ess.getSettings().changeDisplayName())
{
enabledGraph.addPlotter(new SimplePlotter("DisplayName"));

View File

@@ -35,7 +35,7 @@ public class BPermissions2Handler extends SuperpermsHandler
@Override
public boolean inGroup(final Player base, final String group)
{
return ApiLayer.hasGroup(base.getWorld().getName(), CalculableType.USER, base.getName(), group);
return ApiLayer.hasGroupRecursive(base.getWorld().getName(), CalculableType.USER, base.getName(), group);
}
@Override

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