1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-09-08 13:40:45 +02:00

Compare commits

..

708 Commits

Author SHA1 Message Date
KHobbits
fdb5d85ba5 Merge pull request #488 from necrodoom/patch-21
fix typo in eco warning
2013-06-17 08:19:59 -07:00
Necrodoom
2b4b1520d3 fix typo in eco warning 2013-06-17 16:05:45 +03:00
KHobbits
07bcd17e0f Block external access to unsupported saveConfig() method. 2013-06-17 01:08:42 +01:00
KHobbits
8fb91c5a61 Allow new lines and add secure broadcast keywords. 2013-06-16 01:18:35 +01:00
KHobbits
aa6d85eacc Cleanup broadcast, allow limited keywords in. 2013-06-16 01:07:16 +01:00
KHobbits
f5986194aa Clarify 'permission-based-item-spawn' config setting. 2013-06-16 00:05:27 +01:00
KHobbits
b646bda9d2 Update to 1.5.2 RB:
Bukkit #1776 CraftBukkit #2788
2013-06-15 11:53:47 +01:00
KHobbits
fe86f3a01d Reset suffix on /nick even if op and prefix/suffix are disabled. 2013-06-13 09:18:47 +01:00
KHobbits
ae2a03d80c Merge pull request #485 from necrodoom/patch-29
no permissions is not an error, so dont output it as a warning
2013-06-12 02:59:55 -07:00
Necrodoom
e4d7aacc5d no permissions is not an error, so dont output it as a warning 2013-06-12 12:41:15 +03:00
KHobbits
129fd53d5a Merge branch 'temp1' into 2.9 2013-06-11 20:50:24 +01:00
KHobbits
6bf57de64d Merge branch 'release' of github.com:essentials/Essentials into 2.9 2013-06-11 20:46:28 +01:00
Iaccidentally
f1eae9be6f Cleanup imports 2013-06-11 20:45:12 +01:00
KHobbits
a77c2d6d95 Restore support for replacing CAPITAL colour codes. 2013-06-11 16:38:24 +01:00
KHobbits
c476471978 Don't look up valid looking IP's in the player database. 2013-06-09 23:10:02 +01:00
Iaccidentally
8755935fcb Remove old permissions handlers that are no longer used. This fixes an issue where new versions of Bpermissions would be detected as old. 2013-06-09 14:38:27 -04:00
KHobbits
9976cc847f Allow use of deprecated teleport function through interface. 2013-06-09 13:38:09 +01:00
theudis
56f86c9ae4 Update messages_fr.properties
Small changes in what I had done previously.
2013-06-09 03:09:20 +01:00
Necrodoom
bdb5d095ca Fix arg length checks on /exp 2013-06-09 03:07:35 +01:00
cexikitin
f38ed576c5 Alert give sender that the user was unable to receive all the items. 2013-06-09 03:05:40 +01:00
KHobbits
09f67c9723 Split util classes. 2013-06-08 22:31:19 +01:00
KHobbits
98e427e831 Cleanup ITarget 2013-06-08 21:43:42 +01:00
KHobbits
ac6b74887f Turn Target into a real class. 2013-06-08 21:40:02 +01:00
KHobbits
7276bcccab Trapdoors should be treated as half blocks, not transparent blocks. 2013-06-08 21:26:11 +01:00
KHobbits
a7b62c65b8 Teleport invulnerability should trigger on respawn as well as normal teleport. 2013-06-08 21:06:33 +01:00
KHobbits
f48ed6988d Essentials API cleanup and teleport possession fixing. (UNSTABLE) 2013-06-08 19:34:14 +01:00
KHobbits
b8300cc35a Throw a little testing on toggle logic. 2013-06-08 16:33:30 +01:00
KHobbits
a3e6996ef9 Try and make toggles DRYer without loosing command flow.
Allow socialspy to match multiple players.
2013-06-08 15:13:51 +01:00
KHobbits
34daa5691c Allow spawning zombies without the trademark gold boots.
Also limit armor to zombies and skeletons.
2013-06-05 03:15:12 +01:00
KHobbits
0457705850 Fix unit tests. 2013-06-02 17:56:48 +01:00
KHobbits
5d5fee4612 Attempt to fix /seen times on vanish. 2013-06-02 17:45:56 +01:00
KHobbits
43f4a69760 Mute and sudo should check for essentials.vanish.interact permission. 2013-06-02 16:09:56 +01:00
KHobbits
55cee73a48 Allow spawning zombies with swords too. 2013-06-02 00:09:12 +01:00
KHobbits
51f554827c [Feature]Extend spawning mob meta to allow more customized spawning:
/spawnmob (skeleton|zombie|pigzombie):(diamond|iron|gold)armor
2013-06-02 00:02:40 +01:00
KHobbits
d6756a2605 [Fix] Set some default mob data.
Fixes skeletons spawning without bows.
2013-06-01 23:33:31 +01:00
KHobbits
b065f4a05a Update Essentials spawn to use new kit params. 2013-05-27 02:29:28 +01:00
KHobbits
867bfbf1b8 Better handle kit item casting. 2013-05-27 02:25:30 +01:00
KHobbits
7fe83dbd91 Ignore extra spaces in kit config. 2013-05-26 23:53:39 +01:00
KHobbits
1a4c2e8484 Exempt [repair] signs from 'essentials.repair.all' permissions check. 2013-05-26 22:00:35 +01:00
KHobbits
84874c9855 Update inventory when closing ghost-dupe-able inventory, to remove ghost items. 2013-05-26 18:21:19 +01:00
KHobbits
6512a53a3f Reduce duplicated broadcast code. 2013-05-26 17:58:04 +01:00
KHobbits
423c8c54dc Simplify player matching. 2013-05-26 17:37:11 +01:00
KHobbits
160a1a04eb Standardize /getpos and /whois to use essentials.vanish.interact like all other commands. 2013-05-26 17:20:03 +01:00
KHobbits
88c5b64694 GeoIP already has a perm, doesn't need hidden behind essentials.seen.extra as well. 2013-05-26 16:52:25 +01:00
KHobbits
19451c151e Show teleport cancel messages to tpa user. 2013-05-26 16:49:11 +01:00
KHobbits
e4d041b9b0 Fix /helpop for console use. 2013-05-26 16:23:36 +01:00
KHobbits
3bcd3390fe [Fix] Fix vanished player matching in: /seen /give /burn /nuke /tpall /tpaall 2013-05-26 16:02:40 +01:00
KHobbits
35783ee429 Forgot to push Essentials spawn changes. 2013-05-24 00:10:39 +01:00
KHobbits
66911bb0a9 Improve hidden player matching.
Replace essentials.teleport.hidden with essentials.vanish.interact
Fix perm checks in tpall and tpaall
2013-05-23 22:59:09 +01:00
KHobbits
d48c342e37 Fixing feed messages. 2013-05-23 22:12:54 +01:00
KHobbits
5c05870490 Improve user matching 2013-05-20 18:50:14 +01:00
KHobbits
d76fe946b7 Don't throw NPE on broken sign state, just allow block to break. 2013-05-19 01:21:21 +01:00
KHobbits
a738e49e3c Default chat formatting should strip all format codes, not just colours. 2013-05-19 01:03:54 +01:00
KHobbits
9dc6e7ad1e Add indication of when kit's cannot be used yet, in the /kit output. 2013-05-18 23:27:41 +01:00
KHobbits
293406a603 Tidy up /gc's TPS output. 2013-05-18 21:42:02 +01:00
KHobbits
727c53eb2b [Feature] Add hunger level to /whois 2013-05-18 18:20:06 +01:00
KHobbits
274ad06665 Fix null when trying to tempban players in console for times longer than max ban. 2013-05-18 17:57:05 +01:00
KHobbits
5e6f6b2482 Tweak /baltop to not show displaynames on vanished players. 2013-05-12 21:19:54 +01:00
KHobbits
29c9a46c2f Tiny listener optimizations. 2013-05-12 20:59:07 +01:00
KHobbits
6d317fd26d Small tweak to warning display and make config variable 'economy-lag-warning' set in ms not ns. 2013-05-12 16:31:40 +01:00
KHobbits
8ebe55a294 Make the lag warning configurable, useful to debug economy lag on larger servers. 2013-05-12 16:10:41 +01:00
KHobbits
af2c514f2a Throw console warning on slow economy api call. 2013-05-12 04:12:34 +01:00
GunfighterJ
3042151fee [Fix] Check initial direction when looking for a safe teleport spot 2013-05-10 11:21:39 -05:00
KHobbits
59f67acfd0 Don't treat AFK players as god mode when dealing with food regen. 2013-05-09 17:44:10 +01:00
snowleo
7051801a85 Update ItemDb.java 2013-05-08 00:53:37 +03:00
snowleo
0d02b91506 Doesn't need this 2013-05-08 00:52:39 +03:00
KHobbits
5f6cca83ce [Feature] Withdraw from trade signs without dropping items as overflow. [EXPERIMENTAL] 2013-05-06 23:09:31 +01:00
KHobbits
ed5743147b Add some sign debugging to /ess debug to help track down charging issues. 2013-05-05 22:37:28 +01:00
KHobbits
1bb7946e13 Couple more bits of Eco cleanup 2013-05-05 20:05:28 +01:00
KHobbits
9ec1a6b78f Fix /sell to handle zero priced items again. 2013-05-05 19:59:35 +01:00
snowleo
76a96d1004 Make it compatible with Factions again. 2013-05-05 19:00:21 +03:00
snowleo
b49aaee66d Catch both exceptions in EssentialsConf and valueOf instead of new 2013-05-05 11:55:39 +02:00
snowleo
0d34b9ae9f Cleanup 2013-05-05 11:42:53 +02:00
snowleo
6044cca54f ECONOMY MADNESS? THIS IS … FIXED 2013-05-05 11:41:19 +02:00
snowleo
aaebb6143e fix NPE in teleport code 2013-05-05 11:08:49 +03:00
KHobbits
c4ac744d35 Further economy cleanup 2013-05-05 08:03:06 +01:00
KHobbits
162b67aaa6 Cleanup player argument matching in loops
Cleanup ess cleanup timestamp matching
2013-05-05 07:15:33 +01:00
KHobbits
2d70bb19f7 Economy Madness 2013-05-05 05:12:17 +01:00
KHobbits
801acbb004 Trim stored precision to below that of a double, to prevent rounding issues. 2013-05-05 01:23:07 +01:00
theudis
aeb1b4601c Update messages_fr.properties 2013-05-04 21:56:32 +01:00
KHobbits
f5b32f51aa Update CS translation with some extra TL keys from tommymortago 2013-05-04 19:34:55 +01:00
KHobbits
0b20055f60 Sorted TL files 2013-05-04 19:22:44 +01:00
pa001024
2f30064ab4 update zh-locate 2013-05-04 18:32:44 +01:00
Necrodoom
a65d0db57d Throw invalid kit message on invalid delay 2013-05-04 18:26:34 +01:00
KHobbits
479dad9966 cleanup 2013-05-04 18:22:55 +01:00
KHobbits
b7acccfc8b [Feature] Make /kit list kit costs if any are set. 2013-05-04 18:11:35 +01:00
KHobbits
fbcfd4948b Merge pull request #465 from skmedix/patch-1
Update Polish translation
2013-05-04 08:55:18 -07:00
KHobbits
cdbdb5e8e9 [Permission] Add essentials.repair.all permission, which is required to unlock /repair all
Also make it to /repair defaults to hand.
2013-05-04 16:06:06 +01:00
KHobbits
6e20275cc7 [Fix] Allow Feed to be used via console
Throw events when modifying heath or food levels.
2013-05-04 16:04:59 +01:00
snowleo
aac9e4884d Remove User instance from Teleport class 2013-05-03 01:53:54 +02:00
snowleo
ddb3b13931 Don't trust File.length() 2013-05-03 01:26:51 +02:00
snowleo
c62f762724 Do not keep hard references to User objects 2013-05-03 01:15:02 +02:00
snowleo
4bdeb1324d *angry eyes* 2013-05-03 00:25:07 +02:00
snowleo
555a300378 Fix cleanup to not hold Users in memory. 2013-05-03 00:12:40 +02:00
Iaccidentally
ebc6b14284 Update libs for 1.5.2 :: Minimum CB version now 2763 2013-05-02 11:54:05 -04:00
SKmedix
041fa8537d Update messages_pl.properties
Changelog:
---
* Added:
kitError2 (216)
kitNotFound (536)
socialSpy (537)
setBal (538)
insufficientFunds (540)

* Fixed:
backUsageMsg (21)
banFormat (28)
bedMissing (30)
connectedPlayers (58)
downloadingGeoIp (91)
fullStack (125)
geoIpUrlEmpty (131)
geoIpUrlInvalid (132)
healOther (148)
itemSpawn (200)
jailReleased (206)
jailSentenceExtended (208)
jailSet (209)
kickedAll (213)
kitInvFull (221)
kitOnce (222)
markMailAsRead (239)
matchingIPAddress (242)
messageTruncated (246)
nickChanged (272)
removed (376)
repairNone (381)
teleportAll (419)
tempBanned (434)
thunderDuration (437)
timeSet (442)
totalWorthAll (446)
totalWorthBlocks (447)
tradeSignEmpty (450)
youAreHealed (520)
youHaveNewMail (521)
balanceOther (527)
2013-04-30 20:34:33 +03:00
Iaccidentally
7bbceed491 Minor cleanup 2013-04-30 12:57:38 -04:00
Iaccidentally
7a46de6b02 Fix some tl keys :: update Portuguese translation 2013-04-30 12:26:09 -04:00
Iaccidentally
1ab2a51550 API & misc cleanup 2013-04-30 12:25:25 -04:00
Iaccidentally
42dc6a2e07 Merge pull request #460 from main--/2.9
Made the "throws" declaration of getWarps() more specific
2013-04-30 08:30:41 -07:00
KHobbits
9ba9223632 Support /me in console 2013-04-30 02:24:30 +01:00
KHobbits
c4173c0486 Allow powertool to be set from console. 2013-04-30 02:18:22 +01:00
KHobbits
049886797b Fix tests. 2013-04-30 01:50:02 +01:00
KHobbits
a43cbe061a Move spawnmob.stack perm check to the right place. 2013-04-30 01:37:39 +01:00
KHobbits
9d2358ed4d [Fix] Stacked mobs count towards spawnmob-limit count. 2013-04-30 01:04:40 +01:00
KHobbits
7913cfdb3c Fix currency rounding up. 2013-04-30 00:35:39 +01:00
KHobbits
137d0df9dc Fix TL messages. 2013-04-30 00:18:53 +01:00
KHobbits
d425ab5f93 Fix Eco take bug and fix NPE 2013-04-30 00:07:28 +01:00
KHobbits
012741fea6 Merge branch '2.9' of github.com:essentials/Essentials into 2.9 2013-04-29 23:50:49 +01:00
GunfighterJ
006f996283 Remove ArrayListInput
Formatting
2013-04-29 14:04:59 -05:00
main()
538a2425c5 Made the "throws" declaration of getWarps() more specific
It is very difficult to handle an Exception thrown by an API method when you don't have any way to **programatically** (without dirty stuff like string comparisons, so the message is not enough) distinguish errors and find out what's going on.
2013-04-29 20:29:42 +02:00
GunfighterJ
79bdd8a212 Add keyword replacements in kits
Add SimpleTextInput constructor for lists
Variable refactoring for clarity.
2013-04-29 06:31:08 -05:00
Iaccidentally
28cbac6610 cleanup last commit a bit 2013-04-28 17:22:11 -04:00
Iaccidentally
0a03696983 [API] Add a warp api, with future 3.x support :: minor cleanup 2013-04-28 16:23:45 -04:00
KHobbits
f0ab66c4c6 Fix ZH TL messages 2013-04-28 14:18:19 +01:00
pa001024
57184f01e9 Add China/Hong Kong/Taiwan Translations 2013-04-28 14:12:21 +01:00
Iaccidentally
02df03a4b1 [CHANGE] Rewrite eco command with better logic :: the command will now attempt to do exactly what it is told, with respect to the minimum balance :: fix missing messages 2013-04-27 23:44:23 -04:00
KHobbits
3396cf6e02 [Fix] Try singular and plural entity names in /remove. 2013-04-28 04:26:39 +01:00
Necrodoom
e60f17bb53 Fix radius in /remove and add world.
Fix SocialSpy
Fix /killall world argument.
2013-04-28 04:20:28 +01:00
Necrodoom
eb0c71984c [Feature] Add /socialspy other 2013-04-28 03:44:24 +01:00
KHobbits
865b581d06 Update Polish translation by skmedix 2013-04-28 03:31:18 +01:00
Necrodoom
b093111920 [Fix] Output proper message if typo'd kit 2013-04-28 03:22:31 +01:00
snowleo
c55e52539e Update Commandgc.java 2013-04-23 08:57:22 +03:00
snowleo
1dfad57c6f Derp, still need currentTime 2013-04-23 08:55:02 +03:00
snowleo
6148583fb2 Fix tps after Timer changes 2013-04-23 08:51:25 +03:00
snowleo
9160410a50 Allow to forceSave conf files 2013-04-23 00:47:45 +02:00
snowleo
2588e20140 Delayed write to file (experimental) 2013-04-22 23:31:11 +02:00
U-SFX\wardcg
e291633ac8 Merge remote-tracking branch 'origin/groupmanager' into 2.9 2013-04-23 01:02:31 +10:00
KHobbits
dfc62bca76 Minor TP and timer tweaks. 2013-04-22 00:11:13 +01:00
KHobbits
f48871ff29 Attempt to smooth out timer usage.
Add extra sign metrics.
2013-04-21 23:39:50 +01:00
snowleo
c2eb7b05b3 Restrict EssentialsTimer to 10ms execution time 2013-04-22 01:23:21 +03:00
Iaccidentally
547e262061 [FEATURE] Add kill exempt :: new permission: essentials.kill.exempt
players with essentials.kill.force and console will still be able to override this
2013-04-19 14:40:10 -04:00
Iaccidentally
62942bdb3d Merge pull request #453 from necrodoom/patch-20
[FIX] ID 18, 29, 33 invalid damage values and more
2013-04-19 10:32:47 -07:00
ElgarL
e8c2a9792f Merge pull request #452 from evonuts/groupmanager
Minor grammatical changes to config.yml
2013-04-19 09:57:16 -07:00
Necrodoom
f1bc7a305a [FIX] ID 18, 29, 33 invalid damage values and more
expand IDs 98:1, 98:2, 98:3
2013-04-19 19:43:22 +03:00
GunfighterJ
fd0134227c Fix NPE on invalid enchant 2013-04-19 10:06:43 -05:00
evonuts
59c833aa9e Minor grammatical changes to config.yml 2013-04-19 12:13:09 +12:00
Iaccidentally
f6e2db1eda [Feature] Add a blacklist for what dispensers can dispense to antibuild 2013-04-16 17:01:01 -04:00
Iaccidentally
eeb31e054f [UPDATE] Update to 1.5.1-r0.2 beta build 2013-04-16 16:59:36 -04:00
Iaccidentally
4629cad99b Clean up last commit 2013-04-16 16:16:07 -04:00
Iaccidentally
5e360995eb [FIX] Update user activity when shooting a bow 2013-04-16 15:58:13 -04:00
GunfighterJ
a72777d043 Allow permission control of stacked mobs
Adds essentials.spawnmob.stack to allow stacking of more than one mob using the /spawnmob command

Adds https://www.assembla.com/spaces/essentials/tickets/4050
2013-04-14 15:01:25 -05:00
snowleo
39d66b1c43 Changing that name too, thanks jomp16 2013-04-14 12:30:30 +03:00
snowleo
9a3295439b Threading Fix 2013-04-14 04:44:16 +03:00
KHobbits
656a40abb2 Remove duplicate perm. 2013-04-13 23:50:17 +01:00
KHobbits
7e80f440ca Check threading on backup init. 2013-04-13 23:10:09 +01:00
GunfighterJ
e353ec7f66 Merge pull request #438 from GunfighterJ/2.9
Add Romanian translation
2013-04-08 17:27:16 -07:00
GunfighterJ
bacb84a943 Add Romanian translation 2013-04-06 17:13:59 -05:00
GunfighterJ
bac2b3f878 [Feature] pweather command 2013-04-06 16:20:12 -05:00
snowleo
8f41cc07e3 Still need that check 2013-04-06 18:40:42 +03:00
snowleo
4f033d8073 Math fail 2013-04-06 18:38:49 +03:00
snowleo
284d7a23ca Fix § at end of line 2013-04-06 18:37:13 +03:00
KHobbits
8777410d30 Balance others message. 2013-04-06 05:54:44 +01:00
KHobbits
3356db080a Fix group name when using wildcard group definitions. 2013-04-06 05:05:28 +01:00
ementalo
55e8aa765b Remove GB from main build.xml 2013-04-04 20:49:55 +01:00
ementalo
d2ee2e3646 [update] Remove GroupBridge 2013-04-04 20:45:09 +01:00
KHobbits
d9a6974ae2 Missing file update. 2013-04-04 08:45:08 +01:00
KHobbits
641fbca40c Update Bukkit for 1.5.1-R0.1 Beta.
CB: 2735 Bukkit: 1741
2013-04-04 08:39:57 +01:00
Paul A.
11fafb5339 Merge pull request #435 from GunfighterJ/2.9
[Fix] NPE on ptime from console
2013-04-02 08:31:42 -07:00
GunfighterJ
e4b04db412 [Fix] NPE on ptime from console 2013-04-02 10:21:20 -05:00
Iaccidentally
93b76446f5 Merge pull request #431 from GunfighterJ/2.9
Show Geolocation in /seen
2013-04-01 14:20:42 -07:00
GunfighterJ
e3183e66df Show Geolocation in /seen
Refactor argument for clarity
2013-04-01 16:00:09 -05:00
KHobbits
9d1f25c455 Block sign interact if player is dead. 2013-04-01 05:23:04 +01:00
KHobbits
9fe226b79a Merge pull request #428 from necrodoom/patch-15
readd "forest" and "jungle"
2013-03-31 08:27:26 -07:00
Necrodoom
228ecd2a5c readd "forest" and "jungle" 2013-03-31 18:26:38 +03:00
KHobbits
4eb6c9b54f For group overflow, add a little colour. 2013-03-30 02:40:20 +00:00
KHobbits
c093b6e7c2 Use original casing in config file group name. 2013-03-30 02:36:09 +00:00
Iaccidentally
757a41f890 [FIX] add itemframe support to remove 2013-03-29 22:20:54 -04:00
KHobbits
8427b41e30 Prevent sign healing when the player is recently dead. 2013-03-29 14:37:30 +00:00
SKmedix
159cbba809 Update messages_pl.properties
Update Polish translation.
2013-03-29 03:19:43 +00:00
Necrodoom
8604debc4e [Fix] Allow console to afk others 2013-03-29 03:16:18 +00:00
Necrodoom
22efa3e000 wipe too general log name aliases 2013-03-29 03:13:03 +00:00
Necrodoom
578576e317 [Fix] Sudo allowed on vanished players. 2013-03-29 03:10:45 +00:00
Necrodoom
98aa303ff5 prevent confusion at /ci code 2013-03-29 03:04:54 +00:00
KHobbits
c857832759 Spacing. 2013-03-29 03:01:53 +00:00
KHobbits
aab6af768d Fixing casing and formatting issues in /list 2013-03-29 02:59:55 +00:00
KHobbits
879560092f Merge pull request #423 from kukelekuuk00/patch-1
[Fix] Strip colourcodes from groups in /list (internal only)
2013-03-28 19:50:50 -07:00
ElgarL
411b4e2b8f another string fix. 2013-03-28 16:08:59 +00:00
ElgarL
519785d09f More Necrodoom fixes. 2013-03-28 15:38:18 +00:00
ElgarL
231f9d49c1 Fix loops. 2013-03-28 13:10:17 +00:00
ElgarL
e15a8c50d6 Merge pull request #371 from necrodoom/patch-72
add new commands and others
2013-03-28 05:59:35 -07:00
Luuk Jacobs
386b73dbdb [Fix] Strip colourcodes from groups
This way groups with colourcodes in the middle of the name work with /who <groupname> ie. §4S§cerveradmin
2013-03-26 11:43:45 +01:00
Iaccidentally
c7f62700d5 Merge pull request #409 from GunfighterJ/2.9
[Feature] Stack more mobs with /spawnmob
2013-03-22 14:39:55 -07:00
GunfighterJ
85741288ce [Feature] Stack more mobs with /spawnmob
Uses same syntax, now supports more than 2 mobs
2013-03-22 16:35:01 -05:00
KHobbits
566a826cf1 Abort user login code, if user disconnects before it runs. 2013-03-21 22:30:02 +00:00
KHobbits
28e069eb6b Don't allow an empty list value. 2013-03-21 21:41:30 +00:00
KHobbits
44584b11c5 Tweak ess version 2013-03-21 21:12:58 +00:00
KHobbits
b8e079ddcb Add the max-walk-speed config variable back to the default config file. 2013-03-20 23:24:45 +00:00
SKmedix
35792f9728 Update messages_pl.properties
Update Polish translation.
2013-03-20 08:53:00 +00:00
KHobbits
353423efec Use correct getPlayer method to not match offline users. 2013-03-20 01:29:54 +00:00
KHobbits
889157371c [Permission] essentials.vanish.interact - Players with this permission will be able to interact with hidden players. 2013-03-20 01:00:50 +00:00
KHobbits
896e14670f Add some missing hidden checks 2013-03-19 23:24:06 +00:00
KHobbits
8f6c61fa99 Try to unify player matching for hidden users:
kill, lightning and ptime still need cleanup
2013-03-19 23:17:34 +00:00
KHobbits
1d6ac42311 [Fix] Reset walk/fly speed on login.
[Permission] essentials.speed.<fly|walk> - If a player only has one of these, they will only be able to toggle the given state.
2013-03-19 22:55:00 +00:00
KHobbits
61b115ceac Don't close inventories every plugin disable, just our own. 2013-03-19 21:05:12 +00:00
Necrodoom
a5ec8b9cbb [Fix] Print correct sender name on /spawn player from console. 2013-03-19 20:59:02 +00:00
Necrodoom
5af1f50b65 Fix exception in /heal, "playernotfound" should be exception. 2013-03-19 20:56:50 +00:00
KHobbits
093611fb2a Use original case for default /list groups. 2013-03-19 18:34:28 +00:00
KHobbits
709ddae508 readmeupdate 2013-03-19 14:32:23 +00:00
Necrodoom
cac53ab12e kittycannon should actually fire kittens 2013-03-19 14:31:34 +00:00
Necrodoom
df55e162d4 console should be able to mute admins 2013-03-19 14:09:30 +00:00
Necrodoom
ea9bf854cc [Fix] offline player matching for online only commands.
/kick,/warp, /burn & /tppos should only match online players
2013-03-19 14:07:42 +00:00
KHobbits
f5c17fc7c7 Pull the default list behavior from the old 'sort-list-by-groups' variable if it exists. 2013-03-19 09:00:50 +00:00
KHobbits
2dda15d47f Add Travis notifications 2013-03-18 23:48:01 +00:00
KHobbits
d9485cea8d Try different ant command 2013-03-18 23:35:00 +00:00
KHobbits
e728236dd3 Travis 2013-03-18 23:27:15 +00:00
KHobbits
fe28faf79d Merge pull request #396 from GunfighterJ/2.9
Allow potion clear/apply commands to work
2013-03-18 16:20:45 -07:00
KHobbits
66e87bdd1c Minor code cleanup 2013-03-18 23:15:18 +00:00
KHobbits
4b5cc8cfd8 Cleanup: Run Kukes code through a dryer, add more comments. 2013-03-18 22:43:05 +00:00
GunfighterJ
8b97a84652 Allow potion clear/apply commands to work 2013-03-18 11:21:28 -05:00
KHobbits
16ca842929 Edit default config to not cause confusion. 2013-03-18 08:59:40 +00:00
KHobbits
984eca9723 Cleanup: Comment and simplify /list code - More to do. 2013-03-18 08:53:12 +00:00
KHobbits
5b55fd97e6 Cleanup - Split /list into methods 2013-03-18 08:16:34 +00:00
kukelekuuk00
0c82c61574 fixes and addition of '*' to match all unmatched users. 2013-03-18 06:16:02 +00:00
kukelekuuk00
32099a4109 Added /list [group] and some more detailed configuration regarding /list 2013-03-18 06:16:02 +00:00
GunfighterJ
ce51a07bf1 Potion erroring and duration/power fix 2013-03-18 06:14:44 +00:00
Necrodoom
5e4659e6ae update IDs 27, 28, 66, 157
update rails aliases to match bukkit item names
2013-03-18 06:14:00 +00:00
GunfighterJ
2f96ef1e97 [Fix] Potion erroring and duration/power fix 2013-03-17 13:34:10 -05:00
KHobbits
5ea1bdec56 [Fix] Restore /speed command's ability to control walk speed. 2013-03-17 06:38:24 +00:00
KHobbits
f338d3c135 Fixing TL edit error. 2013-03-16 12:17:13 +00:00
Necrodoom
20d019383f Update messages.properties
fix typos in new messages
2013-03-16 12:15:57 +00:00
KHobbits
ee080e56c2 Fix raw bukkit itemdb lookup 2013-03-16 12:11:03 +00:00
KHobbits
d9a238fb80 Cleanup open inventories 2013-03-16 11:01:56 +00:00
KHobbits
3ddf883d5d Import cleanup 2013-03-16 09:19:30 +00:00
KHobbits
1111254e46 Fix potion effect errors 2013-03-16 09:13:21 +00:00
KHobbits
6185581962 Fix Minecart class rename
Lets use consistent versions in the code base
Bukkit: 1700 CB: 2648
2013-03-16 08:55:39 +00:00
KHobbits
24a9a74fd5 We use tabs not spaces for indenting. 2013-03-16 08:43:52 +00:00
KHobbits
208d673c2b Check health is 0 after /suicide 2013-03-16 08:42:24 +00:00
KHobbits
2b0506de77 Fix missing /ci syntax update. 2013-03-16 08:32:21 +00:00
Alexander Schepp
d63e259461 Merge pull request #388 from GunfighterJ/2.9
[Feature] Additional spawnable mob types
2013-03-15 13:44:43 -07:00
GunfighterJ
c8a867be38 [Feature] Additional spawnable mob types 2013-03-15 15:41:23 -05:00
Alexander Schepp
734286e8d3 Merge pull request #387 from GunfighterJ/2.9
Initial 1.5 update
2013-03-15 12:59:50 -07:00
GunfighterJ
96c5bebdf2 Initial 1.5 update 2013-03-15 14:54:51 -05:00
Alexander Schepp
fc96d7e0e9 Merge pull request #342 from necrodoom/patch-60
[feature] update items.csv to minecraft 1.5
2013-03-15 12:25:09 -07:00
KHobbits
fa445790e7 Merge pull request #383 from necrodoom/patch-73
[fix] trying to AFK others should work now
2013-03-15 06:28:56 -07:00
KHobbits
20b61a6147 Merge branch 'groupmanager' of github.com:essentials/Essentials into 2.9 2013-03-14 18:01:50 +00:00
Iaccidentally
c61abadd91 Merge pull request #385 from Skylexia/patch-1
[Fix] Fixing message (Tl key).
2013-03-13 17:41:10 -07:00
Skylexia
89c1cc5503 Fixing message. 2013-03-13 20:23:01 -03:00
KHobbits
db86648b84 Fix missing console notifications on /unban and /unbanip 2013-03-12 22:26:24 +00:00
Necrodoom
e68035cc7a [fix] trying to AFK others should work now 2013-03-11 15:36:12 +02:00
KHobbits
895c14430a Fixing ban ip broadcast notification. 2013-03-11 10:33:59 +00:00
KHobbits
664fe18bbe Fix Essentials version display 2013-03-11 02:01:57 +00:00
KHobbits
e60c65cfc5 Fixed lost TL. 2013-03-10 23:43:13 +00:00
Skylexia-PC
6b70899484 Shows IP unbans to online staff. 2013-03-10 23:41:17 +00:00
Necrodoom
973e918d3a readd some checks 2013-03-10 14:42:03 +02:00
KHobbits
5cfb9326f6 Merge pull request #380 from Skylexia/2.9
[Feature] Broadcast unbans to online staff.
2013-03-10 00:38:09 -08:00
Skylexia-PC
16857da2b4 Update tl properties to remove unused properties. 2013-03-10 04:37:04 -04:00
Skylexia-PC
ee7b50a014 [Feature] Broadcast unbans to online staff. 2013-03-10 03:22:35 -04:00
KHobbits
56bd973e94 Use lower locale. 2013-03-10 02:04:11 +00:00
KHobbits
9ff0571cea Protect us from npe. 2013-03-10 02:01:59 +00:00
Iaccidentally
fc019af9f6 Merge pull request #379 from GunfighterJ/2.9
Allow potion meta to work
2013-03-09 16:46:59 -08:00
GunfighterJ
937ef0bb85 Allow potion meta to work
Instead of denying if they have perms
2013-03-09 18:38:59 -06:00
KHobbits
45fe5f2c02 Fix TL key casing. 2013-03-09 21:41:30 +00:00
KHobbits
b1f427d52e [Fix] Allow /nick to change nickname case, without adding prefix character. 2013-03-09 14:24:19 +00:00
KHobbits
46e9471a63 [Fix] Move allowunsafe enchant perm to: essentials.enchantments.allowunsafe 2013-03-09 14:02:34 +00:00
KHobbits
4d9685e10d [Fix] Move all enchant type perms to: essentials.enchantments.<enchant>
[Fix] Move all potion effect perms to: essentials.potions.<effect>
[Fix] Move multiple potion perm to: essentials.potions.multiple
Other perms: essentials.itemspawn.meta-(firework|firework-multiple|firework-power|name|lore|head|book|chapter|chapter-<chapter>|author|title)
2013-03-09 13:56:38 +00:00
Necrodoom
fd3cdde354 fix alias 2013-03-09 15:12:15 +02:00
KHobbits
d93719ebcf Merge pull request #378 from Skylexia/2.9
Fixing exp trading type.
2013-03-08 14:08:08 -08:00
Skylexia-PC
63b2766e2b Fixing exp trading type. 2013-03-08 17:04:54 -05:00
KHobbits
6d552281d4 Allow item/item trades still. 2013-03-08 12:34:11 +00:00
KHobbits
6436baf7a4 Merge pull request #370 from necrodoom/patch-71
[fix] EssentialsAntiBuild shouldn't run without Essentials
2013-03-08 04:01:08 -08:00
KHobbits
896298a9e8 Clean up meta error messages.
Add enchant perm checks back.
2013-03-07 03:17:58 +00:00
KHobbits
7d0fafd084 Don't check people for meta perms when using kits. 2013-03-07 02:57:25 +00:00
KHobbits
32d44eb13d Merge pull request #375 from GunfighterJ/patch-15
[Feature] Adds meta permissions
2013-03-06 18:46:55 -08:00
KHobbits
c275626bee [Fix] Prevent same item type trades on signs, prevents amount confusion scams. 2013-03-07 02:42:47 +00:00
KHobbits
861b04b680 Fix cleanup comparison number base 2013-03-06 23:39:11 +00:00
KHobbits
d8e4862e82 Add cleanup logging to debug mode. 2013-03-06 22:36:36 +00:00
GunfighterJ
4aaf0eda79 [Feature] Adds meta permissions
TL MetaItemStack.java
Some meta cleanup
Parameter refactor for clarity
Full list of added perms http://goo.gl/do1XL
2013-03-06 15:09:51 -06:00
KHobbits
2f9dcfee16 Fix a color code mistake. 2013-03-06 20:46:19 +00:00
KHobbits
292f8a8799 Sort TL files. 2013-03-06 17:44:05 +00:00
Necrodoom
ec87104c57 add armor aliases since new leather names 2013-03-05 18:56:40 +02:00
KHobbits
d7588e61bc [Fix] Unify item spawning permissions in /give 2013-03-03 20:33:23 +00:00
Necrodoom
061794e86d add mising isopoverride check 2013-03-03 18:35:05 +02:00
KHobbits
b9285b2aeb Merge pull request #372 from skmedix/patch-21
Update messages_pl.properties
2013-03-02 09:43:35 -08:00
SKmedix
2187b7536e Update messages_pl.properties
Update Polish translations.
---
Date: 2.03.13

---
Added "playerBanIpAddress" (27)
2013-03-02 18:41:04 +01:00
KHobbits
86c0767833 Fix /banip so it compiles, also throw it through a DRYer. 2013-03-02 17:08:22 +00:00
Necrodoom
090c1f6f83 Include IP address when banning IP 2013-03-02 17:08:16 +00:00
Necrodoom
69c40a2f1a add new commands, add alias to listgroups 2013-03-02 10:03:45 +02:00
Necrodoom
42edd14939 Update GroupManagerPermissions.java 2013-03-02 09:56:38 +02:00
Necrodoom
dba47cb44c fix clear commands change mandemote and manpromote
dont make manpromote and mandemote act like manuadd when OP, 3 manuadd commands arent needed.
2013-03-02 09:50:31 +02:00
Necrodoom
b020983471 messages fix, add /manuclearp and /mangclearp 2013-03-01 20:48:12 +02:00
ementalo
13efbb666d Remove reference to c3p0 from build.xml 2013-02-28 21:23:33 +00:00
ementalo
8d77a3f941 [Breaking] Remove protect database functionality for protecting signs and rails.
- Removed config entries
- Removed c3p0 lib
2013-02-28 21:02:37 +00:00
Necrodoom
8f785598b0 [fix] essantibuild shouldnt run without essentials 2013-02-28 19:04:05 +02:00
KHobbits
58b1b34e44 Merge pull request #369 from TheReverend403/2.9
Fix geoip messages
2013-02-28 05:32:42 -08:00
Lee Watson
ffbc05144c Updated ALL local files 2013-02-28 13:23:28 +00:00
KHobbits
207a8d1b4f Merge pull request #364 from necrodoom/patch-69
deny empty warp name
2013-02-28 04:55:40 -08:00
KHobbits
919f3abe6d Merge pull request #357 from skmedix/patch-20
Update Essentials/src/messages_pl.properties
2013-02-28 04:53:58 -08:00
KHobbits
c1f66fc817 [Fix] Charging players at wrong point in /spawn 2013-02-28 12:52:22 +00:00
KHobbits
8d2b10d783 Add extra trade log messages for sign charges. 2013-02-28 03:15:21 +00:00
Necrodoom
38b7fa64fa deny empty warp name 2013-02-26 19:07:10 +02:00
ElgarL
f5ed4dd6cd Merge pull request #361 from necrodoom/patch-66
add catches for the last 2 config settings
2013-02-26 08:49:40 -08:00
ElgarL
17dab04094 Merge pull request #362 from necrodoom/patch-67
fix a few groupmanager.java errors
2013-02-26 06:43:31 -08:00
Necrodoom
308f05b8bf change commandblock message 2013-02-26 13:05:45 +02:00
Necrodoom
48db088fb4 fix a few groupmanager.java errors 2013-02-26 12:27:05 +02:00
Necrodoom
9965e41567 add catches for the last 2 config settings 2013-02-26 12:17:26 +02:00
Iaccidentally
0ddcfafbc0 This is still needed. 2013-02-25 22:44:52 -05:00
KHobbits
6f55e4b316 Revert "[Spawn] Please join me in welcoming EssentialsSpawn to Java 1.6 and modern bukkit.
This reverts commit a11e8d4236.
If you don't understand the code, don't touch it.
2013-02-26 03:30:11 +00:00
Iaccidentally
de91073dda Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2013-02-25 22:01:49 -05:00
Iaccidentally
a11e8d4236 [Spawn] Please join me in welcoming EssentialsSpawn to Java 1.6 and modern bukkit. :: http://i.imgur.com/79Izo.jpg 2013-02-25 22:01:06 -05:00
Iaccidentally
bf8f0365d9 Merge pull request #360 from GunfighterJ/patch-15
[Protect] Prevent creepers from breaking paintings if their explosions a...
2013-02-25 18:46:44 -08:00
GunfighterJ
d5f702f2cb [Protect] Prevent creepers from breaking paintings if their explosions are disabled.
Backport from 3.0
2013-02-25 17:15:20 -06:00
ElgarL
c1b4ed5920 Show the world a group change is made in when using notify. 2013-02-25 14:11:42 +00:00
ElgarL
cc83553d72 Store worldSelection indexed on the senders name rather than the object
(fixes commandblocks using manselect).
2013-02-25 13:49:18 +00:00
ElgarL
643a9be985 Only prevent adding nodes with '/manuaddp' and '/mangaddp' if they are
exact matches (not wildcards).
2013-02-25 12:47:23 +00:00
ElgarL
9f13653be6 Warn when adding a node where an exception already exist. 2013-02-25 10:46:16 +00:00
ElgarL
5f5a9adf31 Don't allow adding a node with '/manuaddp' and '/mangaddp' which is
already negated.
2013-02-25 10:27:01 +00:00
ElgarL
29746df914 Fix setting of accessLevel on User level permission tests. 2013-02-25 10:11:44 +00:00
SKmedix
c3b42993de Update Essentials/src/messages_pl.properties
Update Polish translations.
---
Date: 24.02.13

---
+ Added "noMatchingPlayers" (509)
+ Added "matchingIPAddress" (510)
+ Added "runningPlayerMatch" (511)
* Fixed "adventure" (8)
* Fixed "antiBuildInteract" (14)
2013-02-24 11:45:56 +01:00
KHobbits
964bdc6d30 [Feature] Allow IP lookup in /seen command.
[Permission] essentials.seen.ipsearch - allows /seen <ip address>
2013-02-24 03:55:20 +00:00
KHobbits
3d5aa40965 Clarify vanish status a little. 2013-02-23 23:34:31 +00:00
Iaccidentally
26352ac6b6 Merge pull request #352 from GunfighterJ/patch-15
[Fix] Persist yaw and pitch on teleport
2013-02-23 11:57:15 -08:00
KHobbits
00ec717e7d Merge pull request #356 from skmedix/patch-19
Update Essentials/src/messages_pl.properties
2013-02-23 05:26:21 -08:00
skmedix
f70015e8c5 Update Essentials/src/messages_pl.properties
Update Polish translations.
---
Date: 23.02.13
---
* Fixed "fireworkSyntax" (502)
* Fixed colors.
2013-02-23 11:08:47 +01:00
ElgarL
399be38680 Merge pull request #355 from necrodoom/patch-63
add "all_unnamed_worlds" info
2013-02-22 12:47:12 -08:00
Necrodoom
3bceecdfb6 fix typo 2013-02-22 20:49:57 +02:00
Necrodoom
68b95c668d add "all_unnamed_worlds" info 2013-02-22 20:48:09 +02:00
ElgarL
a7648c7c12 Only one error this time Necrodoom :) 2013-02-22 17:21:14 +00:00
ElgarL
bda3c32370 Merge pull request #353 from necrodoom/patch-61
various messages fixes - This better work!!!!!!
2013-02-22 09:19:56 -08:00
ElgarL
9ce067a7fd Fix global mirroring of non main worlds. 2013-02-22 17:07:55 +00:00
Necrodoom
ef7d323902 various messages fixes 2013-02-22 19:07:01 +02:00
GunfighterJ
b83a8eccee [Fix] Persist yaw and pitch on teleport
Vanilla bukkit/MC persists yaw on teleport
2013-02-22 10:56:39 -06:00
ElgarL
51ddcdcf87 Merge pull request #351 from GunfighterJ/gm-patch-1
Receive was spelt wrong
2013-02-22 05:56:53 -08:00
GunfighterJ
8ca738a436 I before E except after C 2013-02-22 07:50:54 -06:00
ElgarL
f9b5d74f6d Do not list "all_unnamed_worlds" as a selectable world. 2013-02-22 13:17:58 +00:00
ElgarL
8960417d56 Don't try to use the worldHolder before it's initialised. 2013-02-22 12:59:50 +00:00
ElgarL
90730f63d5 Added a new mirroring option in the config of 'all_unnamed_worlds'. This
will cause all new or unnamed worlds to use this mirroring.
2013-02-22 12:39:41 +00:00
ElgarL
13e07f64ec '/manselect' will no longer list duplicate worlds. 2013-02-22 11:46:59 +00:00
KHobbits
6308b1ecf3 Merge pull request #350 from skmedix/patch-18
Update Polish TL - Thanks to andrewkm for proofing.
2013-02-22 02:44:03 -08:00
skmedix
dff7e81b7f Update Essentials/src/messages_pl.properties
Update Polish translations.
---
Date: 21.02.13
---
+ Added "cleaned" (42)
+ Added "cleaned" (43)
2013-02-21 11:03:06 +01:00
GunfighterJ
bf0a11e4fe Cache teleport invulnerability time 2013-02-20 13:46:28 +00:00
Chris Ward
c9efe14ad3 Final! 2013-02-20 12:46:47 +11:00
KHobbits
64ee6b7914 Readme cleanup. 2013-02-20 01:39:04 +00:00
KHobbits
6ae6c51dc0 Code cleanup 2013-02-19 23:06:04 +00:00
kukelekuuk00
8710a133ce Added /essentials cleanup <days> [money] [homes] [bans]
Delete userdata of players offline for over <days> and with less money than [money], less homes than [homes] and less bans than [bans].
2013-02-19 22:43:23 +00:00
Necrodoom
32b1ce9e39 add 1.5 new slab blocks 2013-02-19 19:47:49 +02:00
Necrodoom
c982592674 update items.csv to minecraft 1.5
dont pull till 1.5 bukkit devbuild
2013-02-19 13:35:29 +02:00
Chris Ward
ff02f0e270 Merge pull request #341 from necrodoom/patch-59
fix rest of "posion" aliases
2013-02-19 02:26:44 -08:00
Necrodoom
8f52908eed fix rest of "posion" aliases 2013-02-19 11:46:26 +02:00
GunfighterJ
8f8fc4a08d Fixes Necrodoom's code Needs more exception 2013-02-18 15:25:09 +00:00
Necrodoom
e63276242c make sure player isnt dead before healing 2013-02-18 15:08:55 +00:00
KHobbits
3ddbeea45a Fix socialspy command list. 2013-02-17 18:05:07 +00:00
ElgarL
7f972801bf Fix Necrodooms code...again! 2013-02-17 17:24:52 +00:00
ElgarL
36e354388c Merge pull request #338 from necrodoom/patch-57
if variable is inside ' ', strip them
2013-02-17 09:22:36 -08:00
ElgarL
bbd0021a8b Merge pull request #328 from necrodoom/patch-53
delete player command messages, bukkit does it
2013-02-17 09:21:12 -08:00
Necrodoom
880fb29b44 if variable is inside ' ', strip them 2013-02-17 19:09:04 +02:00
KHobbits
31f3662101 Clarify command disabling. 2013-02-17 16:30:05 +00:00
Necrodoom
5f2c759a8f fix auto afk description 2013-02-17 16:26:18 +00:00
KHobbits
a91cfbf43a Merge pull request #334 from necrodoom/patch-54
add skull alias to head item
2013-02-17 08:17:10 -08:00
Necrodoom
33fa32cbff add skull alias to head item 2013-02-17 18:15:48 +02:00
snowleo
69e941670f why do we even remove the items?
derp
2013-02-17 15:34:49 +01:00
snowleo
af10a2050a Revert the last 2 commits and actually fix the right one. 2013-02-17 15:17:47 +01:00
snowleo
ce9e630072 Fix all removeItem()
This could fix some broken logging of selling items
2013-02-17 15:10:41 +01:00
snowleo
ef063c255e Items can't be reused after the have been used in removeItem 2013-02-17 15:07:32 +01:00
KHobbits
0e7d64f9e7 Fix a couple of cosmetic errors in /seen 2013-02-17 01:18:50 +00:00
Skylexia
2a91f593de Fixed colour coding.
Fixed colour coding.

Fixed colour coding.

Fixed colour coding.

Fixed colour coding.

Fixed colour coding.

Fixed colour coding.

Fixed colour coding.

Fixed colour coding.

Fixed colour coding.

Fixed colour coding.

Fixed colour coding.

Fixed colour coding.

totalWorthAll
totalWorthBlocks
2013-02-16 18:22:25 +00:00
KHobbits
9186ca2c9a Merge pull request #333 from GunfighterJ/patch-12
Adds optional argument to clear both inventory and armor with /clear
2013-02-16 08:40:44 -08:00
GunfighterJ
f1e4e49779 Adds optional argument to clear inventory and armor with /clear 2013-02-15 12:38:41 -06:00
ElgarL
3740f200f8 Catch the error when using an out of date config for
'allow_commandblocks' So it doesn't kill the whole config.
2013-02-15 17:39:34 +00:00
KHobbits
5840c02efc Merge pull request #331 from kukelekuuk00/2.9
Add methods to UserData and IUser for accessing and writing of data from other plugins.
2013-02-14 03:05:41 -08:00
kukelekuuk00
f16907412d Add a method to write to the userdata to UserData.java and IUser.java. 2013-02-13 08:24:25 -06:00
Iaccidentally
44a6f4d562 Merge branch '2.9' of https://github.com/essentials/Essentials.git into 2.9 2013-02-12 18:38:35 -05:00
Iaccidentally
ec8c778f68 Clean up protect :: transient is not needed :: remove unnecessary returns :: @Override all the things! 2013-02-12 18:37:40 -05:00
KHobbits
56df6b36a5 Fix /give|/item descriptions for itemmeta. 2013-02-12 22:56:17 +00:00
KHobbits
30b65a0bc7 Merge branch '2.9' of github.com:essentials/Essentials into patch-41 2013-02-12 22:46:35 +00:00
Necrodoom
0dc8980d32 remove color from bedNull 2013-02-12 22:45:54 +00:00
KHobbits
fa8b8bec5a fix typo in messages
add new messages to messages.properties

add new messages to messages_en.properties

add new messages to messages_cs.properties

add new messages to messages_da.properties

add new messages to messages_de.properties

add new messages to messages_es.properties

add new messages to messages_fi.properties

add new messages to messages_fr.properties

add new messages to messages_it.properties

add new messages to messages_nl.properties

add new messages to messages_pl.properties

add new messages to messages_pt.properties

add new messages to messages_se.properties

remove color from bedNull

remove color from bedNull

remove color from bedNull

remove color from bedNull

remove color from bedNull

remove color from bedNull

remove color from bedNull

remove color from bedNull

remove color from bedNull

remove color from bedNull

remove color from bedNull

remove color from bedNull
2013-02-12 22:45:54 +00:00
Necrodoom
63c7d4519a change bed spawn set message 2013-02-12 22:43:07 +00:00
Necrodoom
2a816cef7b try improve bed spawn handle
dont act as if bed doesnt exist if its missing
2013-02-12 22:43:06 +00:00
Iaccidentally
c2d904ac7d Fix build :: This is what happens when you don't use an IDE 2013-02-12 17:42:04 -05:00
Necrodoom
911224dc64 fix typo 2013-02-12 22:26:02 +00:00
KHobbits
0ad765e1c8 add inventoryclearall message
update messages.properties

update messages_en.properties

update messages_da.properties

update messages_de.properties

update messages_en.properties

update messages_es.properties

update messages_fi.properties

update messages_fr.properties

update messages_it.properties

update messages_nl.properties

update messages_pl.properties

update messages_pt.properties

update messages_se.properties
2013-02-12 22:26:02 +00:00
Skylexia
9db040edd4 Update Essentials/src/config.yml 2013-02-12 17:17:48 -05:00
Skylexia
c0f3e9073d Update Essentials/src/plugin.yml 2013-02-12 17:13:08 -05:00
Necrodoom
e4565de717 delete player command messages, bukkit does it 2013-02-12 16:56:54 +02:00
ElgarL
33382f9940 Merge pull request #327 from necrodoom/patch-52
add missing return false in manudelp
2013-02-12 06:49:27 -08:00
Necrodoom
1d0c2f75dc add missing return false; 2013-02-12 16:47:39 +02:00
KHobbits
c3f0d34293 Minor entity optimization. 2013-02-11 23:33:30 +00:00
KHobbits
c298fb9332 Attempt to optimize Essentials login event. 2013-02-11 23:11:37 +00:00
KHobbits
a1f1319990 Merge pull request #325 from Skylexia/patch-2
Fixed all "poison" typos; add ppotato alias.
2013-02-11 15:00:14 -08:00
Skylexia
2316bfbd28 Update Essentials/src/items.csv 2013-02-11 17:57:20 -05:00
KHobbits
96348a5e92 Merge pull request #324 from Skylexia/patch-1
Update Essentials/src/items.csv
2013-02-11 10:41:09 -08:00
Skylexia
d9903efcf4 Update Essentials/src/items.csv 2013-02-11 13:38:11 -05:00
KHobbits
bc90deb87d Merge pull request #322 from necrodoom/patch-50
add dye aliases to match bukkit
2013-02-11 09:22:56 -08:00
Necrodoom
c35e5bf53a add dye aliases to match bukkit 2013-02-11 18:56:23 +02:00
KHobbits
8ea0a152d4 Merge pull request #321 from GunfighterJ/patch-10
Fix array index out of bounds on /firework fire
2013-02-11 08:41:47 -08:00
GunfighterJ
8e205768b3 Fix array index out of bounds on /firework fire 2013-02-11 10:35:55 -06:00
ElgarL
fcfa3ce31d Merge pull request #298 from necrodoom/patch-37
Fix typo at groupmanager config.yml
2013-02-10 02:12:42 -08:00
Chris Ward
05aeba521f Merge pull request #317 from necrodoom/patch-47
update AFK documation
2013-02-10 01:54:37 -08:00
Necrodoom
8dff1155bf update AFK documation 2013-02-10 11:46:59 +02:00
Chris Ward
b6648ad9bd Fix compilation, unreachable code. 2013-02-10 20:37:46 +11:00
Chris Ward
40f03295a1 Merge pull request #316 from necrodoom/patch-46
throw exception on banexempt
2013-02-10 01:34:53 -08:00
Necrodoom
5fdb10a5bf throw exception on banexempt
match rest of moderator commands
2013-02-10 11:04:55 +02:00
KHobbits
e9bb2df87d Fix kit messages when giving kit to another player. 2013-02-10 00:07:40 +00:00
KHobbits
be29e4da59 missing alias 2013-02-09 23:39:21 +00:00
GunfighterJ
b2a0166c46 Proper TL 2013-02-09 16:27:54 -06:00
GunfighterJ
03b115d4c3 Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2013-02-09 16:27:19 -06:00
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
GunfighterJ
37029e6b5d Un-deletes deleted things. 2013-02-08 17:14:46 -06:00
GunfighterJ
631e0bbd0a Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2013-02-08 16:05:48 -06: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
GunfighterJ
ef341ae539 Adds potion meta
Some cleanup as well
2013-02-05 13:13:19 -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
dd095e15cb Fix typo at groupmanager config.yml 2013-02-05 13:13:00 +02: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
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
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
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
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
KHobbits
4e399778b4 Merge branch '2.9' of github.com:essentials/Essentials into 2.9 2012-12-19 12:54:00 +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
258fbdb0e8 Merge pull request #216 from chrisgward/patch-1
Add tempban limit (with override node)
2012-12-18 02:24:45 -08:00
Chris Ward
ecf5d47e97 Add tempban limit (with override node) and console override to exempt node. 2012-12-17 02:12:38 +11:00
Necrodoom
30bc597851 update items.csv to minecraft 1.4.6 2012-12-16 12:52:16 +02:00
Iaccidentally
92bdd51cd4 Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2012-11-27 14:54:18 -05:00
Iaccidentally
4a4f443fee Merge branch '2.9' of https://github.com/essentials/Essentials into 2.9 2012-11-24 14:55:54 -05:00
Iaccidentally
fd87933aa9 Merge remote-tracking branch 'remotes/origin/release' into 2.9 2012-11-13 22:57:14 -05:00
315 changed files with 15995 additions and 10994 deletions

17
.travis.yml Normal file
View File

@@ -0,0 +1,17 @@
language: java
jdk:
- oraclejdk7
- openjdk7
- openjdk6
script: ant collect
notifications:
irc:
channels:
- "irc.esper.net#lain"
on_success: change
on_failure: always
email:
recipients:
- "khobbits@ess3.net"
on_success: change
on_failure: always

View File

@@ -934,13 +934,6 @@ is divided into following sections:
<param name="call.target" value="jar"/>
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
</antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-jar.properties}"/>
<param location="${project.EssentialsGroupBridge}" name="call.subproject"/>
<param location="${project.EssentialsGroupBridge}/build.xml" name="call.script"/>
<param name="call.target" value="jar"/>
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
</antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-jar.properties}"/>
<param location="${project.EssentialsGroupManager}" name="call.subproject"/>
@@ -1477,13 +1470,6 @@ is divided into following sections:
<param name="call.target" value="clean"/>
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
</antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-clean.properties}"/>
<param location="${project.EssentialsGroupBridge}" name="call.subproject"/>
<param location="${project.EssentialsGroupBridge}/build.xml" name="call.script"/>
<param name="call.target" value="clean"/>
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
</antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-clean.properties}"/>
<param location="${project.EssentialsGroupManager}" name="call.subproject"/>

View File

@@ -1,4 +1,4 @@
build.xml.data.CRC32=b4df970c
build.xml.data.CRC32=cab45985
build.xml.script.CRC32=7a797370
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.

View File

@@ -70,7 +70,6 @@ javac.classpath=\
${reference.EssentialsProtect.jar}:\
${reference.EssentialsSpawn.jar}:\
${reference.EssentialsGeoIP.jar}:\
${reference.EssentialsGroupBridge.jar}:\
${reference.EssentialsXMPP.jar}:\
${reference.EssentialsGroupManager.jar}
# Space-separated list of extra javac options
@@ -102,7 +101,6 @@ platform.active=default_platform
project.Essentials=../Essentials
project.EssentialsChat=../EssentialsChat
project.EssentialsGeoIP=../EssentialsGeoIP
project.EssentialsGroupBridge=../EssentialsGroupBridge
project.EssentialsGroupManager=../EssentialsGroupManager
project.EssentialsAntiBuild=../EssentialsAntiBuild
project.EssentialsProtect=../EssentialsProtect
@@ -111,7 +109,6 @@ project.EssentialsXMPP=../EssentialsXMPP
reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar
reference.EssentialsChat.jar=${project.EssentialsChat}/dist/EssentialsChat.jar
reference.EssentialsGeoIP.jar=${project.EssentialsGeoIP}/dist/EssentialsGeoIP.jar
reference.EssentialsGroupBridge.jar=${project.EssentialsGroupBridge}/dist/EssentialsGroupBridge.jar
reference.EssentialsGroupManager.jar=${project.EssentialsGroupManager}/dist/EssentialsGroupManager.jar
reference.EssentialsAntiBuild.jar=${project.EssentialsAntiBuild}/dist/EssentialsAntiBuild.jar
reference.EssentialsProtect.jar=${project.EssentialsProtect}/dist/EssentialsProtect.jar

View File

@@ -39,14 +39,6 @@
<clean-target>clean</clean-target>
<id>jar</id>
</reference>
<reference>
<foreign-project>EssentialsGroupBridge</foreign-project>
<artifact-type>jar</artifact-type>
<script>build.xml</script>
<target>jar</target>
<clean-target>clean</clean-target>
<id>jar</id>
</reference>
<reference>
<foreign-project>EssentialsGroupManager</foreign-project>
<artifact-type>jar</artifact-type>

View File

@@ -395,6 +395,11 @@ is divided into following sections:
</and>
</condition>
</target>
<target name="-init-test-properties">
<property name="test.binaryincludes" value="&lt;nothing&gt;"/>
<property name="test.binarytestincludes" value=""/>
<property name="test.binaryexcludes" value=""/>
</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"/>
@@ -418,7 +423,7 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-batch" unless="${nb.junit.single}">
<target depends="-init-test-properties" 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"/>
@@ -432,6 +437,9 @@ is divided into following sections:
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
<fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
<filename name="${test.binarytestincludes}"/>
</fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
@@ -559,7 +567,7 @@ is divided into following sections:
</sequential>
</macrodef>
</target>
<target if="${nb.junit.batch}" name="-init-macrodef-junit-debug-batch">
<target depends="-init-test-properties" 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"/>
@@ -573,6 +581,9 @@ is divided into following sections:
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
<filename name="@{testincludes}"/>
</fileset>
<fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes},${test.binaryexcludes}" includes="${test.binaryincludes}">
<filename name="${test.binarytestincludes}"/>
</fileset>
</batchtest>
<syspropertyset>
<propertyref prefix="test-sys-prop."/>
@@ -952,7 +963,7 @@ is divided into following sections:
<target if="has.persistence.xml" name="-copy-persistence-xml">
<mkdir dir="${build.classes.dir}/META-INF"/>
<copy todir="${build.classes.dir}/META-INF">
<fileset dir="${meta.inf.dir}" includes="persistence.xml"/>
<fileset dir="${meta.inf.dir}" includes="persistence.xml orm.xml"/>
</copy>
</target>
<target name="-post-compile">

View File

@@ -4,8 +4,8 @@ build.xml.stylesheet.CRC32=28e38971@1.38.2.45
# 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=a830bc14
nbproject/build-impl.xml.script.CRC32=7c507372
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
nbproject/build-impl.xml.script.CRC32=21ffdddf
nbproject/build-impl.xml.stylesheet.CRC32=c6d2a60f@1.56.1.46
nbproject/profiler-build-impl.xml.data.CRC32=ab78ce15
nbproject/profiler-build-impl.xml.script.CRC32=abda56ed
nbproject/profiler-build-impl.xml.stylesheet.CRC32=f10cf54c@1.11.1

View File

@@ -78,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
@@ -97,7 +98,8 @@ javac.classpath=\
${file.reference.bukkit.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=-Xlint:unchecked
javac.deprecation=false

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

@@ -25,16 +25,33 @@ public class Backup implements Runnable
server = ess.getServer();
if (server.getOnlinePlayers().length > 0)
{
startTask();
ess.runTaskAsynchronously(new Runnable()
{
@Override
public void run()
{
startTask();
}
});
}
}
void onPlayerJoin()
public void onPlayerJoin()
{
startTask();
}
private void startTask()
public synchronized void stopTask()
{
running = false;
if (taskId != -1)
{
server.getScheduler().cancelTask(taskId);
}
taskId = -1;
}
private synchronized void startTask()
{
if (!running)
{
@@ -61,7 +78,8 @@ public class Backup implements Runnable
{
return;
}
if ("save-all".equalsIgnoreCase(command)) {
if ("save-all".equalsIgnoreCase(command))
{
final CommandSender cs = server.getConsoleSender();
server.dispatchCommand(cs, "save-all");
active = false;
@@ -72,7 +90,7 @@ public class Backup implements Runnable
server.dispatchCommand(cs, "save-all");
server.dispatchCommand(cs, "save-off");
ess.scheduleAsyncDelayedTask(
ess.runTaskAsynchronously(
new Runnable()
{
@Override
@@ -123,11 +141,7 @@ public class Backup implements Runnable
server.dispatchCommand(cs, "save-on");
if (server.getOnlinePlayers().length == 0)
{
running = false;
if (taskId != -1)
{
server.getScheduler().cancelTask(taskId);
}
stopTask();
}
active = false;
LOGGER.log(Level.INFO, _("backupFinished"));

View File

@@ -1,17 +1,16 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.HashMap;
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,72 +19,82 @@ 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);
ENCHANTMENTS.put("baneofarthropods", Enchantment.DAMAGE_ARTHROPODS);
ALIASENCHANTMENTS.put("baneofarthropod", Enchantment.DAMAGE_ARTHROPODS);
ALIASENCHANTMENTS.put("arthropod", Enchantment.DAMAGE_ARTHROPODS);
ALIASENCHANTMENTS.put("dar", Enchantment.DAMAGE_ARTHROPODS);
ENCHANTMENTS.put("undeaddamage", Enchantment.DAMAGE_UNDEAD);
ENCHANTMENTS.put("smite", Enchantment.DAMAGE_UNDEAD);
ALIASENCHANTMENTS.put("du", Enchantment.DAMAGE_UNDEAD);
ENCHANTMENTS.put("digspeed", Enchantment.DIG_SPEED);
ENCHANTMENTS.put("efficiency", Enchantment.DIG_SPEED);
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);
ALIASENCHANTMENTS.put("meleeflame", Enchantment.FIRE_ASPECT);
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);
ENCHANTMENTS.put("mobloot", Enchantment.LOOT_BONUS_MOBS);
ENCHANTMENTS.put("looting", Enchantment.LOOT_BONUS_MOBS);
ALIASENCHANTMENTS.put("lbm", Enchantment.LOOT_BONUS_MOBS);
ALIASENCHANTMENTS.put("oxygen", Enchantment.OXYGEN);
ENCHANTMENTS.put("respiration", Enchantment.OXYGEN);
ALIASENCHANTMENTS.put("breathing", Enchantment.OXYGEN);
ENCHANTMENTS.put("breath", Enchantment.OXYGEN);
ALIASENCHANTMENTS.put("o", Enchantment.OXYGEN);
ENCHANTMENTS.put("protection", Enchantment.PROTECTION_ENVIRONMENTAL);
ALIASENCHANTMENTS.put("prot", Enchantment.PROTECTION_ENVIRONMENTAL);
ENCHANTMENTS.put("protect", Enchantment.PROTECTION_ENVIRONMENTAL);
ALIASENCHANTMENTS.put("p", Enchantment.PROTECTION_ENVIRONMENTAL);
ALIASENCHANTMENTS.put("explosionsprotection", Enchantment.PROTECTION_EXPLOSIONS);
ALIASENCHANTMENTS.put("explosionprotection", Enchantment.PROTECTION_EXPLOSIONS);
ALIASENCHANTMENTS.put("expprot", Enchantment.PROTECTION_EXPLOSIONS);
ALIASENCHANTMENTS.put("blastprotection", Enchantment.PROTECTION_EXPLOSIONS);
ENCHANTMENTS.put("blastprotect", Enchantment.PROTECTION_EXPLOSIONS);
ALIASENCHANTMENTS.put("pe", Enchantment.PROTECTION_EXPLOSIONS);
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);
ALIASENCHANTMENTS.put("flameprotection", Enchantment.PROTECTION_FIRE);
ENCHANTMENTS.put("fireprotect", Enchantment.PROTECTION_FIRE);
@@ -93,36 +102,36 @@ public class Enchantments
ENCHANTMENTS.put("fireprot", Enchantment.PROTECTION_FIRE);
ALIASENCHANTMENTS.put("flameprot", Enchantment.PROTECTION_FIRE);
ALIASENCHANTMENTS.put("pf", Enchantment.PROTECTION_FIRE);
ENCHANTMENTS.put("projectileprotection", Enchantment.PROTECTION_PROJECTILE);
ENCHANTMENTS.put("projprot", Enchantment.PROTECTION_PROJECTILE);
ALIASENCHANTMENTS.put("pp", Enchantment.PROTECTION_PROJECTILE);
ENCHANTMENTS.put("silktouch", Enchantment.SILK_TOUCH);
ALIASENCHANTMENTS.put("softtouch", Enchantment.SILK_TOUCH);
ALIASENCHANTMENTS.put("st", Enchantment.SILK_TOUCH);
ENCHANTMENTS.put("waterworker", Enchantment.WATER_WORKER);
ENCHANTMENTS.put("aquaaffinity", Enchantment.WATER_WORKER);
ALIASENCHANTMENTS.put("watermine", Enchantment.WATER_WORKER);
ALIASENCHANTMENTS.put("ww", Enchantment.WATER_WORKER);
ALIASENCHANTMENTS.put("firearrow", Enchantment.ARROW_FIRE);
ENCHANTMENTS.put("flame", Enchantment.ARROW_FIRE);
ENCHANTMENTS.put("flamearrow", Enchantment.ARROW_FIRE);
ALIASENCHANTMENTS.put("af", Enchantment.ARROW_FIRE);
ENCHANTMENTS.put("arrowdamage", Enchantment.ARROW_DAMAGE);
ENCHANTMENTS.put("power", Enchantment.ARROW_DAMAGE);
ALIASENCHANTMENTS.put("arrowpower", Enchantment.ARROW_DAMAGE);
ALIASENCHANTMENTS.put("ad", Enchantment.ARROW_DAMAGE);
ENCHANTMENTS.put("arrowknockback", Enchantment.ARROW_KNOCKBACK);
ALIASENCHANTMENTS.put("arrowkb", Enchantment.ARROW_KNOCKBACK);
ENCHANTMENTS.put("punch", Enchantment.ARROW_KNOCKBACK);
ALIASENCHANTMENTS.put("arrowpunch", Enchantment.ARROW_KNOCKBACK);
ALIASENCHANTMENTS.put("ak", Enchantment.ARROW_KNOCKBACK);
ALIASENCHANTMENTS.put("infinitearrows", Enchantment.ARROW_INFINITE);
ENCHANTMENTS.put("infarrows", Enchantment.ARROW_INFINITE);
ENCHANTMENTS.put("infinity", Enchantment.ARROW_INFINITE);
@@ -131,10 +140,10 @@ public class Enchantments
ALIASENCHANTMENTS.put("unlimitedarrows", Enchantment.ARROW_INFINITE);
ALIASENCHANTMENTS.put("ai", Enchantment.ARROW_INFINITE);
}
public static Enchantment getByName(String name) {
Enchantment enchantment;
if (NUMPATTERN.matcher(name).matches()) {
if (NumberUtil.isInt(name)) {
enchantment = Enchantment.getById(Integer.parseInt(name));
} else {
enchantment = Enchantment.getByName(name.toUpperCase(Locale.ENGLISH));

View File

@@ -31,6 +31,10 @@ import com.earth2me.essentials.register.payment.Methods;
import com.earth2me.essentials.signs.SignBlockListener;
import com.earth2me.essentials.signs.SignEntityListener;
import com.earth2me.essentials.signs.SignPlayerListener;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.KeywordReplacer;
import com.earth2me.essentials.textreader.SimpleTextInput;
import com.earth2me.essentials.utils.DateUtil;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
@@ -47,9 +51,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 +67,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 = 2543;
public static final int BUKKIT_VERSION = 2763;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
@@ -84,6 +92,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 +131,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 +186,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 +219,45 @@ 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);
scheduleSyncRepeatingTask(timer, 1000, 50);
Economy.setEss(this);
execTimer.mark("RegHandler");
final MetricsStarter metricsStarter = new MetricsStarter(this);
if (metricsStarter.getStart() != null && metricsStarter.getStart() == true)
{
runTaskLaterAsynchronously(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);
}
}
@Override
public void saveConfig() {
// We don't use any of the bukkit config writing, as this breaks our config file formatting.
}
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 +283,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
@@ -270,11 +296,13 @@ public class Essentials extends JavaPlugin implements IEssentials
User user = getUser(p);
if (user.isVanished())
{
user.toggleVanished();
user.setVanished(false);
p.sendMessage(_("unvanishedReload"));
}
}
cleanupOpenInventories();
i18n.onDisable();
backup.stopTask();
Economy.setEss(null);
Trade.closeLog();
}
@@ -291,6 +319,9 @@ public class Essentials extends JavaPlugin implements IEssentials
}
i18n.updateLocale(settings.getLocale());
final PluginManager pm = getServer().getPluginManager();
registerListeners(pm);
}
@Override
@@ -308,7 +339,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);
@@ -331,7 +362,7 @@ public class Essentials extends JavaPlugin implements IEssentials
}
// New mail notification
if (user != null && !getSettings().isCommandDisabled("mail") && !commandLabel.equals("mail") && user.isAuthorized("essentials.mail"))
if (user != null && !getSettings().isCommandDisabled("mail") && !command.getName().equals("mail") && user.isAuthorized("essentials.mail"))
{
final List<String> mail = user.getMails();
if (mail != null && !mail.isEmpty())
@@ -340,9 +371,26 @@ public class Essentials extends JavaPlugin implements IEssentials
}
}
//Print version even if admin command is not available
if (commandLabel.equalsIgnoreCase("essversion"))
{
sender.sendMessage("This server is running Essentials " + getDescription().getVersion());
return true;
}
// 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;
}
@@ -363,11 +411,24 @@ public class Essentials extends JavaPlugin implements IEssentials
// Check authorization
if (user != null && !user.isAuthorized(cmd, permissionPrefix))
{
LOGGER.log(Level.WARNING, _("deniedAccessCommand", user.getName()));
LOGGER.log(Level.INFO, _("deniedAccessCommand", user.getName()));
user.sendMessage(_("noAccessCommand"));
return true;
}
if (user != null && user.isJailed() && !user.isAuthorized(cmd, "essentials.jail.allow."))
{
if (user.getJailTimeout() > 0)
{
user.sendMessage(_("playerJailedFor", user.getName(), DateUtil.formatDateDiff(user.getJailTimeout())));
}
else
{
user.sendMessage(_("jailMessage"));
}
return true;
}
// Run the command
try
{
@@ -408,6 +469,26 @@ public class Essentials extends JavaPlugin implements IEssentials
}
}
public void cleanupOpenInventories()
{
for (Player player : getServer().getOnlinePlayers())
{
User user = getUser(player);
if (user.isRecipeSee())
{
user.getPlayer().getOpenInventory().getTopInventory().clear();
user.getPlayer().getOpenInventory().close();
user.setRecipeSee(false);
}
if (user.isInvSee() || user.isEnderSee())
{
user.getPlayer().getOpenInventory().close();
user.setInvSee(false);
user.setEnderSee(false);
}
}
}
@Override
public void showError(final CommandSender sender, final Throwable exception, final String commandLabel)
{
@@ -471,7 +552,7 @@ public class Essentials extends JavaPlugin implements IEssentials
}
return null;
}
@Override
public User getOfflineUser(final String name)
{
@@ -540,25 +621,49 @@ public class Essentials extends JavaPlugin implements IEssentials
return paymentMethod;
}
@Override
public int broadcastMessage(final String message)
{
return broadcastMessage(null, null, message, true);
}
@Override
public int broadcastMessage(final IUser sender, final String message)
{
if (sender == null)
{
return getServer().broadcastMessage(message);
}
if (sender.isHidden())
return broadcastMessage(sender, null, message, false);
}
@Override
public int broadcastMessage(final String permission, final String message)
{
return broadcastMessage(null, permission, message, false);
}
private int broadcastMessage(final IUser sender, final String permission, final String message, final boolean keywords)
{
if (sender != null && sender.isHidden())
{
return 0;
}
IText broadcast = new SimpleTextInput(message);
final Player[] players = getServer().getOnlinePlayers();
for (Player player : players)
{
final User user = getUser(player);
if (!user.isIgnoredPlayer(sender))
if ((permission == null && (sender == null || !user.isIgnoredPlayer(sender)))
|| (permission != null && user.isAuthorized(permission)))
{
player.sendMessage(message);
if (keywords)
{
broadcast = new KeywordReplacer(broadcast, player, this, false);
}
for (String messageText : broadcast.getLines())
{
player.sendMessage(messageText);
}
}
}
@@ -566,9 +671,15 @@ 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

@@ -1,5 +1,6 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.LocationUtil;
import org.bukkit.GameMode;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -21,15 +22,14 @@ public class EssentialsBlockListener implements Listener
public void onBlockPlace(final BlockPlaceEvent event)
{
// Do not rely on getItemInHand();
// http://leaky.bukkit.org/issues/663
final ItemStack is = Util.convertBlockToItem(event.getBlockPlaced());
// http://leaky.bukkit.org/issues/663
final ItemStack is = LocationUtil.convertBlockToItem(event.getBlockPlaced());
if (is == null)
{
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

@@ -1,14 +1,23 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.InvalidWorldException;
import com.google.common.io.Files;
import java.io.*;
import java.math.BigDecimal;
import java.math.MathContext;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CoderResult;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.*;
@@ -24,21 +33,27 @@ import org.bukkit.util.Vector;
public class EssentialsConf extends YamlConfiguration
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient File configFile;
private transient String templateName = null;
private transient Class<?> resourceClass = EssentialsConf.class;
private final File configFile;
private String templateName = null;
private Class<?> resourceClass = EssentialsConf.class;
private static final Charset UTF8 = Charset.forName("UTF-8");
private static final ExecutorService EXECUTOR_SERVICE = Executors.newSingleThreadExecutor();
private final AtomicInteger pendingDiskWrites = new AtomicInteger(0);
public EssentialsConf(final File configFile)
{
super();
this.configFile = configFile;
this.configFile = configFile.getAbsoluteFile();
}
private final byte[] bytebuffer = new byte[1024];
public synchronized void load()
{
configFile = configFile.getAbsoluteFile();
if (pendingDiskWrites.get() != 0)
{
LOGGER.log(Level.INFO, "File " + configFile + " not read, because it's not yet written to disk.");
return;
}
if (!configFile.getParentFile().exists())
{
if (!configFile.getParentFile().mkdirs())
@@ -101,14 +116,26 @@ public class EssentialsConf extends YamlConfiguration
final FileInputStream inputStream = new FileInputStream(configFile);
try
{
final ByteBuffer buffer = ByteBuffer.allocate((int)configFile.length());
long startSize = configFile.length();
if (startSize > Integer.MAX_VALUE) {
throw new InvalidConfigurationException("File too big");
}
ByteBuffer buffer = ByteBuffer.allocate((int)startSize);
int length;
while ((length = inputStream.read(bytebuffer)) != -1)
{
if (length > buffer.remaining()) {
ByteBuffer resize = ByteBuffer.allocate(buffer.capacity()+length-buffer.remaining());
int resizePosition = buffer.position();
buffer.rewind();
resize.put(buffer);
resize.position(resizePosition);
buffer = resize;
}
buffer.put(bytebuffer, 0, length);
}
buffer.rewind();
final CharBuffer data = CharBuffer.allocate((int)configFile.length());
final CharBuffer data = CharBuffer.allocate(buffer.capacity());
CharsetDecoder decoder = UTF8.newDecoder();
CoderResult result = decoder.decode(buffer, data, true);
if (result.isError())
@@ -221,12 +248,161 @@ 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
{
delayedSave(file);
}
public synchronized void forceSave()
{
try
{
Future<?> future = delayedSave(configFile);
if (future != null)
{
future.get();
}
}
catch (InterruptedException ex)
{
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
}
catch (ExecutionException ex)
{
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
}
}
private Future<?> delayedSave(final File file)
{
//long startTime = System.nanoTime();
if (file == null)
{
throw new IllegalArgumentException("File cannot be null");
}
final String data = saveToString();
if (data.length() == 0)
{
return null;
}
pendingDiskWrites.incrementAndGet();
Future<?> future = EXECUTOR_SERVICE.submit(new WriteRunner(configFile, data, pendingDiskWrites));
//LOGGER.log(Level.INFO, configFile + " prepared for writing in " + (System.nanoTime() - startTime) + " nsec.");
return future;
}
private static class WriteRunner implements Runnable
{
private final File configFile;
private final String data;
private final AtomicInteger pendingDiskWrites;
private WriteRunner(final File configFile, final String data, final AtomicInteger pendingDiskWrites)
{
this.configFile = configFile;
this.data = data;
this.pendingDiskWrites = pendingDiskWrites;
}
@Override
public void run()
{
//long startTime = System.nanoTime();
synchronized (configFile)
{
if (pendingDiskWrites.get() > 1)
{
// Writes can be skipped, because they are stored in a queue (in the executor).
// Only the last is actually written.
pendingDiskWrites.decrementAndGet();
//LOGGER.log(Level.INFO, configFile + " skipped writing in " + (System.nanoTime() - startTime) + " nsec.");
return;
}
try
{
Files.createParentDirs(configFile);
if (!configFile.exists())
{
try
{
LOGGER.log(Level.INFO, _("creatingEmptyConfig", configFile.toString()));
if (!configFile.createNewFile())
{
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
return;
}
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()), ex);
return;
}
}
final FileOutputStream fos = new FileOutputStream(configFile);
try
{
final OutputStreamWriter writer = new OutputStreamWriter(fos, UTF8);
try
{
writer.write(data);
}
finally
{
writer.close();
}
}
finally
{
fos.close();
}
}
catch (IOException e)
{
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
finally
{
//LOGGER.log(Level.INFO, configFile + " written to disk in " + (System.nanoTime() - startTime) + " nsec.");
pendingDiskWrites.decrementAndGet();
}
}
}
}
public boolean hasProperty(final String path)
{
return isSet(path);
}
public Location getLocation(final String path, final Server server) throws Exception
public Location getLocation(final String path, final Server server) throws InvalidWorldException
{
final String worldName = getString((path == null ? "" : path + ".") + "world");
if (worldName == null || worldName.isEmpty())
@@ -236,7 +412,7 @@ public class EssentialsConf extends YamlConfiguration
final World world = server.getWorld(worldName);
if (world == null)
{
throw new Exception(_("invalidWorld"));
throw new InvalidWorldException(worldName);
}
return new Location(world,
getDouble((path == null ? "" : path + ".") + "x", 0),
@@ -305,100 +481,25 @@ 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);
}
}
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();
}
set(path, new LinkedHashMap(object));
}
public Object getProperty(String path)
{
return get(path);
}
public void setProperty(final String path, final BigDecimal bigDecimal)
{
set(path, bigDecimal.toString());
}
public void setProperty(String path, Object object)
{
@@ -421,6 +522,36 @@ public class EssentialsConf extends YamlConfiguration
{
return super.get(path, def);
}
public synchronized BigDecimal getBigDecimal(final String path, final BigDecimal def)
{
final String input = super.getString(path);
return toBigDecimal(input, def);
}
public static BigDecimal toBigDecimal(final String input, final BigDecimal def)
{
if (input == null || input.isEmpty())
{
return def;
}
else
{
try
{
return new BigDecimal(input, MathContext.DECIMAL128);
}
catch (NumberFormatException e)
{
return def;
}
catch (ArithmeticException e)
{
return def;
}
}
}
@Override
public synchronized boolean getBoolean(String path)
@@ -464,6 +595,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)
{
@@ -524,6 +661,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)
{
@@ -666,4 +809,5 @@ public class EssentialsConf extends YamlConfiguration
{
super.set(path, value);
}
}

View File

@@ -4,13 +4,14 @@ import static com.earth2me.essentials.I18n._;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import org.bukkit.Material;
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;
@@ -18,6 +19,7 @@ public class EssentialsEntityListener implements Listener
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private final IEssentials ess;
private static final transient Pattern powertoolPlayer = Pattern.compile("\\{player\\}");
public EssentialsEntityListener(IEssentials ess)
{
@@ -30,52 +32,49 @@ public class EssentialsEntityListener implements Listener
{
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);
onPlayerVsPlayerDamage(event, defender, attacker);
onPlayerVsPlayerPowertool(event, defender, attacker);
}
else if (eDefend instanceof Player && eAttack instanceof Projectile)
{
Entity shooter = ((Projectile)event.getDamager()).getShooter();
if (shooter instanceof Player)
if (eDefend instanceof Player)
{
final User defender = ess.getUser(eDefend);
final User attacker = ess.getUser(shooter);
onPlayerVsPlayerDamage(event, defender, attacker);
onPlayerVsPlayerPowertool(event, defender, attacker);
onPlayerVsPlayerDamage(event, (Player)eDefend, attacker);
}
}
else if (eAttack instanceof Player)
{
final User player = ess.getUser(eAttack);
player.updateActivity(true);
if (eDefend instanceof Ageable)
else 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 User defender, final User attacker)
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())))
if (ess.getSettings().getLoginAttackDelay() > 0
&& (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay()))
&& !attacker.isAuthorized("essentials.pvpdelay.exempt"))
{
event.setCancelled(true);
}
if (attacker.hasInvulnerabilityAfterTeleport() || defender.hasInvulnerabilityAfterTeleport())
if (!defender.equals(attacker.getBase()) && (attacker.hasInvulnerabilityAfterTeleport() || ess.getUser(defender).hasInvulnerabilityAfterTeleport()))
{
event.setCancelled(true);
}
@@ -90,17 +89,18 @@ public class EssentialsEntityListener implements Listener
event.setCancelled(true);
}
attacker.updateActivity(true);
onPlayerVsPlayerPowertool(event, defender, attacker);
}
private void onPlayerVsPlayerPowertool(final EntityDamageByEntityEvent event, final User defender, final User 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 command : commandList)
for (final String tempCommand : commandList)
{
if (command != null && !command.isEmpty())
final String command = powertoolPlayer.matcher(tempCommand).replaceAll(defender.getName());
if (command != null && !command.isEmpty() && !command.equals(tempCommand))
{
ess.scheduleSyncDelayedTask(
new Runnable()
@@ -108,7 +108,7 @@ public class EssentialsEntityListener implements Listener
@Override
public void run()
{
attacker.getServer().dispatchCommand(attacker.getBase(), command.replaceAll("\\{player\\}", defender.getName()));
attacker.getServer().dispatchCommand(attacker.getBase(), command);
LOGGER.log(Level.INFO, String.format("[PT] %s issued server command: /%s", attacker.getName(), command));
}
});
@@ -170,9 +170,18 @@ public class EssentialsEntityListener implements Listener
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onFoodLevelChange(final FoodLevelChangeEvent event)
{
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
if (event.getEntity() instanceof Player)
{
event.setCancelled(true);
final User user = ess.getUser(event.getEntity());
if (user.isGodModeEnabled())
{
if (user.isGodModeEnabledRaw())
{
user.setFoodLevel(20);
user.setSaturation(10);
}
event.setCancelled(true);
}
}
}
@@ -197,4 +206,17 @@ public class EssentialsEntityListener implements Listener
}
}
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityShootBow(EntityShootBowEvent event)
{
if (event.getEntity() instanceof Player)
{
final User user = ess.getUser(event.getEntity());
if (user.isAfk())
{
user.updateActivity(true);
}
}
}
}

View File

@@ -5,8 +5,9 @@ import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.KeywordReplacer;
import com.earth2me.essentials.textreader.TextInput;
import com.earth2me.essentials.textreader.TextPager;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.LocationUtil;
import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@@ -15,6 +16,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 +25,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.*;
import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
@@ -48,6 +51,11 @@ public class EssentialsPlayerListener implements Listener
final User user = ess.getUser(event.getPlayer());
updateCompass(user);
user.setDisplayNick();
if (ess.getSettings().isTeleportInvulnerability())
{
user.enableInvulnerabilityAfterTeleport();
}
}
@EventHandler(priority = EventPriority.LOWEST)
@@ -76,14 +84,25 @@ 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 (event.getFrom().getBlockX() == event.getTo().getBlockX()
&& event.getFrom().getBlockZ() == event.getTo().getBlockZ()
&& event.getFrom().getBlockY() == event.getTo().getBlockY())
{
return;
}
if (!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers())
{
event.getHandlers().unregister(this);
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Unregistering move listener");
}
return;
}
final User user = ess.getUser(event.getPlayer());
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers())
{
@@ -100,7 +119,7 @@ public class EssentialsPlayerListener implements Listener
to.setZ(from.getZ());
try
{
event.setTo(Util.getSafeDestination(to));
event.setTo(LocationUtil.getSafeDestination(to));
}
catch (Exception ex)
{
@@ -125,11 +144,12 @@ public class EssentialsPlayerListener implements Listener
}
if (user.isVanished())
{
user.toggleVanished();
user.setVanished(false);
}
if (!user.isJailed())
user.setLogoutLocation();
if (user.isRecipeSee())
{
user.setLastLocation();
user.getPlayer().getOpenInventory().getTopInventory().clear();
}
user.updateActivity(false);
user.dispose();
@@ -138,7 +158,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()
@@ -154,75 +174,112 @@ public class EssentialsPlayerListener implements Listener
{
return;
}
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"))
if (user.isNPC())
{
for (String p : ess.getVanishedPlayers())
{
Player toVanish = ess.getUser(p).getBase();
if (toVanish.isOnline())
{
user.hidePlayer(toVanish);
}
}
user.setNPC(false);
}
if (user.isAuthorized("essentials.sleepingignored"))
final long currentTime = System.currentTimeMillis();
user.checkMuteTimeout(currentTime);
user.updateActivity(false);
ess.scheduleSyncDelayedTask(new Runnable()
{
ess.scheduleSyncDelayedTask(new Runnable()
@Override
public void run()
{
@Override
public void run()
if (!user.isOnline())
{
return;
}
user.setLastLogin(currentTime);
user.setDisplayNick();
updateCompass(user);
if (!ess.getVanishedPlayers().isEmpty() && !user.isAuthorized("essentials.vanish.see"))
{
for (String p : ess.getVanishedPlayers())
{
Player toVanish = ess.getServer().getPlayerExact(p);
if (toVanish != null && toVanish.isOnline())
{
user.hidePlayer(toVanish);
}
}
}
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.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
{
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
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());
}
}
}
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())
if (!ess.getSettings().isCommandDisabled("mail") && user.isAuthorized("essentials.mail"))
{
user.sendMessage(msg);
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 (LocationUtil.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()));
}
}
user.setFlySpeed(0.1f);
user.setWalkSpeed(0.2f);
}
else
{
user.sendMessage(_("youHaveNewMail", mail.size()));
}
}
});
}
// Makes the compass item ingame always point to the first essentials home. #EasterEgg
@@ -236,14 +293,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);
}
}
@@ -252,7 +302,6 @@ public class EssentialsPlayerListener implements Listener
{
switch (event.getResult())
{
case ALLOWED:
case KICK_FULL:
case KICK_BANNED:
break;
@@ -261,21 +310,25 @@ public class EssentialsPlayerListener implements Listener
}
final User user = ess.getUser(event.getPlayer());
if (user.isNPC())
{
user.setNPC(false);
}
final long currentTime = System.currentTimeMillis();
final boolean banExpired = user.checkBanTimeout(currentTime);
user.checkMuteTimeout(currentTime);
user.checkJailTimeout(currentTime);
if (!banExpired && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
if (event.getResult() == Result.KICK_BANNED || user.isBanned())
{
final String banReason = user.getBanReason();
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : _("defaultBanReason"));
return;
final boolean banExpired = user.checkBanTimeout(System.currentTimeMillis());
if (!banExpired)
{
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 " + DateUtil.formatDateDiff(user.getBanTimeout());
}
event.disallow(Result.KICK_BANNED, banReason);
return;
}
}
if (event.getResult() == Result.KICK_FULL && !user.isAuthorized("essentials.joinfullserver"))
@@ -335,14 +388,13 @@ public class EssentialsPlayerListener implements Listener
});
}
}
private final static List<String> COMMANDS = Arrays.asList("msg", "w", "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())
{
@@ -360,11 +412,11 @@ public class EssentialsPlayerListener implements Listener
}
}
@EventHandler(priority = EventPriority.LOW)
public void onPlayerChangedWorldHack(final PlayerChangedWorldEvent event)
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerChangedWorldFlyReset(final PlayerChangedWorldEvent event)
{
final Player user = event.getPlayer();
if (user.getGameMode() != GameMode.CREATIVE)
final User user = ess.getUser(event.getPlayer());
if (user.getGameMode() != GameMode.CREATIVE && !user.isAuthorized("essentials.fly"))
{
user.setAllowFlight(false);
}
@@ -384,10 +436,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)
@@ -398,9 +454,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(_("bedSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
}
}
break;
case LEFT_CLICK_AIR:
@@ -434,7 +493,7 @@ public class EssentialsPlayerListener implements Listener
{
try
{
final Location otarget = Util.getTarget(user);
final Location otarget = LocationUtil.getTarget(user);
ess.scheduleSyncDelayedTask(
new Runnable()
@@ -445,7 +504,7 @@ public class EssentialsPlayerListener implements Listener
Location loc = user.getLocation();
loc.setX(otarget.getX());
loc.setZ(otarget.getZ());
while (Util.isBlockDamaging(loc.getWorld(), loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()))
while (LocationUtil.isBlockDamaging(loc.getWorld(), loc.getBlockX(), loc.getBlockY() - 1, loc.getBlockZ()))
{
loc.setY(loc.getY() + 1d);
}
@@ -515,10 +574,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);
@@ -527,10 +589,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")))
@@ -538,23 +601,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);
user.updateInventory();
}
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);
user.updateInventory();
}
else if (type == InventoryType.WORKBENCH)
{
final User user = ess.getUser(event.getPlayer());
if (user.isRecipeSee())
{
user.setRecipeSee(false);
event.getView().getTopInventory().clear();
user.updateInventory();
}
}
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);
user.updateInventory();
}
}
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerFishEvent(final PlayerFishEvent event)
{

View File

@@ -11,7 +11,7 @@ import org.bukkit.event.server.PluginEnableEvent;
public class EssentialsPluginListener implements Listener, IConf
{
private final transient IEssentials ess;
public EssentialsPluginListener(final IEssentials ess)
{
this.ess = ess;
@@ -20,7 +20,8 @@ public class EssentialsPluginListener implements Listener, IConf
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(final PluginEnableEvent event)
{
if (event.getPlugin().getName().equals("EssentialsChat")) {
if (event.getPlugin().getName().equals("EssentialsChat"))
{
ess.getSettings().setEssentialsChatActive(true);
}
ess.getPermissionsHandler().checkPermissions();
@@ -34,7 +35,8 @@ public class EssentialsPluginListener implements Listener, IConf
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(final PluginDisableEvent event)
{
if (event.getPlugin().getName().equals("EssentialsChat")) {
if (event.getPlugin().getName().equals("EssentialsChat"))
{
ess.getSettings().setEssentialsChatActive(false);
}
ess.getPermissionsHandler().checkPermissions();

View File

@@ -11,20 +11,26 @@ import org.bukkit.entity.Player;
public class EssentialsTimer implements Runnable
{
private final transient IEssentials ess;
private final transient Set<User> onlineUsers = new HashSet<User>();
private transient long lastPoll = System.currentTimeMillis();
private final transient LinkedList<Float> history = new LinkedList<Float>();
private final transient Set<String> onlineUsers = new HashSet<String>();
private transient long lastPoll = System.nanoTime();
private final LinkedList<Double> history = new LinkedList<Double>();
private int skip1 = 0;
private int skip2 = 0;
private final long maxTime = 10 * 1000000;
private final long tickInterval = 50;
EssentialsTimer(final IEssentials ess)
{
this.ess = ess;
history.add(20d);
}
@Override
public void run()
{
final long startTime = System.nanoTime();
final long currentTime = System.currentTimeMillis();
long timeSpent = (currentTime - lastPoll) / 1000;
long timeSpent = (startTime - lastPoll) / 1000;
if (timeSpent == 0)
{
timeSpent = 1;
@@ -33,18 +39,33 @@ public class EssentialsTimer implements Runnable
{
history.remove();
}
float tps = 100f / timeSpent;
if (tps <= 20)
double tps = tickInterval * 1000000.0 / timeSpent;
if (tps <= 21)
{
history.add(tps);
}
lastPoll = currentTime;
lastPoll = startTime;
int count = 0;
for (Player player : ess.getServer().getOnlinePlayers())
{
count++;
if (skip1 > 0)
{
skip1--;
continue;
}
if (count % 10 == 0)
{
if (System.nanoTime() - startTime > maxTime / 2)
{
skip1 = count - 1;
break;
}
}
try
{
final User user = ess.getUser(player);
onlineUsers.add(user);
onlineUsers.add(user.getName());
user.setLastOnlineActivity(currentTime);
user.checkActivity();
}
@@ -53,14 +74,31 @@ public class EssentialsTimer implements Runnable
ess.getLogger().log(Level.WARNING, "EssentialsTimer Error:", e);
}
}
final Iterator<User> iterator = onlineUsers.iterator();
count = 0;
final Iterator<String> iterator = onlineUsers.iterator();
while (iterator.hasNext())
{
final User user = iterator.next();
count++;
if (skip2 > 0)
{
skip2--;
continue;
}
if (count % 10 == 0)
{
if (System.nanoTime() - startTime > maxTime)
{
skip2 = count - 1;
break;
}
}
final User user = ess.getUser(iterator.next());
if (user.getLastOnlineActivity() < currentTime && user.getLastOnlineActivity() > user.getLastLogout())
{
user.setLastLogout(user.getLastOnlineActivity());
if (!user.isHidden()) {
user.setLastLogout(user.getLastOnlineActivity());
}
iterator.remove();
continue;
}
@@ -69,17 +107,17 @@ public class EssentialsTimer implements Runnable
user.resetInvulnerabilityAfterTeleport();
}
}
public float getAverageTPS()
public double getAverageTPS()
{
float avg = 0;
for (Float f : history)
double avg = 0;
for (Double f : history)
{
if (f != null)
{
avg += f;
}
}
}
return avg / history.size();
}
}

View File

@@ -1,5 +1,6 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.StringUtil;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.craftbukkit.FakeWorld;
import com.earth2me.essentials.settings.Spawns;
@@ -230,7 +231,7 @@ public class EssentialsUpgrade
config.removeProperty("home");
config.setProperty("home.default", worldName);
config.setProperty("home.worlds." + worldName, loc);
config.save();
config.forceSave();
}
}
}
@@ -285,7 +286,7 @@ public class EssentialsUpgrade
((Map<String, Object>)powertools).put(entry.getKey(), temp);
}
}
config.save();
config.forceSave();
}
}
catch (RuntimeException ex)
@@ -358,7 +359,7 @@ public class EssentialsUpgrade
}
}
config.removeProperty("home");
config.save();
config.forceSave();
}
}
@@ -580,7 +581,7 @@ public class EssentialsUpgrade
{
continue;
}
final String sanitizedFilename = Util.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml";
final String sanitizedFilename = StringUtil.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml";
if (sanitizedFilename.equals(filename))
{
continue;

View File

@@ -43,6 +43,7 @@ public class I18n implements II18n
instance = null;
}
@Override
public Locale getCurrentLocale()
{
return currentLocale;

View File

@@ -1,5 +1,6 @@
package com.earth2me.essentials;
public interface IConf {
public interface IConf
{
public void reloadConfig();
}

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials;
import com.earth2me.essentials.api.IJails;
import com.earth2me.essentials.api.IWarps;
import com.earth2me.essentials.metrics.Metrics;
import com.earth2me.essentials.perm.PermissionsHandler;
import com.earth2me.essentials.register.payment.Methods;
@@ -10,6 +11,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
@@ -28,15 +30,19 @@ public interface IEssentials extends Plugin
World getWorld(String name);
int broadcastMessage(String message);
int broadcastMessage(IUser sender, String message);
int broadcastMessage(String permission, String message);
ISettings getSettings();
BukkitScheduler getScheduler();
IJails getJails();
Warps getWarps();
IWarps getWarps();
Worth getWorth();
@@ -44,7 +50,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);
@@ -63,12 +71,12 @@ public interface IEssentials extends Plugin
ItemDb getItemDb();
UserMap getUserMap();
Metrics getMetrics();
void setMetrics(Metrics metrics);
EssentialsTimer getTimer();
List<String> getVanishedPlayers();
}

View File

@@ -2,8 +2,17 @@ package com.earth2me.essentials;
import org.bukkit.command.CommandSender;
public interface IReplyTo {
public interface IReplyTo
{
/**
* Sets the user to reply to
* @param user
*/
public void setReplyTo(CommandSender user);
/**
* Gets the user the sender should reply to
* @return
*/
public CommandSender getReplyTo();
}

View File

@@ -3,6 +3,7 @@ package com.earth2me.essentials;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.signs.EssentialsSign;
import com.earth2me.essentials.textreader.IText;
import java.math.BigDecimal;
import java.text.MessageFormat;
import java.util.List;
import java.util.Map;
@@ -30,9 +31,9 @@ public interface ISettings extends IConf
int getChatRadius();
double getCommandCost(IEssentialsCommand cmd);
BigDecimal getCommandCost(IEssentialsCommand cmd);
double getCommandCost(String label);
BigDecimal getCommandCost(String label);
String getCurrencySymbol();
@@ -42,6 +43,8 @@ public interface ISettings extends IConf
double getHealCooldown();
Set<String> getSocialSpyCommands();
Map<String, Object> getKit(String name);
ConfigurationSection getKits();
@@ -74,11 +77,9 @@ public interface ISettings extends IConf
int getHomeLimit(User user);
boolean getSortListByGroups();
int getSpawnMobLimit();
int getStartingBalance();
BigDecimal getStartingBalance();
double getTeleportCooldown();
@@ -110,9 +111,9 @@ public interface ISettings extends IConf
boolean warnOnSmite();
double getMaxMoney();
BigDecimal getMaxMoney();
double getMinMoney();
BigDecimal getMinMoney();
boolean isEcoLogEnabled();
@@ -142,6 +143,8 @@ public interface ISettings extends IConf
boolean cancelAfkOnMove();
boolean cancelAfkOnInteract();
boolean areDeathMessagesEnabled();
public void setDebug(boolean debug);
@@ -150,6 +153,8 @@ public interface ISettings extends IConf
boolean getUpdateBedAtDaytime();
boolean allowUnsafeEnchantments();
boolean getRepairEnchanted();
boolean isWorldTeleportPermissions();
@@ -182,5 +187,11 @@ public interface ISettings extends IConf
public int getMailsPerMinute();
public long getEconomyLagWarning();
public void setEssentialsChatActive(boolean b);
long getMaxTempban();
public Map<String, Object> getListGroupConfig();
}

View File

@@ -0,0 +1,9 @@
package com.earth2me.essentials;
import org.bukkit.Location;
public interface ITarget
{
public Location getLocation();
}

View File

@@ -1,6 +1,10 @@
package com.earth2me.essentials;
import com.earth2me.essentials.api.ITeleport;
import com.earth2me.essentials.commands.IEssentialsCommand;
import java.math.BigDecimal;
import java.util.Map;
import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -21,13 +25,13 @@ public interface IUser extends Player
Player getBase();
double getMoney();
BigDecimal getMoney();
void takeMoney(double value);
void takeMoney(BigDecimal value);
void giveMoney(double value);
boolean canAfford(double value);
void giveMoney(BigDecimal value);
boolean canAfford(BigDecimal value);
String getGroup();
@@ -37,11 +41,48 @@ public interface IUser extends Player
Location getHome(Location loc) throws Exception;
/**
* 'Hidden' Represents when a player is hidden from others. This status includes when the player is hidden via other
* supported plugins. Use isVanished() if you want to check if a user is vanished by Essentials.
*
* @return If the user is hidden or not
* @see isVanished
*/
boolean isHidden();
Teleport getTeleport();
void setHidden(boolean vanish);
/**
* 'Vanished' Represents when a player is hidden from others by Essentials. This status does NOT include when the
* player is hidden via other plugins. Use isHidden() if you want to check if a user is vanished by any supported
* plugin.
*
* @return If the user is vanished or not
* @see isHidden
*/
boolean isVanished();
void setVanished(boolean vanish);
ITeleport getTeleport();
void setJail(String jail);
boolean isIgnoreExempt();
boolean isAfk();
void setAfk(final boolean set);
void setLogoutLocation();
Location getLogoutLocation();
void setConfigProperty(String node, Object object);
Set<String> getConfigKeys();
Map<String, Object> getConfigMap();
Map<String, Object> getConfigMap(String node);
}

View File

@@ -1,8 +1,11 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.StringUtil;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IItemDb;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.*;
import java.util.regex.Pattern;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@@ -20,6 +23,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()
@@ -72,6 +76,7 @@ public class ItemDb implements IConf, IItemDb
}
}
@Override
public ItemStack get(final String id, final int quantity) throws Exception
{
final ItemStack retval = get(id.toLowerCase(Locale.ENGLISH));
@@ -79,24 +84,26 @@ public class ItemDb implements IConf, IItemDb
return retval;
}
@Override
public ItemStack get(final String id) throws Exception
{
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 (NumberUtil.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
{
@@ -113,9 +120,9 @@ public class ItemDb implements IConf, IItemDb
metaData = durabilities.get(itemname);
}
}
else if (Material.getMaterial(itemname) != null)
else if (Material.getMaterial(itemname.toUpperCase(Locale.ENGLISH)) != null)
{
itemid = Material.getMaterial(itemname).getId();
itemid = Material.getMaterial(itemname.toUpperCase(Locale.ENGLISH)).getId();
metaData = 0;
}
else
@@ -139,22 +146,25 @@ public class ItemDb implements IConf, IItemDb
{
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);
}
return Util.joinList(", ", nameList);
return StringUtil.joinList(", ", nameList);
}
class ItemData
static class ItemData
{
final private int itemNo;
final private short itemData;
@@ -198,6 +208,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();
}
@@ -298,6 +310,8 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
public void onPlayerJoin(final PlayerJoinEvent event)
{
final User user = ess.getUser(event.getPlayer());
final long currentTime = System.currentTimeMillis();
user.checkJailTimeout(currentTime);
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
{
return;

View File

@@ -2,13 +2,18 @@ package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import static com.earth2me.essentials.I18n.capitalCase;
import com.earth2me.essentials.Trade.OverflowType;
import com.earth2me.essentials.commands.NoChargeException;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.KeywordReplacer;
import com.earth2me.essentials.textreader.SimpleTextInput;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.DateUtil;
import java.math.BigDecimal;
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;
@@ -21,11 +26,29 @@ public class Kit
{
final ConfigurationSection kits = ess.getSettings().getKits();
final StringBuilder list = new StringBuilder();
for (String kiteItem : kits.getKeys(false))
for (String kitItem : kits.getKeys(false))
{
if (user == null || user.isAuthorized("essentials.kits." + kiteItem.toLowerCase(Locale.ENGLISH)))
if (user == null)
{
list.append(" ").append(capitalCase(kiteItem));
list.append(" ").append(capitalCase(kitItem));
}
else if (user.isAuthorized("essentials.kits." + kitItem.toLowerCase(Locale.ENGLISH)))
{
String cost = "";
String name = capitalCase(kitItem);
BigDecimal costPrice = new Trade("kit-" + kitItem.toLowerCase(Locale.ENGLISH), ess).getCommandCost(user);
if (costPrice.signum() > 0)
{
cost = _("kitCost", NumberUtil.displayCurrency(costPrice, ess));
}
final Map<String, Object> kit = ess.getSettings().getKit(kitItem);
if (Kit.getNextUse(user, kitItem, kit) != 0)
{
name = _("kitDelay", name);
}
list.append(" ").append(name).append(cost);
}
}
return list.toString().trim();
@@ -39,64 +62,105 @@ public class Kit
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws Exception
{
if (user.isAuthorized("essentials.kit.exemptdelay")) {
return;
}
final Calendar time = new GregorianCalendar();
long nextUse = getNextUse(user, kitName, els);
// Take the current time, and remove the delay from it.
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));
// This value contains the most recent time a kit could have been used that would allow another use.
final long earliestLong = earliestTime.getTimeInMillis();
// When was the last kit used?
final long lastTime = user.getKitTimestamp(kitName);
if (lastTime < earliestLong || lastTime == 0L)
if (nextUse == 0L)
{
user.setKitTimestamp(kitName, time.getTimeInMillis());
}
else if (lastTime > time.getTimeInMillis())
{
// This is to make sure time didn't get messed up on last kit use.
// If this happens, let's give the user the benifit of the doubt.
user.setKitTimestamp(kitName, time.getTimeInMillis());
}
else if (earliestLong < 0L)
else if (nextUse < 0L)
{
user.sendMessage(_("kitOnce"));
throw new NoChargeException();
}
else
{
time.setTimeInMillis(lastTime);
time.add(Calendar.SECOND, (int)delay);
time.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
user.sendMessage(_("kitTimed", Util.formatDateDiff(time.getTimeInMillis())));
user.sendMessage(_("kitTimed", DateUtil.formatDateDiff(nextUse)));
throw new NoChargeException();
}
}
public static List<String> getItems(final User user, final Map<String, Object> kit) throws Exception
public static long getNextUse(final User user, final String kitName, final Map<String, Object> els) throws Exception
{
if (kit == null)
if (user.isAuthorized("essentials.kit.exemptdelay"))
{
throw new Exception(_("kitError2"));
return 0L;
}
final Calendar time = new GregorianCalendar();
double delay = 0;
try
{
return (List<String>)kit.get("items");
// Make sure delay is valid
delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0.0d;
}
catch (Exception e)
{
user.sendMessage(_("kitError2"));
throw new Exception(_("kitErrorHelp"), e);
throw new Exception(_("kitError2"));
}
// When was the last kit used?
final long lastTime = user.getKitTimestamp(kitName);
// When can be use the kit again?
final Calendar delayTime = new GregorianCalendar();
delayTime.setTimeInMillis(lastTime);
delayTime.add(Calendar.SECOND, (int)delay);
delayTime.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
if (lastTime == 0L || lastTime > time.getTimeInMillis())
{
// If we have no record of kit use, or its corrupted, give them benifit of the doubt.
return 0L;
}
else if (delay < 0d)
{
// If the kit has a negative kit time, it can only be used once.
return -1;
}
else if (delayTime.before(time))
{
// If the kit was used in the past, but outside the delay time, it can be used.
return 0L;
}
else
{
// If the kit has been used recently, return the next time it can be used.
return delayTime.getTimeInMillis();
}
}
public static List<String> getItems(final IEssentials ess, final User user, final Map<String, Object> kit) throws Exception
{
if (kit == null)
{
throw new Exception(_("kitNotFound"));
}
try
{
final List<String> itemList = new ArrayList<String>();
final Object kitItems = kit.get("items");
if (kitItems instanceof List)
{
for (Object item : (List)kitItems)
{
if (item instanceof String)
{
itemList.add(item.toString());
continue;
}
throw new Exception("Error parsing kit item: " + item.toString());
}
return itemList;
}
throw new Exception("Error parsing kit: " + kitItems.toString());
}
catch (Exception e)
{
ess.getLogger().log(Level.WARNING, e.getMessage());
throw new Exception(_("kitError2"), e);
}
}
@@ -104,65 +168,39 @@ public class Kit
{
try
{
IText input = new SimpleTextInput(items);
IText output = new KeywordReplacer(input, user, ess);
boolean spew = false;
for (String d : items)
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
for (String kitItem : output.getLines())
{
if (d.startsWith(ess.getSettings().getCurrencySymbol()))
if (kitItem.startsWith(ess.getSettings().getCurrencySymbol()))
{
Double value = Double.parseDouble(d.substring(ess.getSettings().getCurrencySymbol().length()).trim());
BigDecimal value = new BigDecimal(kitItem.substring(ess.getSettings().getCurrencySymbol().length()).trim());
Trade t = new Trade(value, ess);
t.pay(user);
t.pay(user, OverflowType.DROP);
continue;
}
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;
final ItemStack stack = new ItemStack(id, amount, data);
final String[] parts = kitItem.split(" +");
final ItemStack parseStack = ess.getItemDb().get(parts[0], parts.length > 1 ? Integer.parseInt(parts[1]) : 1);
final MetaItemStack metaStack = new MetaItemStack(parseStack);
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);
}
}
// We pass a null sender here because kits should not do perm checks
metaStack.parseStringMeta(null, allowUnsafe, parts, 2, ess);
}
final Map<Integer, ItemStack> overfilled;
if (user.isAuthorized("essentials.oversizedstacks"))
{
overfilled = InventoryWorkaround.addOversizedItems(user.getInventory(), ess.getSettings().getOversizedStackSize(), stack);
overfilled = InventoryWorkaround.addOversizedItems(user.getInventory(), ess.getSettings().getOversizedStackSize(), metaStack.getItemStack());
}
else
{
overfilled = InventoryWorkaround.addItems(user.getInventory(), stack);
overfilled = InventoryWorkaround.addItems(user.getInventory(), metaStack.getItemStack());
}
for (ItemStack itemStack : overfilled.values())
{
@@ -179,14 +217,7 @@ public class Kit
catch (Exception e)
{
user.updateInventory();
if (ess.getSettings().isDebug())
{
ess.getLogger().log(Level.WARNING, e.getMessage());
}
else
{
ess.getLogger().log(Level.WARNING, e.getMessage());
}
ess.getLogger().log(Level.WARNING, e.getMessage());
throw new Exception(_("kitError2"), e);
}
}

View File

@@ -0,0 +1,20 @@
package com.earth2me.essentials;
import org.bukkit.Location;
public class LocationTarget implements ITarget
{
private final Location location;
LocationTarget(Location location)
{
this.location = location;
}
@Override
public Location getLocation()
{
return location;
}
}

View File

@@ -0,0 +1,521 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.textreader.BookInput;
import com.earth2me.essentials.textreader.BookPager;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.utils.FormatUtil;
import com.earth2me.essentials.utils.NumberUtil;
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.*;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
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 PotionEffectType pEffectType;
private PotionEffect pEffect;
private boolean validFirework = false;
private boolean validPotionEffect = false;
private boolean validPotionDuration = false;
private boolean validPotionPower = false;
private boolean completePotion = false;
private int power = 1;
private int duration = 120;
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 boolean isValidPotion()
{
return validPotionEffect && validPotionDuration && validPotionPower;
}
public FireworkEffect.Builder getFireworkBuilder()
{
return builder;
}
public PotionEffect getPotionEffect()
{
return pEffect;
}
public boolean completePotion()
{
return completePotion;
}
private void resetPotionMeta()
{
pEffect = null;
pEffectType = null;
validPotionEffect = false;
validPotionDuration = false;
validPotionPower = false;
completePotion = true;
}
public void parseStringMeta(final CommandSender sender, final boolean allowUnsafe, String[] string, int fromArg, final IEssentials ess) throws Exception
{
for (int i = fromArg; i < string.length; i++)
{
addStringMeta(sender, allowUnsafe, string[i], ess);
}
if (validFirework)
{
if (!hasMetaPermission(sender, "firework", true, true, ess))
{
throw new Exception(_("noMetaFirework"));
}
FireworkEffect effect = builder.build();
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
fmeta.addEffect(effect);
if (fmeta.getEffects().size() > 1 && !hasMetaPermission(sender, "firework-multiple", true, true, ess))
{
throw new Exception(_("multipleCharges"));
}
stack.setItemMeta(fmeta);
}
}
private void addStringMeta(final CommandSender sender, 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") && hasMetaPermission(sender, "name", false, true, ess))
{
final String displayName = FormatUtil.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")) && hasMetaPermission(sender, "lore", false, true, ess))
{
final List<String> lore = new ArrayList<String>();
for (String line : split[1].split("\\|"))
{
lore.add(FormatUtil.replaceFormat(line.replace('_', ' ')));
}
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 && hasMetaPermission(sender, "head", false, true, ess))
{
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(_("onlyPlayerSkulls"));
}
}
else if (split.length > 1 && split[0].equalsIgnoreCase("book") && stack.getType() == Material.WRITTEN_BOOK
&& (hasMetaPermission(sender, "book", true, true, ess) || hasMetaPermission(sender, "chapter-" + split[1].toLowerCase(Locale.ENGLISH), true, true, ess)))
{
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 && hasMetaPermission(sender, "author", false, true, ess))
{
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 && hasMetaPermission(sender, "title", false, true, ess))
{
final String title = FormatUtil.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 && hasMetaPermission(sender, "firework-power", false, true, ess))
{
final int power = NumberUtil.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(sender, false, string, ess);
}
else if (stack.getType() == Material.POTION) //WARNING - Meta for potions will be ignored after this point.
{
addPotionMeta(sender, 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 = NumberUtil.isInt(color[0]) ? Integer.parseInt(color[0]) : 0;
final int green = NumberUtil.isInt(color[1]) ? Integer.parseInt(color[1]) : 0;
final int blue = NumberUtil.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(_("leatherSyntax"));
}
}
else
{
parseEnchantmentStrings(sender, allowUnsafe, split, ess);
}
}
public void addFireworkMeta(final CommandSender sender, 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)
{
if (!hasMetaPermission(sender, "firework", true, true, ess))
{
throw new Exception(_("noMetaFirework"));
}
FireworkEffect effect = builder.build();
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
fmeta.addEffect(effect);
if (fmeta.getEffects().size() > 1 && !hasMetaPermission(sender, "firework-multiple", true, true, ess))
{
throw new Exception(_("multipleCharges"));
}
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
{
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
{
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
{
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
{
throw new Exception(_("invalidFireworkFormat", split[1], split[0]));
}
}
}
}
}
public void addPotionMeta(final CommandSender sender, final boolean allowShortName, final String string, final IEssentials ess) throws Exception
{
if (stack.getType() == Material.POTION)
{
final String[] split = splitPattern.split(string, 2);
if (split.length < 2)
{
return;
}
if (split[0].equalsIgnoreCase("effect") || (allowShortName && split[0].equalsIgnoreCase("e")))
{
pEffectType = Potions.getByName(split[1]);
if (pEffectType != null && pEffectType.getName() != null)
{
if (hasMetaPermission(sender, "potions." + pEffectType.getName().toLowerCase(Locale.ENGLISH), true, false, ess))
{
validPotionEffect = true;
}
else
{
throw new Exception(_("noPotionEffectPerm", pEffectType.getName().toLowerCase(Locale.ENGLISH)));
}
}
else
{
throw new Exception(_("invalidPotionMeta", split[1]));
}
}
else if (split[0].equalsIgnoreCase("power") || (allowShortName && split[0].equalsIgnoreCase("p")))
{
if (NumberUtil.isInt(split[1]))
{
validPotionPower = true;
power = Integer.parseInt(split[1]);
if (power > 0 && power < 4)
{
power -= 1;
}
}
else
{
throw new Exception(_("invalidPotionMeta", split[1]));
}
}
else if (split[0].equalsIgnoreCase("duration") || (allowShortName && split[0].equalsIgnoreCase("d")))
{
if (NumberUtil.isInt(split[1]))
{
validPotionDuration = true;
duration = Integer.parseInt(split[1]) * 20; //Duration is in ticks by default, converted to seconds
}
else
{
throw new Exception(_("invalidPotionMeta", split[1]));
}
}
if (isValidPotion())
{
PotionMeta pmeta = (PotionMeta)stack.getItemMeta();
pEffect = pEffectType.createEffect(duration, power);
if (pmeta.getCustomEffects().size() > 1 && !hasMetaPermission(sender, "potions.multiple", true, false, ess))
{
throw new Exception(_("multiplePotionEffects"));
}
pmeta.addCustomEffect(pEffect, true);
stack.setItemMeta(pmeta);
resetPotionMeta();
}
}
}
private void parseEnchantmentStrings(final CommandSender sender, final boolean allowUnsafe, final String[] split, final IEssentials ess) throws Exception
{
final Enchantment enchantment = Enchantments.getByName(split[0]);
if (enchantment == null || !hasMetaPermission(sender, "enchantments." + enchantment.getName().toLowerCase(Locale.ENGLISH), false, false, ess))
{
return;
}
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(sender, allowUnsafe, enchantment, level);
}
public void addEnchantment(final CommandSender sender, final boolean allowUnsafe, final Enchantment enchantment, final int level) throws Exception
{
if (enchantment == null)
{
throw new Exception(_("enchantmentNotFound"));
}
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);
}
}
public Enchantment getEnchantment(final User user, final String name) throws Exception
{
final Enchantment enchantment = Enchantments.getByName(name);
if (enchantment == null)
{
return null;
}
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
if (!hasMetaPermission(user, "enchantments." + enchantmentName, true, false))
{
throw new Exception(_("enchantmentPerm", enchantmentName));
}
return enchantment;
}
private boolean hasMetaPermission(final CommandSender sender, final String metaPerm, final boolean graceful, final boolean includeBase, final IEssentials ess) throws Exception
{
final User user = ess.getUser(sender);
return hasMetaPermission(user, metaPerm, graceful, includeBase);
}
private boolean hasMetaPermission(final User user, final String metaPerm, final boolean graceful, final boolean includeBase) throws Exception
{
final String permBase = includeBase ? "essentials.itemspawn.meta-" : "essentials.";
if (user == null || user.isAuthorized(permBase + metaPerm))
{
return true;
}
if (graceful)
{
return false;
}
else
{
throw new Exception(_("noMetaPerm", metaPerm));
}
}
}

View File

@@ -7,8 +7,8 @@ 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;
@@ -43,8 +43,15 @@ public enum Mob
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);
WITCH("Witch", Enemies.ENEMY, EntityType.WITCH),
BOAT("Boat", Enemies.NEUTRAL, EntityType.BOAT),
MINECART("Minecart", Enemies.NEUTRAL, EntityType.MINECART),
MINECART_CHEST("ChestMinecart", Enemies.NEUTRAL, EntityType.MINECART_CHEST),
MINECART_FURNACE("FurnaceMinecart", Enemies.NEUTRAL, EntityType.MINECART_FURNACE),
MINECART_TNT("TNTMinecart", Enemies.NEUTRAL, EntityType.MINECART_TNT),
MINECART_HOPPER("HopperMinecart", Enemies.NEUTRAL, EntityType.MINECART_HOPPER),
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)
@@ -75,18 +82,19 @@ public enum 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
{
return spawn(player.getWorld(), server, loc);
}
public LivingEntity spawn(final World world, final Server server, final Location loc) throws MobException
public Entity spawn(final World world, final Server server, final Location loc) throws MobException
{
final LivingEntity entity = world.spawn(loc, (Class<? extends LivingEntity>)this.bukkitType.getEntityClass());
final Entity entity = world.spawn(loc, (Class<? extends Entity>)this.bukkitType.getEntityClass());
if (entity == null)
{
logger.log(Level.WARNING, _("unableToSpawnMob"));

View File

@@ -21,6 +21,7 @@ import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.util.Vector;
public class OfflinePlayer implements Player
@@ -31,6 +32,8 @@ public class OfflinePlayer implements Player
private final transient UUID uniqueId = UUID.randomUUID();
@Delegate(types = org.bukkit.OfflinePlayer.class)
private transient org.bukkit.OfflinePlayer base;
private boolean allowFlight = false;
private boolean isFlying = false;
public OfflinePlayer(final String name, final IEssentials ess)
{
@@ -823,13 +826,13 @@ public class OfflinePlayer implements Player
@Override
public void setAllowFlight(boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
allowFlight = bln;
}
@Override
public boolean getAllowFlight()
{
throw new UnsupportedOperationException("Not supported yet.");
return allowFlight;
}
@Override
@@ -1046,13 +1049,13 @@ public class OfflinePlayer implements Player
@Override
public boolean isFlying()
{
throw new UnsupportedOperationException("Not supported yet.");
return isFlying;
}
@Override
public void setFlying(boolean arg0)
{
throw new UnsupportedOperationException("Not supported yet.");
isFlying = arg0;
}
@Override
@@ -1150,4 +1153,82 @@ public class OfflinePlayer implements Player
{
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.");
}
@Override
public void setCustomName(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getCustomName()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setCustomNameVisible(boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isCustomNameVisible()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setPlayerWeather(WeatherType arg0)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public WeatherType getPlayerWeather()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void resetPlayerWeather()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isOnGround()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Scoreboard getScoreboard()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setScoreboard(Scoreboard scrbrd) throws IllegalArgumentException, IllegalStateException
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -0,0 +1,22 @@
package com.earth2me.essentials;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public class PlayerTarget implements ITarget
{
private final String name;
PlayerTarget(Player entity)
{
this.name = entity.getName();
}
@Override
public Location getLocation()
{
return Bukkit.getServer().getPlayerExact(name).getLocation();
}
}

View File

@@ -0,0 +1,131 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.bukkit.potion.PotionEffectType;
public class Potions
{
private static final Map<String, PotionEffectType> POTIONS = new HashMap<String, PotionEffectType>();
private static final Map<String, PotionEffectType> ALIASPOTIONS = new HashMap<String, PotionEffectType>();
static
{
POTIONS.put("speed", PotionEffectType.SPEED);
ALIASPOTIONS.put("fast", PotionEffectType.SPEED);
ALIASPOTIONS.put("runfast", PotionEffectType.SPEED);
ALIASPOTIONS.put("sprint", PotionEffectType.SPEED);
ALIASPOTIONS.put("swift", PotionEffectType.SPEED);
POTIONS.put("slowness", PotionEffectType.SLOW);
ALIASPOTIONS.put("slow", PotionEffectType.SLOW);
ALIASPOTIONS.put("sluggish", PotionEffectType.SLOW);
POTIONS.put("haste", PotionEffectType.FAST_DIGGING);
ALIASPOTIONS.put("superpick", PotionEffectType.FAST_DIGGING);
ALIASPOTIONS.put("quickmine", PotionEffectType.FAST_DIGGING);
ALIASPOTIONS.put("digspeed", PotionEffectType.FAST_DIGGING);
ALIASPOTIONS.put("digfast", PotionEffectType.FAST_DIGGING);
ALIASPOTIONS.put("sharp", PotionEffectType.FAST_DIGGING);
POTIONS.put("fatigue", PotionEffectType.SLOW_DIGGING);
ALIASPOTIONS.put("slow", PotionEffectType.SLOW_DIGGING);
ALIASPOTIONS.put("dull", PotionEffectType.SLOW_DIGGING);
POTIONS.put("strength", PotionEffectType.INCREASE_DAMAGE);
ALIASPOTIONS.put("strong", PotionEffectType.INCREASE_DAMAGE);
ALIASPOTIONS.put("bull", PotionEffectType.INCREASE_DAMAGE);
ALIASPOTIONS.put("attack", PotionEffectType.INCREASE_DAMAGE);
POTIONS.put("heal", PotionEffectType.HEAL);
ALIASPOTIONS.put("healthy", PotionEffectType.HEAL);
ALIASPOTIONS.put("instaheal", PotionEffectType.HEAL);
POTIONS.put("harm", PotionEffectType.HARM);
ALIASPOTIONS.put("harming", PotionEffectType.HARM);
ALIASPOTIONS.put("injure", PotionEffectType.HARM);
ALIASPOTIONS.put("damage", PotionEffectType.HARM);
ALIASPOTIONS.put("inflict", PotionEffectType.HARM);
POTIONS.put("jump", PotionEffectType.JUMP);
ALIASPOTIONS.put("leap", PotionEffectType.JUMP);
POTIONS.put("nausea", PotionEffectType.CONFUSION);
ALIASPOTIONS.put("sick", PotionEffectType.CONFUSION);
ALIASPOTIONS.put("sickness", PotionEffectType.CONFUSION);
ALIASPOTIONS.put("confusion", PotionEffectType.CONFUSION);
POTIONS.put("regeneration", PotionEffectType.REGENERATION);
ALIASPOTIONS.put("regen", PotionEffectType.REGENERATION);
POTIONS.put("resistance", PotionEffectType.DAMAGE_RESISTANCE);
ALIASPOTIONS.put("dmgresist", PotionEffectType.DAMAGE_RESISTANCE);
ALIASPOTIONS.put("armor", PotionEffectType.DAMAGE_RESISTANCE);
ALIASPOTIONS.put("dmgresist", PotionEffectType.DAMAGE_RESISTANCE);
POTIONS.put("fireresist", PotionEffectType.FIRE_RESISTANCE);
ALIASPOTIONS.put("fireresistance", PotionEffectType.FIRE_RESISTANCE);
ALIASPOTIONS.put("resistfire", PotionEffectType.FIRE_RESISTANCE);
POTIONS.put("waterbreath", PotionEffectType.WATER_BREATHING);
ALIASPOTIONS.put("waterbreathing", PotionEffectType.WATER_BREATHING);
POTIONS.put("invisibility", PotionEffectType.INVISIBILITY);
ALIASPOTIONS.put("invisible", PotionEffectType.INVISIBILITY);
ALIASPOTIONS.put("invis", PotionEffectType.INVISIBILITY);
ALIASPOTIONS.put("vanish", PotionEffectType.INVISIBILITY);
ALIASPOTIONS.put("disappear", PotionEffectType.INVISIBILITY);
POTIONS.put("blindness", PotionEffectType.BLINDNESS);
ALIASPOTIONS.put("blind", PotionEffectType.BLINDNESS);
POTIONS.put("nightvision", PotionEffectType.NIGHT_VISION);
ALIASPOTIONS.put("vision", PotionEffectType.NIGHT_VISION);
POTIONS.put("hunger", PotionEffectType.HUNGER);
ALIASPOTIONS.put("hungry", PotionEffectType.HUNGER);
ALIASPOTIONS.put("starve", PotionEffectType.HUNGER);
POTIONS.put("weakness", PotionEffectType.WEAKNESS);
ALIASPOTIONS.put("weak", PotionEffectType.WEAKNESS);
POTIONS.put("poison", PotionEffectType.POISON);
ALIASPOTIONS.put("venom", PotionEffectType.POISON);
POTIONS.put("wither", PotionEffectType.WITHER);
ALIASPOTIONS.put("decay", PotionEffectType.WITHER);
}
public static PotionEffectType getByName(String name)
{
PotionEffectType peffect;
if (NumberUtil.isInt(name))
{
peffect = PotionEffectType.getById(Integer.parseInt(name));
}
else
{
peffect = PotionEffectType.getByName(name.toUpperCase(Locale.ENGLISH));
}
if (peffect == null)
{
peffect = POTIONS.get(name.toLowerCase(Locale.ENGLISH));
}
if (peffect == null)
{
peffect = ALIASPOTIONS.get(name.toLowerCase(Locale.ENGLISH));
}
return peffect;
}
public static Set<Entry<String, PotionEffectType>> entrySet()
{
return POTIONS.entrySet();
}
}

View File

@@ -6,7 +6,9 @@ import com.earth2me.essentials.signs.EssentialsSign;
import com.earth2me.essentials.signs.Signs;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.SimpleTextInput;
import com.earth2me.essentials.utils.FormatUtil;
import java.io.File;
import java.math.BigDecimal;
import java.text.MessageFormat;
import java.util.*;
import java.util.logging.Level;
@@ -112,9 +114,9 @@ public class Settings implements ISettings
}
@Override
public int getStartingBalance()
public BigDecimal getStartingBalance()
{
return config.getInt("starting-balance", 0);
return config.getBigDecimal("starting-balance", BigDecimal.ZERO);
}
@Override
@@ -177,12 +179,12 @@ public class Settings implements ISettings
private ConfigurationSection commandCosts;
@Override
public double getCommandCost(IEssentialsCommand cmd)
public BigDecimal getCommandCost(IEssentialsCommand cmd)
{
return getCommandCost(cmd.getName());
}
public ConfigurationSection _getCommandCosts()
private ConfigurationSection _getCommandCosts()
{
if (config.isConfigurationSection("command-costs"))
{
@@ -228,14 +230,40 @@ public class Settings implements ISettings
}
@Override
public double getCommandCost(String name)
public BigDecimal getCommandCost(String name)
{
name = name.replace('.', '_').replace('/', '_');
if (commandCosts != null)
{
return commandCosts.getDouble(name, 0.0);
return EssentialsConf.toBigDecimal(commandCosts.getString(name), BigDecimal.ZERO);
}
return 0.0;
return BigDecimal.ZERO;
}
private Set<String> socialSpyCommands = new HashSet<String>();
private Set<String> _getSocialSpyCommands()
{
Set<String> socialspyCommands = new HashSet<String>();
if (config.isList("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;
}
@Override
public Set<String> getSocialSpyCommands()
{
return socialSpyCommands;
}
private String nicknamePrefix = "~";
@@ -263,7 +291,7 @@ public class Settings implements ISettings
}
private ConfigurationSection kits;
public ConfigurationSection _getKits()
private ConfigurationSection _getKits()
{
if (config.isConfigurationSection("kits"))
{
@@ -383,8 +411,8 @@ public class Settings implements ISettings
if (mFormat == null)
{
String format = config.getString("chat.group-formats." + (group == null ? "Default" : group),
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
format = Util.replaceFormat(format);
config.getString("chat.format", "&7[{GROUP}]&r {DISPLAYNAME}&7:&r {MESSAGE}"));
format = FormatUtil.replaceFormat(format);
format = format.replace("{DISPLAYNAME}", "%1$s");
format = format.replace("{GROUP}", "{0}");
format = format.replace("{MESSAGE}", "%2$s");
@@ -407,7 +435,7 @@ public class Settings implements ISettings
@Override
public IText getAnnounceNewPlayerFormat()
{
return new SimpleTextInput(Util.replaceFormat(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")));
return new SimpleTextInput(FormatUtil.replaceFormat(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")));
}
@Override
@@ -429,9 +457,26 @@ public class Settings implements ISettings
}
@Override
public boolean getSortListByGroups()
public Map<String, Object> getListGroupConfig()
{
return config.getBoolean("sort-list-by-groups", true);
if (config.isConfigurationSection("list"))
{
Map<String, Object> values = config.getConfigurationSection("list").getValues(false);
if (!values.isEmpty())
{
return values;
}
}
Map<String, Object> defaultMap = new HashMap<String, Object>();
if (config.getBoolean("sort-list-by-groups", false))
{
defaultMap.put("ListByGroup", "ListByGroup");
}
else
{
defaultMap.put("Players", "*");
}
return defaultMap;
}
@Override
@@ -440,10 +485,12 @@ public class Settings implements ISettings
config.load();
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds"));
enabledSigns = _getEnabledSigns();
teleportInvulnerabilityTime = _getTeleportInvulnerability();
teleportInvulnerability = _isTeleportInvulnerability();
disableItemPickupWhileAfk = _getDisableItemPickupWhileAfk();
registerBackInListener = _registerBackInListener();
cancelAfkOnMove = _cancelAfkOnMove();
cancelAfkOnInteract = _cancelAfkOnInteract();
cancelAfkOnMove = _cancelAfkOnMove() && cancelAfkOnInteract;
getFreezeAfkPlayers = _getFreezeAfkPlayers();
itemSpawnBl = _getItemSpawnBlacklist();
loginAttackDelay = _getLoginAttackDelay();
@@ -462,8 +509,14 @@ public class Settings implements ISettings
disableSuffix = _disableSuffix();
chatRadius = _getChatRadius();
commandCosts = _getCommandCosts();
socialSpyCommands = _getSocialSpyCommands();
warnOnBuildDisallow = _warnOnBuildDisallow();
mailsPerMinute = _getMailsPerMinute();
maxMoney = _getMaxMoney();
minMoney = _getMinMoney();
economyLagWarning = _getEconomyLagWarning();
economyLog = _isEcoLogEnabled();
economyLogUpdate = _isEcoLogUpdateEnabled();
}
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
@@ -590,12 +643,14 @@ public class Settings implements ISettings
return config.getString("currency-symbol", "$").concat("$").substring(0, 1).replaceAll("[0-9]", "$");
}
// #easteregg
@Override
public boolean isTradeInStacks(int id)
{
return config.getBoolean("trade-in-stacks-" + id, false);
}
// #easteregg
@Override
public boolean isEcoDisabled()
{
@@ -644,43 +699,59 @@ public class Settings implements ISettings
{
return config.getBoolean(configName, def);
}
private final static double MAXMONEY = 10000000000000.0;
private final static BigDecimal MAXMONEY = new BigDecimal("10000000000000");
private BigDecimal maxMoney = MAXMONEY;
@Override
public double getMaxMoney()
private BigDecimal _getMaxMoney()
{
double max = config.getDouble("max-money", MAXMONEY);
if (Math.abs(max) > MAXMONEY)
{
max = max < 0 ? -MAXMONEY : MAXMONEY;
}
return max;
return config.getBigDecimal("max-money", MAXMONEY);
}
private final static double MINMONEY = -10000000000000.0;
@Override
public double getMinMoney()
public BigDecimal getMaxMoney()
{
double min = config.getDouble("min-money", MINMONEY);
if (min > 0)
return maxMoney;
}
private final static BigDecimal MINMONEY = new BigDecimal("-10000000000000");
private BigDecimal minMoney = MINMONEY;
private BigDecimal _getMinMoney()
{
BigDecimal min = config.getBigDecimal("min-money", MINMONEY);
if (min.signum() > 0)
{
min = -min;
}
if (min < MINMONEY)
{
min = MINMONEY;
min = min.negate();
}
return min;
}
@Override
public BigDecimal getMinMoney()
{
return minMoney;
}
private boolean economyLog = false;
@Override
public boolean isEcoLogEnabled()
{
return economyLog;
}
public boolean _isEcoLogEnabled()
{
return config.getBoolean("economy-log-enabled", false);
}
// #easteregg
private boolean economyLogUpdate = false;
@Override
public boolean isEcoLogUpdateEnabled()
{
return economyLogUpdate;
}
public boolean _isEcoLogUpdateEnabled()
{
return config.getBoolean("economy-log-update-enabled", false);
}
@@ -745,6 +816,7 @@ public class Settings implements ISettings
{
return prefixsuffixconfigured ? addprefixsuffix : essentialsChatActive;
}
// #easteregg
private boolean disablePrefix = false;
private boolean _disablePrefix()
@@ -757,6 +829,7 @@ public class Settings implements ISettings
{
return disablePrefix;
}
// #easteregg
private boolean disableSuffix = false;
private boolean _disableSuffix()
@@ -805,6 +878,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()
@@ -831,6 +916,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()
{
@@ -897,7 +988,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
@@ -911,13 +1002,19 @@ public class Settings implements ISettings
{
this.metricsEnabled = metricsEnabled;
}
private boolean teleportInvulnerability;
private long teleportInvulnerabilityTime;
private long _getTeleportInvulnerability()
{
return config.getLong("teleport-invulnerability", 0) * 1000;
}
@Override
public long getTeleportInvulnerability()
{
return config.getLong("teleport-invulnerability", 0) * 1000;
return teleportInvulnerabilityTime;
}
private boolean teleportInvulnerability;
private boolean _isTeleportInvulnerability()
{
@@ -958,12 +1055,10 @@ public class Settings implements ISettings
@Override
public double getMaxFlySpeed()
{
double maxSpeed = config.getDouble("max-fly-speed", 1.0);
double maxSpeed = config.getDouble("max-fly-speed", 0.8);
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()
{
@@ -982,4 +1077,25 @@ public class Settings implements ISettings
{
return mailsPerMinute;
}
// #easteregg
private long economyLagWarning;
private long _getEconomyLagWarning()
{
// Default to 20ms
final long value = (long)(config.getDouble("economy-lag-warning", 20.0) * 1000000);
return value;
}
@Override
public long getEconomyLagWarning()
{
return economyLagWarning;
}
@Override
public long getMaxTempban()
{
return config.getLong("max-tempban-time", -1);
}
}

View File

@@ -1,18 +1,26 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.StringUtil;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Mob.MobException;
import com.earth2me.essentials.utils.LocationUtil;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import java.util.Set;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
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.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Colorable;
@@ -24,7 +32,7 @@ public class SpawnMob
final Set<String> availableList = new HashSet<String>();
for (String mob : mobList)
{
if (user.isAuthorized("essentials.spawnmob." + mob.toLowerCase()))
if (user.isAuthorized("essentials.spawnmob." + mob.toLowerCase(Locale.ENGLISH)))
{
availableList.add(mob);
}
@@ -33,92 +41,105 @@ public class SpawnMob
{
availableList.add(_("none"));
}
return Util.joinList(availableList);
return StringUtil.joinList(availableList);
}
public static String[] mobData(final String mobString)
public static List<String> mobParts(final String mobString)
{
String[] returnString = new String[4];
String[] mobParts = mobString.split(",");
final String[] parts = mobString.split(",");
String[] mobParts = parts[0].split(":");
List<String> mobs = new ArrayList<String>();
returnString[0] = mobParts[0];
if (mobParts.length == 2)
for (String mobPart : mobParts)
{
returnString[1] = mobParts[1];
String[] mobDatas = mobPart.split(":");
mobs.add(mobDatas[0]);
}
return mobs;
}
if (parts.length > 1)
public static List<String> mobData(final String mobString)
{
String[] mobParts = mobString.split(",");
List<String> mobData = new ArrayList<String>();
for (String mobPart : mobParts)
{
String[] mountParts = parts[1].split(":");
returnString[2] = mountParts[0];
if (mountParts.length == 2)
String[] mobDatas = mobPart.split(":");
if (mobDatas.length == 1)
{
returnString[3] = mountParts[1];
mobData.add(null);
}
else
{
mobData.add(mobDatas[1]);
}
}
return returnString;
return mobData;
}
// 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
public static void spawnmob(final IEssentials ess, final Server server, final User user, final List<String> parts, final List<String> data, int mobCount) throws Exception
{
final Block block = Util.getTarget(user).getBlock();
final Block block = LocationUtil.getTarget(user).getBlock();
if (block == null)
{
throw new Exception(_("unableToSpawnMob"));
}
spawnmob(ess, server, user, user, block.getLocation(), Data, mobCount);
spawnmob(ess, server, user, user, block.getLocation(), parts, 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
public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final Location loc, final List<String> parts, final List<String> data, int mobCount) throws Exception
{
spawnmob(ess, server, sender, null, loc, Data, mobCount);
spawnmob(ess, server, sender, null, loc, parts, 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
public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final User target, final List<String> parts, final List<String> data, int mobCount) throws Exception
{
spawnmob(ess, server, sender, target, target.getLocation(), Data, mobCount);
spawnmob(ess, server, sender, target, target.getLocation(), parts, 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
public static void spawnmob(final IEssentials ess, final Server server, final CommandSender sender, final User target, final Location loc, final List<String> parts, final List<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];
final Location sloc = LocationUtil.getSafeDestination(loc);
Mob mob = Mob.fromName(mobType);
Mob mobMount = null;
checkSpawnable(ess, sender, mob);
if (mountType != null)
for (int i = 0; i < parts.size(); i++)
{
mobMount = Mob.fromName(mountType);
checkSpawnable(ess, sender, mobMount);
Mob mob = Mob.fromName(parts.get(i));
checkSpawnable(ess, sender, mob);
}
int serverLimit = ess.getSettings().getSpawnMobLimit();
if (mobCount > serverLimit)
final int serverLimit = ess.getSettings().getSpawnMobLimit();
int effectiveLimit = serverLimit / parts.size();
if (effectiveLimit < 1)
{
mobCount = serverLimit;
effectiveLimit = 1;
while (parts.size() > serverLimit)
{
parts.remove(serverLimit);
}
}
if (mobCount > effectiveLimit)
{
mobCount = effectiveLimit;
sender.sendMessage(_("mobSpawnLimit"));
}
Mob mob = Mob.fromName(parts.get(0)); // Get the first mob
try
{
for (int i = 0; i < mobCount; i++)
{
spawnMob(ess, server, sender, target, sloc, mob, mobData, mobMount, mountData);
spawnMob(ess, server, sender, target, sloc, parts, data);
}
sender.sendMessage(mobCount + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned"));
sender.sendMessage(mobCount * parts.size() + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned"));
}
catch (MobException e1)
{
@@ -134,23 +155,42 @@ public class SpawnMob
}
}
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
private static void spawnMob(final IEssentials ess, final Server server, final CommandSender sender, final User target, final Location sloc, List<String> parts, List<String> data) throws Exception
{
Entity spawnedMob = mob.spawn(sloc.getWorld(), server, sloc);
Entity spawnedMount = null;
Mob mob;
Entity spawnedMob = null;
Entity spawnedMount;
if (mobMount != null)
for (int i = 0; i < parts.size(); i++)
{
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);
if (i == 0)
{
mob = Mob.fromName(parts.get(i));
spawnedMob = mob.spawn(sloc.getWorld(), server, sloc);
defaultMobData(mob.getType(), spawnedMob);
if (data.get(i) != null)
{
changeMobData(mob.getType(), spawnedMob, data.get(i), target);
}
}
int next = (i + 1);
if (next < parts.size()) //If it's the last mob in the list, don't set the mount
{
Mob mMob = Mob.fromName(parts.get(next));
spawnedMount = mMob.spawn(sloc.getWorld(), server, sloc);
defaultMobData(mMob.getType(), spawnedMount);
if (data.get(next) != null)
{
changeMobData(mMob.getType(), spawnedMount, data.get(next), target);
}
spawnedMob.setPassenger(spawnedMount);
spawnedMob = spawnedMount;
}
}
}
@@ -166,7 +206,7 @@ public class SpawnMob
throw new Exception(_("disabledToSpawnMob"));
}
if (sender instanceof User && !((User)sender).isAuthorized("essentials.spawnmob." + mob.name.toLowerCase()))
if (sender instanceof User && !((User)sender).isAuthorized("essentials.spawnmob." + mob.name.toLowerCase(Locale.ENGLISH)))
{
throw new Exception(_("noPermToSpawnMob"));
}
@@ -176,6 +216,52 @@ public class SpawnMob
{
data = data.toLowerCase(Locale.ENGLISH);
if (spawned instanceof Zombie || type == EntityType.SKELETON)
{
//This should match all Living Entities but most mobs will just ignore the equipment.
if (data.contains("armor") || data.contains("armour"))
{
final EntityEquipment invent = ((LivingEntity)spawned).getEquipment();
if (data.contains("diamond"))
{
invent.setBoots(new ItemStack(Material.DIAMOND_BOOTS, 1));
invent.setLeggings(new ItemStack(Material.DIAMOND_BOOTS, 1));
invent.setChestplate(new ItemStack(Material.DIAMOND_BOOTS, 1));
invent.setHelmet(new ItemStack(Material.DIAMOND_BOOTS, 1));
}
else if (data.contains("gold"))
{
invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
invent.setLeggings(new ItemStack(Material.GOLD_BOOTS, 1));
invent.setChestplate(new ItemStack(Material.GOLD_BOOTS, 1));
invent.setHelmet(new ItemStack(Material.GOLD_BOOTS, 1));
}
else if (data.contains("leather"))
{
invent.setBoots(new ItemStack(Material.LEATHER_BOOTS, 1));
invent.setLeggings(new ItemStack(Material.LEATHER_BOOTS, 1));
invent.setChestplate(new ItemStack(Material.LEATHER_BOOTS, 1));
invent.setHelmet(new ItemStack(Material.LEATHER_BOOTS, 1));
}
else if (data.contains("no"))
{
invent.clear();
}
else
{
invent.setBoots(new ItemStack(Material.IRON_BOOTS, 1));
invent.setLeggings(new ItemStack(Material.IRON_BOOTS, 1));
invent.setChestplate(new ItemStack(Material.IRON_BOOTS, 1));
invent.setHelmet(new ItemStack(Material.IRON_BOOTS, 1));
}
invent.setBootsDropChance(0f);
invent.setLeggingsDropChance(0f);
invent.setChestplateDropChance(0f);
invent.setHelmetDropChance(0f);
}
}
if (spawned instanceof Slime)
{
try
@@ -238,15 +324,15 @@ public class SpawnMob
if (type == EntityType.OCELOT)
{
if (data.contains("siamese"))
if (data.contains("siamese") || data.contains("white"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.SIAMESE_CAT);
}
else if (data.contains("red"))
else if (data.contains("red") || data.contains("orange") || data.contains("tabby"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.RED_CAT);
}
else if (data.contains("black"))
else if (data.contains("black") || data.contains("tuxedo"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.BLACK_CAT);
}
@@ -274,6 +360,31 @@ public class SpawnMob
((Zombie)spawned).setBaby(true);
}
}
if (spawned instanceof Zombie || type == EntityType.SKELETON)
{
if (data.contains("sword"))
{
final EntityEquipment invent = ((LivingEntity)spawned).getEquipment();
if (data.contains("diamond"))
{
invent.setItemInHand(new ItemStack(Material.DIAMOND_SWORD, 1));
}
else if (data.contains("gold"))
{
invent.setItemInHand(new ItemStack(Material.GOLD_SWORD, 1));
}
else if (data.contains("iron"))
{
invent.setItemInHand(new ItemStack(Material.IRON_SWORD, 1));
}
else
{
invent.setItemInHand(new ItemStack(Material.STONE_SWORD, 1));
}
invent.setItemInHandDropChance(0.1f);
}
}
if (type == EntityType.SKELETON)
{
@@ -283,5 +394,44 @@ public class SpawnMob
}
}
if (type == EntityType.EXPERIENCE_ORB)
{
if (NumberUtil.isInt(data))
{
((ExperienceOrb)spawned).setExperience(Integer.parseInt(data));
}
}
}
private static void defaultMobData(final EntityType type, final Entity spawned)
{
if (type == EntityType.SKELETON)
{
final EntityEquipment invent = ((LivingEntity)spawned).getEquipment();
invent.setItemInHand(new ItemStack(Material.BOW, 1));
invent.setItemInHandDropChance(0.1f);
invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
invent.setBootsDropChance(0.0f);
}
if (type == EntityType.PIG_ZOMBIE)
{
final EntityEquipment invent = ((LivingEntity)spawned).getEquipment();
invent.setItemInHand(new ItemStack(Material.GOLD_SWORD, 1));
invent.setItemInHandDropChance(0.1f);
invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
invent.setBootsDropChance(0.0f);
}
if (type == EntityType.ZOMBIE)
{
final EntityEquipment invent = ((LivingEntity)spawned).getEquipment();
invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
invent.setBootsDropChance(0.0f);
}
}
}

View File

@@ -2,391 +2,256 @@ package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.ITeleport;
import com.earth2me.essentials.commands.NoChargeException;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.LocationUtil;
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;
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)
{
return ess.getServer().getPlayerExact(name).getLocation();
}
return location;
}
}
private IUser user;
private IUser teleportUser;
private int teleTimer = -1;
private long started; // time this task was initiated
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)
// so, the X/Y/Z values are stored instead and rounded off
private long initX;
private long initY;
private long initZ;
private Target teleportTarget;
private boolean respawn;
private Trade chargeFor;
public class Teleport implements ITeleport
{
private final IUser teleportOwner;
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.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(false);
return;
}
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 = teleportUser.getHealth(); // in case user healed, then later gets injured
long now = System.currentTimeMillis();
if (now > started + tpdelay)
{
try
{
cooldown(false);
teleportUser.sendMessage(_("teleportationCommencing"));
try
{
if (respawn) {
teleportUser.getTeleport().respawn(cause);
}
else {
teleportUser.getTeleport().now(teleportTarget, cause);
}
cancel(false);
if (chargeFor != null)
{
chargeFor.charge(user);
}
}
catch (Throwable ex)
{
ess.showError(user.getBase(), ex, "teleport");
}
}
catch (Exception ex)
{
user.sendMessage(_("cooldownWithMessage", ex.getMessage()));
if (user != teleportUser)
{
teleportUser.sendMessage(_("cooldownWithMessage", ex.getMessage()));
}
}
}
}
private TimedTeleport timedTeleport;
public Teleport(IUser user, IEssentials ess)
{
this.user = user;
this.teleportOwner = user;
this.ess = ess;
}
public void cooldown(boolean check) throws Exception
{
final Calendar time = new GregorianCalendar();
if (user.getLastTeleportTimestamp() > 0)
if (teleportOwner.getLastTeleportTimestamp() > 0)
{
// Take the current time, and remove the delay from it.
final double cooldown = ess.getSettings().getTeleportCooldown();
final Calendar earliestTime = new GregorianCalendar();
earliestTime.add(Calendar.SECOND, -(int)cooldown);
earliestTime.add(Calendar.MILLISECOND, -(int)((cooldown * 1000.0) % 1000.0));
// This value contains the most recent time a teleport could have been used that would allow another use.
// This value contains the most recent time a teleportPlayer could have been used that would allow another use.
final long earliestLong = earliestTime.getTimeInMillis();
// When was the last teleport used?
final Long lastTime = user.getLastTeleportTimestamp();
// When was the last teleportPlayer used?
final Long lastTime = teleportOwner.getLastTeleportTimestamp();
if (lastTime > time.getTimeInMillis())
{
// This is to make sure time didn't get messed up on last kit use.
// This is to make sure time didn't get messed up on last teleportPlayer use.
// If this happens, let's give the user the benifit of the doubt.
user.setLastTeleportTimestamp(time.getTimeInMillis());
teleportOwner.setLastTeleportTimestamp(time.getTimeInMillis());
return;
}
else if (lastTime > earliestLong && !user.isAuthorized("essentials.teleport.cooldown.bypass"))
else if (lastTime > earliestLong && !teleportOwner.isAuthorized("essentials.teleport.cooldown.bypass"))
{
time.setTimeInMillis(lastTime);
time.add(Calendar.SECOND, (int)cooldown);
time.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
throw new Exception(_("timeBeforeTeleport", Util.formatDateDiff(time.getTimeInMillis())));
throw new Exception(_("timeBeforeTeleport", DateUtil.formatDateDiff(time.getTimeInMillis())));
}
}
// if justCheck is set, don't update lastTeleport; we're just checking
if (!check)
{
user.setLastTeleportTimestamp(time.getTimeInMillis());
teleportOwner.setLastTeleportTimestamp(time.getTimeInMillis());
}
}
//If we need to cancel a pending teleport call this method
public void cancel(boolean notifyUser)
{
if (teleTimer == -1)
{
return;
}
try
{
ess.getServer().getScheduler().cancelTask(teleTimer);
if (notifyUser)
{
user.sendMessage(_("pendingTeleportCancelled"));
if (teleportUser != user)
{
teleportUser.sendMessage(_("pendingTeleportCancelled"));
}
}
}
finally
{
teleTimer = -1;
}
}
//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(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);
}
cooldown(true);
if (delay <= 0 || user.isAuthorized("essentials.teleport.timer.bypass"))
{
cooldown(false);
now(target, cause);
if (chargeFor != null)
{
chargeFor.charge(user);
}
return;
}
cancel(false);
warnUser(user, delay);
initTimer((long)(delay * 1000.0), target, chargeFor, cause);
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
}
//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())));
user.sendMessage(_("dontMoveMessage", DateUtil.formatDateDiff(c.getTimeInMillis())));
}
//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
//The now function is used when you want to skip tp delay when teleporting someone to a location or player.
@Override
public void now(Location loc, boolean cooldown, 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"))
if (cooldown)
{
cooldown(false);
respawn(cause);
}
now(teleportOwner, new LocationTarget(loc), cause);
}
@Override
public void now(Player entity, boolean cooldown, TeleportCause cause) throws Exception
{
if (cooldown)
{
cooldown(false);
}
now(teleportOwner, new PlayerTarget(entity), cause);
}
protected void now(IUser teleportee, ITarget target, TeleportCause cause) throws Exception
{
cancel(false);
teleportee.setLastLocation();
teleportee.getBase().teleport(LocationUtil.getSafeDestination(target.getLocation()), cause);
}
//The teleportPlayer function is used when you want to normally teleportPlayer 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(loc, chargeFor, TeleportCause.PLUGIN);
}
@Override
public void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
{
teleport(teleportOwner, new LocationTarget(loc), chargeFor, cause);
}
@Override
public void teleport(Player entity, Trade chargeFor, TeleportCause cause) throws Exception
{
teleport(teleportOwner, new PlayerTarget(entity), chargeFor, cause);
}
@Override
public void teleportPlayer(IUser teleportee, Location loc, Trade chargeFor, TeleportCause cause) throws Exception
{
teleport(teleportee, new LocationTarget(loc), chargeFor, cause);
}
@Override
public void teleportPlayer(IUser teleportee, Player entity, Trade chargeFor, TeleportCause cause) throws Exception
{
teleport(teleportee, new PlayerTarget(entity), chargeFor, cause);
}
private void teleport(IUser teleportee, ITarget target, Trade chargeFor, TeleportCause cause) throws Exception
{
double delay = ess.getSettings().getTeleportDelay();
if (chargeFor != null)
{
chargeFor.isAffordableFor(teleportOwner);
}
cooldown(true);
if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass")
|| teleportee.isAuthorized("essentials.teleport.timer.bypass"))
{
cooldown(false);
now(teleportee, target, cause);
if (chargeFor != null)
{
chargeFor.charge(user);
chargeFor.charge(teleportOwner);
}
return;
}
cancel(false);
initTimer((long)(delay * 1000.0), user, null, chargeFor, cause, true);
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
warnUser(teleportee, delay);
initTimer((long)(delay * 1000.0), teleportee, target, chargeFor, cause, false);
}
public void respawn(TeleportCause cause) throws Exception
//The teleportToMe function is a wrapper used to handle teleporting players to them, like /tphere
@Override
public void teleportToMe(IUser otherUser, Trade chargeFor, TeleportCause cause) throws Exception
{
final Player player = user.getBase();
Location bed = player.getBedSpawnLocation();
if (bed != null && bed.getBlock().getType() != Material.BED_BLOCK)
ITarget target = new PlayerTarget(teleportOwner);
teleport(otherUser, target, chargeFor, cause);
}
//The respawn function is a wrapper used to handle tp fallback, on /jail and /home
@Override
public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception
{
double delay = ess.getSettings().getTeleportDelay();
if (chargeFor != null)
{
now(new Target(bed), cause);
chargeFor.isAffordableFor(teleportOwner);
}
cooldown(true);
if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass"))
{
cooldown(false);
respawnNow(teleportOwner, cause);
if (chargeFor != null)
{
chargeFor.charge(teleportOwner);
}
return;
}
cancel(false);
warnUser(teleportOwner, delay);
initTimer((long)(delay * 1000.0), teleportOwner, null, chargeFor, cause, true);
}
protected void respawnNow(IUser teleportee, TeleportCause cause) throws Exception
{
final Player player = teleportee.getBase();
Location bed = player.getBedSpawnLocation();
if (bed != null)
{
now(teleportee, new LocationTarget(bed), cause);
}
else
{
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(teleportee, new LocationTarget(pre.getRespawnLocation()), 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
//The warp function is a wrapper used to teleportPlayer a player to a /warp
@Override
public void warp(IUser teleportee, String warp, Trade chargeFor, TeleportCause cause) throws Exception
{
Location loc = ess.getWarps().getWarp(warp);
user.sendMessage(_("warpingTo", warp));
teleport(new Target(loc), chargeFor, cause);
teleportee.sendMessage(_("warpingTo", warp));
teleport(teleportee, new LocationTarget(loc), chargeFor, cause);
}
//The back function is a wrapper used to teleport a player /back to their previous location.
//The back function is a wrapper used to teleportPlayer a player /back to their previous location.
@Override
public void back(Trade chargeFor) throws Exception
{
teleport(new Target(user.getLastLocation()), chargeFor, TeleportCause.COMMAND);
teleport(teleportOwner, new LocationTarget(teleportOwner.getLastLocation()), chargeFor, TeleportCause.COMMAND);
}
//This function is used to throw a user back after a jail sentence
@Override
public void back() throws Exception
{
now(new Target(user.getLastLocation()), TeleportCause.COMMAND);
now(teleportOwner, new LocationTarget(teleportOwner.getLastLocation()), TeleportCause.COMMAND);
}
//This function handles teleporting to /home
@Override
public void home(Location loc, Trade chargeFor) throws Exception
{
teleport(new Target(loc), chargeFor, TeleportCause.COMMAND);
teleport(teleportOwner, new LocationTarget(loc), chargeFor, TeleportCause.COMMAND);
}
//If we need to cancelTimer a pending teleportPlayer call this method
private void cancel(boolean notifyUser)
{
if (timedTeleport != null)
{
timedTeleport.cancelTimer(notifyUser);
timedTeleport = null;
}
}
private void initTimer(long delay, IUser teleportUser, ITarget target, Trade chargeFor, TeleportCause cause, boolean respawn)
{
timedTeleport = new TimedTeleport(teleportOwner, ess, this, delay, teleportUser, target, chargeFor, cause, respawn);
}
}

View File

@@ -0,0 +1,153 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import org.bukkit.Location;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class TimedTeleport implements Runnable
{
private static final double MOVE_CONSTANT = 0.3;
private final IUser teleportOwner;
private final IEssentials ess;
private final Teleport teleport;
private String timer_teleportee;
private int timer_task = -1;
private long timer_started; // time this task was initiated
private long timer_delay; // how long to delay the teleportPlayer
private int timer_health;
// note that I initially stored a clone of the location for reference, but...
// when comparing locations, I got incorrect mismatches (rounding errors, looked like)
// so, the X/Y/Z values are stored instead and rounded off
private long timer_initX;
private long timer_initY;
private long timer_initZ;
private ITarget timer_teleportTarget;
private boolean timer_respawn;
private boolean timer_canMove;
private Trade timer_chargeFor;
private TeleportCause timer_cause;
public TimedTeleport(IUser user, IEssentials ess, Teleport teleport, long delay, IUser teleportUser, ITarget target, Trade chargeFor, TeleportCause cause, boolean respawn)
{
this.teleportOwner = user;
this.ess = ess;
this.teleport = teleport;
this.timer_started = System.currentTimeMillis();
this.timer_delay = delay;
this.timer_health = teleportUser.getHealth();
this.timer_initX = Math.round(teleportUser.getLocation().getX() * MOVE_CONSTANT);
this.timer_initY = Math.round(teleportUser.getLocation().getY() * MOVE_CONSTANT);
this.timer_initZ = Math.round(teleportUser.getLocation().getZ() * MOVE_CONSTANT);
this.timer_teleportee = teleportUser.getName();
this.timer_teleportTarget = target;
this.timer_chargeFor = chargeFor;
this.timer_cause = cause;
this.timer_respawn = respawn;
this.timer_canMove = user.isAuthorized("essentials.teleport.timer.move");
timer_task = ess.scheduleSyncRepeatingTask(this, 20, 20);
}
@Override
public void run()
{
if (teleportOwner == null || !teleportOwner.isOnline() || teleportOwner.getLocation() == null)
{
cancelTimer(false);
return;
}
IUser teleportUser = ess.getUser(this.timer_teleportee);
if (teleportUser == null || !teleportUser.isOnline())
{
cancelTimer(false);
return;
}
final Location currLocation = teleportUser.getLocation();
if (currLocation == null)
{
cancelTimer(false);
return;
}
if (!timer_canMove
&& (Math.round(currLocation.getX() * MOVE_CONSTANT) != timer_initX
|| Math.round(currLocation.getY() * MOVE_CONSTANT) != timer_initY
|| Math.round(currLocation.getZ() * MOVE_CONSTANT) != timer_initZ
|| teleportUser.getHealth() < timer_health))
{
// user moved, cancelTimer teleportPlayer
cancelTimer(true);
return;
}
timer_health = teleportUser.getHealth(); // in case user healed, then later gets injured
final long now = System.currentTimeMillis();
if (now > timer_started + timer_delay)
{
try
{
teleport.cooldown(false);
teleportUser.sendMessage(_("teleportationCommencing"));
try
{
if (timer_respawn)
{
teleport.respawnNow(teleportUser, timer_cause);
}
else
{
teleport.now(teleportUser, timer_teleportTarget, timer_cause);
}
cancelTimer(false);
if (timer_chargeFor != null)
{
timer_chargeFor.charge(teleportOwner);
}
}
catch (Throwable ex)
{
ess.showError(teleportOwner.getBase(), ex, "teleport");
}
}
catch (Exception ex)
{
teleportOwner.sendMessage(_("cooldownWithMessage", ex.getMessage()));
if (teleportOwner != teleportUser)
{
teleportUser.sendMessage(_("cooldownWithMessage", ex.getMessage()));
}
}
}
}
//If we need to cancelTimer a pending teleportPlayer call this method
public void cancelTimer(boolean notifyUser)
{
if (timer_task == -1)
{
return;
}
try
{
ess.getServer().getScheduler().cancelTask(timer_task);
if (notifyUser)
{
teleportOwner.sendMessage(_("pendingTeleportCancelled"));
if (timer_teleportee != null && !timer_teleportee.equals(teleportOwner.getName()))
{
ess.getUser(timer_teleportee).sendMessage(_("pendingTeleportCancelled"));
}
}
}
finally
{
timer_task = -1;
}
}
}

View File

@@ -6,6 +6,7 @@ import com.earth2me.essentials.craftbukkit.SetExpFix;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
@@ -21,11 +22,27 @@ public class Trade
{
private final transient String command;
private final transient Trade fallbackTrade;
private final transient Double money;
private final transient BigDecimal money;
private final transient ItemStack itemStack;
private final transient Integer exp;
private final transient IEssentials ess;
public enum TradeType
{
MONEY,
EXP,
ITEM
}
public enum OverflowType
{
ABORT,
DROP,
RETURN
}
public Trade(final String command, final IEssentials ess)
{
this(command, null, null, null, null, ess);
@@ -36,7 +53,13 @@ public class Trade
this(command, fallback, null, null, null, ess);
}
@Deprecated
public Trade(final double money, final IEssentials ess)
{
this(null, null, BigDecimal.valueOf(money), null, null, ess);
}
public Trade(final BigDecimal money, final IEssentials ess)
{
this(null, null, money, null, null, ess);
}
@@ -51,7 +74,7 @@ public class Trade
this(null, null, null, null, exp, ess);
}
private Trade(final String command, final Trade fallback, final Double money, final ItemStack item, final Integer exp, final IEssentials ess)
private Trade(final String command, final Trade fallback, final BigDecimal money, final ItemStack item, final Integer exp, final IEssentials ess)
{
this.command = command;
this.fallbackTrade = fallback;
@@ -70,7 +93,7 @@ public class Trade
}
if (getMoney() != null
&& getMoney() > 0
&& getMoney().signum() > 0
&& !user.canAfford(getMoney()))
{
throw new ChargeException(_("notEnoughMoney"));
@@ -82,9 +105,9 @@ public class Trade
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
}
double money;
BigDecimal money;
if (command != null && !command.isEmpty()
&& 0 < (money = getCommandCost(user))
&& (money = getCommandCost(user)).signum() > 0
&& !user.canAfford(money))
{
throw new ChargeException(_("notEnoughMoney"));
@@ -97,47 +120,82 @@ public class Trade
}
}
public void pay(final IUser user)
public boolean pay(final IUser user)
{
pay(user, true);
return pay(user, OverflowType.ABORT) == null;
}
public boolean pay(final IUser user, final boolean dropItems)
public Map<Integer, ItemStack> pay(final IUser user, final OverflowType type)
{
boolean success = true;
if (getMoney() != null && getMoney() > 0)
if (getMoney() != null && getMoney().signum() > 0)
{
if (ess.getSettings().isDebug())
{
ess.getLogger().log(Level.INFO, "paying user " + user.getName() + " via trade " + getMoney().toPlainString());
}
user.giveMoney(getMoney());
}
if (getItemStack() != null)
{
if (dropItems)
// This stores the would be overflow
Map<Integer, ItemStack> overFlow = InventoryWorkaround.addAllItems(user.getInventory(), getItemStack());
if (overFlow != null)
{
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItems(user.getInventory(), getItemStack());
final Location loc = user.getLocation();
for (ItemStack itemStack : leftOver.values())
switch (type)
{
final int maxStackSize = itemStack.getType().getMaxStackSize();
final int stacks = itemStack.getAmount() / maxStackSize;
final int leftover = itemStack.getAmount() % maxStackSize;
final Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
for (int i = 0; i < stacks; i++)
case ABORT:
if (ess.getSettings().isDebug())
{
final ItemStack stack = itemStack.clone();
stack.setAmount(maxStackSize);
itemStacks[i] = loc.getWorld().dropItem(loc, stack);
ess.getLogger().log(Level.INFO, "abort paying " + user.getName() + " itemstack " + getItemStack().toString() + " due to lack of inventory space ");
}
if (leftover > 0)
return overFlow;
case RETURN:
// Pay the user the items, and return overflow
final Map<Integer, ItemStack> returnStack = InventoryWorkaround.addItems(user.getInventory(), getItemStack());
user.updateInventory();
if (ess.getSettings().isDebug())
{
final ItemStack stack = itemStack.clone();
stack.setAmount(leftover);
itemStacks[stacks] = loc.getWorld().dropItem(loc, stack);
ess.getLogger().log(Level.INFO, "paying " + user.getName() + " partial itemstack " + getItemStack().toString() + " with overflow " + returnStack.get(0).toString());
}
return returnStack;
case DROP:
// Pay the users the items directly, and drop the rest, will always return no overflow.
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItems(user.getInventory(), getItemStack());
final Location loc = user.getLocation();
for (ItemStack loStack : leftOver.values())
{
final int maxStackSize = loStack.getType().getMaxStackSize();
final int stacks = loStack.getAmount() / maxStackSize;
final int leftover = loStack.getAmount() % maxStackSize;
final Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
for (int i = 0; i < stacks; i++)
{
final ItemStack stack = loStack.clone();
stack.setAmount(maxStackSize);
itemStacks[i] = loc.getWorld().dropItem(loc, stack);
}
if (leftover > 0)
{
final ItemStack stack = loStack.clone();
stack.setAmount(leftover);
itemStacks[stacks] = loc.getWorld().dropItem(loc, stack);
}
}
if (ess.getSettings().isDebug())
{
ess.getLogger().log(Level.INFO, "paying " + user.getName() + " partial itemstack " + getItemStack().toString() + " and dropping overflow " + leftOver.get(0).toString());
}
}
}
else
else if (ess.getSettings().isDebug())
{
success = InventoryWorkaround.addAllItems(user.getInventory(), getItemStack());
ess.getLogger().log(Level.INFO, "paying " + user.getName() + " itemstack " + getItemStack().toString());
}
user.updateInventory();
}
@@ -145,19 +203,22 @@ public class Trade
{
SetExpFix.setTotalExperience(user, SetExpFix.getTotalExperience(user) + getExperience());
}
return success;
return null;
}
public void charge(final IUser user) throws ChargeException
{
if (ess.getSettings().isDebug())
{
ess.getLogger().log(Level.INFO, "charging user " + user.getName());
ess.getLogger().log(Level.INFO, "attempting to charge user " + user.getName());
}
if (getMoney() != null)
{
if (!user.canAfford(getMoney()) && getMoney() > 0.0d)
if (ess.getSettings().isDebug())
{
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " money " + getMoney().toPlainString());
}
if (!user.canAfford(getMoney()) && getMoney().signum() > 0)
{
throw new ChargeException(_("notEnoughMoney"));
}
@@ -165,7 +226,11 @@ public class Trade
}
if (getItemStack() != null)
{
if (!user.getInventory().containsAtLeast(itemStack, itemStack.getAmount()))
if (ess.getSettings().isDebug())
{
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " itemstack " + getItemStack().toString());
}
if (!user.getInventory().containsAtLeast(getItemStack(), getItemStack().getAmount()))
{
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
}
@@ -174,8 +239,8 @@ public class Trade
}
if (command != null)
{
final double cost = getCommandCost(user);
if (!user.canAfford(cost) && cost > 0.0d)
final BigDecimal cost = getCommandCost(user);
if (!user.canAfford(cost) && cost.signum() > 0)
{
throw new ChargeException(_("notEnoughMoney"));
}
@@ -183,6 +248,10 @@ public class Trade
}
if (getExperience() != null)
{
if (ess.getSettings().isDebug())
{
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " exp " + getExperience());
}
final int experience = SetExpFix.getTotalExperience(user);
if (experience < getExperience() && getExperience() > 0)
{
@@ -190,9 +259,13 @@ public class Trade
}
SetExpFix.setTotalExperience(user, experience - getExperience());
}
if (ess.getSettings().isDebug())
{
ess.getLogger().log(Level.INFO, "charge user " + user.getName() + " completed");
}
}
public Double getMoney()
public BigDecimal getMoney()
{
return money;
}
@@ -207,13 +280,28 @@ public class Trade
return exp;
}
public Double getCommandCost(final IUser user)
public TradeType getType()
{
double cost = 0.0d;
if (getExperience() != null)
{
return TradeType.EXP;
}
if (getItemStack() != null)
{
return TradeType.ITEM;
}
return TradeType.MONEY;
}
public BigDecimal getCommandCost(final IUser user)
{
BigDecimal cost = BigDecimal.ZERO;
if (command != null && !command.isEmpty())
{
cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
if (cost == 0.0d && fallbackTrade != null)
if (cost.signum() == 0 && fallbackTrade != null)
{
cost = fallbackTrade.getCommandCost(user);
}
@@ -223,10 +311,10 @@ public class Trade
ess.getLogger().log(Level.INFO, "calculated command (" + command + ") cost for " + user.getName() + " as " + cost);
}
}
if (cost != 0.0d && (user.isAuthorized("essentials.nocommandcost.all")
|| user.isAuthorized("essentials.nocommandcost." + command)))
if (cost.signum() != 0 && (user.isAuthorized("essentials.nocommandcost.all")
|| user.isAuthorized("essentials.nocommandcost." + command)))
{
return 0.0d;
return BigDecimal.ZERO;
}
return cost;
}
@@ -236,7 +324,7 @@ public class Trade
{
//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

@@ -3,6 +3,10 @@ package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.register.payment.Method;
import com.earth2me.essentials.utils.NumberUtil;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.FormatUtil;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.logging.Level;
@@ -12,12 +16,14 @@ 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
{
private CommandSender replyTo = null;
private transient User teleportRequester;
private transient String teleportRequester;
private transient boolean teleportRequestHere;
private transient boolean vanished;
private transient final Teleport teleport;
@@ -29,6 +35,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");
@@ -40,6 +47,9 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
afkPosition = getLocation();
}
if (isOnline()) {
lastOnlineActivity = System.currentTimeMillis();
}
}
User update(final Player base)
@@ -79,11 +89,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return false;
}
if (isJailed())
{
return false;
}
try
{
return ess.getPermissionsHandler().hasPermission(base, node);
@@ -115,44 +120,44 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
if (cooldownTime.after(now) && !isAuthorized("essentials.heal.cooldown.bypass"))
{
throw new Exception(_("timeBeforeHeal", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
throw new Exception(_("timeBeforeHeal", DateUtil.formatDateDiff(cooldownTime.getTimeInMillis())));
}
}
setLastHealTimestamp(now.getTimeInMillis());
}
@Override
public void giveMoney(final double value)
public void giveMoney(final BigDecimal value)
{
giveMoney(value, null);
}
public void giveMoney(final double value, final CommandSender initiator)
public void giveMoney(final BigDecimal value, final CommandSender initiator)
{
if (value == 0.0d)
if (value.signum() == 0)
{
return;
}
setMoney(getMoney() + value);
sendMessage(_("addedToAccount", Util.displayCurrency(value, ess)));
setMoney(getMoney().add(value));
sendMessage(_("addedToAccount", NumberUtil.displayCurrency(value, ess)));
if (initiator != null)
{
initiator.sendMessage(_("addedToOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
initiator.sendMessage(_("addedToOthersAccount", NumberUtil.displayCurrency(value, ess), this.getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess)));
}
}
public void payUser(final User reciever, final double value) throws Exception
public void payUser(final User reciever, final BigDecimal value) throws Exception
{
if (value == 0.0d)
if (value.signum() == 0)
{
return;
}
if (canAfford(value))
{
setMoney(getMoney() - value);
reciever.setMoney(reciever.getMoney() + value);
sendMessage(_("moneySentTo", Util.displayCurrency(value, ess), reciever.getDisplayName()));
reciever.sendMessage(_("moneyRecievedFrom", Util.displayCurrency(value, ess), getDisplayName()));
setMoney(getMoney().subtract(value));
reciever.setMoney(reciever.getMoney().add(value));
sendMessage(_("moneySentTo", NumberUtil.displayCurrency(value, ess), reciever.getDisplayName()));
reciever.sendMessage(_("moneyRecievedFrom", NumberUtil.displayCurrency(value, ess), getDisplayName()));
}
else
{
@@ -161,43 +166,43 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
@Override
public void takeMoney(final double value)
public void takeMoney(final BigDecimal value)
{
takeMoney(value, null);
}
public void takeMoney(final double value, final CommandSender initiator)
public void takeMoney(final BigDecimal value, final CommandSender initiator)
{
if (value == 0.0d)
if (value.signum() == 0)
{
return;
}
setMoney(getMoney() - value);
sendMessage(_("takenFromAccount", Util.displayCurrency(value, ess)));
setMoney(getMoney().subtract(value));
sendMessage(_("takenFromAccount", NumberUtil.displayCurrency(value, ess)));
if (initiator != null)
{
initiator.sendMessage(_("takenFromOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
initiator.sendMessage(_("takenFromOthersAccount", NumberUtil.displayCurrency(value, ess), this.getDisplayName(), NumberUtil.displayCurrency(getMoney(), ess)));
}
}
@Override
public boolean canAfford(final double cost)
public boolean canAfford(final BigDecimal cost)
{
return canAfford(cost, true);
}
public boolean canAfford(final double cost, final boolean permcheck)
public boolean canAfford(final BigDecimal cost, final boolean permcheck)
{
if (cost <= 0.0d)
if (cost.signum() <= 0)
{
return true;
}
final double mon = getMoney();
final BigDecimal remainingBalance = getMoney().subtract(cost);
if (!permcheck || isAuthorized("essentials.eco.loan"))
{
return (mon - cost) >= ess.getSettings().getMinMoney();
return (remainingBalance.compareTo(ess.getSettings().getMinMoney()) >= 0);
}
return cost <= mon;
return (remainingBalance.signum() >= 0);
}
public void dispose()
@@ -220,7 +225,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
@Override
public int compareTo(final User other)
{
return Util.stripFormat(this.getDisplayName()).compareToIgnoreCase(Util.stripFormat(other.getDisplayName()));
return FormatUtil.stripFormat(this.getDisplayName()).compareToIgnoreCase(FormatUtil.stripFormat(other.getDisplayName()));
}
@Override
@@ -256,14 +261,20 @@ 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)
{
teleportRequestTime = System.currentTimeMillis();
teleportRequester = player;
teleportRequester = player == null ? null : player.getName();
teleportRequestHere = here;
}
public User getTeleportRequest()
public String getTeleportRequest()
{
return teleportRequester;
}
@@ -279,13 +290,14 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
String nickname;
String suffix = "";
final String nick = getNickname();
if (ess.getSettings().isCommandDisabled("nick") || nick == null || nick.isEmpty() || nick.equals(getName()))
if (ess.getSettings().isCommandDisabled("nick") || nick == null || nick.isEmpty() || nick.equalsIgnoreCase(getName()))
{
nickname = getName();
}
else
{
nickname = ess.getSettings().getNicknamePrefix() + nick;
suffix = "§r";
}
if (isOp())
@@ -328,11 +340,11 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
if (!longnick && output.length() > 16)
{
output = Util.lastCode(strPrefix) + nickname;
output = FormatUtil.lastCode(strPrefix) + nickname;
}
if (!longnick && output.length() > 16)
{
output = Util.lastCode(strPrefix) + nickname.substring(0, 14);
output = FormatUtil.lastCode(strPrefix) + nickname.substring(0, 14);
}
if (output.charAt(output.length() - 1) == '§')
{
@@ -387,7 +399,19 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
@Override
public double getMoney()
public BigDecimal getMoney()
{
final long start = System.nanoTime();
final BigDecimal value = _getMoney();
final long elapsed = System.nanoTime() - start;
if (elapsed > ess.getSettings().getEconomyLagWarning())
{
ess.getLogger().log(Level.INFO, "Lag Notice - Slow Economy Response - Request took over {0}ms!", elapsed / 1000000.0);
}
return value;
}
private BigDecimal _getMoney()
{
if (ess.getPaymentMethod().hasMethod())
{
@@ -399,7 +423,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
throw new Exception();
}
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
return account.balance();
return BigDecimal.valueOf(account.balance());
}
catch (Throwable ex)
{
@@ -409,7 +433,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
@Override
public void setMoney(final double value)
public void setMoney(final BigDecimal value)
{
if (ess.getPaymentMethod().hasMethod())
{
@@ -421,7 +445,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
throw new Exception();
}
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
account.set(value);
account.set(value.doubleValue());
}
catch (Throwable ex)
{
@@ -431,7 +455,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
Trade.log("Update", "Set", "API", getName(), new Trade(value, ess), null, null, null, ess);
}
public void updateMoneyCache(final double value)
public void updateMoneyCache(final BigDecimal value)
{
if (ess.getPaymentMethod().hasMethod() && super.getMoney() != value)
{
@@ -468,6 +492,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return hidden;
}
@Override
public void setHidden(final boolean hidden)
{
this.hidden = hidden;
@@ -532,7 +557,7 @@ 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())
@@ -540,7 +565,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
setDisplayNick();
final String msg = _("userIsNotAway", getDisplayName());
if (!msg.isEmpty())
{
{
ess.broadcastMessage(this, msg);
}
}
@@ -577,7 +602,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
setDisplayNick();
final String msg = _("userIsAway", getDisplayName());
if (!msg.isEmpty())
{
{
ess.broadcastMessage(this, msg);
}
}
@@ -670,11 +695,13 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return teleportInvulnerabilityTimestamp != 0 && teleportInvulnerabilityTimestamp >= System.currentTimeMillis();
}
@Override
public boolean isVanished()
{
return vanished;
}
@Override
public void setVanished(final boolean set)
{
vanished = set;
@@ -689,6 +716,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
{
@@ -698,15 +729,13 @@ 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);
}
}
}
public void toggleVanished()
{
final boolean set = !vanished;
this.setVanished(set);
}
public boolean checkSignThrottle()
{
if (isSignThrottled())
@@ -741,6 +770,16 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
@Override
public boolean isIgnoreExempt()
{
return this.isAuthorized("essentials.chat.ignoreexempt");
return this.isAuthorized("essentials.chat.ignoreexempt");
}
public boolean isRecipeSee()
{
return recipeSee;
}
public void setRecipeSee(boolean recipeSee)
{
this.recipeSee = recipeSee;
}
}

View File

@@ -1,11 +1,13 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.StringUtil;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.utils.NumberUtil;
import java.io.File;
import java.math.BigDecimal;
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;
@@ -13,7 +15,7 @@ import org.bukkit.inventory.ItemStack;
public abstract class UserData extends PlayerExtension implements IConf
{
protected final transient IEssentials ess;
private EssentialsConf config;
private final EssentialsConf config;
private final File folder;
protected UserData(Player base, IEssentials ess)
@@ -25,15 +27,14 @@ public abstract class UserData extends PlayerExtension implements IConf
{
folder.mkdirs();
}
config = new EssentialsConf(new File(folder, Util.sanitizeFileName(base.getName()) + ".yml"));
config = new EssentialsConf(new File(folder, StringUtil.sanitizeFileName(base.getName()) + ".yml"));
reloadConfig();
}
public final void reset()
{
config.getFile().delete();
config = new EssentialsConf(new File(folder, Util.sanitizeFileName(base.getName()) + ".yml"));
reloadConfig();
ess.getUserMap().removeUser(this.getName());
}
@Override
@@ -65,37 +66,51 @@ public abstract class UserData extends PlayerExtension implements IConf
arePowerToolsEnabled = _arePowerToolsEnabled();
kitTimestamps = _getKitTimestamps();
nickname = _getNickname();
setIgnoredPlayers(_getIgnoredPlayers());
ignoredPlayers = _getIgnoredPlayers();
logoutLocation = _getLogoutLocation();
}
private double money;
private BigDecimal money;
private double _getMoney()
private BigDecimal _getMoney()
{
double money = ess.getSettings().getStartingBalance();
BigDecimal result = ess.getSettings().getStartingBalance();
BigDecimal maxMoney = ess.getSettings().getMaxMoney();
BigDecimal minMoney = ess.getSettings().getMinMoney();
if (config.hasProperty("money"))
{
money = config.getDouble("money", money);
result = config.getBigDecimal("money", result);
}
if (Math.abs(money) > ess.getSettings().getMaxMoney())
if (result.compareTo(maxMoney) > 0)
{
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
result = maxMoney;
}
return money;
if (result.compareTo(minMoney) < 0)
{
result = minMoney;
}
return result;
}
public double getMoney()
public BigDecimal getMoney()
{
return money;
}
public void setMoney(double value)
public void setMoney(BigDecimal value)
{
money = value;
if (Math.abs(money) > ess.getSettings().getMaxMoney())
BigDecimal maxMoney = ess.getSettings().getMaxMoney();
BigDecimal minMoney = ess.getSettings().getMinMoney();
if (money.compareTo(maxMoney) > 0)
{
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
money = maxMoney;
}
config.setProperty("money", value);
if (money.compareTo(minMoney) < 0)
{
money = minMoney;
}
config.setProperty("money", money);
config.save();
}
private Map<String, Object> homes;
@@ -111,7 +126,7 @@ public abstract class UserData extends PlayerExtension implements IConf
private String getHomeName(String search)
{
if (Util.isInt(search))
if (NumberUtil.isInt(search))
{
try
{
@@ -123,11 +138,11 @@ public abstract class UserData extends PlayerExtension implements IConf
}
return search;
}
public Location getHome(String name) throws Exception
{
String search = getHomeName(name);
return config.getLocation("homes." + search, getServer());
return config.getLocation("homes." + search, getServer());
}
public Location getHome(final Location world)
@@ -161,7 +176,7 @@ public abstract class UserData extends PlayerExtension implements IConf
public void setHome(String name, Location loc)
{
//Invalid names will corrupt the yaml
name = Util.safeString(name);
name = StringUtil.safeString(name);
homes.put(name, loc);
config.setProperty("homes." + name, loc);
config.save();
@@ -172,7 +187,7 @@ public abstract class UserData extends PlayerExtension implements IConf
String search = getHomeName(name);
if (!homes.containsKey(search))
{
search = Util.safeString(search);
search = StringUtil.safeString(search);
}
if (homes.containsKey(search))
{
@@ -319,6 +334,35 @@ 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()
@@ -432,19 +476,6 @@ public abstract class UserData extends PlayerExtension implements IConf
config.save();
}
public boolean toggleTeleportEnabled()
{
boolean ret = !isTeleportEnabled();
setTeleportEnabled(ret);
return ret;
}
public boolean toggleSocialSpy()
{
boolean ret = !isSocialSpyEnabled();
setSocialSpyEnabled(ret);
return ret;
}
private List<String> ignoredPlayers;
public List<String> _getIgnoredPlayers()
@@ -519,7 +550,7 @@ public abstract class UserData extends PlayerExtension implements IConf
{
return config.getBoolean("muted", false);
}
public boolean getMuted()
{
return muted;
@@ -600,12 +631,12 @@ public abstract class UserData extends PlayerExtension implements IConf
public String getBanReason()
{
return config.getString("ban.reason");
return config.getString("ban.reason", "");
}
public void setBanReason(String reason)
{
config.setProperty("ban.reason", Util.sanitizeString(reason));
config.setProperty("ban.reason", StringUtil.sanitizeString(reason));
config.save();
}
@@ -794,48 +825,102 @@ public abstract class UserData extends PlayerExtension implements IConf
{
return config.getBoolean("powertoolsenabled", true);
}
private ConfigurationSection kitTimestamps;
private Map<String, Long> kitTimestamps;
private ConfigurationSection _getKitTimestamps()
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();
}
public void setConfigProperty(String node, Object object)
{
final String prefix = "info.";
node = prefix + node;
if (object instanceof Map)
{
config.setProperty(node, (Map)object);
}
else if (object instanceof List)
{
config.setProperty(node, (List<String>)object);
}
else if (object instanceof Location)
{
config.setProperty(node, (Location)object);
}
else if (object instanceof ItemStack)
{
config.setProperty(node, (ItemStack)object);
}
else
{
config.setProperty(node, object);
}
config.save();
}
public Set<String> getConfigKeys()
{
if (config.isConfigurationSection("info"))
{
return config.getConfigurationSection("info").getKeys(true);
}
return new HashSet<String>();
}
public Map<String, Object> getConfigMap()
{
if (config.isConfigurationSection("info"))
{
return config.getConfigurationSection("info").getValues(true);
}
return new HashMap<String, Object>();
}
public Map<String, Object> getConfigMap(String node)
{
if (config.isConfigurationSection("info." + node))
{
return config.getConfigurationSection("info." + node).getValues(true);
}
return new HashMap<String, Object>();
}
public void save()
{
config.save();

View File

@@ -1,5 +1,6 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.StringUtil;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
@@ -27,7 +28,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()
@@ -46,7 +47,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
continue;
}
final String name = string.substring(0, string.length() - 4);
keys.add(Util.sanitizeFileName(name));
keys.add(StringUtil.sanitizeFileName(name));
}
}
});
@@ -54,7 +55,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
public boolean userExists(final String name)
{
return keys.contains(Util.sanitizeFileName(name));
return keys.contains(StringUtil.sanitizeFileName(name));
}
public User getUser(final String name)
@@ -76,7 +77,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
@Override
public User load(final String name) throws Exception
{
String sanitizedName = Util.sanitizeFileName(name);
String sanitizedName = StringUtil.sanitizeFileName(name);
if (!sanitizedName.equals(name))
{
User user = getUser(sanitizedName);
@@ -114,8 +115,8 @@ public class UserMap extends CacheLoader<String, User> implements IConf
public void removeUser(final String name)
{
keys.remove(Util.sanitizeFileName(name));
users.invalidate(Util.sanitizeFileName(name));
keys.remove(StringUtil.sanitizeFileName(name));
users.invalidate(StringUtil.sanitizeFileName(name));
users.invalidate(name);
}
@@ -131,7 +132,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
public File getUserFile(final String name)
{
return getUserFile2(Util.sanitizeFileName(name));
return getUserFile2(StringUtil.sanitizeFileName(name));
}
private File getUserFile2(final String name)

View File

@@ -1,715 +0,0 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.*;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
public class Util
{
private Util()
{
}
private final static Logger logger = Logger.getLogger("Minecraft");
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)
{
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("");
}
public static String formatDateDiff(long date)
{
Calendar c = new GregorianCalendar();
c.setTimeInMillis(date);
Calendar now = new GregorianCalendar();
return Util.formatDateDiff(now, c);
}
public static String formatDateDiff(Calendar fromDate, Calendar toDate)
{
boolean future = false;
if (toDate.equals(fromDate))
{
return _("now");
}
if (toDate.after(fromDate))
{
future = true;
}
StringBuilder sb = new StringBuilder();
int[] types = new int[]
{
Calendar.YEAR,
Calendar.MONTH,
Calendar.DAY_OF_MONTH,
Calendar.HOUR_OF_DAY,
Calendar.MINUTE,
Calendar.SECOND
};
String[] names = new String[]
{
_("year"),
_("years"),
_("month"),
_("months"),
_("day"),
_("days"),
_("hour"),
_("hours"),
_("minute"),
_("minutes"),
_("second"),
_("seconds")
};
int accuracy = 0;
for (int i = 0; i < types.length; i++)
{
if (accuracy > 2)
{
break;
}
int diff = dateDiff(types[i], fromDate, toDate, future);
if (diff > 0)
{
accuracy++;
sb.append(" ").append(diff).append(" ").append(names[i * 2 + (diff > 1 ? 1 : 0)]);
}
}
if (sb.length() == 0)
{
return "now";
}
return sb.toString().trim();
}
private static int dateDiff(int type, Calendar fromDate, Calendar toDate, boolean future)
{
int diff = 0;
long savedDate = fromDate.getTimeInMillis();
while ((future && !fromDate.after(toDate)) || (!future && !fromDate.before(toDate)))
{
savedDate = fromDate.getTimeInMillis();
fromDate.add(type, future ? 1 : -1);
diff++;
}
diff--;
fromDate.setTimeInMillis(savedDate);
return diff;
}
public static long parseDateDiff(String time, boolean future) throws Exception
{
Pattern timePattern = Pattern.compile(
"(?:([0-9]+)\\s*y[a-z]*[,\\s]*)?"
+ "(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?"
+ "(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?"
+ "(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?"
+ "(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?"
+ "(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?"
+ "(?:([0-9]+)\\s*(?:s[a-z]*)?)?", Pattern.CASE_INSENSITIVE);
Matcher m = timePattern.matcher(time);
int years = 0;
int months = 0;
int weeks = 0;
int days = 0;
int hours = 0;
int minutes = 0;
int seconds = 0;
boolean found = false;
while (m.find())
{
if (m.group() == null || m.group().isEmpty())
{
continue;
}
for (int i = 0; i < m.groupCount(); i++)
{
if (m.group(i) != null && !m.group(i).isEmpty())
{
found = true;
break;
}
}
if (found)
{
if (m.group(1) != null && !m.group(1).isEmpty())
{
years = Integer.parseInt(m.group(1));
}
if (m.group(2) != null && !m.group(2).isEmpty())
{
months = Integer.parseInt(m.group(2));
}
if (m.group(3) != null && !m.group(3).isEmpty())
{
weeks = Integer.parseInt(m.group(3));
}
if (m.group(4) != null && !m.group(4).isEmpty())
{
days = Integer.parseInt(m.group(4));
}
if (m.group(5) != null && !m.group(5).isEmpty())
{
hours = Integer.parseInt(m.group(5));
}
if (m.group(6) != null && !m.group(6).isEmpty())
{
minutes = Integer.parseInt(m.group(6));
}
if (m.group(7) != null && !m.group(7).isEmpty())
{
seconds = Integer.parseInt(m.group(7));
}
break;
}
}
if (!found)
{
throw new Exception(_("illegalDate"));
}
Calendar c = new GregorianCalendar();
if (years > 0)
{
c.add(Calendar.YEAR, years * (future ? 1 : -1));
}
if (months > 0)
{
c.add(Calendar.MONTH, months * (future ? 1 : -1));
}
if (weeks > 0)
{
c.add(Calendar.WEEK_OF_YEAR, weeks * (future ? 1 : -1));
}
if (days > 0)
{
c.add(Calendar.DAY_OF_MONTH, days * (future ? 1 : -1));
}
if (hours > 0)
{
c.add(Calendar.HOUR_OF_DAY, hours * (future ? 1 : -1));
}
if (minutes > 0)
{
c.add(Calendar.MINUTE, minutes * (future ? 1 : -1));
}
if (seconds > 0)
{
c.add(Calendar.SECOND, seconds * (future ? 1 : -1));
}
Calendar max = new GregorianCalendar();
max.add(Calendar.YEAR, 10);
if (c.after(max))
{
return max.getTimeInMillis();
}
return c.getTimeInMillis();
}
// The player can stand inside these materials
private static final Set<Integer> AIR_MATERIALS = new HashSet<Integer>();
private static final HashSet<Byte> AIR_MATERIALS_TARGET = new HashSet<Byte>();
static
{
AIR_MATERIALS.add(Material.AIR.getId());
AIR_MATERIALS.add(Material.SAPLING.getId());
AIR_MATERIALS.add(Material.POWERED_RAIL.getId());
AIR_MATERIALS.add(Material.DETECTOR_RAIL.getId());
AIR_MATERIALS.add(Material.LONG_GRASS.getId());
AIR_MATERIALS.add(Material.DEAD_BUSH.getId());
AIR_MATERIALS.add(Material.YELLOW_FLOWER.getId());
AIR_MATERIALS.add(Material.RED_ROSE.getId());
AIR_MATERIALS.add(Material.BROWN_MUSHROOM.getId());
AIR_MATERIALS.add(Material.RED_MUSHROOM.getId());
AIR_MATERIALS.add(Material.TORCH.getId());
AIR_MATERIALS.add(Material.REDSTONE_WIRE.getId());
AIR_MATERIALS.add(Material.SEEDS.getId());
AIR_MATERIALS.add(Material.SIGN_POST.getId());
AIR_MATERIALS.add(Material.WOODEN_DOOR.getId());
AIR_MATERIALS.add(Material.LADDER.getId());
AIR_MATERIALS.add(Material.RAILS.getId());
AIR_MATERIALS.add(Material.WALL_SIGN.getId());
AIR_MATERIALS.add(Material.LEVER.getId());
AIR_MATERIALS.add(Material.STONE_PLATE.getId());
AIR_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
AIR_MATERIALS.add(Material.WOOD_PLATE.getId());
AIR_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
AIR_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
AIR_MATERIALS.add(Material.STONE_BUTTON.getId());
AIR_MATERIALS.add(Material.SNOW.getId());
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
AIR_MATERIALS.add(Material.TRAP_DOOR.getId());
AIR_MATERIALS.add(Material.PUMPKIN_STEM.getId());
AIR_MATERIALS.add(Material.MELON_STEM.getId());
AIR_MATERIALS.add(Material.VINE.getId());
AIR_MATERIALS.add(Material.FENCE_GATE.getId());
AIR_MATERIALS.add(Material.WATER_LILY.getId());
AIR_MATERIALS.add(Material.NETHER_FENCE.getId());
AIR_MATERIALS.add(Material.NETHER_WARTS.getId());
for (Integer integer : AIR_MATERIALS)
{
AIR_MATERIALS_TARGET.add(integer.byteValue());
}
AIR_MATERIALS_TARGET.add((byte)Material.WATER.getId());
AIR_MATERIALS_TARGET.add((byte)Material.STATIONARY_WATER.getId());
}
public static Location getTarget(final LivingEntity entity) throws Exception
{
final Block block = entity.getTargetBlock(AIR_MATERIALS_TARGET, 300);
if (block == null)
{
throw new Exception("Not targeting a block");
}
return block.getLocation();
}
public final static int RADIUS = 3;
public final static Vector3D[] VOLUME;
public static class Vector3D
{
public Vector3D(int x, int y, int z)
{
this.x = x;
this.y = y;
this.z = z;
}
public int x;
public int y;
public int z;
}
static
{
List<Vector3D> pos = new ArrayList<Vector3D>();
for (int x = -RADIUS; x <= RADIUS; x++)
{
for (int y = -RADIUS; y <= RADIUS; y++)
{
for (int z = -RADIUS; z <= RADIUS; z++)
{
pos.add(new Vector3D(x, y, z));
}
}
}
Collections.sort(pos, new Comparator<Vector3D>()
{
@Override
public int compare(Vector3D a, Vector3D b)
{
return (a.x * a.x + a.y * a.y + a.z * a.z) - (b.x * b.x + b.y * b.y + b.z * b.z);
}
});
VOLUME = pos.toArray(new Vector3D[0]);
}
public static Location getSafeDestination(final Location loc) throws Exception
{
if (loc == null || loc.getWorld() == null)
{
throw new Exception(_("destinationNotSet"));
}
final World world = loc.getWorld();
int x = loc.getBlockX();
int y = (int)Math.round(loc.getY());
int z = loc.getBlockZ();
final int origX = x;
final int origY = y;
final int origZ = z;
while (isBlockAboveAir(world, x, y, z))
{
y -= 1;
if (y < 0)
{
y = origY;
break;
}
}
int i = 0;
while (isBlockUnsafe(world, x, y, z))
{
i++;
if (i >= VOLUME.length)
{
x = origX;
y = origY + RADIUS;
z = origZ;
break;
}
x = origX + VOLUME[i].x;
y = origY + VOLUME[i].y;
z = origZ + VOLUME[i].z;
}
while (isBlockUnsafe(world, x, y, z))
{
y += 1;
if (y >= world.getMaxHeight())
{
x += 1;
break;
}
}
while (isBlockUnsafe(world, x, y, z))
{
y -= 1;
if (y <= 1)
{
x += 1;
y = world.getHighestBlockYAt(x, z);
if (x - 48 > loc.getBlockX())
{
throw new Exception(_("holeInFloor"));
}
}
}
return new Location(world, x + 0.5D, y, z + 0.5D, loc.getYaw(), loc.getPitch());
}
private static boolean isBlockAboveAir(final World world, final int x, final int y, final int z)
{
return AIR_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId());
}
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z)
{
if (isBlockDamaging(world, x, y, z))
{
return true;
}
return isBlockAboveAir(world, x, y, z);
}
public static boolean isBlockDamaging(final World world, final int x, final int y, final int z)
{
final Block below = world.getBlockAt(x, y - 1, z);
if (below.getType() == Material.LAVA || below.getType() == Material.STATIONARY_LAVA)
{
return true;
}
if (below.getType() == Material.FIRE)
{
return true;
}
if (below.getType() == Material.BED_BLOCK)
{
return true;
}
if ((!AIR_MATERIALS.contains(world.getBlockAt(x, y, z).getType().getId()))
|| (!AIR_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType().getId())))
{
return true;
}
return false;
}
public static ItemStack convertBlockToItem(final Block block)
{
final ItemStack is = new ItemStack(block.getType(), 1, (short)0, block.getData());
switch (is.getType())
{
case WOODEN_DOOR:
is.setType(Material.WOOD_DOOR);
is.setDurability((short)0);
break;
case IRON_DOOR_BLOCK:
is.setType(Material.IRON_DOOR);
is.setDurability((short)0);
break;
case SIGN_POST:
case WALL_SIGN:
is.setType(Material.SIGN);
is.setDurability((short)0);
break;
case CROPS:
is.setType(Material.SEEDS);
is.setDurability((short)0);
break;
case CAKE_BLOCK:
is.setType(Material.CAKE);
is.setDurability((short)0);
break;
case BED_BLOCK:
is.setType(Material.BED);
is.setDurability((short)0);
break;
case REDSTONE_WIRE:
is.setType(Material.REDSTONE);
is.setDurability((short)0);
break;
case REDSTONE_TORCH_OFF:
case REDSTONE_TORCH_ON:
is.setType(Material.REDSTONE_TORCH_ON);
is.setDurability((short)0);
break;
case DIODE_BLOCK_OFF:
case DIODE_BLOCK_ON:
is.setType(Material.DIODE);
is.setDurability((short)0);
break;
case DOUBLE_STEP:
is.setType(Material.STEP);
break;
case TORCH:
case RAILS:
case LADDER:
case WOOD_STAIRS:
case COBBLESTONE_STAIRS:
case LEVER:
case STONE_BUTTON:
case FURNACE:
case DISPENSER:
case PUMPKIN:
case JACK_O_LANTERN:
case WOOD_PLATE:
case STONE_PLATE:
case PISTON_STICKY_BASE:
case PISTON_BASE:
case IRON_FENCE:
case THIN_GLASS:
case TRAP_DOOR:
case FENCE:
case FENCE_GATE:
case NETHER_FENCE:
is.setDurability((short)0);
break;
case FIRE:
return null;
case PUMPKIN_STEM:
is.setType(Material.PUMPKIN_SEEDS);
break;
case MELON_STEM:
is.setType(Material.MELON_SEEDS);
break;
}
return is;
}
private static DecimalFormat dFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
public static String formatAsCurrency(final double value)
{
String str = dFormat.format(value);
if (str.endsWith(".00"))
{
str = str.substring(0, str.length() - 3);
}
return str;
}
public static String displayCurrency(final double value, final IEssentials ess)
{
return _("currency", ess.getSettings().getCurrencySymbol(), formatAsCurrency(value));
}
public static String shortCurrency(final double value, final IEssentials ess)
{
return ess.getSettings().getCurrencySymbol() + formatAsCurrency(value);
}
public static double roundDouble(final double d)
{
return Math.round(d * 100.0) / 100.0;
}
public static boolean isInt(final String sInt)
{
try
{
Integer.parseInt(sInt);
}
catch (NumberFormatException e)
{
return false;
}
return true;
}
public static String joinList(Object... list)
{
return joinList(", ", list);
}
public static String joinList(String seperator, Object... list)
{
StringBuilder buf = new StringBuilder();
for (Object each : list)
{
if (buf.length() > 0)
{
buf.append(seperator);
}
if (each instanceof Collection)
{
buf.append(joinList(seperator, ((Collection)each).toArray()));
}
else
{
try
{
buf.append(each.toString());
}
catch (Exception e)
{
buf.append(each.toString());
}
}
}
return buf.toString();
}
public static String lastCode(final String input)
{
int pos = input.lastIndexOf("§");
if (pos == -1 || (pos + 1) == input.length())
{
return "";
}
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 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]");
private static transient final Pattern VANILLA_FORMAT_PATTERN = Pattern.compile("\u00A7+[L-ORl-or]");
private static transient final Pattern REPLACE_COLOR_PATTERN = Pattern.compile("&([0-9a-f])");
private static transient final Pattern REPLACE_MAGIC_PATTERN = Pattern.compile("&(k)");
private static transient final Pattern REPLACE_FORMAT_PATTERN = Pattern.compile("&([l-or])");
public static String stripFormat(final String input)
{
if (input == null)
{
return null;
}
return VANILLA_PATTERN.matcher(input).replaceAll("");
}
public static String stripLogColorFormat(final String input)
{
if (input == null)
{
return null;
}
return LOGCOLOR_PATTERN.matcher(input).replaceAll("");
}
public static String replaceFormat(final String input)
{
if (input == null)
{
return null;
}
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;
}
public static String formatString(final IUser user, final String permBase, final String input)
{
if (input == null)
{
return null;
}
String message;
if (user.isAuthorized(permBase + ".color"))
{
message = Util.replaceColor(input, REPLACE_COLOR_PATTERN);
}
else
{
message = Util.stripColor(input, VANILLA_COLOR_PATTERN);
}
if (user.isAuthorized(permBase + ".magic"))
{
message = Util.replaceColor(message, REPLACE_MAGIC_PATTERN);
}
else
{
message = Util.stripColor(message, VANILLA_MAGIC_PATTERN);
}
if (user.isAuthorized(permBase + ".format"))
{
message = Util.replaceColor(message, REPLACE_FORMAT_PATTERN);
}
else
{
message = Util.stripColor(message, VANILLA_FORMAT_PATTERN);
}
return message;
}
public static String formatMessage(final IUser user, final String permBase, final String input)
{
if (input == null)
{
return null;
}
String message = formatString(user, permBase, input);
if (!user.isAuthorized(permBase + ".url"))
{
message = Util.blockURL(message);
}
return message;
}
private static String stripColor(final String input, final Pattern pattern)
{
return pattern.matcher(input).replaceAll("");
}
private static String replaceColor(final String input, final Pattern pattern)
{
return pattern.matcher(input).replaceAll("\u00a7$1");
}
}

View File

@@ -1,6 +1,10 @@
package com.earth2me.essentials;
import com.earth2me.essentials.utils.StringUtil;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IWarps;
import com.earth2me.essentials.api.InvalidNameException;
import com.earth2me.essentials.api.InvalidWorldException;
import com.earth2me.essentials.commands.WarpNotFoundException;
import java.io.File;
import java.io.IOException;
@@ -11,7 +15,7 @@ import org.bukkit.Location;
import org.bukkit.Server;
public class Warps implements IConf
public class Warps implements IConf, IWarps
{
private static final Logger logger = Logger.getLogger("Minecraft");
private final Map<StringIgnoreCase, EssentialsConf> warpPoints = new HashMap<StringIgnoreCase, EssentialsConf>();
@@ -29,12 +33,14 @@ public class Warps implements IConf
reloadConfig();
}
@Override
public boolean isEmpty()
{
return warpPoints.isEmpty();
}
public Collection<String> getWarpNames()
@Override
public Collection<String> getList()
{
final List<String> keys = new ArrayList<String>();
for (StringIgnoreCase stringIgnoreCase : warpPoints.keySet())
@@ -45,7 +51,8 @@ public class Warps implements IConf
return keys;
}
public Location getWarp(String warp) throws Exception
@Override
public Location getWarp(String warp) throws WarpNotFoundException, InvalidWorldException
{
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp));
if (conf == null)
@@ -55,9 +62,10 @@ public class Warps implements IConf
return conf.getLocation(null, server);
}
@Override
public void setWarp(String name, Location loc) throws Exception
{
String filename = Util.sanitizeFileName(name);
String filename = StringUtil.sanitizeFileName(name);
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(name));
if (conf == null)
{
@@ -81,7 +89,8 @@ public class Warps implements IConf
}
}
public void delWarp(String name) throws Exception
@Override
public void removeWarp(String name) throws Exception
{
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(name));
if (conf == null)
@@ -126,6 +135,18 @@ public class Warps implements IConf
}
}
//This is here for future 3.x api support. Not implemented here becasue storage is handled differently
@Override
public File getWarpFile(String name) throws InvalidNameException
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getCount()
{
return getList().size();
}
private static class StringIgnoreCase
{

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials;
import java.io.File;
import java.math.BigDecimal;
import java.util.Locale;
import java.util.logging.Logger;
import org.bukkit.inventory.ItemStack;
@@ -18,22 +19,26 @@ public class Worth implements IConf
config.load();
}
public double getPrice(ItemStack itemStack)
public BigDecimal getPrice(ItemStack itemStack)
{
String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
double result;
result = config.getDouble("worth." + itemname + "." + itemStack.getDurability(), Double.NaN);
if (Double.isNaN(result))
BigDecimal result;
result = config.getBigDecimal("worth." + itemname + "." + itemStack.getDurability(), BigDecimal.ONE.negate());
if (result.signum() < 0)
{
result = config.getDouble("worth." + itemname + ".0", Double.NaN);
result = config.getBigDecimal("worth." + itemname + ".0", BigDecimal.ONE.negate());
}
if (Double.isNaN(result))
if (result.signum() < 0)
{
result = config.getDouble("worth." + itemname, Double.NaN);
result = config.getBigDecimal("worth." + itemname, BigDecimal.ONE.negate());
}
if (Double.isNaN(result))
if (result.signum() < 0)
{
result = config.getDouble("worth-" + itemStack.getTypeId(), Double.NaN);
result = config.getBigDecimal("worth-" + itemStack.getTypeId(), BigDecimal.ONE.negate());
}
if (result.signum() < 0)
{
return null;
}
return result;
}

View File

@@ -4,15 +4,17 @@ import com.earth2me.essentials.EssentialsConf;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import com.earth2me.essentials.utils.NumberUtil;
import java.io.File;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Instead of using this api directly, we recommend to use the register plugin:
* http://bit.ly/RegisterMethod
* Instead of using this api directly, we recommend to use the register plugin: http://bit.ly/RegisterMethod
*/
public final class Economy
{
@@ -22,6 +24,7 @@ public final class Economy
private static final Logger logger = Logger.getLogger("Minecraft");
private static IEssentials ess;
private static final String noCallBeforeLoad = "Essentials API is called before Essentials is loaded.";
public static final MathContext MATH_CONTEXT = MathContext.DECIMAL128;
/**
* @param aEss the ess to set
@@ -38,11 +41,11 @@ public final class Economy
{
folder.mkdirs();
}
EssentialsConf npcConfig = new EssentialsConf(new File(folder, Util.sanitizeFileName(name) + ".yml"));
EssentialsConf npcConfig = new EssentialsConf(new File(folder, StringUtil.sanitizeFileName(name) + ".yml"));
npcConfig.load();
npcConfig.setProperty("npc", true);
npcConfig.setProperty("money", ess.getSettings().getStartingBalance());
npcConfig.save();
npcConfig.forceSave();
}
private static void deleteNPC(String name)
@@ -52,7 +55,7 @@ public final class Economy
{
folder.mkdirs();
}
File config = new File(folder, Util.sanitizeFileName(name) + ".yml");
File config = new File(folder, StringUtil.sanitizeFileName(name) + ".yml");
EssentialsConf npcConfig = new EssentialsConf(config);
npcConfig.load();
if (npcConfig.hasProperty("npc") && npcConfig.getBoolean("npc", false))
@@ -76,11 +79,18 @@ public final class Economy
/**
* Returns the balance of a user
*
* @param name Name of the user
* @return balance
* @throws UserDoesNotExistException
* @throws UserDoesNotExistException
*/
@Deprecated
public static double getMoney(String name) throws UserDoesNotExistException
{
return getMoneyExact(name).doubleValue();
}
public static BigDecimal getMoneyExact(String name) throws UserDoesNotExistException
{
User user = getUserByName(name);
if (user == null)
@@ -92,23 +102,37 @@ public final class Economy
/**
* Sets the balance of a user
*
* @param name Name of the user
* @param balance The balance you want to set
* @throws UserDoesNotExistException If a user by that name does not exists
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
*/
@Deprecated
public static void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException
{
try
{
setMoney(name, BigDecimal.valueOf(balance));
}
catch (ArithmeticException e)
{
logger.log(Level.WARNING, "Failed to set balance of " + name + " to " + balance + ": " + e.getMessage(), e);
}
}
public static void setMoney(String name, BigDecimal balance) throws UserDoesNotExistException, NoLoanPermittedException
{
User user = getUserByName(name);
if (user == null)
{
throw new UserDoesNotExistException(name);
}
if (balance < ess.getSettings().getMinMoney())
if (balance.compareTo(ess.getSettings().getMinMoney()) < 0)
{
throw new NoLoanPermittedException();
}
if (balance < 0.0 && !user.isAuthorized("essentials.eco.loan"))
if (balance.signum() < 0 && !user.isAuthorized("essentials.eco.loan"))
{
throw new NoLoanPermittedException();
}
@@ -117,58 +141,115 @@ public final class Economy
/**
* Adds money to the balance of a user
*
* @param name Name of the user
* @param amount The money you want to add
* @throws UserDoesNotExistException If a user by that name does not exists
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
*/
@Deprecated
public static void add(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException
{
double result = getMoney(name) + amount;
try
{
add(name, BigDecimal.valueOf(amount));
}
catch (ArithmeticException e)
{
logger.log(Level.WARNING, "Failed to add " + amount + " to balance of " + name + ": " + e.getMessage(), e);
}
}
public static void add(String name, BigDecimal amount) throws UserDoesNotExistException, NoLoanPermittedException, ArithmeticException
{
BigDecimal result = getMoneyExact(name).add(amount, MATH_CONTEXT);
setMoney(name, result);
}
/**
* Substracts money from the balance of a user
*
* @param name Name of the user
* @param amount The money you want to substract
* @throws UserDoesNotExistException If a user by that name does not exists
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
*/
@Deprecated
public static void subtract(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException
{
double result = getMoney(name) - amount;
try
{
substract(name, BigDecimal.valueOf(amount));
}
catch (ArithmeticException e)
{
logger.log(Level.WARNING, "Failed to substract " + amount + " of balance of " + name + ": " + e.getMessage(), e);
}
}
public static void substract(String name, BigDecimal amount) throws UserDoesNotExistException, NoLoanPermittedException, ArithmeticException
{
BigDecimal result = getMoneyExact(name).subtract(amount, MATH_CONTEXT);
setMoney(name, result);
}
/**
* Divides the balance of a user by a value
*
* @param name Name of the user
* @param value The balance is divided by this value
* @throws UserDoesNotExistException If a user by that name does not exists
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
*/
public static void divide(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException
@Deprecated
public static void divide(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException
{
double result = getMoney(name) / value;
try
{
divide(name, BigDecimal.valueOf(amount));
}
catch (ArithmeticException e)
{
logger.log(Level.WARNING, "Failed to divide balance of " + name + " by " + amount + ": " + e.getMessage(), e);
}
}
public static void divide(String name, BigDecimal amount) throws UserDoesNotExistException, NoLoanPermittedException, ArithmeticException
{
BigDecimal result = getMoneyExact(name).divide(amount, MATH_CONTEXT);
setMoney(name, result);
}
/**
* Multiplies the balance of a user by a value
*
* @param name Name of the user
* @param value The balance is multiplied by this value
* @throws UserDoesNotExistException If a user by that name does not exists
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
*/
public static void multiply(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException
@Deprecated
public static void multiply(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException
{
double result = getMoney(name) * value;
try
{
multiply(name, BigDecimal.valueOf(amount));
}
catch (ArithmeticException e)
{
logger.log(Level.WARNING, "Failed to multiply balance of " + name + " by " + amount + ": " + e.getMessage(), e);
}
}
public static void multiply(String name, BigDecimal amount) throws UserDoesNotExistException, NoLoanPermittedException, ArithmeticException
{
BigDecimal result = getMoneyExact(name).multiply(amount, MATH_CONTEXT);
setMoney(name, result);
}
/**
* Resets the balance of a user to the starting balance
*
* @param name Name of the user
* @throws UserDoesNotExistException If a user by that name does not exists
* @throws NoLoanPermittedException If the user is not allowed to have a negative balance
@@ -188,9 +269,23 @@ public final class Economy
* @return true, if the user has more or an equal amount of money
* @throws UserDoesNotExistException If a user by that name does not exists
*/
@Deprecated
public static boolean hasEnough(String name, double amount) throws UserDoesNotExistException
{
return amount <= getMoney(name);
try
{
return hasEnough(name, BigDecimal.valueOf(amount));
}
catch (ArithmeticException e)
{
logger.log(Level.WARNING, "Failed to compare balance of " + name + " with " + amount + ": " + e.getMessage(), e);
return false;
}
}
public static boolean hasEnough(String name, BigDecimal amount) throws UserDoesNotExistException, ArithmeticException
{
return amount.compareTo(getMoneyExact(name)) <= 0;
}
/**
@@ -199,9 +294,23 @@ public final class Economy
* @return true, if the user has more money
* @throws UserDoesNotExistException If a user by that name does not exists
*/
@Deprecated
public static boolean hasMore(String name, double amount) throws UserDoesNotExistException
{
return amount < getMoney(name);
try
{
return hasMore(name, BigDecimal.valueOf(amount));
}
catch (ArithmeticException e)
{
logger.log(Level.WARNING, "Failed to compare balance of " + name + " with " + amount + ": " + e.getMessage(), e);
return false;
}
}
public static boolean hasMore(String name, BigDecimal amount) throws UserDoesNotExistException, ArithmeticException
{
return amount.compareTo(getMoneyExact(name)) < 0;
}
/**
@@ -210,39 +319,69 @@ public final class Economy
* @return true, if the user has less money
* @throws UserDoesNotExistException If a user by that name does not exists
*/
@Deprecated
public static boolean hasLess(String name, double amount) throws UserDoesNotExistException
{
return amount > getMoney(name);
try
{
return hasLess(name, BigDecimal.valueOf(amount));
}
catch (ArithmeticException e)
{
logger.log(Level.WARNING, "Failed to compare balance of " + name + " with " + amount + ": " + e.getMessage(), e);
return false;
}
}
public static boolean hasLess(String name, BigDecimal amount) throws UserDoesNotExistException, ArithmeticException
{
return amount.compareTo(getMoneyExact(name)) > 0;
}
/**
* Test if the user has a negative balance
*
* @param name Name of the user
* @return true, if the user has a negative balance
* @throws UserDoesNotExistException If a user by that name does not exists
*/
public static boolean isNegative(String name) throws UserDoesNotExistException
{
return getMoney(name) < 0.0;
return getMoneyExact(name).signum() < 0;
}
/**
* Formats the amount of money like all other Essentials functions.
* Example: $100000 or $12345.67
* Formats the amount of money like all other Essentials functions. Example: $100000 or $12345.67
*
* @param amount The amount of money
* @return Formatted money
*/
@Deprecated
public static String format(double amount)
{
try
{
return format(BigDecimal.valueOf(amount));
}
catch (NumberFormatException e)
{
logger.log(Level.WARNING, "Failed to display " + amount + ": " + e.getMessage(), e);
return "NaN";
}
}
public static String format(BigDecimal amount)
{
if (ess == null)
{
throw new RuntimeException(noCallBeforeLoad);
}
return Util.displayCurrency(amount, ess);
return NumberUtil.displayCurrency(amount, ess);
}
/**
* Test if a player exists to avoid the UserDoesNotExistException
*
* @param name Name of the user
* @return true, if the user exists
*/
@@ -253,9 +392,10 @@ public final class Economy
/**
* Test if a player is a npc
*
* @param name Name of the player
* @return true, if it's a npc
* @throws UserDoesNotExistException
* @throws UserDoesNotExistException
*/
public static boolean isNPC(String name) throws UserDoesNotExistException
{
@@ -269,6 +409,7 @@ public final class Economy
/**
* Creates dummy files for a npc, if there is no player yet with that name.
*
* @param name Name of the player
* @return true, if a new npc was created
*/
@@ -284,9 +425,10 @@ public final class Economy
}
/**
* Deletes a user, if it is marked as npc.
* Deletes a user, if it is marked as npc.
*
* @param name Name of the player
* @throws UserDoesNotExistException
* @throws UserDoesNotExistException
*/
public static void removeNPC(String name) throws UserDoesNotExistException
{

View File

@@ -5,5 +5,9 @@ import java.util.Locale;
public interface II18n
{
/**
* Gets the current locale setting
* @return the current locale, if not set it will return the default locale
*/
Locale getCurrentLocale();
}

View File

@@ -6,6 +6,6 @@ import org.bukkit.inventory.ItemStack;
public interface IItemDb
{
ItemStack get(final String name, final int quantity) throws Exception;
ItemStack get(final String name) throws Exception;
}

View File

@@ -6,15 +6,47 @@ import org.bukkit.Location;
public interface IJails extends IReload
{
/**
* Gets the location of the jail with the given name
* @param jailName The name of the jail
* @return the location of the jail
* @throws Exception if the jail does not exist
*/
Location getJail(String jailName) throws Exception;
/**
* Gets a list of jails by names
* @return a list of jails, if there are none the list will be empty
* @throws Exception
*/
Collection<String> getList() throws Exception;
/**
* Gets the number of jails
* @return the size of the list of jails
*/
int getCount();
/**
* Remove the jail with the given name
* @param jail the jail to remove
* @throws Exception if the jail does not exist
*/
void removeJail(String jail) throws Exception;
/**
* Attempts to send the given user to the given jail
* @param user the user to send to jail
* @param jail the jail to send the user to
* @throws Exception if the user is offline or jail does not exist
*/
void sendToJail(com.earth2me.essentials.IUser user, String jail) throws Exception;
/**
* Set a new jail with the given name and location
* @param jailName the name of the jail being set
* @param loc the location of the jail being set
* @throws Exception
*/
void setJail(String jailName, Location loc) throws Exception;
}

View File

@@ -1,10 +1,130 @@
package com.earth2me.essentials.api;
import com.earth2me.essentials.IUser;
import com.earth2me.essentials.Trade;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public interface ITeleport
{
{
/**
* Used to skip teleportPlayer delay when teleporting someone to a location or player.
*
* @param loc - Where should the player end up
* @param cooldown - If cooldown should be enforced
* @param cause - The reported teleportPlayer cause
* @throws Exception
*/
void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception;
/**
* Used to skip teleportPlayer delay when teleporting someone to a location or player.
*
* @param entity - Where should the player end up
* @param cooldown - If cooldown should be enforced
* @param cause - The reported teleportPlayer cause
* @throws Exception
*/
void now(Player entity, boolean cooldown, TeleportCause cause) throws Exception;
@Deprecated
void teleport(Location loc, Trade chargeFor) throws Exception;
/**
* Teleport a player to a specific location
*
* @param loc - Where should the player end up
* @param chargeFor - What the user will be charged if teleportPlayer is successful
* @param cause - The reported teleportPlayer cause
* @throws Exception
*/
void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception;
/**
* Teleport a player to a specific player
*
* @param entity - Where should the player end up
* @param chargeFor - What the user will be charged if teleportPlayer is successful
* @param cause - The reported teleportPlayer cause
* @throws Exception
*/
void teleport(Player entity, Trade chargeFor, TeleportCause cause) throws Exception;
/**
* Teleport a player to a specific location
*
* @param otherUser - Which user will be teleported
* @param loc - Where should the player end up
* @param chargeFor - What the user will be charged if teleportPlayer is successful
* @param cause - The reported teleportPlayer cause
* @throws Exception
*/
void teleportPlayer(IUser otherUser, Location loc, Trade chargeFor, TeleportCause cause) throws Exception;
/**
* Teleport a player to a specific player
*
* @param otherUser - Which user will be teleported
* @param entity - Where should the player end up
* @param chargeFor - What the user will be charged if teleportPlayer is successful
* @param cause - The reported teleportPlayer cause
* @throws Exception
*/
void teleportPlayer(IUser otherUser, Player entity, Trade chargeFor, TeleportCause cause) throws Exception;
/**
* Teleport wrapper used to handle teleporting players to them, like /tphere
*
* @param otherUser - Which user will be teleported
* @param chargeFor - What the user will be charged if teleportPlayer is successful
* @param cause - The reported teleportPlayer cause
* @throws Exception
*/
public void teleportToMe(IUser otherUser, Trade chargeFor, TeleportCause cause) throws Exception;
/**
* Teleport wrapper used to handle tp fallback on /jail and /home
*
* @param chargeFor - What the user will be charged if teleportPlayer is successful
* @param cause - The reported teleportPlayer cause
* @throws Exception
*/
public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception;
/**
* Teleport wrapper used to handle /warp teleports
*
* @param otherUser - Which user will be teleported
* @param warp - The name of the warp the user will be teleported too.
* @param chargeFor - What the user will be charged if teleportPlayer is successful
* @param cause - The reported teleportPlayer cause
* @throws Exception
*/
public void warp(IUser otherUser, String warp, Trade chargeFor, TeleportCause cause) throws Exception;
/**
* Teleport wrapper used to handle /back teleports
*
* @param chargeFor - What the user will be charged if teleportPlayer is successful
* @throws Exception
*/
public void back(Trade chargeFor) throws Exception;
/**
* Teleport wrapper used to handle throwing user home after a jail sentence
*
* @throws Exception
*/
public void back() throws Exception;
/**
* Teleport wrapper used to handle /home teleports
*
* @param loc - Location where player will be teleported too
* @param chargeFor - What the user will be charged if teleportPlayer is successful
* @throws Exception
*/
public void home(Location loc, Trade chargeFor) throws Exception;
}

View File

@@ -0,0 +1,69 @@
package com.earth2me.essentials.api;
import com.earth2me.essentials.IConf;
import java.io.File;
import java.util.Collection;
import com.earth2me.essentials.commands.WarpNotFoundException;
import org.bukkit.Location;
public interface IWarps extends IConf
{
/**
* Get a warp by name
*
* @param warp - Warp name
* @return - Location the warp is set to
* @throws WarpNotFoundException When the warp is not found
* @throws InvalidWorldException When the world the warp is in is not found
*/
Location getWarp(String warp) throws WarpNotFoundException, InvalidWorldException;
/**
* Gets a list of warps
*
* @return - A {@link Collection} of warps
*/
Collection<String> getList();
/**
* Gets the number of warps
*
* @return the size of the list of warps
*/
int getCount();
/**
* Delete a warp from the warp DB
*
* @param name - Name of warp
* @throws Exception
*/
void removeWarp(String name) throws Exception;
/**
* Set a warp
*
* @param name - Name of warp
* @param loc - Location of warp
* @throws Exception
*/
void setWarp(String name, Location loc) throws Exception;
/**
* Check to see if the file is empty
*
* @return
*/
boolean isEmpty();
/**
* Get a warp file note: this is not yet implemented, as 3.x uses different storage methods
*
* @param name - name of file
* @return - an instance of the file
* @throws InvalidNameException - When the file is not found
*/
File getWarpFile(String name) throws InvalidNameException;
}

View File

@@ -0,0 +1,16 @@
package com.earth2me.essentials.api;
public class InvalidNameException extends Exception
{
/**
* NOTE: This is not implemented yet, just here for future 3.x api support
* Allow serialization of the InvalidNameException exception
*/
private static final long serialVersionUID = 1485321420293663139L;
public InvalidNameException(Throwable thrwbl)
{
super(thrwbl);
}
}

View File

@@ -0,0 +1,20 @@
package com.earth2me.essentials.api;
import static com.earth2me.essentials.I18n._;
public class InvalidWorldException extends Exception
{
private final String world;
public InvalidWorldException(final String world)
{
super(_("invalidWorld"));
this.world = world;
}
public String getWorld()
{
return this.world;
}
}

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.command.CommandSender;
import org.bukkit.Server;
@@ -17,17 +18,28 @@ public class Commandafk extends EssentialsCommand
{
if (args.length > 0 && user.isAuthorized("essentials.afk.others"))
{
User afkUser = ess.getUser(ess.getServer().matchPlayer(args[0]));
if (afkUser != null)
{
toggleAfk(afkUser);
}
User afkUser = getPlayer(server, user, args, 0);
toggleAfk(afkUser);
}
else
{
toggleAfk(user);
}
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length > 0)
{
User afkUser = getPlayer(server, args, 0, true, false);
toggleAfk(afkUser);
}
else
{
throw new NotEnoughArgumentsException();
}
}
private void toggleAfk(User user)
{
@@ -56,3 +68,4 @@ public class Commandafk extends EssentialsCommand
}
}
}

View File

@@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.LocationUtil;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.entity.TNTPrimed;
@@ -21,9 +21,9 @@ public class Commandantioch extends EssentialsCommand
{
ess.broadcastMessage(user, "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
ess.broadcastMessage(user, "who being naughty in My sight, shall snuff it.");
}
}
final Location loc = Util.getTarget(user);
final Location loc = LocationUtil.getTarget(user);
loc.getWorld().spawn(loc, TNTPrimed.class);
}
}

View File

@@ -2,7 +2,8 @@ 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.utils.NumberUtil;
import java.math.BigDecimal;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -21,18 +22,25 @@ public class Commandbalance extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
sender.sendMessage(_("balance", Util.displayCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
User target = getPlayer(server, args, 0, true, true);
sender.sendMessage(_("balanceOther", target.getDisplayName(), NumberUtil.displayCurrency(target.getMoney(), ess)));
}
@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"))
? user
: getPlayer(server, args, 0, true)).getMoney();
user.sendMessage(_("balance", Util.displayCurrency(bal, ess)));
if (args.length < 1 || !user.isAuthorized("essentials.balance.others"))
{
final BigDecimal bal = user.getMoney();
user.sendMessage(_("balance", NumberUtil.displayCurrency(bal, ess)));
}
else
{
final User target = getPlayer(server, args, 0, true, true);
final BigDecimal bal = target.getMoney();
user.sendMessage(_("balanceOther", target.getDisplayName(), NumberUtil.displayCurrency(bal, ess)));
}
}
}

View File

@@ -2,9 +2,10 @@ 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.textreader.ArrayListInput;
import com.earth2me.essentials.textreader.SimpleTextInput;
import com.earth2me.essentials.textreader.TextPager;
import com.earth2me.essentials.utils.NumberUtil;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.util.*;
import java.util.Map.Entry;
@@ -12,7 +13,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()
@@ -21,7 +22,7 @@ public class Commandbalancetop extends EssentialsCommand
}
private static final int CACHETIME = 2 * 60 * 1000;
public static final int MINUSERS = 50;
private static ArrayListInput cache = new ArrayListInput();
private static SimpleTextInput cache = new SimpleTextInput();
private static long cacheage = 0;
private static ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
@@ -63,7 +64,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 +72,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 +83,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);
}
@@ -105,36 +106,37 @@ public class Commandbalancetop extends EssentialsCommand
{
if (force || cacheage <= System.currentTimeMillis() - CACHETIME)
{
cache.getLines().clear();
final Map<String, Double> balances = new HashMap<String, Double>();
double totalMoney = 0d;
cache.getLines().clear();
final Map<String, BigDecimal> balances = new HashMap<String, BigDecimal>();
BigDecimal totalMoney = BigDecimal.ZERO;
for (String u : ess.getUserMap().getAllUniqueUsers())
{
final User user = ess.getUserMap().getUser(u);
if (user != null)
{
final double userMoney = user.getMoney();
final BigDecimal userMoney = user.getMoney();
user.updateMoneyCache(userMoney);
totalMoney += userMoney;
balances.put(user.getDisplayName(), userMoney);
totalMoney = totalMoney.add(userMoney);
final String name = user.isHidden() ? user.getName() : user.getDisplayName();
balances.put(name, userMoney);
}
}
final List<Map.Entry<String, Double>> sortedEntries = new ArrayList<Map.Entry<String, Double>>(balances.entrySet());
Collections.sort(sortedEntries, new Comparator<Map.Entry<String, Double>>()
final List<Map.Entry<String, BigDecimal>> sortedEntries = new ArrayList<Map.Entry<String, BigDecimal>>(balances.entrySet());
Collections.sort(sortedEntries, new Comparator<Map.Entry<String, BigDecimal>>()
{
@Override
public int compare(final Entry<String, Double> entry1, final Entry<String, Double> entry2)
public int compare(final Entry<String, BigDecimal> entry1, final Entry<String, BigDecimal> entry2)
{
return -entry1.getValue().compareTo(entry2.getValue());
return entry2.getValue().compareTo(entry1.getValue());
}
});
cache.getLines().add(_("serverTotal", Util.displayCurrency(totalMoney, ess)));
cache.getLines().add(_("serverTotal", NumberUtil.displayCurrency(totalMoney, ess)));
int pos = 1;
for (Map.Entry<String, Double> entry : sortedEntries)
for (Map.Entry<String, BigDecimal> entry : sortedEntries)
{
cache.getLines().add(pos + ". " + entry.getKey() + ", " + Util.displayCurrency(entry.getValue(), ess));
cache.getLines().add(pos + ". " + entry.getKey() + ", " + NumberUtil.displayCurrency(entry.getValue(), ess));
pos++;
}
cacheage = System.currentTimeMillis();
@@ -144,7 +146,7 @@ public class Commandbalancetop extends EssentialsCommand
{
lock.writeLock().unlock();
}
ess.scheduleAsyncDelayedTask(viewer);
ess.runTaskAsynchronously(viewer);
}
}
@@ -178,7 +180,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, false), 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.utils.FormatUtil;
import java.util.logging.Level;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -28,7 +29,7 @@ public class Commandban extends EssentialsCommand
User user;
try
{
user = getPlayer(server, args, 0, true);
user = getPlayer(server, args, 0, true, true);
}
catch (NoSuchFieldException e)
{
@@ -40,16 +41,14 @@ public class Commandban extends EssentialsCommand
if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
{
sender.sendMessage(_("banExempt"));
return;
throw new Exception(_("banExempt"));
}
}
else
{
if (user.isAuthorized("essentials.ban.exempt") && sender instanceof Player)
{
sender.sendMessage(_("banExempt"));
return;
throw new Exception(_("banExempt"));
}
}
@@ -57,30 +56,25 @@ public class Commandban extends EssentialsCommand
String banReason;
if (args.length > 1)
{
banReason = _("banFormat", getFinalArg(args, 1), senderName);
banReason = FormatUtil.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) {
if (nomatch)
{
sender.sendMessage(_("userUnknown", user.getName()));
}
for (Player onlinePlayer : server.getOnlinePlayers())
{
final User player = ess.getUser(onlinePlayer);
if (onlinePlayer == sender || player.isAuthorized("essentials.ban.notify"))
{
onlinePlayer.sendMessage(_("playerBanned", senderName, user.getName(), banReason));
}
}
ess.broadcastMessage("essentials.ban.notify", _("playerBanned", senderName, user.getName(), banReason));
}
}

View File

@@ -1,9 +1,13 @@
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.utils.FormatUtil;
import java.util.logging.Level;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandbanip extends EssentialsCommand
@@ -21,22 +25,34 @@ public class Commandbanip extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final User player = ess.getUser(args[0]);
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
if (player == null)
String ipAddress;
if (FormatUtil.validIP(args[0]))
{
ess.getServer().banIP(args[0]);
sender.sendMessage(_("banIpAddress"));
ipAddress = args[0];
}
else
{
final String ipAddress = player.getLastLoginAddress();
if (ipAddress.length() == 0)
try
{
throw new Exception(_("playerNotFound"));
User player = getPlayer(server, args, 0, true, true);
ipAddress = player.getLastLoginAddress();
}
catch (PlayerNotFoundException ex)
{
ipAddress = args[0];
}
ess.getServer().banIP(player.getLastLoginAddress());
sender.sendMessage(_("banIpAddress"));
}
if (ipAddress.isEmpty())
{
throw new PlayerNotFoundException();
}
ess.getServer().banIP(ipAddress);
server.getLogger().log(Level.INFO, _("playerBanIpAddress", senderName, ipAddress));
ess.broadcastMessage("essentials.ban.notify", _("playerBanIpAddress", senderName, ipAddress));
}
}

View File

@@ -2,7 +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.utils.LocationUtil;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.TreeType;
@@ -36,8 +36,8 @@ public class Commandbigtree extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final Location loc = Util.getTarget(user);
final Location safeLocation = Util.getSafeDestination(loc);
final Location loc = LocationUtil.getTarget(user);
final Location safeLocation = LocationUtil.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, tree);
if (success)
{

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") && (isAuthor(bmeta, player) || user.isAuthorized("essentials.book.others")))
{
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,7 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.FormatUtil;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -13,14 +14,25 @@ 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
{
sendBroadcast(user.getDisplayName(), args);
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
sendBroadcast(sender.getName(), args);
}
private void sendBroadcast(final String name, final String[] args) throws NotEnoughArgumentsException
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
ess.broadcastMessage(null, _("broadcast", Util.replaceFormat(getFinalArg(args, 0))));
ess.broadcastMessage(_("broadcast", FormatUtil.replaceFormat(getFinalArg(args, 0)).replace("\\n", "\n"), name));
}
}

View File

@@ -1,9 +1,9 @@
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 Commandburn extends EssentialsCommand
@@ -20,17 +20,15 @@ public class Commandburn extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
//TODO: TL this
if (args[0].trim().length() < 2)
{
throw new NotEnoughArgumentsException("You need to specify a player to burn.");
}
for (Player p : server.matchPlayer(args[0]))
{
p.setFireTicks(Integer.parseInt(args[1]) * 20);
sender.sendMessage(_("burnMsg", p.getDisplayName(), Integer.parseInt(args[1])));
}
User user = getPlayer(server, sender, args, 0);
user.setFireTicks(Integer.parseInt(args[1]) * 20);
sender.sendMessage(_("burnMsg", user.getDisplayName(), Integer.parseInt(args[1])));
}
}

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.utils.NumberUtil;
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,77 +23,138 @@ 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)
else if (args[0].trim().length() < 2)
{
u.getInventory().clear();
sender.sendMessage(_("inventoryClearedOthers", u.getDisplayName()));
throw new Exception(_("playerNotFound"));
}
else
{
throw new Exception(_("playerNotFound"));
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(_("inventoryClearedAll"));
}
else
{
throw new NotEnoughArgumentsException();
}
}
private void cleanInventoryOthers(Server server, CommandSender sender, 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();
}
sender.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 if (arg.equalsIgnoreCase("**"))
{
player.getInventory().clear();
player.getInventory().setArmorContents(null);
}
else
{
final String[] split = arg.split(":");
final ItemStack item = ess.getItemDb().get(split[0]);
final int type = item.getTypeId();
if (split.length > 1 && NumberUtil.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 (NumberUtil.isInt(split[0]))
{
player.getInventory().clear(type, -1);
}
else
{
player.getInventory().clear(type, item.getDurability());
}
}
}
}

View File

@@ -39,7 +39,7 @@ public class Commanddelhome extends EssentialsCommand
if (expandedArg.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
{
user = getPlayer(server, expandedArg, 0, true);
user = getPlayer(server, expandedArg, 0, true, true);
name = expandedArg[1];
}
else if (user == null)
@@ -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

@@ -19,7 +19,7 @@ public class Commanddelwarp extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
ess.getWarps().delWarp(args[0]);
ess.getWarps().removeWarp(args[0]);
sender.sendMessage(_("deleteWarp", args[0]));
}
}

View File

@@ -2,6 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.NumberUtil;
import java.math.BigDecimal;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -22,12 +24,16 @@ public class Commandeco extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
EcoCommands cmd;
double amount;
Commandeco.EcoCommands cmd;
BigDecimal startingBalance = ess.getSettings().getStartingBalance();
BigDecimal amount;
BigDecimal broadcast = null;
BigDecimal broadcastAll = null;
try
{
cmd = EcoCommands.valueOf(args[0].toUpperCase(Locale.ENGLISH));
amount = Double.parseDouble(args[2].replaceAll("[^0-9\\.]", ""));
cmd = Commandeco.EcoCommands.valueOf(args[0].toUpperCase(Locale.ENGLISH));
amount = (cmd == Commandeco.EcoCommands.RESET) ? startingBalance : new BigDecimal(args[2].replaceAll("[^0-9\\.]", ""));
}
catch (Exception ex)
{
@@ -46,14 +52,13 @@ public class Commandeco extends EssentialsCommand
break;
case TAKE:
if (player.canAfford(amount, false))
{
player.takeMoney(amount);
}
take(amount, player, null);
break;
case RESET:
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
case SET:
set(amount, player, null);
broadcastAll = amount;
break;
}
}
@@ -70,22 +75,20 @@ public class Commandeco extends EssentialsCommand
break;
case TAKE:
if (!player.canAfford(amount, false))
{
throw new Exception(_("notEnoughMoney"));
}
player.takeMoney(amount);
take(amount, player, null);
break;
case RESET:
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
case SET:
set(amount, player, null);
broadcast = amount;
break;
}
}
}
else
{
final User player = getPlayer(server, args, 1, true);
final User player = getPlayer(server, args, 1, true, true);
switch (cmd)
{
case GIVE:
@@ -93,23 +96,60 @@ public class Commandeco extends EssentialsCommand
break;
case TAKE:
if (!player.canAfford(amount, false))
{
throw new Exception(_("notEnoughMoney"));
}
player.takeMoney(amount, sender);
take(amount, player, sender);
break;
case RESET:
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
case SET:
set(amount, player, sender);
break;
}
}
if (broadcast != null)
{
server.broadcastMessage(_("resetBal", NumberUtil.displayCurrency(broadcast, ess)));
}
if (broadcastAll != null)
{
server.broadcastMessage(_("resetBalAll", NumberUtil.displayCurrency(broadcastAll, ess)));
}
}
private void take(BigDecimal amount, final User player, final CommandSender sender) throws Exception
{
BigDecimal money = player.getMoney();
BigDecimal minBalance = ess.getSettings().getMinMoney();
if (money.subtract(amount).compareTo(minBalance) > 0)
{
player.takeMoney(amount, sender);
}
else if (sender == null)
{
player.setMoney(minBalance);
player.sendMessage(_("takenFromAccount", NumberUtil.displayCurrency(player.getMoney(), ess)));
}
else
{
throw new Exception(_("insufficientFunds"));
}
}
private void set(BigDecimal amount, final User player, final CommandSender sender)
{
BigDecimal minBalance = ess.getSettings().getMinMoney();
boolean underMinimum = (amount.compareTo(minBalance) < 0);
player.setMoney(underMinimum ? minBalance : amount);
player.sendMessage(_("setBal", NumberUtil.displayCurrency(player.getMoney(), ess)));
if (sender != null)
{
sender.sendMessage(_("setBalOthers", player.getDisplayName(), NumberUtil.displayCurrency(player.getMoney(), ess)));
}
}
private enum EcoCommands
{
GIVE, TAKE, RESET
GIVE, TAKE, SET, RESET
}
}
}

View File

@@ -2,12 +2,14 @@ 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 com.earth2me.essentials.utils.StringUtil;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
@@ -25,7 +27,7 @@ public class Commandenchant extends EssentialsCommand
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
final ItemStack stack = user.getItemInHand();
if (stack == null)
if (stack == null || stack.getType() == Material.AIR)
{
throw new Exception(_("nothingInHand"));
}
@@ -35,14 +37,15 @@ 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.enchantments." + enchantmentName) && entry.getValue().canEnchantItem(stack)))
{
enchantmentslist.add(entry.getKey());
//enchantmentslist.add(enchantmentName);
}
}
throw new NotEnoughArgumentsException(_("enchantments", Util.joinList(enchantmentslist.toArray())));
throw new NotEnoughArgumentsException(_("enchantments", StringUtil.joinList(enchantmentslist.toArray())));
}
int level = -1;
if (args.length > 1)
{
@@ -55,20 +58,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.enchantments.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 +77,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

@@ -16,7 +16,7 @@ public class Commandenderchest extends EssentialsCommand
{
if (args.length > 0 && user.isAuthorized("essentials.enderchest.others"))
{
final User invUser = getPlayer(server, args, 0);
final User invUser = getPlayer(server, user, args, 0);
user.openInventory(invUser.getEnderChest());
user.setEnderSee(true);
}

View File

@@ -2,13 +2,16 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.UserMap;
import com.earth2me.essentials.metrics.Metrics;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.NumberUtil;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
@@ -27,7 +30,8 @@ public class Commandessentials extends EssentialsCommand
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length == 0) {
if (args.length == 0)
{
run_disabled(server, sender, commandLabel, args);
}
else if (args[0].equalsIgnoreCase("debug"))
@@ -50,130 +54,112 @@ public class Commandessentials extends EssentialsCommand
{
run_optout(server, sender, commandLabel, args);
}
else {
else if (args[0].equalsIgnoreCase("cleanup"))
{
run_cleanup(server, sender, commandLabel, args);
}
else
{
run_reload(server, sender, commandLabel, args);
}
}
//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());
sender.sendMessage("/<command> <reload/debug>");
final StringBuilder disabledCommands = new StringBuilder();
for (Map.Entry<String, String> entry : ess.getAlternativeCommandsHandler().disabledCommands().entrySet())
{
if (disabledCommands.length() > 0) {
if (disabledCommands.length() > 0)
{
disabledCommands.append(", ");
}
disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue());
}
if (disabledCommands.length() > 0) {
if (disabledCommands.length() > 0)
{
sender.sendMessage(_("blockList"));
sender.sendMessage(disabledCommands.toString());
}
}
private void run_reset(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
throw new NotEnoughArgumentsException("/<command> reset <player>");
throw new Exception("/<command> reset <player>");
}
final User user = getPlayer(server, args, 1, true);
final User user = getPlayer(server, args, 1, true, true);
user.reset();
sender.sendMessage("Reset Essentials userdata for player: " + user.getDisplayName());
}
private void run_debug(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
ess.getSettings().setDebug(!ess.getSettings().isDebug());
sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
}
private void run_reload(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
ess.reload();
sender.sendMessage(_("essentialsReload", ess.getDescription().getVersion()));
}
private void run_nya(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
noteMap.put("1F#", (byte)0x0);
noteMap.put("1G", (byte)0x1);
noteMap.put("1G#", (byte)0x2);
noteMap.put("1A", (byte)0x3);
noteMap.put("1A#", (byte)0x4);
noteMap.put("1B", (byte)0x5);
noteMap.put("1C", (byte)0x6);
noteMap.put("1C#", (byte)0x7);
noteMap.put("1D", (byte)0x8);
noteMap.put("1D#", (byte)0x9);
noteMap.put("1E", (byte)0xA);
noteMap.put("1F", (byte)0xB);
noteMap.put("2F#", (byte)(0x0 + 0xC));
noteMap.put("2G", (byte)(0x1 + 0xC));
noteMap.put("2G#", (byte)(0x2 + 0xC));
noteMap.put("2A", (byte)(0x3 + 0xC));
noteMap.put("2A#", (byte)(0x4 + 0xC));
noteMap.put("2B", (byte)(0x5 + 0xC));
noteMap.put("2C", (byte)(0x6 + 0xC));
noteMap.put("2C#", (byte)(0x7 + 0xC));
noteMap.put("2D", (byte)(0x8 + 0xC));
noteMap.put("2D#", (byte)(0x9 + 0xC));
noteMap.put("2E", (byte)(0xA + 0xC));
noteMap.put("2F", (byte)(0xB + 0xC));
if (!noteBlocks.isEmpty())
{
return;
}
final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1B,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,";
final String[] tune = tuneStr.split(",");
for (Player player : server.getOnlinePlayers())
{
final Location loc = player.getLocation();
loc.add(0, 3, 0);
while (loc.getBlockY() < player.getLocation().getBlockY() + 10 && loc.getBlock().getTypeId() != 0)
{
loc.add(0, 1, 0);
}
if (loc.getBlock().getTypeId() == 0)
{
noteBlocks.put(player, loc.getBlock());
loc.getBlock().setType(Material.NOTE_BLOCK);
}
}
taskid = ess.scheduleSyncRepeatingTask(new Runnable()
{
int i = 0;
final Map<String, Float> noteMap = new HashMap<String, Float>();
noteMap.put("1F#", 0.5f);
noteMap.put("1G", 0.53f);
noteMap.put("1G#", 0.56f);
noteMap.put("1A", 0.6f);
noteMap.put("1A#", 0.63f);
noteMap.put("1B", 0.67f);
noteMap.put("1C", 0.7f);
noteMap.put("1C#", 0.76f);
noteMap.put("1D", 0.8f);
noteMap.put("1D#", 0.84f);
noteMap.put("1E", 0.9f);
noteMap.put("1F", 0.94f);
noteMap.put("2F#", 1.0f);
noteMap.put("2G", 1.06f);
noteMap.put("2G#", 1.12f);
noteMap.put("2A", 1.18f);
noteMap.put("2A#", 1.26f);
noteMap.put("2B", 1.34f);
noteMap.put("2C", 1.42f);
noteMap.put("2C#", 1.5f);
noteMap.put("2D", 1.6f);
noteMap.put("2D#", 1.68f);
noteMap.put("2E", 1.78f);
noteMap.put("2F", 1.88f);
final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1B,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,";
final String[] tune = tuneStr.split(",");
taskid = ess.scheduleSyncRepeatingTask(new Runnable()
{
int i = 0;
@Override
public void run()
@Override
public void run()
{
final String note = tune[i];
i++;
if (i >= tune.length)
{
final String note = tune[i];
i++;
if (i >= tune.length)
{
Commandessentials.this.stopTune();
}
if (note.isEmpty())
{
return;
}
Map<Player, Block> noteBlocks = Commandessentials.this.noteBlocks;
for (Player onlinePlayer : server.getOnlinePlayers())
{
final Block block = noteBlocks.get(onlinePlayer);
if (block == null || block.getType() != Material.NOTE_BLOCK)
{
continue;
}
onlinePlayer.playNote(block.getLocation(), (byte)0, noteMap.get(note));
}
Commandessentials.this.stopTune();
}
}, 20, 2);
if (note.isEmpty() || note == null)
{
return;
}
for (Player onlinePlayer : server.getOnlinePlayers())
{
onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.NOTE_PIANO, 1, noteMap.get(note));
}
}
}, 20, 2);
}
private void stopTune()
@@ -188,24 +174,39 @@ public class Commandessentials extends EssentialsCommand
}
noteBlocks.clear();
}
private void run_moo(final Server server, final CommandSender sender, final String command, final String args[])
{
if(sender instanceof ConsoleCommandSender)
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | ||", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } );
if (sender instanceof ConsoleCommandSender)
{
sender.sendMessage(new String[]
{
" (__)", " (oo)", " /------\\/", " / | ||", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..."
});
}
else
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | | |", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } );
{
sender.sendMessage(new String[]
{
" (__)", " (oo)", " /------\\/", " / | | |", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..."
});
final Player player = (Player)sender;
player.playSound(player.getLocation(), Sound.COW_IDLE, 1, 1.0f);
}
}
private void run_optout(final Server server, final CommandSender sender, final String command, final String args[])
{
final Metrics metrics = ess.getMetrics();
try
{
sender.sendMessage("Essentials collects simple metrics to highlight which features to concentrate work on in the future.");
if (metrics.isOptOut()) {
metrics.enable();
} else {
if (metrics.isOptOut())
{
metrics.enable();
}
else
{
metrics.disable();
}
sender.sendMessage("Anonymous Metrics are now: " + (metrics.isOptOut() ? "disabled" : "enabled"));
@@ -215,4 +216,71 @@ public class Commandessentials extends EssentialsCommand
sender.sendMessage("Unable to modify 'plugins/PluginMetrics/config.yml': " + ex.getMessage());
}
}
private void run_cleanup(final Server server, final CommandSender sender, final String command, final String args[]) throws Exception
{
if (args.length < 2 || !NumberUtil.isInt(args[1]))
{
sender.sendMessage("This sub-command will delete users who havent logged in in the last <days> days.");
sender.sendMessage("Optional parameters define the minium amount required to prevent deletion.");
sender.sendMessage("Unless you define larger default values, this command wil ignore people who have more than 0 money/homes/bans.");
throw new Exception("/<command> cleanup <days> [money] [homes] [ban count]");
}
sender.sendMessage(_("cleaning"));
final long daysArg = Long.parseLong(args[1]);
final double moneyArg = args.length >= 3 ? Double.parseDouble(args[2].replaceAll("[^0-9\\.]", "")) : 0;
final int homesArg = args.length >= 4 && NumberUtil.isInt(args[3]) ? Integer.parseInt(args[3]) : 0;
final int bansArg = args.length >= 5 && NumberUtil.isInt(args[4]) ? Integer.parseInt(args[4]) : 0;
final UserMap userMap = ess.getUserMap();
ess.runTaskAsynchronously(new Runnable()
{
@Override
public void run()
{
Long currTime = System.currentTimeMillis();
for (String u : userMap.getAllUniqueUsers())
{
final User user = ess.getUserMap().getUser(u);
if (user == null)
{
continue;
}
int ban = user.getBanReason().equals("") ? 0 : 1;
long lastLog = user.getLastLogout();
if (lastLog == 0)
{
lastLog = user.getLastLogin();
}
if (lastLog == 0)
{
user.setLastLogin(currTime);
}
long timeDiff = currTime - lastLog;
long milliDays = daysArg * 24L * 60L * 60L * 1000L;
int homeCount = user.getHomes().size();
double moneyCount = user.getMoney().doubleValue();
if ((lastLog == 0) || (ban > bansArg) || (timeDiff < milliDays)
|| (homeCount > homesArg) || (moneyCount > moneyArg))
{
continue;
}
if (ess.getSettings().isDebug())
{
ess.getLogger().info("Deleting user: " + user.getName() + " Money: " + moneyCount + " Homes: " + homeCount + " Last seen: " + DateUtil.formatDateDiff(lastLog));
}
user.reset();
}
sender.sendMessage(_("cleaned"));
}
});
}
}

View File

@@ -3,6 +3,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.SetExpFix;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.List;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -23,7 +25,7 @@ public class Commandexp extends EssentialsCommand
{
showExp(user, user);
}
else if (args[0].equalsIgnoreCase("set") && user.isAuthorized("essentials.exp.set"))
else if (args.length > 1 && args[0].equalsIgnoreCase("set") && user.isAuthorized("essentials.exp.set"))
{
if (args.length == 3 && user.isAuthorized("essentials.exp.set.others"))
{
@@ -34,7 +36,7 @@ public class Commandexp extends EssentialsCommand
setExp(user, user, args[1], false);
}
}
else if (args[0].equalsIgnoreCase("give") && user.isAuthorized("essentials.exp.give"))
else if (args.length > 1 && args[0].equalsIgnoreCase("give") && user.isAuthorized("essentials.exp.give"))
{
if (args.length == 3 && user.isAuthorized("essentials.exp.give.others"))
{
@@ -45,21 +47,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 && NumberUtil.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 +102,14 @@ public class Commandexp extends EssentialsCommand
else
{
String match = args[0].trim();
if (args.length == 2)
if (args.length >= 2 && NumberUtil.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);
}
@@ -91,12 +117,18 @@ public class Commandexp extends EssentialsCommand
private void showMatch(final Server server, final CommandSender sender, final String match) throws NotEnoughArgumentsException
{
boolean skipHidden = sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.vanish.interact");
boolean foundUser = false;
for (Player matchPlayer : server.matchPlayer(match))
final List<Player> matchedPlayers = server.matchPlayer(match);
for (Player matchPlayer : matchedPlayers)
{
final User player = ess.getUser(matchPlayer);
if (skipHidden && player.isHidden())
{
continue;
}
foundUser = true;
final User target = ess.getUser(matchPlayer);
showExp(sender, target);
showExp(sender, player);
}
if (!foundUser)
{
@@ -104,14 +136,20 @@ 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 skipHidden = sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.vanish.interact");
boolean foundUser = false;
for (Player matchPlayer : server.matchPlayer(match))
final List<Player> matchedPlayers = server.matchPlayer(match);
for (Player matchPlayer : matchedPlayers)
{
final User target = ess.getUser(matchPlayer);
setExp(sender, target, amount, toggle);
final User player = ess.getUser(matchPlayer);
if (skipHidden && player.isHidden())
{
continue;
}
foundUser = true;
setExp(sender, player, amount, give);
}
if (!foundUser)
{
@@ -121,17 +159,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) throws NotEnoughArgumentsException
//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") || strAmount.endsWith("l"))
if (strAmount.contains("l"))
{
strAmount = strAmount.replaceAll("l","");
strAmount = strAmount.replaceAll("l", "");
int neededLevel = Integer.parseInt(strAmount);
if (give)
{
@@ -140,11 +178,12 @@ public class Commandexp extends EssentialsCommand
amount = (long)SetExpFix.getExpToLevel(neededLevel);
SetExpFix.setTotalExperience(target, 0);
}
else {
else
{
amount = Long.parseLong(strAmount);
if (amount < 0 || amount > Integer.MAX_VALUE)
if (amount > Integer.MAX_VALUE || amount < Integer.MIN_VALUE)
{
throw new NotEnoughArgumentsException();
throw new NotEnoughArgumentsException();
}
}
@@ -156,7 +195,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,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -35,15 +36,33 @@ public class Commandext extends EssentialsCommand
return;
}
extinguishPlayers(server, user, commandLabel);
if (args[0].trim().length() < 2)
{
throw new Exception(_("playerNotFound"));
}
extinguishPlayers(server, user, args[0]);
}
private void extinguishPlayers(final Server server, final CommandSender sender, final String name) throws Exception
{
for (Player matchPlayer : server.matchPlayer(name))
boolean skipHidden = sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.vanish.interact");
boolean foundUser = false;
final List<Player> matchedPlayers = server.matchPlayer(name);
for (Player matchPlayer : matchedPlayers)
{
final User player = ess.getUser(matchPlayer);
if (skipHidden && player.isHidden())
{
continue;
}
foundUser = true;
matchPlayer.setFireTicks(0);
sender.sendMessage(_("extinguishOthers", matchPlayer.getDisplayName()));
}
if (!foundUser)
{
throw new NotEnoughArgumentsException(_("playerNotFound"));
}
}
}

View File

@@ -6,6 +6,7 @@ import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.FoodLevelChangeEvent;
public class Commandfeed extends EssentialsCommand
@@ -20,32 +21,89 @@ public class Commandfeed extends EssentialsCommand
{
if (args.length > 0 && user.isAuthorized("essentials.feed.others"))
{
feedOtherPlayers(server,user,args[0]);
}
else
{
user.setFoodLevel(20);
user.setSaturation(10);
user.sendMessage(_("feed"));
}
}
private void feedOtherPlayers(final Server server, final CommandSender sender, final String name)
{
final List<Player> players = server.matchPlayer(name);
if (players.isEmpty())
{
sender.sendMessage(_("playerNotFound"));
if (args[0].trim().length() < 2)
{
throw new Exception(_("playerNotFound"));
}
if (!user.isAuthorized("essentials.heal.cooldown.bypass"))
{
user.healCooldown();
}
feedOtherPlayers(server, user, args[0]);
return;
}
for (Player player : players)
if (!user.isAuthorized("essentials.heal.cooldown.bypass"))
{
if (ess.getUser(player).isHidden())
user.healCooldown();
}
try
{
feedPlayer(user, user);
}
catch (QuietAbortException e)
{
//User does not need feeding.
}
user.sendMessage(_("feed"));
}
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
feedOtherPlayers(server, sender, args[0]);
}
private void feedOtherPlayers(final Server server, final CommandSender sender, final String name) throws NotEnoughArgumentsException
{
boolean skipHidden = sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.vanish.interact");
boolean foundUser = false;
final List<Player> matchedPlayers = server.matchPlayer(name);
for (Player matchPlayer : matchedPlayers)
{
final User player = ess.getUser(matchPlayer);
if (skipHidden && player.isHidden())
{
continue;
}
player.setFoodLevel(20);
player.setSaturation(10);
foundUser = true;
try
{
feedPlayer(sender, matchPlayer);
}
catch (QuietAbortException e)
{
//User does not need feeding.
}
}
if (!foundUser)
{
throw new NotEnoughArgumentsException(_("playerNotFound"));
}
}
private void feedPlayer(CommandSender sender, Player player) throws QuietAbortException
{
final int amount = 30;
final FoodLevelChangeEvent flce = new FoodLevelChangeEvent(player, amount);
ess.getServer().getPluginManager().callEvent(flce);
if (flce.isCancelled())
{
throw new QuietAbortException();
}
player.setFoodLevel(flce.getFoodLevel() > 20 ? 20 : flce.getFoodLevel());
player.setSaturation(10);
if (!sender.equals(player))
{
sender.sendMessage(_("feedOther", player.getDisplayName()));
}
}

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;
@@ -17,13 +16,43 @@ public class Commandfireball extends EssentialsCommand
@Override
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,153 @@
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.utils.NumberUtil;
import java.util.regex.Pattern;
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("[:+',;.]");
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("f")))
&& user.isAuthorized("essentials.firework.fire"))
{
int amount = 1;
boolean direction = false;
if (args.length > 1)
{
if (NumberUtil.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)
{
try
{
mStack.addFireworkMeta(user, true, arg, ess);
}
catch (Exception e)
{
user.sendMessage(_("fireworkSyntax"));
throw e;
}
}
if (mStack.isValidFirework())
{
FireworkMeta fmeta = (FireworkMeta)mStack.getItemStack().getItemMeta();
FireworkEffect effect = mStack.getFireworkBuilder().build();
if (fmeta.getEffects().size() > 0 && !user.isAuthorized("essentials.firework.multiple"))
{
throw new Exception(_("multipleCharges"));
}
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

@@ -4,25 +4,19 @@ 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 Commandfly extends EssentialsCommand
public class Commandfly extends EssentialsToggleCommand
{
public Commandfly()
{
super("fly");
super("fly", "essentials.fly.others");
}
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
flyOtherPlayers(server, sender, args);
toggleOtherPlayers(server, sender, args);
}
@Override
@@ -30,67 +24,45 @@ public class Commandfly extends EssentialsCommand
{
if (args.length == 1)
{
if (args[0].equalsIgnoreCase("on") || args[0].startsWith("ena") || args[0].equalsIgnoreCase("1"))
Boolean toggle = matchToggleArgument(args[0]);
if (toggle == null && user.isAuthorized(othersPermission))
{
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;
}
else
{
user.setAllowFlight(!user.getAllowFlight());
if (!user.getAllowFlight())
{
user.setFlying(false);
}
}
user.sendMessage(_("flyMode", _(user.getAllowFlight() ? "enabled" : "disabled"), user.getDisplayName()));
}
private void flyOtherPlayers(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.setAllowFlight(true);
}
else
{
player.setAllowFlight(false);
}
toggleOtherPlayers(server, user, args);
}
else
{
player.setAllowFlight(!player.getAllowFlight());
togglePlayer(user, user, toggle);
}
}
else if (args.length == 2 && user.isAuthorized(othersPermission))
{
toggleOtherPlayers(server, user, args);
}
else
{
togglePlayer(user, user, null);
}
}
if (!player.getAllowFlight())
{
player.setFlying(false);
}
sender.sendMessage(_("flyMode", _(player.getAllowFlight() ? "enabled" : "disabled"), player.getDisplayName()));
@Override
void togglePlayer(CommandSender sender, User user, Boolean enabled)
{
if (enabled == null)
{
enabled = !user.getAllowFlight();
}
user.setAllowFlight(enabled);
if (!user.getAllowFlight())
{
user.setFlying(false);
}
user.sendMessage(_("flyMode", _(enabled ? "enabled" : "disabled"), user.getDisplayName()));
if (!sender.equals(user))
{
sender.sendMessage(_("flyMode", _(enabled ? "enabled" : "disabled"), user.getDisplayName()));
}
}
}

View File

@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import java.util.List;
import java.util.Locale;
import org.bukkit.GameMode;
import org.bukkit.Server;
@@ -76,25 +77,27 @@ public class Commandgamemode extends EssentialsCommand
user.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
}
private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final GameMode gameMode, final String player) throws NotEnoughArgumentsException
private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final GameMode gameMode, final String name) throws NotEnoughArgumentsException
{
//TODO: TL this
if (player.trim().length() < 2 || gameMode == null)
if (name.trim().length() < 2 || gameMode == null)
{
throw new NotEnoughArgumentsException("You need to specify a valid player/mode.");
}
boolean skipHidden = sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.vanish.interact");
boolean foundUser = false;
for (Player matchPlayer : server.matchPlayer(player))
final List<Player> matchedPlayers = server.matchPlayer(name);
for (Player matchPlayer : matchedPlayers)
{
final User user = ess.getUser(matchPlayer);
if (user.isHidden())
final User player = ess.getUser(matchPlayer);
if (skipHidden && player.isHidden())
{
continue;
}
user.setGameMode(gameMode);
sender.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
foundUser = true;
player.setGameMode(gameMode);
sender.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName()));
}
if (!foundUser)
{

View File

@@ -1,8 +1,10 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.NumberUtil;
import java.lang.management.ManagementFactory;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.World;
@@ -19,13 +21,13 @@ public class Commandgc extends EssentialsCommand
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
float tps = ess.getTimer().getAverageTPS();
double tps = ess.getTimer().getAverageTPS();
ChatColor color;
if (tps >= 18)
if (tps >= 18.0)
{
color = ChatColor.GREEN;
}
else if (tps >= 15)
else if (tps >= 15.0)
{
color = ChatColor.YELLOW;
}
@@ -33,14 +35,15 @@ public class Commandgc extends EssentialsCommand
{
color = ChatColor.RED;
}
sender.sendMessage(_("uptime", Util.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime())));
sender.sendMessage(_("tps", "" + color + tps));
sender.sendMessage(_("uptime", DateUtil.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime())));
sender.sendMessage(_("tps", "" + color + NumberUtil.formatDouble(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 +58,5 @@ public class Commandgc extends EssentialsCommand
sender.sendMessage(_("gcWorld", worldType, w.getName(), w.getLoadedChunks().length, w.getEntities().size()));
}
}
}

View File

@@ -19,13 +19,9 @@ public class Commandgetpos extends EssentialsCommand
{
if (args.length > 0 && user.isAuthorized("essentials.getpos.others"))
{
final User otherUser = getPlayer(server, args, 0);
if (!otherUser.isHidden() || user.isAuthorized("essentials.list.hidden"))
{
outputPosition(user, otherUser.getLocation(), user.getLocation());
return;
}
final User otherUser = getPlayer(server, user, args, 0);
outputPosition(user, otherUser.getLocation(), user.getLocation());
return;
}
outputPosition(user, user.getLocation(), null);
}
@@ -37,7 +33,7 @@ public class Commandgetpos extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
final User user = getPlayer(server, args, 0);
final User user = getPlayer(server, args, 0, true, false);
outputPosition(sender, user.getLocation(), null);
}

View File

@@ -1,14 +1,15 @@
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;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.Locale;
import java.util.Map;
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,61 +29,59 @@ 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
&& (ess.getSettings().permissionBasedItemSpawn()
? (!ess.getUser(sender).isAuthorized("essentials.give.item-all")
&& !ess.getUser(sender).isAuthorized("essentials.give.item-" + itemname)
&& !ess.getUser(sender).isAuthorized("essentials.give.item-" + stack.getTypeId()))
? (!ess.getUser(sender).isAuthorized("essentials.itemspawn.item-all")
&& !ess.getUser(sender).isAuthorized("essentials.itemspawn.item-" + itemname)
&& !ess.getUser(sender).isAuthorized("essentials.itemspawn.item-" + stack.getTypeId()))
: (!ess.getUser(sender).isAuthorized("essentials.itemspawn.exempt")
&& !ess.getUser(sender).canSpawnItem(stack.getTypeId()))))
{
throw new Exception(_("cantSpawnItem", itemname));
}
final User giveTo = getPlayer(server, args, 0);
final User giveTo = getPlayer(server, sender, 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 && NumberUtil.isInt(args[2]) && NumberUtil.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.enchantments.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, NumberUtil.isInt(args[3]) ? 4 : 3, ess);
stack = metaStack.getItemStack();
}
if (stack.getType() == Material.AIR)
@@ -92,14 +91,23 @@ public class Commandgive extends EssentialsCommand
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
sender.sendMessage(_("giveSpawn", stack.getAmount(), itemName, giveTo.getDisplayName()));
Map<Integer, ItemStack> leftovers;
if (giveTo.isAuthorized("essentials.oversizedstacks"))
{
InventoryWorkaround.addOversizedItems(giveTo.getInventory(), ess.getSettings().getOversizedStackSize(), stack);
leftovers = InventoryWorkaround.addOversizedItems(giveTo.getInventory(), ess.getSettings().getOversizedStackSize(), stack);
}
else
{
InventoryWorkaround.addItems(giveTo.getInventory(), stack);
leftovers = InventoryWorkaround.addItems(giveTo.getInventory(), stack);
}
for (ItemStack item : leftovers.values())
{
sender.sendMessage(_("giveSpawnFailure", item.getAmount(), itemName, giveTo.getDisplayName()));
}
giveTo.updateInventory();
}
}

View File

@@ -4,73 +4,66 @@ 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 Commandgod extends EssentialsCommand
public class Commandgod extends EssentialsToggleCommand
{
public Commandgod()
{
super("god");
super("god", "essentials.god.others");
}
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
godOtherPlayers(server, sender, args);
toggleOtherPlayers(server, sender, args);
}
@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.god.others"))
if (args.length == 1)
{
godOtherPlayers(server, user, args);
return;
}
user.setGodModeEnabled(!user.isGodModeEnabled());
user.sendMessage(_("godMode", (user.isGodModeEnabled() ? _("enabled") : _("disabled"))));
}
private void godOtherPlayers(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())
Boolean toggle = matchToggleArgument(args[0]);
if (toggle == null && user.isAuthorized(othersPermission))
{
continue;
}
if (args.length > 1)
{
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
{
player.setGodModeEnabled(true);
}
else
{
player.setGodModeEnabled(false);
}
toggleOtherPlayers(server, user, args);
}
else
{
player.setGodModeEnabled(!player.isGodModeEnabled());
togglePlayer(user, user, toggle);
}
}
else if (args.length == 2 && user.isAuthorized(othersPermission))
{
toggleOtherPlayers(server, user, args);
}
else
{
togglePlayer(user, user, null);
}
}
final boolean enabled = player.isGodModeEnabled();
if (enabled)
{
player.setFoodLevel(20);
}
@Override
void togglePlayer(CommandSender sender, User user, Boolean enabled)
{
if (enabled == null)
{
enabled = !user.isGodModeEnabled();
}
user.setGodModeEnabled(enabled);
player.sendMessage(_("godMode", (enabled ? _("enabled") : _("disabled"))));
sender.sendMessage(_("godMode", _(enabled ? "godEnabledFor" : "godDisabledFor", matchPlayer.getDisplayName())));
if (enabled && user.getHealth() != 0)
{
user.setHealth(user.getMaxHealth());
user.setFoodLevel(20);
}
user.sendMessage(_("godMode", enabled ? _("enabled") : _("disabled")));
if (!sender.equals(user))
{
sender.sendMessage(_("godMode", _(enabled ? "godEnabledFor" : "godDisabledFor", user.getDisplayName())));
}
}
}

View File

@@ -44,7 +44,6 @@ public class Commandhat extends EssentialsCommand
{
final PlayerInventory inv = user.getInventory();
final ItemStack head = inv.getHelmet();
inv.removeItem(hand);
inv.setHelmet(hand);
inv.setItemInHand(head);
user.sendMessage(_("hatPlaced"));

View File

@@ -6,8 +6,9 @@ import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class Commandheal extends EssentialsCommand
@@ -23,6 +24,10 @@ public class Commandheal extends EssentialsCommand
if (args.length > 0 && user.isAuthorized("essentials.heal.others"))
{
if (args[0].trim().length() < 2)
{
throw new Exception(_("playerNotFound"));
}
if (!user.isAuthorized("essentials.heal.cooldown.bypass"))
{
user.healCooldown();
@@ -49,33 +54,63 @@ public class Commandheal extends EssentialsCommand
healOtherPlayers(server, sender, args[0]);
}
private void healOtherPlayers(final Server server, final CommandSender sender, final String name)
private void healOtherPlayers(final Server server, final CommandSender sender, final String name) throws Exception
{
final List<Player> players = server.matchPlayer(name);
if (players.isEmpty())
boolean skipHidden = sender instanceof Player && !ess.getUser(sender).isAuthorized("essentials.vanish.interact");
boolean foundUser = false;
final List<Player> matchedPlayers = server.matchPlayer(name);
for (Player matchPlayer : matchedPlayers)
{
sender.sendMessage(_("playerNotFound"));
return;
}
for (Player p : players)
{
if (ess.getUser(p).isHidden())
final User player = ess.getUser(matchPlayer);
if (skipHidden && player.isHidden())
{
continue;
}
healPlayer(p);
sender.sendMessage(_("healOther", p.getDisplayName()));
foundUser = true;
try
{
healPlayer(matchPlayer);
sender.sendMessage(_("healOther", matchPlayer.getDisplayName()));
}
catch (QuietAbortException e)
{
//Handle Quietly
}
}
if (!foundUser)
{
throw new NotEnoughArgumentsException(_("playerNotFound"));
}
}
private void healPlayer(final Player p)
private void healPlayer(final Player player) throws Exception
{
p.setHealth(20);
p.setFoodLevel(20);
p.sendMessage(_("heal"));
for (PotionEffect effect : p.getActivePotionEffects())
if (player.getHealth() == 0)
{
p.removePotionEffect(effect.getType());
throw new Exception(_("healDead"));
}
final int amount = player.getMaxHealth() - player.getHealth();
final EntityRegainHealthEvent erhe = new EntityRegainHealthEvent(player, amount, RegainReason.CUSTOM);
ess.getServer().getPluginManager().callEvent(erhe);
if (erhe.isCancelled())
{
throw new QuietAbortException();
}
int newAmount = player.getHealth() + erhe.getAmount();
if (newAmount > player.getMaxHealth())
{
newAmount = player.getMaxHealth();
}
player.setHealth(newAmount);
player.setFoodLevel(20);
player.setFireTicks(0);
player.sendMessage(_("heal"));
for (PotionEffect effect : player.getActivePotionEffects())
{
player.removePotionEffect(effect.getType());
}
}
}

View File

@@ -2,8 +2,8 @@ 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.textreader.*;
import com.earth2me.essentials.utils.NumberUtil;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -27,7 +27,7 @@ public class Commandhelp extends EssentialsCommand
if (input.getLines().isEmpty())
{
if (Util.isInt(pageStr) || pageStr == null)
if (NumberUtil.isInt(pageStr) || pageStr == null)
{
output = new HelpInput(user, "", ess);
}

View File

@@ -1,10 +1,11 @@
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 com.earth2me.essentials.utils.FormatUtil;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -17,14 +18,26 @@ public class Commandhelpop extends EssentialsCommand
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
user.setDisplayNick();
sendMessage(server, user, user.getDisplayName(), args);
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
sendMessage(server, sender, Console.NAME, args);
}
private void sendMessage(final Server server, final CommandSender sender, final String from, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
user.setDisplayNick();
final String message = _("helpOp", user.getDisplayName(), Util.stripFormat(getFinalArg(args, 0)));
logger.log(Level.INFO, message);
final String message = _("helpOp", from, FormatUtil.stripFormat(getFinalArg(args, 0)));
CommandSender cs = Console.getCommandSender(server);
cs.sendMessage(message);
for (Player onlinePlayer : server.getOnlinePlayers())
{
final User player = ess.getUser(onlinePlayer);

View File

@@ -3,11 +3,10 @@ package com.earth2me.essentials.commands;
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.utils.StringUtil;
import java.util.List;
import java.util.Locale;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@@ -35,7 +34,7 @@ public class Commandhome extends EssentialsCommand
}
else
{
player = getPlayer(server, nameParts, 0, true);
player = getPlayer(server, nameParts, 0, true, true);
if (nameParts.length > 1)
{
homeName = nameParts[1];
@@ -47,21 +46,21 @@ public class Commandhome extends EssentialsCommand
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();
}
else
{
throw new Exception(_("bedMissing"));
}
}
goHome(user, player, homeName.toLowerCase(Locale.ENGLISH), charge);
}
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))
{
@@ -69,7 +68,7 @@ public class Commandhome extends EssentialsCommand
}
else if (homes.isEmpty())
{
throw new Exception(player == user ? _("noHomeSet") : _("noHomeSetPlayer"));
throw new Exception(_("noHomeSetPlayer"));
}
else if (homes.size() == 1 && player.equals(user))
{
@@ -77,11 +76,18 @@ public class Commandhome extends EssentialsCommand
}
else
{
if (bed != null && user.isAuthorized("essentials.home.bed"))
if (user.isAuthorized("essentials.home.bed"))
{
homes.add("bed");
if (bed != null)
{
homes.add(_("bed"));
}
else
{
homes.add(_("bedNull"));
}
}
user.sendMessage(_("homes", Util.joinList(homes)));
user.sendMessage(_("homes", StringUtil.joinList(homes)));
}
}
throw new NoChargeException();

View File

@@ -22,7 +22,7 @@ public class Commandignore extends EssentialsCommand
User player;
try
{
player = getPlayer(server, args, 0);
player = getPlayer(server, args, 0, true, true);
}
catch (NoSuchFieldException ex)
{

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);
final User invUser = getPlayer(server, user, 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.enchantments.allowunsafe");
metaStack.parseStringMeta(user, allowUnsafe, args, 2, ess);
stack = metaStack.getItemStack();
}
if (stack.getType() == Material.AIR)
{

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -15,6 +15,6 @@ public class Commandjails extends EssentialsCommand
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
sender.sendMessage("§7" + Util.joinList(" ", ess.getJails().getList()));
sender.sendMessage("§7" + StringUtil.joinList(" ", ess.getJails().getList()));
}
}

View File

@@ -3,7 +3,7 @@ package com.earth2me.essentials.commands;
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.utils.LocationUtil;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@@ -39,7 +39,7 @@ public class Commandjump extends EssentialsCommand
try
{
loc = Util.getTarget(user);
loc = LocationUtil.getTarget(user);
loc.setYaw(cloc.getYaw());
loc.setPitch(cloc.getPitch());
loc.setY(loc.getY() + 1);

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.utils.FormatUtil;
import java.util.logging.Level;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -24,30 +25,28 @@ public class Commandkick extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final User target = getPlayer(server, args, 0, true);
if (sender instanceof Player) {
final User target = getPlayer(server, args, 0, true, false);
if (sender instanceof Player)
{
User user = ess.getUser(sender);
if (target.isHidden() && !user.isAuthorized("essentials.list.hidden")) {
if (target.isHidden() && !user.isAuthorized("essentials.vanish.interact"))
{
throw new PlayerNotFoundException();
}
if (target.isAuthorized("essentials.kick.exempt"))
{
throw new Exception(_("kickExempt"));
}
}
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : _("kickDefault");
String kickReason = args.length > 1 ? getFinalArg(args, 1) : _("kickDefault");
kickReason = FormatUtil.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, target.getName(), kickReason));
for (Player onlinePlayer : server.getOnlinePlayers())
{
User player = ess.getUser(onlinePlayer);
if (player.isAuthorized("essentials.kick.notify"))
{
onlinePlayer.sendMessage(_("playerKicked", senderName, target.getName(), kickReason));
}
}
server.getLogger().log(Level.INFO, _("playerKicked", senderName, target.getName(), kickReason));
ess.broadcastMessage("essentials.kick.notify", _("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.utils.FormatUtil;
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 = FormatUtil.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

@@ -1,6 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -28,17 +29,21 @@ public class Commandkill extends EssentialsCommand
throw new NotEnoughArgumentsException("You need to specify a player to kill.");
}
for (Player matchPlayer : server.matchPlayer(args[0]))
final List<Player> matchedPlayers = server.matchPlayer(args[0]);
for (Player matchPlayer : matchedPlayers)
{
if (ess.getUser(matchPlayer).isAuthorized("essentials.kill.exempt") && !ess.getUser(sender).isAuthorized("essentials.kill.force"))
{
throw new Exception(_("killExempt", matchPlayer.getDisplayName()));
}
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 instanceof Player && !ess.getUser(sender).isAuthorized("essentials.kill.force"))
{
continue;
}
}
matchPlayer.damage(Short.MAX_VALUE);
if (matchPlayer.getHealth() > 0)
{
matchPlayer.setHealth(0);

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
@@ -52,6 +53,10 @@ public class Commandkillall extends EssentialsCommand
throw new Exception(_("numberRequired"), e);
}
}
if (args.length > 2)
{
world = ess.getWorld(args[2]);
}
}
else
{
@@ -109,7 +114,7 @@ public class Commandkillall extends EssentialsCommand
continue;
}
}
if(entity instanceof Ocelot)
if (entity instanceof Ocelot)
{
if (((Ocelot)entity).isTamed())
{
@@ -120,7 +125,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 +135,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 +143,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

@@ -4,7 +4,7 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Kit;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.utils.StringUtil;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -30,13 +30,13 @@ public class Commandkit extends EssentialsCommand
}
else if (args.length > 1 && user.isAuthorized("essentials.kit.others"))
{
final User userTo = getPlayer(server, args, 1, true);
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)).trim();
final User userTo = getPlayer(server, user, args, 1);
final String kitName = StringUtil.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)).trim();
giveKit(userTo, user, kitName);
}
else
{
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)).trim();
final String kitName = StringUtil.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)).trim();
giveKit(user, user, kitName);
}
}
@@ -52,14 +52,15 @@ public class Commandkit extends EssentialsCommand
}
else
{
final User userTo = getPlayer(server, args, 1, true);
final User userTo = getPlayer(server, args, 1, true, false);
final String kitName = args[0].toLowerCase(Locale.ENGLISH);
final Map<String, Object> kit = ess.getSettings().getKit(kitName);
final List<String> items = Kit.getItems(userTo, kit);
final List<String> items = Kit.getItems(ess, userTo, kit);
Kit.expandItems(ess, userTo, items);
sender.sendMessage(_("kitGive", kitName));
sender.sendMessage(_("kitGiveTo", kitName, userTo.getDisplayName()));
userTo.sendMessage(_("kitReceive", kitName));
}
}
@@ -77,7 +78,7 @@ public class Commandkit extends EssentialsCommand
throw new Exception(_("noKitPermission", "essentials.kits." + kitName));
}
final List<String> items = Kit.getItems(userTo, kit);
final List<String> items = Kit.getItems(ess, userTo, kit);
Kit.checkTime(userFrom, kitName, kit);
@@ -87,6 +88,7 @@ public class Commandkit extends EssentialsCommand
Kit.expandItems(ess, userTo, items);
charge.charge(userFrom);
userTo.sendMessage(_("kitGive", kitName));
userFrom.sendMessage(_("kitGiveTo", kitName, userTo.getDisplayName()));
userTo.sendMessage(_("kitReceive", kitName));
}
}

View File

@@ -29,6 +29,7 @@ public class Commandkittycannon extends EssentialsCommand
final int i = random.nextInt(Ocelot.Type.values().length);
ocelot.setCatType(Ocelot.Type.values()[i]);
ocelot.setTamed(true);
ocelot.setBaby();
ocelot.setVelocity(user.getEyeLocation().getDirection().multiply(2));
ess.scheduleSyncDelayedTask(new Runnable()
{

View File

@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.LightningStrike;
@@ -30,11 +31,6 @@ public class Commandlightning extends EssentialsCommand
}
}
if (server.matchPlayer(args[0]).isEmpty())
{
throw new Exception(_("playerNotFound"));
}
int power = 5;
if (args.length > 1)
{
@@ -47,12 +43,18 @@ public class Commandlightning extends EssentialsCommand
}
}
for (Player matchPlayer : server.matchPlayer(args[0]))
if (args[0].trim().length() < 2)
{
throw new Exception(_("playerNotFound"));
}
final List<Player> matchedPlayers = server.matchPlayer(args[0]);
for (Player matchPlayer : matchedPlayers)
{
sender.sendMessage(_("lightningUse", matchPlayer.getDisplayName()));
final LightningStrike strike = matchPlayer.getWorld().strikeLightningEffect(matchPlayer.getLocation());
if (!ess.getUser(matchPlayer).isGodModeEnabled())
{
matchPlayer.damage(power, strike);

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