Compare commits

...
Author SHA1 Message Date
KHobbits 4d0ce90787 Merge branch 'master' of github.com:essentials/Essentials into release 2012-06-23 13:47:32 +01:00
KHobbits 4d17b73291 Revert "fix /back resetting on logout"
This is desired behavior, and required for other features.
This reverts commit 329f93a4f6.
2012-06-23 13:33:36 +01:00
md-5 f7a34c49fb Merge pull request #89 from necrodoom/patch-7
major slab alias expansion for items.csv
2012-06-23 02:07:34 -07:00
necrodoom d0a8dc4812 major slab alias expansion for items.csv 2012-06-23 12:02:28 +03:00
Alexander Schepp 0466a60093 Too much space :D 2012-06-22 20:12:56 +03:00
Alexander Schepp 2c6a81a916 Prevent NPEs in KeywordReplacer 2012-06-22 19:16:40 +03:00
Iaccidentally 329f93a4f6 fix /back resetting on logout 2012-06-22 03:44:19 -04:00
md-5 b70f950479 Merge pull request #88 from SyntaxBlitz/master
Fix /vanish with no arguments doing nothing
2012-06-21 04:31:18 -07:00
Timothy Aveni 38a2e2bcfd Fix /vanish with no arguments doing nothing 2012-06-21 06:17:26 -04:00
md-5 d9b91e0c34 Merge pull request #87 from necrodoom/patch-5
updated items.csv, 43:4, 43:5, 44:4, 44:5
2012-06-21 03:03:39 -07:00
necrodoom 4ae5579068 while enraged at mibbit and esper failing to work, updated items.csv 2012-06-21 12:18:14 +03:00
md_5 622d710aa9 Merge branch 'master' into release 2012-06-21 18:27:54 +10:00
md_5 f1a7be09c2 Merge remote-tracking branch 'origin/groupmanager' 2012-06-21 18:27:21 +10:00
md_5 0742ca23c1 Update Czech translation. 2012-06-21 18:18:57 +10:00
Iaccidentally 8823ce070e change some default values 2012-06-21 05:05:22 -03:00
Iaccidentally d77f6cbbf1 fixxy fixxy 2012-06-19 18:13:47 -04:00
Iaccidentally 909c8b3cb5 Add Finnish translation 2012-06-19 18:02:05 -04:00
Iaccidentally 5b7d29fa55 Merge branch 'master' of https://github.com/essentials/Essentials 2012-06-19 17:56:43 -04:00
KHobbits 8dfb3c03c7 *borrows snowleo's strainer* 2012-06-19 20:57:40 +01:00
Iaccidentally 6e8031f477 Merge branch 'master' of https://github.com/essentials/Essentials 2012-06-19 12:48:55 -04:00
Paul A. 81c545f45b Merge pull request #86 from necrodoom/patch-4
adding beef and steak to items.csv - thanks @necrodoom
2012-06-19 07:13:37 -07:00
KHobbits 65025d47c5 Little safety check for bad plugins. 2012-06-19 09:03:37 +01:00
KHobbits 4f23e8aaeb Patch to allow plugins to use ignore lookup, without updating their own code. 2012-06-19 08:59:26 +01:00
KHobbits aea2c00a95 Add optional 2n'd param to temp ban reason TL key. 2012-06-19 08:46:33 +01:00
necrodoom eafe0380e1 hotfix before 2.9.2 release 2012-06-19 10:04:13 +03:00
ementalo 3975ceb2a0 Fixing vanish on off arguments 2012-06-18 15:35:21 +01:00
ementalo 0a3ecbcd0e Use the assigned variable when looking at durability in itemdb 2012-06-18 10:28:37 +01:00
KHobbits 9679a90d88 Add sign throttle config option.
Allows you to limit how often an Essentials sign can be spammed per player.
2012-06-17 19:28:59 +01:00
Iaccidentally c4a704b1a2 The French are weird : they use colons like this. 2012-06-17 11:50:52 -04:00
Iaccidentally 776900bd7b fix spacing issue in messages.properties 2012-06-17 11:41:00 -04:00
ElgarL 5683ea35fc Better update for the User object player reference. 2012-06-16 19:12:54 +01:00
ElgarL 78d4987d5d Clear the player reference on logout so it's refreshed upon a reconnect. 2012-06-16 19:04:40 +01:00
KHobbits 9f852b3a41 Using /exp, show can't find player message, if no matching player is found. 2012-06-16 18:22:31 +01:00
KHobbits edca2cbdff Added missing syntax to plugin.yml 2012-06-16 17:56:12 +01:00
KHobbits c578302d7c Fix playerlistname update when prefix/suffix option is disabled.
Fixes #2216
2012-06-16 17:42:42 +01:00
KHobbits dfce4b31f3 Adjust kit delay description.
Fixes #1580
2012-06-16 17:37:42 +01:00
KHobbits 669edfc048 Prevent joinbots from triggering join code, unless they are actually connected to the server and online. 2012-06-16 17:31:33 +01:00
KHobbits 0a9c88a990 Added TL key for ban syntax,
Default message: "Banned: <reason>"
Default reason: The Ban Hammer has spoken!
Optional 2nd param to banReason, {1}, will contain user who made the ban.
Example use: "banReason=Banned for {0} by {1}"
2012-06-16 17:10:47 +01:00
KHobbits 4e5e5a9684 Fix teleport cooldowns - thanks @basicsensei
Fixes #2260
2012-06-16 16:46:40 +01:00
KHobbits 97eada7dd6 Players should not be able to ignore Console
Also implement chat exempt permission in other commands.
2012-06-16 16:22:51 +01:00
KHobbits a764f8c929 Fix chat showing [spy] prefix when social spy was not required to see the message.
Fixes #2263
2012-06-16 16:05:48 +01:00
KHobbits 5da886593b Replace op ignore exempt with ignore exempt chat permission:
essentials.chat.ignoreexempt
This permission won't prevent a player from ignoring the player, but the player will see the chat messages anyway.
2012-06-16 16:01:27 +01:00
KHobbits 4c5a88929c Fix /exp so it can be used in the console 2012-06-16 14:26:29 +01:00
KHobbits af7e427545 Avoid silent command failures on /hat (ie typing /hat fish will no longer silently return as if broken) 2012-06-16 14:02:13 +01:00
KHobbits 4638c5ab55 Added missing TL key 'hatRemoved' 2012-06-16 13:56:36 +01:00
KHobbits 0c2e63baad Make /vanish follow the same rules as /fly, /god and /gamemode 2012-06-16 13:53:46 +01:00
Iaccidentally ee61ce35c8 Merge pull request #85 from kukelekuuk00/master
Updated dutch translation and fixed many grammar and spelling mistakes.
2012-06-15 15:06:38 -07:00
kukelekuuk00 6ec5b4a5da Updated dutch translation and fixed many grammar and spelling mistakes. 2012-06-16 00:02:19 +02:00
Iaccidentally d63ad6fc0c Merge pull request #82 from kukelekuuk00/master
Allow your hat to be removed with /hat remove
2012-06-15 13:44:51 -07:00
kukelekuuk00 641a4b9dff Allow your hat to be removed with /hat remove 2012-06-15 22:36:26 +02:00
Paul A. 31001d6b1a Merge pull request #81 from kukelekuuk00/master
/vanish [on|off] - thanks kukelekuuk00
2012-06-15 03:05:13 -07:00
kukelekuuk00 d1a1559dca args[0] instead of args[1]
derp
2012-06-15 11:41:06 +02:00
kukelekuuk00 0d56b700bf /vanish [on|off] 2012-06-15 11:02:04 +02:00
Iaccidentally cafdb919e4 Merge branch 'master' of https://github.com/essentials/Essentials 2012-06-12 22:33:12 -04:00
Iaccidentally 808f448399 add /e<command> aliases to essentials spawn 2012-06-12 22:28:10 -04:00
KHobbits 10d902e730 Revert "Invert teleport timer."
This reverts commit 0436962ee7.
2012-06-13 03:06:42 +01:00
KHobbits 0436962ee7 Invert teleport timer. 2012-06-13 02:51:47 +01:00
KHobbits 2bebb0bd61 3 char min length on /pay and /msg 2012-06-13 00:49:36 +01:00
Iaccidentally 1e04e3f80d This is broken for some reason. Removing until fixed. 2012-06-12 01:41:39 -04:00
Iaccidentally c32e10caac oops. forgot this. 2012-06-12 01:13:12 -04:00
Iaccidentally 120440d45b add admin chat 2012-06-12 00:59:53 -04:00
Iaccidentally 61b85901a3 Merge pull request #79 from Iaccidentally/master
update messages_pt.properties
2012-06-11 19:40:42 -07:00
Iaccidentally f0b3acf491 fix Portuguese translation with new messages 2012-06-11 22:34:40 -04:00
Alexander Schepp f2d624a795 Merge pull request #78 from Iaccidentally/master
fix some tl keys
2012-06-11 19:17:44 -07:00
Iaccidentally 9e1d7aca92 fix some tl keys 2012-06-11 22:05:30 -04:00
KHobbits 3b43f7bf03 Messing around with whois syntax
(TL's probably need some love)
2012-06-12 01:43:20 +01:00
KHobbits 2f18c6edf1 Fix spacing issue in /list 2012-06-12 00:27:21 +01:00
KHobbits 79f8699174 Fixing messed enchantment. 2012-06-12 00:18:53 +01:00
KHobbits 602681dcc2 Merge pull request #76 from necrodoom/patch-2
pull request for expanding enchant database
2012-06-11 16:17:53 -07:00
KHobbits 3e63047c38 Merge pull request #77 from necrodoom/patch-3
woodenslab fix, pointed out by branicyeti
2012-06-11 16:17:21 -07:00
KHobbits 4f2f166824 Adding mute status to /whois 2012-06-12 00:16:09 +01:00
necrodoom fc782f286d woodenslab fix, pointed out by branicyeti 2012-06-11 16:39:18 +03:00
necrodoom 425c548611 pull request for expanding enchant database 2012-06-11 15:08:12 +03:00
KHobbits 593f1dd67f Update Bukkit to 1.2.5-R4
Bukkit: #1473 CB: #2222
2012-06-11 00:40:45 +01:00
md_5 8cff4348a6 Fix the vanish command for good. 2012-06-11 09:18:06 +10:00
KHobbits 40271f2ddf I spied some more big Booleans. 2012-06-11 00:14:19 +01:00
KHobbits aa1205f42d i should prefer boolean to Boolean. 2012-06-11 00:08:31 +01:00
KHobbits 2e15de483d Make /whois throw an error if no matching players are found. 2012-06-11 00:07:22 +01:00
md_5 77b0415c1b Pass the actual player object to Bukkit. 2012-06-11 08:45:24 +10:00
KHobbits 43b3a9df23 /vanish command sets players invisible to essentials commands. 2012-06-10 23:36:10 +01:00
KHobbits 8b47b80b0b Broadcast command allows colour formatting. 2012-06-10 23:35:50 +01:00
KHobbits 13da8c3adc Fix /lightning <player> <damage> to actually deal the proper set damage (5 or 25% by default). 2012-06-10 23:00:49 +01:00
KHobbits a10190df51 Fix /essentials command to not show command debugging if there were no conflicts. 2012-06-10 22:46:56 +01:00
KHobbits ecfa745484 Try to be a little more sensible with stored cooldowns. 2012-06-10 21:55:48 +01:00
KHobbits 20d439578b Fix /mute to follow same convention as /tjail
Fixed #2056
2012-06-10 19:56:24 +01:00
KHobbits dd7f1bcf25 Missing event aborts in sign code. 2012-06-10 19:40:09 +01:00
KHobbits 3b855255cf Fix bug with /remove and minecarts 2012-06-10 19:36:31 +01:00
KHobbits 23283426e0 Allow syntax: /god <player> <on/off> 2012-06-10 19:20:43 +01:00
KHobbits c958bc78dd Allow syntax: /fly <player> <on/off> 2012-06-10 19:11:45 +01:00
KHobbits 24ec242ecf Fixing up some TL mistakes 2012-06-10 18:38:55 +01:00
KHobbits 9068c13e39 Play a bit less greedy with events 2012-06-10 18:33:07 +01:00
KHobbits 024aff0af5 Remove dura command and merge into itemdb. 2012-06-10 18:31:28 +01:00
KHobbits 57c1d75779 Fix kits to only show to people who can use them. 2012-06-10 18:27:55 +01:00
KHobbits 8c434783a2 Merge pull request #72 from kukelekuuk00/master
Durability command
2012-06-10 10:22:42 -07:00
KHobbits 85ae839211 Merge pull request #75 from necrodoom/patch-1
updating items.csv with newest pastebin, fixes duplicates and wrong alia...
2012-06-10 10:21:40 -07:00
necrodoom b218d33a24 file indented for unknown reason 2012-06-10 18:06:26 +03:00
necrodoom 6e0f4674d5 updating items.csv with newest pastebin, fixes duplicates and wrong aliases. 2012-06-10 15:29:34 +03:00
kukelekuuk00 62812e1e3a DERP #2 2012-06-10 14:19:03 +02:00
kukelekuuk00 63680b4911 DERP 2012-06-09 23:06:09 +02:00
snowleo 071254ed8d Fix xmpp format stripping 2012-06-08 00:34:25 +03:00
KHobbits 93980629d3 Merge branch 'master' of github.com:essentials/Essentials 2012-06-03 16:35:12 +01:00
KHobbits f299771044 Fix broken preventmodify permissions check in invsee (*scowls at ementalo*)
Also added check to prevent duping items
2012-06-03 16:34:27 +01:00
md-5 8c013b7680 Merge pull request #74 from Rutr/master
Edit the polish translation, thanks Rutr.
2012-06-02 14:36:00 -07:00
Rutr 78fe659677 translation some new messages and edit some existing 2012-06-02 17:46:26 +03:00
kukelekuuk00 98de950ae2 some more aliases for /durability 2012-06-02 00:36:27 +02:00
kukelekuuk00 96eb9c5db7 added /dura a durability check 2012-05-30 13:42:38 +02:00
md_5 45c1e347b0 Don't allow armor to be used as a hat. 2012-05-27 17:36:04 +10:00
md_5 0559b935e9 Add new command /hat and update translate keys as well as fix colour codes. 2012-05-27 17:24:49 +10:00
md_5 409f337973 Client side note blocks don't play it seems (reverse-merged from commit 0b60d4efe2) 2012-05-26 14:47:30 +10:00
KHobbits 7f5f6b6ac9 Tidy up PVP attack delay. 2012-05-22 21:02:28 +01:00
KHobbits dc36a50d85 Merge branch 'master' of github.com:essentials/Essentials 2012-05-22 17:54:39 +01:00
KHobbits 74f0babc7d Separate toggle for world teleports using homes. 2012-05-22 17:54:19 +01:00
ementalo 5eeaeaee5d Adding new config setting login-attack-delay. Set this in seconds for a delay before players can attack each other after logging on.
Use permission "essentials.pvpdelay.exempt" to bypass this restriction
2012-05-22 01:29:47 +01:00
KHobbits fa58503c9f Code tidy. 2012-05-22 00:41:03 +01:00
KHobbits 9fca3728c3 Merge branch 'master' of github.com:essentials/Essentials 2012-05-22 00:39:44 +01:00
KHobbits 56fccb9645 Patch null error in /home after recent update. 2012-05-22 00:39:23 +01:00
md_5 cab40d7893 Keep track of vanished players and tweak lag meter. 2012-05-21 15:13:24 +10:00
KHobbits faa3a5e027 Make /home and /back obey the world perm system.
This will prevent players from moving between words using virtually all essentials commands.
ATM /warp is excepted, because we already have per warp permissions.
Ess3 may see warp permissions altered to: essentials.warp.<world>.<warpname>
2012-05-20 23:58:03 +01:00
KHobbits 1c0838aa5d Fixing unit tests. 2012-05-19 22:19:24 +01:00
KHobbits 32fa834f3f Forgot to update plugin syntax.
Added missing perm checks.
2012-05-19 22:02:42 +01:00
KHobbits 051af644a7 Exp command cleanup 2012-05-19 21:52:54 +01:00
KHobbits 9b9a6a3148 Merge pull request #70 from kukelekuuk00/master
/exp [set|give|player] [player] [amount]
2012-05-19 12:42:33 -07:00
KHobbits 711426fe69 Update CraftBukkit: 1.2.5-R2.0 - 2190
Update Bukkit: 1.2.5-R2.0 - 1459
2012-05-19 20:35:36 +01:00
KHobbits 18c9c812d7 Merge branch 'master' of github.com:essentials/Essentials 2012-05-19 17:45:09 +01:00
KHobbits bc798977b5 Strip invalid chars from kit names
This may possibly block some kits from working that previous worked, if the kit name contained unusual letters
2012-05-19 17:44:47 +01:00
kukelekuuk00 853d7cb668 Fixes made, added /exp fix [playername] this fixes negative exp. 2012-05-17 14:39:40 +02:00
md_5 3eac027ddb There is no need to start a second task to measure lag, it can in fact be measured with enough precision from the exisitng one. 2012-05-17 20:33:40 +10:00
md_5 1247401a5f Add a LagMeter (ticks per second) to the /gc command. This command can now be accessed with /lag as well. Also added a simple /vanish command, with the extra node essentials.vanish.see
If you require a more advanced vanish solution checkout VanishNoPacket from mbaxter.
2012-05-17 20:25:02 +10:00
kukelekuuk00 9846362836 small description change 2012-05-14 11:43:57 +02:00
kukelekuuk00 16fc88b50c new command /exp [set|give|player] [player] [amount]
perms are essentials.exp,  essentials.exp.others,  essentials.exp.set,  essentials.exp.set.others,  essentials.exp.give and  essentials.exp.give.others
2012-05-14 11:36:44 +02:00
KHobbits fee3d7c0d3 Try to trim long displaynicks instead of blankly refusing to show them.
Will try trimming prefixes and dropping suffixes before trimming nicknames.
2012-05-13 18:58:50 +01:00
kukelekuuk00 5020f6b990 Added an /exp command that shows the amount of exp you have and how much you need for the next level.
Permissions are essentials.exp and essentials.exp.needed
2012-05-13 13:44:41 +02:00
KHobbits a48f6c8c30 Force 3 letters before matching players for /god /gamemode and /fly 2012-05-07 00:30:09 +01:00
KHobbits 8d6b864b5b Revert "Update home count..." This reverts commit 9b731cc39c.
On second thought, this would just lead to inconsistency....
2012-05-07 00:16:45 +01:00
KHobbits deca5e5e73 Home confirmation when using a bed. 2012-05-07 00:08:01 +01:00
KHobbits 9b731cc39c Update home count to include the bed home if set, this does not prevent people from setting a bed home if they are at max. 2012-05-07 00:05:02 +01:00
KHobbits 78cd64c388 Revert "Revert "New config option 'cancel-afk-on-move' - Set to false you don't use afk." -- This should fix afk mode."
This reverts commit 95e6db6797.

Another attempt at adding 'cancel-afk-on-move' toggle.
2012-05-06 23:38:04 +01:00
KHobbits d9e15729fd Revert "/me crashes ementalo's face for making the client crash."
This reverts commit 6d1e2dd10e.

And fix the original bug.
2012-05-06 23:30:55 +01:00
KHobbits 0fbe2da9cb Add whisper to social spy trigger list. 2012-05-06 16:11:16 +01:00
KHobbits d3397279f6 Revert "We can't damage and kill, so we will just kill to make everyone happy, and the event pointless."
This reverts commit 705efc6002.

Also fix kill to do the same.
2012-05-06 16:09:47 +01:00
md_5 705efc6002 We can't damage and kill, so we will just kill to make everyone happy, and the event pointless. 2012-05-05 20:01:18 +10:00
snowleo 3a60191a9d Merge branch 'refs/heads/groupmanager' 2012-04-26 10:42:48 +02:00
snowleo 95e6db6797 Revert "New config option 'cancel-afk-on-move' - Set to false you don't use afk." -- This should fix afk mode.
This reverts commit d927d04765.

Conflicts:

	Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
2012-04-26 10:41:24 +02:00
ementalo e37b1946f5 Latest items.csv by necrodoom 2012-04-25 11:27:18 +01:00
md_5 6d1e2dd10e /me crashes ementalo's face for making the client crash. 2012-04-25 17:02:15 +10:00
snowleo 0668c4214e Fix items.csv 2012-04-24 21:48:28 +03:00
snowleo 1b4c803ce3 Merge pull request #66 from Iaccidentally/patch-8
Necrodoom's update to items.csv
2012-04-24 11:42:50 -07:00
Iaccidentally 8d00da9e98 Necrodoom's update to items.csv 2012-04-24 14:57:56 -03:00
ementalo 1524a06ac6 Updated czech language, thanks tommymortago 2012-04-24 12:29:24 +01:00
md_5 9ca820d45e Small cleanup of things 2012-04-24 20:31:19 +10:00
ementalo 27102d1c38 Adding the kickedAll TL key the the rest of the files 2012-04-24 10:24:08 +01:00
md_5 18b5405c76 Add message to sender when all players kicked, addresses issue #1968 2012-04-24 17:47:27 +10:00
md_5 de541f6654 Use a quick (and working comparer) 2012-04-24 17:44:49 +10:00
ementalo 9d398b1d2e New permission essentials.invsee.preventmodify. People with this permission cannot have their inventories modified by invsee 2012-04-23 23:51:10 +01:00
snowleo caeb3279cb Merge pull request #64 from mdojcar/patch-1
0.2 version of Czech translate: optimized by mdojcar
2012-04-23 14:42:55 -07:00
ElgarL 06247732da Allow 'manucheckp' to notify when superperms reports false but it is
really negated.
2012-04-22 12:12:50 +01:00
ElgarL fc7689354f Fix forgetting sub groups on a manload. 2012-04-21 16:58:22 +01:00
mdojcar a50b74bb36 0.2 version: optimized by mdojcar (modojcar@seznam.cz) - mirne fixy a trochu jsem preklad vylepsil 2012-04-21 09:35:59 +03:00
ElgarL a21b5fac76 updated classpath (eclipse) for teh whole project 2012-04-21 02:33:13 +01:00
ElgarL 3d9022d8fa remove unneeded dependency of craftbukkit 2012-04-21 02:32:37 +01:00
ElgarL 4e10470acd Remove unneeded dependency of craftbukkit (Eclipse building) 2012-04-21 02:32:02 +01:00
KHobbits 3cc1a462f5 Remove stack trace cleaning, didn't actually remove unwanted elements. 2012-04-20 22:31:25 +01:00
ElgarL cd7bf5eff2 Prevent null perms getting past the GlobalGroups loader. 2012-04-18 22:22:35 +01:00
KHobbits 8da3b490d9 Slightly widen block break protection on protected signs (still does not block chain breaks). 2012-04-18 01:30:14 +01:00
KHobbits 00c87c0e60 Merge remote branch 'remotes/origin/groupmanager' 2012-04-18 00:39:14 +01:00
KHobbits 507ecc47b6 Switch the order of the alt give syntax to follow vanilla order. 2012-04-18 00:37:44 +01:00
ElgarL 6ac8abdac8 Fix a couple of perms in GlobalGroups 2012-04-17 18:57:11 +01:00
KHobbits 4a29dd4c9c Don't get the Essentials user object when we don't need it. 2012-04-17 01:14:07 +01:00
KHobbits 6d06636bc2 Wrong default value for AFK disable pickup. 2012-04-17 00:53:57 +01:00
ElgarL da857895fc Re-initialize the WorldsHolder on a reload, as un-registering and
re-registering a new holder means all plugins have to check for the new
service on every quiery.
2012-04-16 23:54:33 +01:00
KHobbits 425a2184c6 Merge branch 'master' of github.com:essentials/Essentials 2012-04-16 21:43:19 +01:00
KHobbits 6919b52f61 Null check, for quick exit. 2012-04-16 21:42:53 +01:00
md_5 8eb7428ad1 Do we have to remind @khobbits not to code while drunk. Again. 2012-04-16 19:43:53 +10:00
KHobbits 327a57de3c Fixing a few TL issues. 2012-04-16 10:33:51 +01:00
KHobbits 01ba8dbc3f Don't fire entity powertool commands, with our user object. 2012-04-16 10:19:19 +01:00
KHobbits a97b3abca3 Minor perf tweak. 2012-04-15 23:13:34 +01:00
KHobbits d927d04765 New config option 'cancel-afk-on-move' - Set to false you don't use afk. 2012-04-15 22:50:55 +01:00
KHobbits 6dc2e96509 Few missing default permissions. 2012-04-15 22:02:08 +01:00
KHobbits 26a0cd0761 Merge remote branch 'remotes/origin/groupmanager' 2012-04-15 19:41:06 +01:00
KHobbits 75b7f7ac22 Fix metrics errors to be... descriptive. 2012-04-15 15:12:42 +01:00
KHobbits d08ea5a650 Revert "Add option to disable jails entirely."
This reverts commit 34f5c19f99.
2012-04-14 23:18:20 +01:00
KHobbits 1bd1665faa Throw syntax error on /item, if syntax is wrong. 2012-04-14 17:53:33 +01:00
KHobbits b3847270fa Merge branch 'master' of github.com:essentials/Essentials 2012-04-14 15:58:12 +01:00
KHobbits 055603b09e Fix null locations in /seen 2012-04-14 15:57:47 +01:00
md_5 34f5c19f99 Add option to disable jails entirely. 2012-04-14 15:21:42 +10:00
md_5 602bd5b0d4 Change some ordering and clean pmd warnings 2012-04-14 15:07:10 +10:00
KHobbits 45de85dae2 Optimize sign interacts. 2012-04-14 04:54:01 +01:00
KHobbits 8b9ff2c58a Try to speed up teleport events. 2012-04-14 04:13:37 +01:00
ElgarL 1599a36642 Correct formatting in command list. 2012-04-13 23:56:50 +01:00
ElgarL 1e30f23ca6 Finally remove all deprecated methods. 2012-04-13 15:16:08 +01:00
ElgarL 2f74510cce Code tidy 2012-04-13 15:00:55 +01:00
ElgarL 08bff3ea5f Stop using our own deprecated methods as we tell others to do. 2012-04-13 14:57:23 +01:00
ementalo 90d2451ce2 Merge branch 'master' of https://github.com/essentials/Essentials 2012-04-13 14:52:25 +01:00
ementalo 5b5df254d5 Don't kill tamed ocelots with killall Test #1921 2012-04-13 14:49:15 +01:00
ElgarL a028abe036 Update all code formatting to use tabs for indentation. 2012-04-13 14:40:26 +01:00
ElgarL 677534c0b7 Fixed the 'last' nested throw/catch and rework all user and group
reading to be certain to trap all errors.
2012-04-13 13:58:05 +01:00
snowleo 2d319fe5aa Fix double charge in /jump 2012-04-12 23:57:19 +03:00
ementalo bbd2c53dd8 Merge branch 'master' of github.com:essentials/Essentials 2012-04-12 21:26:34 +01:00
ementalo d1eb7e5614 Display name of new world on world change 2012-04-12 21:26:19 +01:00
snowleo d9ee666770 Merge branch 'refs/heads/groupmanager' 2012-04-12 04:27:04 +02:00
ElgarL 9f744beb13 Unregister the worldsHolder as a service on a reload/shutdown instead of
the whole plugin.
2012-04-12 03:21:38 +01:00
ElgarL 62a297ec6d Fix silly nested throw/catch statements. Errors are now correctly
generated when reading yml's.
2012-04-12 01:21:22 +01:00
snowleo 3f9e19d279 Merge branch 'refs/heads/groupmanager'
Conflicts:
	EssentialsGroupManager/src/globalgroups.yml
2012-04-11 21:57:58 +02:00
snowleo c9e64d9e46 Prevent that a config file is loaded/saved by more than one thread. 2012-04-11 22:51:34 +03:00
ElgarL 25759064ff Expand GlobalGroups.yml and groups.yml to cover the VanishNoPacket
plugin. Demonstrating how to negate and add nodes when using the '*'
permission with inheritance.
2012-04-11 19:10:28 +01:00
ElgarL cd24ffbada Fix 'manuadd' to use the default or selected world (via 'manselect'), if
the world is not specified in the command.
2012-04-10 20:48:34 +01:00
ElgarL cdae0898c7 Stop the error on shutdown if GM failed to load at startup.
GroupManager will now generate it's own log (in the GM folder) to
keep things tidy, but also to account of those players unable to
find/access their server.log.
Startup errors will now lock out ALL commands other than '/manload'
2012-04-10 20:40:04 +01:00
ElgarL f02691863b Properly fix concurrent modification when removing all attachments. 2012-04-10 17:02:50 +01:00
snowleo 4c8d0ea2d9 Should fix some exp math issues 2012-04-09 17:52:46 +03:00
ElgarL ec4f5cc34d Added missing confirmation message on '/manload'. 2012-04-07 21:30:49 +01:00
ElgarL e8a42e3947 Better handling of errors in user and group yml's. 2012-04-07 19:24:46 +01:00
ElgarL e8dd963545 Fix a concurrent modification error when removing all attachments. 2012-04-07 17:21:48 +01:00
ElgarL 1c0a5c49a5 Expand 'manwhois' to also list a users subgroups. 2012-04-07 11:47:07 +01:00
KHobbits bb83dcc828 Allow vanilla syntax of /give 2012-04-07 04:39:12 +01:00
KHobbits 0eefb7f5a1 Remove 'set' and 'add' from /time command args, to allow use of original syntax. 2012-04-07 04:22:17 +01:00
KHobbits fe95cfe03b New ingame command syntax: /kit <kit> <playername>
New Permission: essentials.kit.others - allows giving kits to other people.
New console commands: /kit & /kit <kit> <playername>
2012-04-07 03:34:01 +01:00
KHobbits 7a6368a980 Console should be able to kick everyone. 2012-04-07 03:07:07 +01:00
KHobbits 9e86681722 Move player loading and updates to new thread, to reduce on join lag. 2012-04-06 19:19:08 +01:00
ElgarL 25bd91eb80 Remove all permission attachments when performing a manload or restart. 2012-04-06 12:53:36 +01:00
KHobbits 6504c88bf7 Chat spy, should show otherworld chat. 2012-04-06 02:36:27 +01:00
KHobbits 6a75d6fe86 Merge branch 'master' of github.com:essentials/Essentials 2012-04-05 23:37:33 +01:00
KHobbits bc876611d0 Fix /time not working with the '##pm' syntax. 2012-04-05 23:36:57 +01:00
md_5 798ea77736 Add version tag 2012-04-06 07:39:25 +10:00
md_5 21ef83c0ff Add polish translation, thanks losdamianos 2012-04-06 07:33:10 +10:00
ElgarL bd7af593e7 Don't throw errors when attempting to remove permission attachments
(bukkit will have already removed it).
2012-04-05 21:06:48 +01:00
snowleo f73a5d0e8d Merge remote-tracking branch 'origin/groupmanager' 2012-04-05 17:05:43 +02:00
ElgarL f7bc04bc34 Fix an error I caused trying to modify an unmodifiable list when parsing
'*' permissions.
2012-04-05 15:02:08 +01:00
KHobbits aa43703094 Fixing up NPE bug in jails (implemented in Dev2.9.163) 2012-04-05 13:28:23 +01:00
ElgarL 381886245b Update to 2.0
Fix GM reporting of permission inheritance to retain the correct order.
Lower inheritance groups can no longer negate a higher groups
permissions.
2012-04-05 12:54:26 +01:00
KHobbits 08642ada20 Added wiki names for enchantments. 2012-04-05 05:46:36 +01:00
KHobbits 10cb4c03b7 Jail update, jailed people can't attack other players. 2012-04-05 03:22:49 +01:00
KHobbits e7d1cb8bb6 Updating plugin.yml to add sendall syntax. 2012-04-04 23:02:13 +01:00
KHobbits 5a7d733cbf Added extra params to setHome TL key {0} world {1} x {2} y {3} z 2012-04-04 18:19:39 +01:00
ementalo e23f491500 1.2.5 Update Craftbukkit #2149 Bukkit ??? 2012-04-04 15:33:11 +01:00
KHobbits 98b716dfbf Fix unit tests. 2012-04-04 03:21:14 +01:00
KHobbits 2ddd31a37d Report invalid enchantments in kits.
Improve error logging
2012-04-04 03:09:27 +01:00
KHobbits 2b99ed9a2a Catch all values greater than 10 years to avoid exploits. 2012-04-04 02:07:01 +01:00
KHobbits eeea16a99a Cap mute/ban/jail to 10 years (any more is silly).
Cap time descriptions to 3 significant notions.
2012-04-04 01:55:06 +01:00
KHobbits e52996609a Update seen to show better data for vanished users:
New Perm: essentials.seen.extra - Shows some extra information for staff
2012-04-04 01:20:57 +01:00
KHobbits 932de33349 Little bit of powertools code cleanup. 2012-04-04 00:40:58 +01:00
KHobbits 195604997b Enable powertools if they are disabled when setting a new tool. 2012-04-04 00:39:59 +01:00
KHobbits a3a3f81e11 Better hide vanished players. 2012-04-03 16:12:49 +01:00
KHobbits d0f3fb4417 Command cost api update: Can now set fallback costs.
Repair command addition: ontop of 'repair' and 'repair-<itemname>' you can now charge for 'repair-all' to charge more for /repair all or 'repair-item' to charge per item repaired.
2012-04-03 15:35:13 +01:00
ElgarL 183602ac28 Prevent Null entries in group inheritance from throwing errors. 2012-04-03 14:30:27 +01:00
KHobbits 37370f722c Switch sign listeners back to compare block id, rather than materials. 2012-04-02 22:58:07 +01:00
ElgarL e2e51c9c95 Added a new permission node 'groupmanager.op'. This will cause players
with this node to be treated as op's when using GroupManager commands
(they will still require each commands
permission node to use them).
2012-04-02 21:12:19 +01:00
KHobbits bf1e073ef4 Allow tppos to be used in console. 2012-04-02 02:47:44 +01:00
KHobbits 767703bfc9 Optional second param to /gm to force gamemode on other players. 2012-04-02 02:31:31 +01:00
KHobbits 0e0a96b6d8 Listener Cleanup 2012-04-02 02:22:30 +01:00
ElgarL 3f73272524 Force remove player attachments on disconnect, and tidyup during player
join in case of any errors. Fixes a bug of losing permissions.
2012-04-01 03:44:37 +01:00
KHobbits d72f831519 Make sure can build checks in permbukkit/privileges work for admins/owners. 2012-04-01 02:44:11 +01:00
KHobbits c6f25c0df6 Minor cleanup to player events. 2012-03-30 21:44:14 +01:00
KHobbits 17058c220c Add newish signs to default enabled commands config. 2012-03-30 21:04:15 +01:00
KHobbits 0e99b35ab2 Formatting. 2012-03-30 13:29:58 +01:00
KHobbits e795c6ed0b Don't push vault version to metrics. 2012-03-30 13:27:57 +01:00
KHobbits f3345247ed Reset ban reason to null on /ban <player>, if no reason is set. 2012-03-30 11:40:44 +01:00
KHobbits 1101a3243d Fix tpo syntax error. 2012-03-29 22:32:16 +01:00
KHobbits c7638efc7e Iaccidentally's changes to pt TL. 2012-03-29 21:17:50 +01:00
KHobbits d90053c8c4 Update TL header. 2012-03-29 18:49:56 +01:00
KHobbits 6235983ddd New translation messages 2012-03-29 18:37:22 +01:00
KHobbits 7a249abc67 Update default permissions. 2012-03-29 18:14:24 +01:00
KHobbits c2c613b652 Missing air materials. 2012-03-29 16:41:13 +01:00
ElgarL 590357004d Merge branch 'groupmanager' of https://elgarl@github.com/essentials/Essentials.git into groupmanager 2012-03-29 14:09:07 +01:00
ElgarL 9dbeb1407c Catch errors caused by bad indentation in yml's. 2012-03-29 14:02:53 +01:00
ElgarL 1ef8ab70d1 Stop attempting to push empty permissions when players edit the yml's
incorrectly.
2012-03-29 13:41:59 +01:00
KHobbits c09ada201c Interact event cleanup 2012-03-29 03:06:52 +01:00
KHobbits d7139cb16c Update to CB #2126 B #1425
Min CB version changed to 2122
2012-03-29 02:00:51 +01:00
KHobbits 10f82a6723 Fix using /setworth <price> 2012-03-29 00:13:56 +01:00
KHobbits 2aed3af3c4 Merge branch 'groupmanager' of github.com:essentials/Essentials 2012-03-28 17:37:03 +01:00
KHobbits c45d38ca69 Implement all abstract methods. 2012-03-28 15:12:25 +01:00
KHobbits 576642a573 Merge branch 'master' of github.com:essentials/Essentials 2012-03-28 15:03:45 +01:00
KHobbits 9d545dcbf1 Don't register jail listeners, if no jails are set. 2012-03-28 15:03:18 +01:00
snowleo 71d8744840 Fix for the fix 2012-03-28 11:21:31 +02:00
snowleo 32c689e0f5 Fix isAffordableFor in Trade class
This fixes buy signs giving out items, when the player has essentials.eco.loan permission, but min-money in config is set to 0.
2012-03-28 10:36:10 +02:00
KHobbits 5b62661404 Pull example perm files out of the ess jar. 2012-03-28 00:59:51 +01:00
KHobbits a7df8a1a0a Try to reduce lag caused by join spam. 2012-03-27 21:08:06 +01:00
snowleo b14e7c197f Adds pvp protection after teleport 2012-03-27 21:15:11 +02:00
KHobbits 97eed50ccc Adding world permission checks to:
tpaall tpall tpahere tphere tpohere
User is required to have the permission for the world he is in, before he can teleport users outside this world, to it.
2012-03-27 15:28:40 +01:00
ElgarL b8453ac792 Update GlobalGroups.yml for new/changed Towny permission nodes. 2012-03-27 10:14:53 +01:00
ElgarL fe7f479e63 Auto rename all case sensitive world folders to lower case (if
possible).
2012-03-26 20:06:59 +01:00
ElgarL 50ea442bf0 Treat all world names as lower case for file handling (please check in
your worlds folder. You should have no folders with upper case letters
from now).
2012-03-26 19:18:19 +01:00
KHobbits 5d45495371 Fix kit enchants for people without oversized stack permission.
Add permissions lookup to debug mode.
2012-03-26 13:28:32 +01:00
KHobbits e30d900289 Clarify how backup works.
Add option for auto save-all.
2012-03-26 00:49:53 +01:00
KHobbits 2cc96e995b Update tp to check if target player has tptoggle disabled.
Update tpo to allow player to player tp.
2012-03-25 23:32:04 +01:00
KHobbits 47cf1289d7 Don't show 'backup started' on /backup if it hasn't been configured. 2012-03-25 19:10:39 +01:00
KHobbits d2506cd928 Reorder login/join event calls. 2012-03-25 17:27:06 +01:00
KHobbits 1dbb11ea55 Don't override other plugins which allow joining over capacity. 2012-03-25 16:46:36 +01:00
KHobbits b60363b6bd Reduce amount of move event calls being processed. 2012-03-25 16:30:22 +01:00
KHobbits 00033c11bc Update [balance] sign to use currency formatting. 2012-03-25 14:26:08 +01:00
KHobbits c588b78adb Merge branch 'master' of github.com:essentials/Essentials 2012-03-25 14:20:53 +01:00
KHobbits 7bd7992b24 Fix chat format regex. 2012-03-25 14:20:26 +01:00
snowleo 6f86b7400a CopyPaste-Fail 2012-03-25 11:47:26 +02:00
snowleo e13a2c371d Wrong url 2012-03-25 11:45:50 +02:00
snowleo 0cbded9fca This is no longer stored in file, so it's not part of UserData anymore. 2012-03-25 11:44:33 +02:00
snowleo 3e6e71ca41 Optimize metrics 2012-03-25 11:39:19 +02:00
snowleo 1b2e3b1951 AntiCheat has different version numbers, so don't check. 2012-03-25 11:09:13 +02:00
KHobbits e53a480c22 Should probably cancel this at lowest. 2012-03-25 02:55:19 +01:00
KHobbits 7280c1c468 Merge branch 'master' of github.com:essentials/Essentials 2012-03-25 02:34:19 +01:00
KHobbits b7221516dc Invsee now shows a live player inventory in a window, rather than cloning players inventory.
New Permission: essentials.invsee.modify - Player with this permission will be able to add/remove items from the other players inventory.
2012-03-25 02:33:52 +01:00
KHobbits 71aaf81bba Update Essentials/src/config.yml 2012-03-24 23:28:56 +00:00
KHobbits 160c3f428c Mysql is bad. 2012-03-24 23:25:43 +00:00
KHobbits 3c3e8d167f Better English. 2012-03-24 21:12:15 +00:00
KHobbits 7ca2b65c4f New permission check: essentials.list.hidden is now required to /getpos hidden players. 2012-03-24 21:08:45 +00:00
KHobbits a8cbb5c8f5 Extra itemcsv. 2012-03-23 23:13:04 +00:00
KHobbits 72028086c0 'Enabled' looks better than 'true'. 2012-03-23 22:38:01 +00:00
KHobbits dddf529ff5 Make sure items don't stack wrong in [free] signs. 2012-03-23 20:15:03 +00:00
KHobbits b3de0aabae Fix for showing plugins when user has no permission. 2012-03-23 18:26:19 +00:00
KHobbits 77c6a3b730 Wrong colour code symbol. 2012-03-23 17:50:15 +00:00
KHobbits bb54dbb688 Merge remote branch 'remotes/origin/groupmanager' 2012-03-23 17:44:00 +00:00
KHobbits 0a74da88d6 Help command refresh. 2012-03-23 17:16:09 +00:00
KHobbits d0b94938e0 Merge branch 'master' of github.com:essentials/Essentials 2012-03-23 13:53:08 +00:00
snowleo a0cba8e63d Spaaaaaace! So much space! Gotta see it all! 2012-03-23 14:30:00 +01:00
KHobbits a4d7b5dcf8 Merge branch 'master' of github.com:essentials/Essentials 2012-03-23 13:26:12 +00:00
KHobbits c503adabc5 Fix url matching. 2012-03-23 13:26:03 +00:00
snowleo 8a22258945 Fix utf-8 decoding problems. 2012-03-23 14:22:10 +01:00
snowleo 29a190f93a http://youtu.be/8DdeLUA0Fms 2012-03-23 12:11:01 +01:00
KHobbits 5c0b522026 Merge branch 'master' of github.com:essentials/Essentials 2012-03-23 10:18:16 +00:00
KHobbits c46f14665c Adding missing entities to Protect Spawn Blacklist 2012-03-23 10:16:38 +00:00
snowleo 20c973dab2 Fix UTF8 handling in Configuration class 2012-03-23 11:13:44 +01:00
KHobbits 49cb482ca5 Update Essentials/src/config.yml 2012-03-23 10:03:15 +00:00
KHobbits 033c2e22cd Remove white user prefix, if prefix is blank. Messes with EssentialsChat colouring. 2012-03-23 07:56:44 +00:00
KHobbits 2f434291cb Fixing chat color formatting. 2012-03-23 00:19:27 +00:00
KHobbits 42d01471d3 Disabling player list updates by default (can mess with tab completion)
Hopefully this will be reverted if/when patch is found.
2012-03-23 00:15:22 +00:00
KHobbits c5eb1bb105 Improve kit matching, and add enchantments.
Enchanted kit example in config.yml
2012-03-22 23:47:35 +00:00
KHobbits 3c9057f68e Fix jar building. 2012-03-22 23:10:59 +00:00
KHobbits 96f0dd5824 Update CB to 2105 2012-03-22 23:07:23 +00:00
KHobbits 71358629f4 New command: /fly
New perm: essentials.fly.others
2012-03-22 22:59:52 +00:00
KHobbits 284fef00e7 Split formatting perms for signs as well. 2012-03-22 22:26:04 +00:00
KHobbits d20519ef8b New Permission: essentials.chat.url
Without this perm, URLs will be modified not to be links.
2012-03-22 22:19:58 +00:00
KHobbits 0dc1270aed Split colour permissions into 3: color/magic/format 2012-03-22 22:07:13 +00:00
KHobbits cd0d37f73c Update to 1.2.4 (R0.1)
New Minimum CB version: 2100
2012-03-22 20:55:56 +00:00
KHobbits 56fce34539 Extra items in 1.2.4 2012-03-22 20:48:27 +00:00
KHobbits 165a76d492 Add villager professions to /spawnmob 2012-03-22 20:03:52 +00:00
ElgarL 9570e5cfd9 Correct Grammar 2012-03-22 17:54:59 +00:00
ElgarL c6bb10489e Merge pull request #62 from bonney12/groupmanager
Update language and commenting
2012-03-22 10:53:25 -07:00
KHobbits 3d7d4a47d9 Bukkit R0.3 api updates. 2012-03-22 17:26:05 +00:00
KHobbits 968c849b13 Update missing 1.2.3 items in items.csv 2012-03-22 17:25:42 +00:00
KHobbits 1746569e1a Extra Trees 2012-03-22 17:25:13 +00:00
KHobbits 209c91d3de Fixed again. 2012-03-22 12:02:19 +00:00
KHobbits 7d7c1d34cf Fix typo. 2012-03-22 11:57:30 +00:00
KHobbits c3ad486f65 Merge branch 'master' of github.com:essentials/Essentials 2012-03-21 23:55:19 +00:00
KHobbits 7bcec32134 Cleaning up displaynames 2012-03-21 23:54:57 +00:00
KHobbits b19b08dc6e Merge pull request #63 from Iaccidentally/patch-6
update default player-commands to support new and missed commands
2012-03-21 09:25:05 -07:00
Iaccidentally 264e175d6c update default player-commands to support new and missed commands 2012-03-21 13:23:36 -03:00
Michael Bonney bcd4fd9bff Removed Portuguese text, and added English replacements. Made more sense of the sentences, and also changed an incorrect message to it's proper form. 2012-03-21 16:13:34 +00:00
KHobbits 3e88fb44f4 Split if tree for readability. 2012-03-20 15:03:53 +00:00
KHobbits 518b013a63 Teleport check cleanup 2012-03-20 13:26:49 +00:00
KHobbits e752538568 Fix per world teleport permission checking. 2012-03-20 11:53:05 +00:00
KHobbits 970364886c Add 'color' sign type to config file.
Enforce colour permission on signs when essentials signs are enabled.
2012-03-19 08:21:39 +00:00
KHobbits 07f859e38b Missing kit time check from [kit] signs. 2012-03-18 17:15:46 +00:00
KHobbits c806059958 Only show nickname update message in debug mode. 2012-03-18 03:29:49 +00:00
KHobbits 14bce8fd82 Shorten help messages. 2012-03-18 03:01:44 +00:00
KHobbits 17be04cd99 Error and info cleanup. 2012-03-17 20:23:46 +00:00
KHobbits b93847f077 Merge remote branch 'remotes/origin/groupmanager' 2012-03-17 18:20:33 +00:00
ElgarL 6476158462 Don't remove an attachment on a player leaving as Bukkit never forgets
it. This fixes non mirrored permissions being messed up if a player
relogs.
2012-03-17 15:56:40 +00:00
snowleo 6dd73ff9d0 Merge branch 'refs/heads/groupmanager' 2012-03-17 13:38:51 +01:00
ElgarL b72083fb18 Removed some debug spam. 2012-03-17 12:37:23 +00:00
snowleo ca11d4d98b Fix bukkit download url 2012-03-17 11:15:28 +01:00
snowleo 12cb4fd5f8 Fix bukkit download url 2012-03-17 11:12:32 +01:00
KHobbits 4df4eba2a5 Merge remote branch 'remotes/origin/groupmanager' 2012-03-17 08:01:19 +00:00
KHobbits 762105d692 New permission: essentials.tp.others - Allows players to /tp <p1> <p2> replaces old reused permission.
New permission usage: if world-teleport-permissions is true in the config, TP commands will now check for essentials.world.<worldname> when a tp would switch worlds.
2012-03-17 06:10:02 +00:00
KHobbits e4ce814c2f Comments to SetExpFix. 2012-03-17 03:38:32 +00:00
KHobbits 87cd693020 Adding Exp to /whois, shows total exp and ingame level.
Due to the way minecraft calculates levels (flawed formula), its possible to not match calculated level.
2012-03-17 01:43:49 +00:00
KHobbits baadd4b1cb Adding reference to &k in MOTD. 2012-03-16 23:03:22 +00:00
KHobbits adf3755abb Handle permission check failures better. 2012-03-15 23:15:19 +00:00
KHobbits 5c280e7cb7 Add missing methods. 2012-03-15 22:23:26 +00:00
KHobbits 4a149855ab Updating Bukkit/CraftBukkit to match minimum ver. 2012-03-15 22:15:17 +00:00
md_5 cf000b04e4 Fill the entire sign with free goodness 2012-03-15 20:55:56 +11:00
md_5 79cd8d6065 Update minimum CraftBukkit version 2012-03-15 20:51:51 +11:00
md_5 5b930cdc3b Restore [free] and [disposal] signs back to their intended behaviour 2012-03-15 20:48:55 +11:00
snowleo c09329e5be :P 2012-03-15 09:15:28 +01:00
KHobbits c513014732 Graph a little bit extra information. 2012-03-15 08:08:25 +00:00
KHobbits bada36be68 Fix fake explosions. 2012-03-15 06:42:58 +00:00
KHobbits e5e81eda72 Make /nuke drop tnt from a more reasonable height. 2012-03-15 05:09:34 +00:00
KHobbits 45cf2ae960 Make /spawner errors more descriptive. 2012-03-15 04:41:56 +00:00
KHobbits d0d0117411 Add metric opt out toggle ingame. 2012-03-15 03:49:17 +00:00
KHobbits 5d79863cfc Fixing setwarp command. 2012-03-15 02:12:43 +00:00
KHobbits b85756f8b1 Adding some simple feature metrics. 2012-03-15 02:12:27 +00:00
KHobbits 8776f4c1c0 Metrics errors aren't important. 2012-03-15 01:32:08 +00:00
KHobbits 5e8fd3993d Basic module graph. 2012-03-15 01:17:12 +00:00
KHobbits d3033716ca Add Griefcraft metrics to Essentials
Warns on first start, and first staff join, and 5 minute warning before logging starts.
2012-03-15 00:49:22 +00:00
ementalo 6cf2bb5cd9 Adding permissions for overwriting exisitng warps
essentials.warp.overwrite.[warpname] will allow overwrting of exsiting warps
essentials.warp.overwrite.* for all warps
Adding WarpNotFoundException class
2012-03-14 21:16:22 +00:00
KHobbits 267495a406 Fixing warp command costs. 2012-03-13 16:15:01 +00:00
ElgarL a8937f7bf0 Fix a globalgroup inheritance in groups.yml 2012-03-12 22:18:25 +00:00
KHobbits dfd63a81ac Missed a TL key. 2012-03-12 16:50:32 +00:00
KHobbits dfbc1956c9 Fixing a few TL Keys 2012-03-12 15:35:20 +00:00
KHobbits c0490c0890 New TL Key, allow formatting/colouring of help output. 2012-03-12 15:21:37 +00:00
KHobbits 2da802d4b7 New permission: essentials.seen.banreason
With this permission players can see why a user was banned, in /seen.
2012-03-12 15:00:44 +00:00
KHobbits adffbab678 Adding jail time to /whois. 2012-03-12 01:15:10 +00:00
KHobbits e11525ab64 Update offline user check.
Add ban reason to /seen
2012-03-12 01:00:57 +00:00
KHobbits 8dcd591beb Update setworth to allow /setworth <price> ingame
Allow /setworth to be used from console.
2012-03-11 23:59:59 +00:00
KHobbits a40c936bcf New Permission: essentials.lightning.others
With this permission you can use /lightning <player>, without only strike based on direction.
2012-03-11 20:58:54 +00:00
KHobbits 5c2622b390 Add Enderman check to EntityChangeEvent (Should fix sheep eating grass). 2012-03-11 01:46:01 +00:00
KHobbits c7046b696a Use ignoreCancelled on event registration. 2012-03-10 21:42:46 +00:00
KHobbits 9ac5ce8a75 Update info.txt to hint at /einfo. 2012-03-07 12:14:32 +00:00
KHobbits 5c55e18d33 Fixing typo in config.yml 2012-03-06 23:17:10 +00:00
ElgarL 19d233454e change []<> for optional command components 2012-03-06 16:23:57 +00:00
ElgarL 1f761ee1cb Expanded '/manuadd'to accept an optional variable for the world (eg
'/manuadd <player> <group> <world>').
2012-03-06 11:02:48 +00:00
KHobbits 1db5d61945 Merge branch 'release'
Conflicts:
	lib/bukkit.jar
	lib/craftbukkit.jar
2012-03-05 16:25:35 +00:00
KHobbits 1e34a396cd Change starter kit to default to stone tools 2012-03-05 15:51:15 +00:00
KHobbits ba96117f55 Temp fix to disable version check on R7 2012-03-05 14:17:09 +00:00
KHobbits 96b217cbe8 Craftbukkit/Bukkit R7 2012-03-05 08:41:19 +00:00
md_5 0dd5c0370e I dont think free noteblocks are a good idea 2012-03-05 08:37:16 +00:00
KHobbits bdf32cde9e Missed one. 2012-03-05 08:37:15 +00:00
KHobbits e91ed60441 Fixing spawnmob count. 2012-03-05 08:37:15 +00:00
KHobbits 8577202f48 Add listgroups as TL key 2012-03-05 08:37:15 +00:00
KHobbits 7819b9d2f0 Apply colors to group tags. 2012-03-05 08:37:15 +00:00
KHobbits 15c0565923 Build custom mob list /spawnmob 2012-03-05 08:37:14 +00:00
KHobbits 2b25ca2932 CME 2012-03-05 08:37:14 +00:00
KHobbits c7a6677d52 Adding starter/newbie kit to EssentialsSpawn
Optimization to EssentialsSpawn join event.
2012-03-05 08:37:14 +00:00
KHobbits c3d5b32986 Extra command alias. 2012-03-05 08:37:14 +00:00
KHobbits cbfb524195 Allow more currency customization.
Added currency key to messages.
2012-03-05 08:37:14 +00:00
KHobbits b16a1f7237 Adding option to modify all users balances (including offline) /eco reset ** <amount> 2012-03-05 08:37:14 +00:00
KHobbits e28f1b1be3 Half-revert double backflip. 10 points.
(op prefix changes that md-5 broke, thinking I broke op prefixes)
2012-03-05 08:37:14 +00:00
md_5 b512a243e7 Fix op colours, which KHobbits broke! 2012-03-05 08:37:13 +00:00
Chris Ward 873c9880dd Cleanup
Signed-off-by: Chris Ward <chris@chrisgward.com>
2012-03-05 08:35:48 +00:00
Chris Ward e6736e48a5 Cleanup
Signed-off-by: Chris Ward <chris@chrisgward.com>
2012-03-05 08:35:48 +00:00
KHobbits caf598f55b Capital case for formatting. 2012-03-05 08:35:48 +00:00
KHobbits 619e099a04 Force all kits to lowercase. 2012-03-05 08:35:48 +00:00
KHobbits faba1e3604 *make it look like i'm doing something* 2012-03-05 08:35:48 +00:00
KHobbits 7cb728b15f I think switches are better. 2012-03-05 08:35:48 +00:00
KHobbits 3e3c7f0d54 Only update displayname on world change, not every teleport. 2012-03-05 08:35:48 +00:00
KHobbits a45c19a08b Extra command aliases 2012-03-05 08:35:47 +00:00
KHobbits eb74a1de9c Make the antioch message optional. 2012-03-05 08:35:47 +00:00
KHobbits 8450734cf1 Entity event cleanup 2012-03-05 08:35:47 +00:00
KHobbits 016299a1dd Shouldn't really be canceling events at priority monitor, oops. 2012-03-05 08:35:47 +00:00
KHobbits d27ff9abb6 Don't think we need animation event anymore. 2012-03-05 08:35:47 +00:00
Iaccidentally cdf5d45483 update messages.properties for the new bukkit download link (ci.bukkit,org no longer works) 2012-03-05 08:35:46 +00:00
md_5 0b60d4efe2 I dont think free noteblocks are a good idea 2012-03-05 18:40:18 +11:00
md_5 d31e434e4d Allow spamming of this, by reducing explosion damage to 0, same effect, no mess 2012-03-05 18:28:04 +11:00
KHobbits fabc1c3dd9 Missed one. 2012-03-05 00:39:37 +00:00
KHobbits 68fbc40605 Fixing spawnmob count. 2012-03-05 00:22:31 +00:00
KHobbits 8b7c5cf2ed Add listgroups as TL key 2012-03-05 00:19:40 +00:00
KHobbits 1811631b93 Apply colors to group tags. 2012-03-05 00:08:37 +00:00
KHobbits 7cec1564b9 Build custom mob list /spawnmob 2012-03-04 21:54:51 +00:00
KHobbits a75eefcdd4 CME 2012-03-04 21:43:24 +00:00
KHobbits 6a9027da6d Adding starter/newbie kit to EssentialsSpawn
Optimization to EssentialsSpawn join event.
2012-03-04 20:09:25 +00:00
KHobbits e55aa3cea7 Extra command alias. 2012-03-04 16:17:16 +00:00
KHobbits 1ce2c60bf4 Updating Craftbukkit #2034 Bukkit #1378 2012-03-04 16:01:49 +00:00
ElgarL 7ba49afa0b Better reporting when a users.yml is failing to load. 2012-03-04 10:39:39 +00:00
KHobbits 6da705c86f Allow more currency customization.
Added currency key to messages.
2012-03-04 10:11:58 +00:00
KHobbits c3fa56322b Adding option to modify all users balances (including offline) /eco reset ** <amount> 2012-03-04 09:20:03 +00:00
KHobbits 53cfab229b Half-revert double backflip. 10 points.
(op prefix changes that md-5 broke, thinking I broke op prefixes)
2012-03-04 08:18:25 +00:00
KHobbits b62217f301 Merge branch 'master' of github.com:essentials/Essentials 2012-03-04 08:13:29 +00:00
md_5 d9a8453995 Fix op colours, which KHobbits broke! 2012-03-04 15:43:00 +11:00
snowleo e6181928e8 Cleanup of /spawnmob 2012-03-03 17:01:53 +01:00
ElgarL c33499797e Minor change to globalgroups 2012-03-03 14:03:52 +00:00
KHobbits 860f6a41ac Merge branch 'master' of github.com:essentials/Essentials 2012-03-03 13:49:26 +00:00
KHobbits 8aa7b1f301 Update CB #2032 B #1377
Min CB #2015
2012-03-03 13:48:58 +00:00
ElgarL 6efd3eaa27 Fix a silly logic error when testing bukkit perms 2012-03-03 13:47:59 +00:00
ElgarL d2d8d191da Minor optimization when checking bukkit permissions. 2012-03-03 13:00:17 +00:00
md-5 cea5c81d44 Merge pull request #56 from Iaccidentally/patch-4
Allow spawning baby villagers and ocelots
2012-03-03 00:34:00 -08:00
md-5 504f28df1a Merge pull request #55 from chrisward/master
Just a really small cleanup
2012-03-03 00:31:48 -08:00
Chris Ward 74a57553f6 Cleanup
Signed-off-by: Chris Ward <chris@chrisgward.com>
2012-03-03 19:21:27 +11:00
Iaccidentally 35576ab64a add little babbys 2012-03-03 03:04:54 -05:00
KHobbits 33605517ff Capital case for formatting. 2012-03-03 07:09:41 +00:00
Chris Ward 6da6e4d2e8 Cleanup
Signed-off-by: Chris Ward <chris@chrisgward.com>
2012-03-03 18:07:43 +11:00
KHobbits c0fa03ede2 Force all kits to lowercase. 2012-03-03 07:03:54 +00:00
KHobbits 301b609e93 *make it look like i'm doing something* 2012-03-03 05:27:02 +00:00
KHobbits b6bbe237ea I think switches are better. 2012-03-03 05:09:03 +00:00
KHobbits de7ab13c03 Only update displayname on world change, not every teleport. 2012-03-02 19:05:30 +00:00
KHobbits 7a0f4da860 Extra command aliases 2012-03-02 17:05:55 +00:00
KHobbits 1bbbfe1c96 Make the antioch message optional. 2012-03-02 17:03:34 +00:00
KHobbits 25ebe68389 Entity event cleanup 2012-03-02 16:54:12 +00:00
KHobbits 7737d19c5a Shouldn't really be canceling events at priority monitor, oops. 2012-03-02 16:33:20 +00:00
KHobbits 622ca4bf8a Don't think we need animation event anymore. 2012-03-02 16:29:06 +00:00
KHobbits b090afbeb3 Merge pull request #54 from Iaccidentally/patch-3
update messages.properties for the new bukkit download link (ci.bukkit,o...
2012-03-01 20:15:16 -08:00
Iaccidentally dce149511e update messages.properties for the new bukkit download link (ci.bukkit,org no longer works) 2012-03-01 23:10:32 -05:00
snowleo 21a248e94d Will be removed until the next release XD 2012-03-02 01:30:52 +01:00
snowleo f1aed4b521 Better cats 2012-03-02 00:40:50 +01:00
snowleo 7564ebf79e Fix world heights 2012-03-02 00:18:31 +01:00
snowleo b9aecbe1d4 Min version CB# 2004 2012-03-02 00:12:22 +01:00
snowleo 49eb451a76 New eggs 2012-03-02 00:09:50 +01:00
snowleo 64d866a77d New Entities and Items for 1.2 2012-03-02 00:06:57 +01:00
snowleo f75779aa7a CB#2004 B#1368 2012-03-01 23:57:34 +01:00
KHobbits 5622882602 Merge branch 'master' of github.com:essentials/Essentials 2012-03-01 22:37:15 +00:00
KHobbits b3d3928db8 Kit sign cleanup 2012-03-01 22:36:51 +00:00
snowleo 6df3b9008a update inventory 2012-03-01 23:23:23 +01:00
snowleo c36ca65e09 Bukkit broke this sign :( 2012-03-01 23:10:12 +01:00
KHobbits 2e788802fe Fix kit timers resetting on server restart. 2012-03-01 22:04:50 +00:00
KHobbits b0552019f5 Fix version matching. 2012-03-01 21:47:01 +00:00
snowleo dae69622a5 Merge branch 'refs/heads/master' into release 2012-03-01 19:08:52 +01:00
snowleo 696b930fb2 EntityType instead of CreatureType 2012-03-01 19:05:50 +01:00
snowleo e43a62f992 Requires #1988 because of the new Inventory stuff 2012-03-01 19:05:50 +01:00
snowleo 02c1cb05c7 Updated to R6 2012-03-01 19:05:50 +01:00
snowleo b44d738867 CB# 1988 B# 1360 2012-03-01 19:05:49 +01:00
md_5 e1818f7e62 Separate config sections evenly 2012-03-01 19:05:47 +01:00
md_5 e5081db7e4 Remove old, unwanted manifest.mf files 2012-03-01 19:05:47 +01:00
ElgarL ba346bd797 Make 'manload' reload the config correctly. 2012-03-01 19:05:47 +01:00
KHobbits 0670ece7f3 Updating Bukkit: CB #1858, B #1334 2012-03-01 19:05:47 +01:00
snowleo a8da3eebd7 Merge remote-tracking branch 'origin/groupmanager' 2012-03-01 17:33:25 +01:00
snowleo 056303b53c EntityType instead of CreatureType 2012-03-01 17:33:09 +01:00
snowleo 454f7d30de Requires #1988 because of the new Inventory stuff 2012-03-01 16:17:40 +01:00
snowleo 6d1c270976 Updated to R6 2012-03-01 16:16:05 +01:00
snowleo d1001274bb CB# 1988 B# 1360 2012-03-01 16:16:05 +01:00
md_5 3099855562 Merge remote-tracking branch 'origin/master' 2012-03-01 16:23:21 +11:00
md_5 3f26d4ad98 Separate config sections evenly 2012-03-01 14:40:57 +11:00
md_5 bae337cc49 Remove old, unwanted manifest.mf files 2012-03-01 12:27:59 +11:00
ElgarL 3823e7a108 Make 'manload' reload the config correctly. 2012-02-28 10:46:10 +00:00
KHobbits 1c2221f52f Adding option to log all eco api transactions. 2012-02-28 02:45:03 +00:00
KHobbits 1b780a4364 Prevent EssSpawn trying to handle spawning of jailed players. 2012-02-28 02:45:03 +00:00
KHobbits ac3e65a829 Change jail listener to catch respawn at Highest 2012-02-28 02:45:03 +00:00
KHobbits 332f19177e Allow people to hit exactly 'min money'. 2012-02-28 02:45:03 +00:00
KHobbits 6ab57b9abe Cleanup. 2012-02-28 02:45:03 +00:00
KHobbits 862f3aad59 Adjustments to negative eco give/take. 2012-02-28 02:45:03 +00:00
KHobbits e277acf80e Display users new balance on /eco give/take. 2012-02-28 02:45:02 +00:00
KHobbits 9f893e68e9 Add Minimum Balance, to allow people to manage overdrafts. 2012-02-28 02:45:02 +00:00
KHobbits 833a5b2b55 Adding option to log all eco api transactions. 2012-02-27 15:31:43 +00:00
KHobbits 340f0c68eb Prevent EssSpawn trying to handle spawning of jailed players. 2012-02-27 03:40:18 +00:00
KHobbits a5e3182dad Change jail listener to catch respawn at Highest 2012-02-27 03:24:58 +00:00
KHobbits 10ae9c3aa2 Allow people to hit exactly 'min money'. 2012-02-26 05:10:04 +00:00
KHobbits bcf903de92 Cleanup. 2012-02-26 05:06:03 +00:00
KHobbits ad08d27504 Adjustments to negative eco give/take. 2012-02-26 05:01:40 +00:00
KHobbits d24f77dbd5 Display users new balance on /eco give/take. 2012-02-26 04:27:29 +00:00
KHobbits a5b38ce1a4 Add Minimum Balance, to allow people to manage overdrafts. 2012-02-26 04:15:14 +00:00
KHobbits 5d048d2c1d Updating Bukkit: CB #1858, B #1334 2012-02-25 17:57:26 +00:00
KHobbits 13d3cc3306 Lowering min bukkit to r4 - 1838, this build should still be compatible. 2012-02-25 17:40:00 +00:00
KHobbits 9f02fb4dd4 Merge branch 'master' into release 2012-02-25 17:22:39 +00:00
KHobbits 07baa6e611 Merge remote branch 'remotes/origin/groupmanager' 2012-02-25 17:22:01 +00:00
ElgarL 50bd5869bf Prevent promoting players to, and demoting to GlobalGroups. 2012-02-25 09:29:54 +00:00
ElgarL fa49fc91d2 Prevent adding inheritances to globalgroups. These are permissions
collections, not player groups.
2012-02-25 09:22:54 +00:00
KHobbits 28f478dd04 Write to user files less, on money update. 2012-02-23 17:25:00 +00:00
KHobbits 6fb8dad0ec Balance top now has server total on first line.
Balance top will update ess balance backup if using register/vault eco.
2012-02-23 15:17:23 +00:00
KHobbits 9f605e9a88 Fixing upgrade script to allow powertool upgrade. 2012-02-23 14:49:23 +00:00
KHobbits e5b91dae73 Fixing kits for new config classes. 2012-02-22 12:32:51 +00:00
KHobbits e1749fecd1 Extra command aliases. 2012-02-22 01:29:37 +00:00
KHobbits 358edff798 Powertools dispatch commands as delayed tasks (should reduce any conflict issues). 2012-02-22 00:23:04 +00:00
KHobbits 34f13ba89c Switch powertools to use different event.
Reduce multiple triggering of powertool events.
Abort event when used with powertool.
2012-02-22 00:11:21 +00:00
KHobbits 945ba6f8ab Fix powertools with new config format. 2012-02-22 00:10:13 +00:00
KHobbits 46f05ee92f Check to see if home section exists. 2012-02-21 22:19:56 +00:00
KHobbits 6d46fc66ce Fixing home list. 2012-02-21 22:12:37 +00:00
KHobbits ed7fe9213f Fix /sudo message display. 2012-02-21 21:39:25 +00:00
ElgarL 9c68cbae72 Removed BukkitPermsOverride as this is now the default with bukkit
handling child nodes.
2012-02-21 18:40:54 +00:00
ElgarL c0df771539 Update for Bukkit R5 compatability.
Removed some unused variables.
2012-02-21 18:38:08 +00:00
snowleo 9bd0c33fef Never give our user object to other plugins! 2012-02-21 18:41:27 +01:00
snowleo cf7da7a83f Merge branch 'refs/heads/groupmanager' 2012-02-21 17:34:45 +01:00
snowleo f46948249e Updated Essentials to work with R5 2012-02-21 17:33:46 +01:00
snowleo 3b81593ebb CB#1952
B#1330
2012-02-21 16:47:25 +01:00
KHobbits 8042cefd3d Merge branch 'master' into release 2012-02-19 01:20:50 +00:00
KHobbits 514f07ce57 Add bPerm2 support for chat prefixes. 2012-02-18 22:47:38 +00:00
KHobbits 4f4d9f6209 Little bit of extra info in the default /einfo file 2012-02-18 22:08:18 +00:00
KHobbits 3077ea4ef1 Re-allow colours in newb welcome messages. 2012-02-18 21:34:05 +00:00
KHobbits 945ae71480 Adding full keyword support for newb join message.
Also adding {ADDRESS} and {USERNAME} as new keywords.
2012-02-18 21:09:18 +00:00
ElgarL 3d1c0fd157 A command of '/manload' with no world arguments now performs a full
reload of GM.
2012-02-18 09:05:28 +00:00
KHobbits fab9688abb Don't try to use old bPerms API if it is not available. 2012-02-16 23:44:13 +00:00
KHobbits b2dbb3f9e3 Fixing being charged twice for /back. 2012-02-16 16:57:50 +00:00
KHobbits 16a0f44b4d Merge remote branch 'remotes/origin/master' into release 2012-02-15 19:09:02 +00:00
md_5 7633b136e3 Its a good idea to actually register the listeners 2012-02-15 19:55:41 +11:00
md_5 0252d756f6 Make Essentials Update use new Listener system, and fix a few general mistakes, including that of the config 2012-02-15 19:34:46 +11:00
md_5 ad05516fd5 Fix formatting in the config.yml and plugin.yml files. Add a new author. 2012-02-15 17:57:53 +11:00
md_5 6d127012d8 Add all the new R4 methods 2012-02-15 17:53:47 +11:00
md_5 c064da9af8 Update to 1.1-R4 2012-02-15 17:44:35 +11:00
md_5 d05f2d7a32 Remove dropItems from the inventory work around 2012-02-15 17:21:28 +11:00
ElgarL 3fc6bb4e4f comment name change 2012-02-15 06:16:33 +00:00
ElgarL 59679e0423 Depreciate PlayerTeleportEvent, PlayerRespawnEvent and PlayerPortalEvent
as it's all handled in PlayerChangedWorldEvent.
This also means we no longer update permissions before we change
worlds.
2012-02-15 06:15:31 +00:00
KHobbits 1a2acb43ae Merge branch 'master' into release 2012-02-14 23:56:02 +00:00
KHobbits f0c0ee1a8d /spawnmob - Only list mobs you have permission to spawn. 2012-02-14 23:55:29 +00:00
snowleo 3c98718387 Don't return null, throw an exception 2012-02-14 20:30:06 +01:00
snowleo cfdb2a36c1 Merge pull request #49 from Iaccidentally/patch-2
fix typo in config.yml (another one)
2012-02-14 11:21:52 -08:00
Iaccidentally 3b7d194902 fix typo in config.yml (another one) 2012-02-14 14:21:07 -05:00
snowleo 72d514d52f Merge pull request #48 from Iaccidentally/patch-1
fix typo in config.yml
2012-02-14 11:18:03 -08:00
Iaccidentally 9fe119e720 fix typo in config.yml 2012-02-14 14:16:34 -05:00
ElgarL 4a5c431163 Depreciate PlayerTeleportEvent as it's all handled in
PlayerChangedWorldEvent.
2012-02-14 13:01:39 +00:00
snowleo a6ac333a74 Less sanitizing for more performance 2012-02-13 21:32:05 +01:00
KHobbits bc2578b788 Caching regex return in user cleanup.
(Pushing this for testing purposes).
2012-02-13 19:40:33 +00:00
KHobbits 36d07cb539 Merge branch 'master' into release 2012-02-13 17:35:05 +00:00
KHobbits effe0d5ec5 Merge remote branch 'remotes/origin/groupmanager' 2012-02-13 17:24:32 +00:00
KHobbits 0ab2e745cf Merge branch 'master' of github.com:essentials/Essentials 2012-02-13 17:17:14 +00:00
KHobbits 57a2ef08d4 Allow charges for different mob types in /spawner 2012-02-13 17:16:27 +00:00
KHobbits 2699e02f96 Add per warp command costs
Make warp other commands charge the commander, not the warped.
2012-02-13 17:09:07 +00:00
md_5 62cd219b4e Clean up the CommandException stack traces so they appear as if Essentials was never there. 2012-02-12 08:19:24 +11:00
KHobbits 2d56de1483 Update trade signs properly, and visibly handle full signs. 2012-02-11 21:15:26 +00:00
KHobbits bbc6da5106 Merge pull request #46 from krinsdeath/master
Added Privileges to known Permissions plugins
2012-02-11 12:12:59 -08:00
KHobbits b0d06ce6ed Refactoring tpaccept perm check to include tpaall. 2012-02-11 20:10:19 +00:00
KHobbits de1554cb68 Merge pull request #45 from Wolvereness/master
Fix /tpaccept permission check
Refactoring to follow.
2012-02-11 12:06:42 -08:00
Jeff Wardian c890ea8f87 Added PrivilegesHandler.java;
Implemented privileges in PermissionsHandler.java;

Fixed PrivilegesHandler.canBuild();
2012-02-11 10:06:18 -08:00
ElgarL c0517c1203 Change Service registration to register WorldsHolder instead of
AnjoPermissionsHandler. This is the correct entry point for all data.
2012-02-11 10:36:55 +00:00
Wolvereness 9efd0eb6f9 Fix exploit with /tpaccept if sender no longer has permission 2012-02-09 23:14:57 -06:00
KHobbits f0ee026fb9 Allow colour codes in /ping 2012-02-09 22:13:00 +00:00
KHobbits b3fc790000 New Permission: essentials.sudo.exempt
If a user has this perm, they cannot be controlled.
2012-02-09 22:11:46 +00:00
KHobbits 83f9209bcc Optional argument to /ping [message]- Message to be echo'd.
Possible use in scripts, checking for lag, /sudo, etc.
2012-02-09 22:02:24 +00:00
KHobbits 691a0ef4ce Fixing silly typo - Fixes shout costs. 2012-02-09 02:11:36 +00:00
ElgarL 97bd49e598 Add some commenting 2012-02-05 16:41:34 +00:00
ElgarL e93e50f6d2 Fix world mirroring so it correctly creates data files and data sources
for partially mirrored worlds.
Fixed world mirroring so it returns the correct data for the
requested world
2012-02-05 16:30:58 +00:00
ElgarL 76ba5caeec Prevent getAllPlayersPermissions() processing a group more than once.
Improves performance when using complex inheritance structures.
2012-02-02 18:10:35 +00:00
ElgarL a0103afde3 fix setGroup to only block superperms update if update is false. 2012-02-02 02:41:10 +00:00
ElgarL dbf30740fb Fix a bug with getWorldData return the main world data for all mirrors,
instead of the worlds parent data.
2012-02-02 02:01:04 +00:00
ElgarL 3f02bcd702 Catch all errors in badly formatted groups. 2012-01-31 03:16:34 +00:00
ElgarL fe050dd725 Track the 'onPlayerChangeWorld' event as some teleports seem to not be
triggering a world move.
2012-01-30 17:08:55 +00:00
ElgarL 5b4966c888 Auto sort permissions on load to speed up population of superperms.
Negating a parent node after adding all nodes with * will now
correctly remove all child nodes of that parent before populating
superperms.
	  eg.
	      - '*'
	      - -vanish.*
	      - vanish.standard
2012-01-30 14:41:19 +00:00
ElgarL 2c8aa20542 .project change for Eclipse Build tool 2012-01-29 21:37:50 +00:00
246 changed files with 13714 additions and 5661 deletions

No files matched your search

-1
View File
@@ -3,6 +3,5 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/bukkit-0.0.1-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="lib/craftbukkit-0.0.1-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="lib/Permissions3.jar"/>
</classpath>
+5 -1
View File
@@ -66,6 +66,7 @@ endorsed.classpath=
excludes=
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
file.reference.bPermissions.jar=../lib/bPermissions.jar
file.reference.bpermissions2.jar=../lib/bpermissions2.jar
file.reference.bukkit.jar=../lib/bukkit.jar
file.reference.craftbukkit.jar=../lib/craftbukkit.jar
file.reference.iCo4.jar=../lib/iCo4.jar
@@ -76,6 +77,7 @@ file.reference.MultiCurrency.jar=../lib/MultiCurrency.jar
file.reference.Permissions3.jar=../lib/Permissions3.jar
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
includes=**
jar.archive.disabled=${jnlp.enabled}
@@ -95,7 +97,9 @@ javac.classpath=\
${reference.EssentialsGroupManager.jar}:\
${file.reference.bukkit.jar}:\
${file.reference.craftbukkit.jar}:\
${file.reference.Vault.jar}
${file.reference.Vault.jar}:\
${file.reference.Privileges.jar}:\
${file.reference.bpermissions2.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
@@ -61,6 +61,12 @@ public class Backup implements Runnable
{
return;
}
if ("save-all".equalsIgnoreCase(command)) {
final CommandSender cs = server.getConsoleSender();
server.dispatchCommand(cs, "save-all");
active = false;
return;
}
LOGGER.log(Level.INFO, _("backupStarted"));
final CommandSender cs = server.getConsoleSender();
server.dispatchCommand(cs, "save-all");
@@ -6,12 +6,11 @@ import java.util.*;
/**
* This utility class is used for converting between the ingame
* time in ticks to ingame time as a friendly string.
* Note that the time is INGAME.
*
* This utility class is used for converting between the ingame time in ticks to ingame time as a friendly string. Note
* that the time is INGAME.
*
* http://www.minecraftwiki.net/wiki/Day/night_cycle
*
*
* @author Olof Larsson
*/
public final class DescParseTickFormat
@@ -156,30 +155,31 @@ public final class DescParseTickFormat
int hours = 0;
int minutes = 0;
desc = desc.toLowerCase(Locale.ENGLISH).replaceAll("[^0-9]", "");
desc = desc.toLowerCase(Locale.ENGLISH);
String parsetime = desc.replaceAll("[^0-9]", "");
if (desc.length() > 4)
if (parsetime.length() > 4)
{
throw new NumberFormatException();
}
if (desc.length() == 4)
if (parsetime.length() == 4)
{
hours += Integer.parseInt(desc.substring(0, 2));
minutes += Integer.parseInt(desc.substring(2, 4));
hours += Integer.parseInt(parsetime.substring(0, 2));
minutes += Integer.parseInt(parsetime.substring(2, 4));
}
else if (desc.length() == 3)
else if (parsetime.length() == 3)
{
hours += Integer.parseInt(desc.substring(0, 1));
minutes += Integer.parseInt(desc.substring(1, 3));
hours += Integer.parseInt(parsetime.substring(0, 1));
minutes += Integer.parseInt(parsetime.substring(1, 3));
}
else if (desc.length() == 2)
else if (parsetime.length() == 2)
{
hours += Integer.parseInt(desc.substring(0, 2));
hours += Integer.parseInt(parsetime.substring(0, 2));
}
else if (desc.length() == 1)
else if (parsetime.length() == 1)
{
hours += Integer.parseInt(desc.substring(0, 1));
hours += Integer.parseInt(parsetime.substring(0, 1));
}
else
{
@@ -19,47 +19,93 @@ public class Enchantments
ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL);
ENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL);
ENCHANTMENTS.put("sharpness", Enchantment.DAMAGE_ALL);
ENCHANTMENTS.put("sharp", Enchantment.DAMAGE_ALL);
ENCHANTMENTS.put("arthropodsdamage", Enchantment.DAMAGE_ARTHROPODS);
ENCHANTMENTS.put("ardmg", Enchantment.DAMAGE_ARTHROPODS);
ENCHANTMENTS.put("baneofarthropods", Enchantment.DAMAGE_ARTHROPODS);
ENCHANTMENTS.put("baneofarthropod", Enchantment.DAMAGE_ARTHROPODS);
ENCHANTMENTS.put("arthropod", Enchantment.DAMAGE_ARTHROPODS);
ENCHANTMENTS.put("undeaddamage", Enchantment.DAMAGE_UNDEAD);
ENCHANTMENTS.put("smite", Enchantment.DAMAGE_UNDEAD);
ENCHANTMENTS.put("digspeed", Enchantment.DIG_SPEED);
ENCHANTMENTS.put("efficiency", Enchantment.DIG_SPEED);
ENCHANTMENTS.put("minespeed", Enchantment.DIG_SPEED);
ENCHANTMENTS.put("cutspeed", Enchantment.DIG_SPEED);
ENCHANTMENTS.put("durability", Enchantment.DURABILITY);
ENCHANTMENTS.put("dura", Enchantment.DURABILITY);
ENCHANTMENTS.put("unbreaking", Enchantment.DURABILITY);
ENCHANTMENTS.put("fireaspect", Enchantment.FIRE_ASPECT);
ENCHANTMENTS.put("fire", Enchantment.FIRE_ASPECT);
ENCHANTMENTS.put("meleefire", Enchantment.FIRE_ASPECT);
ENCHANTMENTS.put("meleeflame", Enchantment.FIRE_ASPECT);
ENCHANTMENTS.put("knockback", Enchantment.KNOCKBACK);
ENCHANTMENTS.put("blockslootbonus", Enchantment.LOOT_BONUS_BLOCKS);
ENCHANTMENTS.put("fortune", Enchantment.LOOT_BONUS_BLOCKS);
ENCHANTMENTS.put("mobslootbonus", Enchantment.LOOT_BONUS_MOBS);
ENCHANTMENTS.put("mobloot", Enchantment.LOOT_BONUS_MOBS);
ENCHANTMENTS.put("looting", Enchantment.LOOT_BONUS_MOBS);
ENCHANTMENTS.put("oxygen", Enchantment.OXYGEN);
ENCHANTMENTS.put("respiration", Enchantment.OXYGEN);
ENCHANTMENTS.put("breathing", Enchantment.OXYGEN);
ENCHANTMENTS.put("breath", Enchantment.OXYGEN);
ENCHANTMENTS.put("protection", Enchantment.PROTECTION_ENVIRONMENTAL);
ENCHANTMENTS.put("prot", Enchantment.PROTECTION_ENVIRONMENTAL);
ENCHANTMENTS.put("protect", Enchantment.PROTECTION_ENVIRONMENTAL);
ENCHANTMENTS.put("explosionsprotection", Enchantment.PROTECTION_EXPLOSIONS);
ENCHANTMENTS.put("explosionprotection", Enchantment.PROTECTION_EXPLOSIONS);
ENCHANTMENTS.put("expprot", Enchantment.PROTECTION_EXPLOSIONS);
ENCHANTMENTS.put("blastprotection", Enchantment.PROTECTION_EXPLOSIONS);
ENCHANTMENTS.put("blastprotect", Enchantment.PROTECTION_EXPLOSIONS);
ENCHANTMENTS.put("fallprotection", Enchantment.PROTECTION_FALL);
ENCHANTMENTS.put("fallprot", Enchantment.PROTECTION_FALL);
ENCHANTMENTS.put("featherfall", Enchantment.PROTECTION_FALL);
ENCHANTMENTS.put("featherfalling", Enchantment.PROTECTION_FALL);
ENCHANTMENTS.put("fireprotection", Enchantment.PROTECTION_FIRE);
ENCHANTMENTS.put("fireprot", Enchantment.PROTECTION_FIRE);
ENCHANTMENTS.put("flameprotection", Enchantment.PROTECTION_FIRE);
ENCHANTMENTS.put("fireprotect", Enchantment.PROTECTION_FIRE);
ENCHANTMENTS.put("flameprotect", Enchantment.PROTECTION_FIRE);
ENCHANTMENTS.put("projectileprotection", Enchantment.PROTECTION_PROJECTILE);
ENCHANTMENTS.put("projprot", Enchantment.PROTECTION_PROJECTILE);
ENCHANTMENTS.put("silktouch", Enchantment.SILK_TOUCH);
ENCHANTMENTS.put("softtouch", Enchantment.SILK_TOUCH);
ENCHANTMENTS.put("waterworker", Enchantment.WATER_WORKER);
ENCHANTMENTS.put("aquaaffinity", Enchantment.WATER_WORKER);
ENCHANTMENTS.put("firearrow", Enchantment.ARROW_FIRE);
ENCHANTMENTS.put("flame", Enchantment.ARROW_FIRE);
ENCHANTMENTS.put("flamearrow", Enchantment.ARROW_FIRE);
ENCHANTMENTS.put("arrowdamage", Enchantment.ARROW_DAMAGE);
ENCHANTMENTS.put("power", Enchantment.ARROW_DAMAGE);
ENCHANTMENTS.put("arrowpower", Enchantment.ARROW_DAMAGE);
ENCHANTMENTS.put("arrowknockback", Enchantment.ARROW_KNOCKBACK);
ENCHANTMENTS.put("arrowkb", Enchantment.ARROW_KNOCKBACK);
ENCHANTMENTS.put("punch", Enchantment.ARROW_KNOCKBACK);
ENCHANTMENTS.put("arrowpunch", Enchantment.ARROW_KNOCKBACK);
ENCHANTMENTS.put("infinitearrows", Enchantment.ARROW_INFINITE);
ENCHANTMENTS.put("infarrows", Enchantment.ARROW_INFINITE);
ENCHANTMENTS.put("infinity", Enchantment.ARROW_INFINITE);
ENCHANTMENTS.put("infinite", Enchantment.ARROW_INFINITE);
ENCHANTMENTS.put("unlimited", Enchantment.ARROW_INFINITE);
ENCHANTMENTS.put("unlimitedarrows", Enchantment.ARROW_INFINITE);
}
public static Enchantment getByName(String name) {
@@ -24,6 +24,9 @@ import com.earth2me.essentials.commands.EssentialsCommand;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.commands.NoChargeException;
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
import com.earth2me.essentials.metrics.Metrics;
import com.earth2me.essentials.metrics.MetricsListener;
import com.earth2me.essentials.metrics.MetricsStarter;
import com.earth2me.essentials.perm.PermissionsHandler;
import com.earth2me.essentials.register.payment.Methods;
import com.earth2me.essentials.signs.SignBlockListener;
@@ -33,11 +36,14 @@ import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.Command;
@@ -61,7 +67,7 @@ import org.yaml.snakeyaml.error.YAMLException;
public class Essentials extends JavaPlugin implements IEssentials
{
public static final int BUKKIT_VERSION = 1846;
public static final int BUKKIT_VERSION = 2149;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
@@ -77,6 +83,9 @@ public class Essentials extends JavaPlugin implements IEssentials
private transient UserMap userMap;
private transient ExecuteTimer execTimer;
private transient I18n i18n;
private transient Metrics metrics;
private transient EssentialsTimer timer;
private transient List<String> vanishedPlayers = new ArrayList<String>();
@Override
public ISettings getSettings()
@@ -119,19 +128,22 @@ public class Essentials extends JavaPlugin implements IEssentials
for (Plugin plugin : pm.getPlugins())
{
if (plugin.getDescription().getName().startsWith("Essentials")
&& !plugin.getDescription().getVersion().equals(this.getDescription().getVersion()))
&& !plugin.getDescription().getVersion().equals(this.getDescription().getVersion())
&& !plugin.getDescription().getName().equals("EssentialsAntiCheat"))
{
LOGGER.log(Level.WARNING, _("versionMismatch", plugin.getDescription().getName()));
}
}
final Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-R[0-9]+-(?:[0-9]+-g[0-9a-f]+-)?b([0-9]+)jnks.*").matcher(getServer().getVersion());
final Matcher versionMatch = Pattern.compile("git-Bukkit-(?:(?:[0-9]+)\\.)+[0-9]+-R[\\.0-9]+-(?:[0-9]+-g[0-9a-f]+-)?b([0-9]+)jnks.*").matcher(getServer().getVersion());
if (versionMatch.matches())
{
final int versionNumber = Integer.parseInt(versionMatch.group(4));
if (versionNumber < BUKKIT_VERSION)
final int versionNumber = Integer.parseInt(versionMatch.group(1));
if (versionNumber < BUKKIT_VERSION && versionNumber > 100)
{
LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *");
LOGGER.log(Level.SEVERE, _("notRecommendedBukkit"));
LOGGER.log(Level.SEVERE, _("requiredBukkit", Integer.toString(BUKKIT_VERSION)));
LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *");
this.setEnabled(false);
return;
}
@@ -218,7 +230,7 @@ public class Essentials extends JavaPlugin implements IEssentials
final EssentialsEntityListener entityListener = new EssentialsEntityListener(this);
pm.registerEvents(entityListener, this);
final EssentialsWorldListener worldListener = new EssentialsWorldListener(this);
pm.registerEvents(worldListener, this);
@@ -228,10 +240,23 @@ public class Essentials extends JavaPlugin implements IEssentials
pm.registerEvents(tntListener, this);
final EssentialsTimer timer = new EssentialsTimer(this);
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
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())
{
@@ -242,6 +267,15 @@ public class Essentials extends JavaPlugin implements IEssentials
@Override
public void onDisable()
{
for (Player p : getServer().getOnlinePlayers())
{
User user = getUser(p);
if (user.isVanished())
{
user.toggleVanished();
p.sendMessage(_("unvanishedReload"));
}
}
i18n.onDisable();
Economy.setEss(null);
Trade.closeLog();
@@ -277,7 +311,16 @@ public class Essentials extends JavaPlugin implements IEssentials
if (pc != null)
{
alternativeCommandsHandler.executed(commandLabel, pc.getLabel());
return pc.execute(sender, commandLabel, args);
try
{
return pc.execute(sender, commandLabel, args);
}
catch (final Exception ex)
{
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
sender.sendMessage(ChatColor.RED + "An internal error occurred while attempting to perform this command");
return true;
}
}
}
@@ -408,6 +451,16 @@ public class Essentials extends JavaPlugin implements IEssentials
return backup;
}
public Metrics getMetrics()
{
return metrics;
}
public void setMetrics(Metrics metrics)
{
this.metrics = metrics;
}
@Override
public User getUser(final Object base)
{
@@ -504,7 +557,7 @@ public class Essentials extends JavaPlugin implements IEssentials
for (Player player : players)
{
final User user = getUser(player);
if (!user.isIgnoredPlayer(sender.getName()))
if (!user.isIgnoredPlayer(sender))
{
player.sendMessage(message);
}
@@ -572,15 +625,27 @@ public class Essentials extends JavaPlugin implements IEssentials
{
return i18n;
}
private static class EssentialsWorldListener implements Listener, Runnable {
@Override
public EssentialsTimer getTimer()
{
return timer;
}
@Override
public List<String> getVanishedPlayers()
{
return vanishedPlayers;
}
private static class EssentialsWorldListener implements Listener, Runnable
{
private transient final IEssentials ess;
public EssentialsWorldListener(final IEssentials ess)
{
this.ess = ess;
}
@EventHandler(priority = EventPriority.LOW)
public void onWorldLoad(final WorldLoadEvent event)
@@ -589,7 +654,8 @@ public class Essentials extends JavaPlugin implements IEssentials
ess.getWarps().reloadConfig();
for (IConf iConf : ((Essentials)ess).confList)
{
if (iConf instanceof IEssentialsModule) {
if (iConf instanceof IEssentialsModule)
{
iConf.reloadConfig();
}
}
@@ -602,7 +668,8 @@ public class Essentials extends JavaPlugin implements IEssentials
ess.getWarps().reloadConfig();
for (IConf iConf : ((Essentials)ess).confList)
{
if (iConf instanceof IEssentialsModule) {
if (iConf instanceof IEssentialsModule)
{
iConf.reloadConfig();
}
}
@@ -17,22 +17,18 @@ public class EssentialsBlockListener implements Listener
this.ess = ess;
}
@EventHandler(priority = EventPriority.LOWEST)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockPlace(final BlockPlaceEvent event)
{
if (event.isCancelled())
{
return;
}
final User user = ess.getUser(event.getPlayer());
// Do not rely on getItemInHand();
// http://leaky.bukkit.org/issues/663
// http://leaky.bukkit.org/issues/663
final ItemStack is = Util.convertBlockToItem(event.getBlockPlaced());
if (is == null)
{
return;
}
boolean unlimitedForUser = user.hasUnlimited(is);
final User user = ess.getUser(event.getPlayer());
final boolean unlimitedForUser = user.hasUnlimited(is);
if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL)
{
ess.scheduleSyncDelayedTask(
@@ -1,9 +1,15 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.google.common.io.Files;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CoderResult;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;
@@ -12,30 +18,28 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.config.Configuration;
public class EssentialsConf extends Configuration
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 static final Charset UTF8 = Charset.forName("UTF-8");
public EssentialsConf(final File configFile)
{
super(configFile);
super();
this.configFile = configFile;
if (this.root == null)
{
this.root = new HashMap<String, Object>();
}
}
@Override
public void load()
public synchronized void load()
{
configFile = configFile.getAbsoluteFile();
if (!configFile.getParentFile().exists())
@@ -105,20 +109,57 @@ public class EssentialsConf extends Configuration
}
}
try
{
super.load();
final FileInputStream inputStream = new FileInputStream(configFile);
try
{
final FileChannel channel = inputStream.getChannel();
final ByteBuffer buffer = ByteBuffer.allocate((int)configFile.length());
channel.read(buffer);
buffer.rewind();
final CharBuffer data = CharBuffer.allocate((int)configFile.length());
CharsetDecoder decoder = UTF8.newDecoder();
CoderResult result = decoder.decode(buffer, data, true);
if (result.isError())
{
buffer.rewind();
data.clear();
LOGGER.log(Level.INFO, "File " + configFile.getAbsolutePath().toString() + " is not utf-8 encoded, trying " + Charset.defaultCharset().displayName());
decoder = Charset.defaultCharset().newDecoder();
result = decoder.decode(buffer, data, true);
if (result.isError())
{
throw new InvalidConfigurationException("Invalid Characters in file " + configFile.getAbsolutePath().toString());
}
else
{
decoder.flush(data);
}
}
else
{
decoder.flush(data);
}
final int end = data.position();
data.rewind();
super.loadFromString(data.subSequence(0, end).toString());
}
finally
{
inputStream.close();
}
}
catch (RuntimeException e)
{
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
}
catch (InvalidConfigurationException ex)
{
File broken = new File(configFile.getAbsolutePath() + ".broken." + System.currentTimeMillis());
configFile.renameTo(broken);
LOGGER.log(Level.SEVERE, "The file " + configFile.toString() + " is broken, it has been renamed to " + broken.toString(), e.getCause());
}
if (this.root == null)
{
this.root = new HashMap<String, Object>();
LOGGER.log(Level.SEVERE, "The file " + configFile.toString() + " is broken, it has been renamed to " + broken.toString(), ex.getCause());
}
}
@@ -193,7 +234,7 @@ public class EssentialsConf extends Configuration
public boolean hasProperty(final String path)
{
return getProperty(path) != null;
return isSet(path);
}
public Location getLocation(final String path, final Server server) throws Exception
@@ -218,24 +259,25 @@ public class EssentialsConf extends Configuration
public void setProperty(final String path, final Location loc)
{
setProperty((path == null ? "" : path + ".") + "world", loc.getWorld().getName());
setProperty((path == null ? "" : path + ".") + "x", loc.getX());
setProperty((path == null ? "" : path + ".") + "y", loc.getY());
setProperty((path == null ? "" : path + ".") + "z", loc.getZ());
setProperty((path == null ? "" : path + ".") + "yaw", loc.getYaw());
setProperty((path == null ? "" : path + ".") + "pitch", loc.getPitch());
set((path == null ? "" : path + ".") + "world", loc.getWorld().getName());
set((path == null ? "" : path + ".") + "x", loc.getX());
set((path == null ? "" : path + ".") + "y", loc.getY());
set((path == null ? "" : path + ".") + "z", loc.getZ());
set((path == null ? "" : path + ".") + "yaw", loc.getYaw());
set((path == null ? "" : path + ".") + "pitch", loc.getPitch());
}
@Override
public ItemStack getItemStack(final String path)
{
final ItemStack stack = new ItemStack(
Material.valueOf(getString(path + ".type", "AIR")),
getInt(path + ".amount", 1),
(short)getInt(path + ".damage", 0));
final List<String> enchants = getKeys(path + ".enchant");
final ConfigurationSection enchants = getConfigurationSection(path + ".enchant");
if (enchants != null)
{
for (String enchant : enchants)
for (String enchant : enchants.getKeys(false))
{
final Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH));
if (enchantment == null)
@@ -271,14 +313,14 @@ public class EssentialsConf extends Configuration
}
// getData().getData() is broken
//map.put("data", stack.getDurability());
setProperty(path, map);
set(path, map);
}
public long getLong(final String path, final long def)
{
try
{
final Number num = (Number)getProperty(path);
final Number num = (Number)get(path);
return num == null ? def : num.longValue();
}
catch (ClassCastException ex)
@@ -292,7 +334,7 @@ public class EssentialsConf extends Configuration
{
try
{
Number num = (Number)getProperty(path);
Number num = (Number)get(path);
return num == null ? def : num.doubleValue();
}
catch (ClassCastException ex)
@@ -300,4 +342,55 @@ public class EssentialsConf extends Configuration
return def;
}
}
public void save()
{
try
{
save(configFile);
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
}
}
@Override
public synchronized void save(final File file) throws IOException
{
if (file == null)
{
throw new IllegalArgumentException("File cannot be null");
}
Files.createParentDirs(file);
final String data = saveToString();
final OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), UTF8);
try
{
writer.write(data);
}
finally
{
writer.close();
}
}
public Object getProperty(String path)
{
return get(path);
}
public void setProperty(String path, Object object)
{
set(path, object);
}
public void removeProperty(String path)
{
set(path, null);
}
}
@@ -3,14 +3,14 @@ package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.inventory.ItemStack;
@@ -23,49 +23,69 @@ public class EssentialsEntityListener implements Listener
this.ess = ess;
}
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageEvent event)
@EventHandler(priority = EventPriority.LOW)
public void onEntityDamage(final EntityDamageByEntityEvent event)
{
if (event instanceof EntityDamageByEntityEvent)
final Entity eAttack = event.getDamager();
final Entity eDefend = event.getEntity();
if (eDefend instanceof Player && eAttack instanceof Player)
{
EntityDamageByEntityEvent edEvent = (EntityDamageByEntityEvent)event;
Entity eAttack = edEvent.getDamager();
Entity eDefend = edEvent.getEntity();
if (eDefend instanceof Player && eAttack instanceof Player)
{
User defender = ess.getUser(eDefend);
User attacker = ess.getUser(eAttack);
attacker.updateActivity(true);
ItemStack is = attacker.getItemInHand();
List<String> commandList = attacker.getPowertool(is);
if (commandList != null && !commandList.isEmpty())
{
for (String command : commandList)
{
final User defender = ess.getUser(eDefend);
final User attacker = ess.getUser(eAttack);
if (command != null && !command.isEmpty())
{
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
event.setCancelled(true);
return;
}
if (ess.getSettings().getLoginAttackDelay() > 0 && !attacker.isAuthorized("essentials.pvpdelay.exempt")
&& (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay())))
{
event.setCancelled(true);
}
if (attacker.hasInvulnerabilityAfterTeleport() || defender.hasInvulnerabilityAfterTeleport())
{
event.setCancelled(true);
}
attacker.updateActivity(true);
final List<String> commandList = attacker.getPowertool(attacker.getItemInHand());
if (commandList != null && !commandList.isEmpty())
{
for (final String command : commandList)
{
if (command != null && !command.isEmpty())
{
ess.scheduleSyncDelayedTask(
new Runnable()
{
@Override
public void run()
{
attacker.getServer().dispatchCommand(attacker.getBase(), command.replaceAll("\\{player\\}", defender.getName()));
}
});
event.setCancelled(true);
return;
}
}
}
if (eDefend instanceof Animals && eAttack instanceof Player)
}
else if (eDefend instanceof Ageable && eAttack instanceof Player)
{
final Player player = (Player)eAttack;
final ItemStack hand = player.getItemInHand();
if (hand != null && hand.getType() == Material.MILK_BUCKET)
{
User player = ess.getUser(eAttack);
ItemStack hand = player.getItemInHand();
if (hand != null && hand.getType() == Material.MILK_BUCKET)
{
((Animals)eDefend).setAge(-24000);
hand.setType(Material.BUCKET);
player.setItemInHand(hand);
player.updateInventory();
event.setCancelled(true);
}
((Ageable)eDefend).setBaby();
hand.setType(Material.BUCKET);
player.setItemInHand(hand);
player.updateInventory();
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityDamage(final EntityDamageEvent event)
{
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{
final Player player = (Player)event.getEntity();
@@ -75,8 +95,8 @@ public class EssentialsEntityListener implements Listener
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityCombust(EntityCombustEvent event)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityCombust(final EntityCombustEvent event)
{
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{
@@ -85,26 +105,22 @@ public class EssentialsEntityListener implements Listener
}
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDeath(final EntityDeathEvent event)
public void onPlayerDeathEvent(final PlayerDeathEvent event)
{
if (event instanceof PlayerDeathEvent)
final User user = ess.getUser(event.getEntity());
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
{
final PlayerDeathEvent pdevent = (PlayerDeathEvent)event;
final User user = ess.getUser(pdevent.getEntity());
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
{
user.setLastLocation();
user.sendMessage(_("backAfterDeath"));
}
if (!ess.getSettings().areDeathMessagesEnabled())
{
pdevent.setDeathMessage("");
}
user.setLastLocation();
user.sendMessage(_("backAfterDeath"));
}
if (!ess.getSettings().areDeathMessagesEnabled())
{
event.setDeathMessage("");
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onFoodLevelChange(FoodLevelChangeEvent event)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onFoodLevelChange(final FoodLevelChangeEvent event)
{
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{
@@ -112,8 +128,8 @@ public class EssentialsEntityListener implements Listener
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityRegainHealth(EntityRegainHealthEvent event)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityRegainHealth(final EntityRegainHealthEvent event)
{
if (event.getRegainReason() == RegainReason.SATIATED && event.getEntity() instanceof Player
&& ess.getUser(event.getEntity()).isAfk() && ess.getSettings().getFreezeAfkPlayers())
@@ -14,28 +14,31 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
public class EssentialsPlayerListener implements Listener
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private final transient Server server;
private final transient IEssentials ess;
private static final int AIR = Material.AIR.getId();
private static final int BED = Material.BED_BLOCK.getId();
public EssentialsPlayerListener(final IEssentials parent)
{
this.ess = parent;
this.server = parent.getServer();
}
@EventHandler(priority = EventPriority.NORMAL)
@@ -43,10 +46,7 @@ public class EssentialsPlayerListener implements Listener
{
final User user = ess.getUser(event.getPlayer());
updateCompass(user);
if (ess.getSettings().changeDisplayName())
{
user.setDisplayNick();
}
user.setDisplayNick();
}
@EventHandler(priority = EventPriority.LOWEST)
@@ -63,27 +63,27 @@ public class EssentialsPlayerListener implements Listener
while (it.hasNext())
{
final User u = ess.getUser(it.next());
if (u.isIgnoredPlayer(user.getName()))
if (u.isIgnoredPlayer(user))
{
it.remove();
}
}
user.updateActivity(true);
if (ess.getSettings().changeDisplayName())
{
user.setDisplayNick();
}
user.setDisplayNick();
}
@EventHandler(priority = EventPriority.HIGH)
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerMove(final PlayerMoveEvent event)
{
if (event.isCancelled())
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())
{
return;
}
final User user = ess.getUser(event.getPlayer());
final User user = ess.getUser(event.getPlayer());
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers())
{
final Location from = event.getFrom();
@@ -101,7 +101,6 @@ public class EssentialsPlayerListener implements Listener
}
return;
}
final Location afk = user.getAfkPosition();
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
{
@@ -115,13 +114,13 @@ public class EssentialsPlayerListener implements Listener
final User user = ess.getUser(event.getPlayer());
if (ess.getSettings().removeGodOnDisconnect() && user.isGodModeEnabled())
{
user.toggleGodModeEnabled();
user.setGodModeEnabled(false);
}
if (user.getSavedInventory() != null)
if (user.isVanished())
{
user.getInventory().setContents(user.getSavedInventory());
user.setSavedInventory(null);
user.toggleVanished();
}
user.setLastLocation();
user.updateActivity(false);
user.dispose();
}
@@ -129,15 +128,37 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(final PlayerJoinEvent event)
{
ess.getBackup().onPlayerJoin();
final User user = ess.getUser(event.getPlayer());
if (ess.getSettings().changeDisplayName())
ess.scheduleAsyncDelayedTask(new Runnable()
{
user.setDisplayNick();
@Override
public void run()
{
delayedJoin(event.getPlayer());
}
});
}
public void delayedJoin(final Player player)
{
if (!player.isOnline())
{
return;
}
user.setLastLoginAddress(user.getAddress().getAddress().getHostAddress());
ess.getBackup().onPlayerJoin();
final User user = ess.getUser(player);
user.setDisplayNick();
updateCompass(user);
user.setLastLogin(System.currentTimeMillis());
user.updateActivity(false);
for (String p : ess.getVanishedPlayers())
{
if (!user.isAuthorized("essentials.vanish.see"))
{
user.hidePlayer(ess.getUser(p).getBase());
}
}
if (user.isAuthorized("essentials.sleepingignored"))
{
user.setSleepingIgnored(true);
@@ -179,39 +200,6 @@ public class EssentialsPlayerListener implements Listener
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerLogin(final PlayerLoginEvent event)
{
if (event.getResult() != Result.ALLOWED && event.getResult() != Result.KICK_FULL && event.getResult() != Result.KICK_BANNED)
{
return;
}
User user = ess.getUser(event.getPlayer());
user.setNPC(false);
final long currentTime = System.currentTimeMillis();
final boolean banExpired = user.checkBanTimeout(currentTime);
user.checkMuteTimeout(currentTime);
user.checkJailTimeout(currentTime);
if (banExpired == false && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
{
final String banReason = user.getBanReason();
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : _("defaultBanReason"));
return;
}
if (server.getOnlinePlayers().length >= server.getMaxPlayers() && !user.isAuthorized("essentials.joinfullserver"))
{
event.disallow(Result.KICK_FULL, _("serverFull"));
return;
}
event.allow();
user.setLastLogin(System.currentTimeMillis());
updateCompass(user);
}
private void updateCompass(final User user)
{
Location loc = user.getHome(user.getLocation());
@@ -221,33 +209,78 @@ public class EssentialsPlayerListener implements Listener
}
if (loc != null)
{
user.setCompassTarget(loc);
final Location updateLoc = loc;
ess.scheduleSyncDelayedTask(new Runnable()
{
@Override
public void run()
{
user.setCompassTarget(updateLoc);
}
});
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerTeleport(final PlayerTeleportEvent event)
public void onPlayerLogin(final PlayerLoginEvent event)
{
if (event.isCancelled())
switch (event.getResult())
{
case ALLOWED:
case KICK_FULL:
case KICK_BANNED:
break;
default:
return;
}
final User user = ess.getUser(event.getPlayer());
//There is TeleportCause.COMMMAND but plugins have to actively pass the cause in on their teleports.
if ((event.getCause() == TeleportCause.PLUGIN || event.getCause() == TeleportCause.COMMAND) && ess.getSettings().registerBackInListener())
if (user.isNPC())
{
user.setLastLocation();
user.setNPC(false);
}
if (ess.getSettings().changeDisplayName())
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))
{
user.setDisplayNick();
final String banReason = user.getBanReason();
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : _("defaultBanReason"));
return;
}
updateCompass(user);
if (event.getResult() == Result.KICK_FULL && !user.isAuthorized("essentials.joinfullserver"))
{
event.disallow(Result.KICK_FULL, _("serverFull"));
return;
}
event.allow();
}
@EventHandler(priority = EventPriority.HIGH)
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerTeleport(final PlayerTeleportEvent event)
{
final boolean backListener = ess.getSettings().registerBackInListener();
final boolean teleportInvulnerability = ess.getSettings().isTeleportInvulnerability();
if (backListener || teleportInvulnerability)
{
final User user = ess.getUser(event.getPlayer());
//There is TeleportCause.COMMMAND but plugins have to actively pass the cause in on their teleports.
if (backListener && (event.getCause() == TeleportCause.PLUGIN || event.getCause() == TeleportCause.COMMAND))
{
user.setLastLocation();
}
if (teleportInvulnerability)
{
user.enableInvulnerabilityAfterTeleport();
}
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerEggThrow(final PlayerEggThrowEvent event)
{
final User user = ess.getUser(event.getPlayer());
@@ -259,7 +292,7 @@ public class EssentialsPlayerListener implements Listener
}
}
@EventHandler(priority = EventPriority.HIGH)
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
{
final User user = ess.getUser(event.getPlayer());
@@ -276,75 +309,27 @@ public class EssentialsPlayerListener implements Listener
});
}
}
private final static List<String> COMMANDS = Arrays.asList("msg", "r", "mail", "m", "t", "whisper", "emsg", "tell", "er", "reply", "ereply", "email");
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerAnimation(final PlayerAnimationEvent event)
{
final User user = ess.getUser(event.getPlayer());
user.updateActivity(true);
if (event.getAnimationType() == PlayerAnimationType.ARM_SWING
&& user.hasPowerTools() && user.arePowerToolsEnabled())
{
usePowertools(user);
}
}
private void usePowertools(final User user)
{
final ItemStack is = user.getItemInHand();
int id;
if (is == null || (id = is.getTypeId()) == 0)
{
return;
}
final List<String> commandList = user.getPowertool(id);
if (commandList == null || commandList.isEmpty())
{
return;
}
// We need to loop through each command and execute
for (String command : commandList)
{
if (command.matches(".*\\{player\\}.*"))
{
//user.sendMessage("Click a player to use this command");
continue;
}
else if (command.startsWith("c:"))
{
user.chat(command.substring(2));
}
else
{
user.getServer().dispatchCommand(user.getBase(), command);
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
{
if (event.isCancelled())
{
return;
}
final User user = ess.getUser(event.getPlayer());
final Player player = event.getPlayer();
final String cmd = event.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "").toLowerCase(Locale.ENGLISH);
final List<String> commands = Arrays.asList("msg", "r", "mail", "m", "t", "emsg", "tell", "er", "reply", "ereply", "email");
if (commands.contains(cmd))
if (COMMANDS.contains(cmd))
{
for (Player player : ess.getServer().getOnlinePlayers())
for (Player onlinePlayer : ess.getServer().getOnlinePlayers())
{
User spyer = ess.getUser(player);
if (spyer.isSocialSpyEnabled() && !user.equals(spyer))
final User spyer = ess.getUser(onlinePlayer);
if (spyer.isSocialSpyEnabled() && !player.equals(onlinePlayer))
{
player.sendMessage(user.getDisplayName() + " : " + event.getMessage());
onlinePlayer.sendMessage(player.getDisplayName() + " : " + event.getMessage());
}
}
}
if (!cmd.equalsIgnoreCase("afk"))
else if (!cmd.equalsIgnoreCase("afk"))
{
final User user = ess.getUser(player);
user.updateActivity(true);
}
}
@@ -352,45 +337,126 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
{
if (ess.getSettings().getNoGodWorlds().contains(event.getPlayer().getLocation().getWorld().getName()))
final User user = ess.getUser(event.getPlayer());
final String newWorld = event.getPlayer().getLocation().getWorld().getName();
user.setDisplayNick();
updateCompass(user);
if (ess.getSettings().getNoGodWorlds().contains(newWorld) && user.isGodModeEnabledRaw())
{
User user = ess.getUser(event.getPlayer());
if (user.isGodModeEnabledRaw())
user.sendMessage(_("noGodWorldWarning"));
}
if (!event.getPlayer().getWorld().getName().equals(newWorld))
{
user.sendMessage(_("currentWorld", newWorld));
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerInteract(final PlayerInteractEvent event)
{
switch (event.getAction())
{
case RIGHT_CLICK_BLOCK:
if (!event.isCancelled() && event.getClickedBlock().getTypeId() == BED && ess.getSettings().getUpdateBedAtDaytime())
{
user.sendMessage(_("noGodWorldWarning"));
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()));
}
break;
case LEFT_CLICK_AIR:
case LEFT_CLICK_BLOCK:
if (event.getItem() != null && event.getItem().getTypeId() != AIR)
{
final User user = ess.getUser(event.getPlayer());
if (user.hasPowerTools() && user.arePowerToolsEnabled() && usePowertools(user, event.getItem().getTypeId()))
{
event.setCancelled(true);
}
}
break;
default:
break;
}
}
private boolean usePowertools(final User user, final int id)
{
final List<String> commandList = user.getPowertool(id);
if (commandList == null || commandList.isEmpty())
{
return false;
}
boolean used = false;
// We need to loop through each command and execute
for (final String command : commandList)
{
if (command.contains("{player}"))
{
continue;
}
else if (command.startsWith("c:"))
{
used = true;
user.chat(command.substring(2));
}
else
{
used = true;
ess.scheduleSyncDelayedTask(
new Runnable()
{
@Override
public void run()
{
user.getServer().dispatchCommand(user.getBase(), command);
}
});
}
}
return used;
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerPickupItem(final PlayerPickupItemEvent event)
{
if (ess.getSettings().getDisableItemPickupWhileAfk())
{
if (ess.getUser(event.getPlayer()).isAfk())
{
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onInventoryClickEvent(final InventoryClickEvent event)
{
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
{
final User user = ess.getUser(event.getWhoClicked());
final InventoryHolder invHolder = event.getView().getTopInventory().getHolder();
if (invHolder != null && invHolder instanceof HumanEntity)
{
final User invOwner = ess.getUser((HumanEntity)invHolder);
if (user.isInvSee() && (!user.isAuthorized("essentials.invsee.modify")
|| invOwner.isAuthorized("essentials.invsee.preventmodify")
|| !invOwner.isOnline()))
{
event.setCancelled(true);
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerInteract(final PlayerInteractEvent event)
public void onInventoryCloseEvent(final InventoryCloseEvent event)
{
if (event.isCancelled())
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
{
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
return;
}
if (ess.getSettings().getUpdateBedAtDaytime() && event.getClickedBlock().getType() == Material.BED_BLOCK)
{
event.getPlayer().setBedSpawnLocation(event.getClickedBlock().getLocation());
}
}
@EventHandler(priority = EventPriority.LOW)
public void onPlayerPickupItem(PlayerPickupItemEvent event)
{
if (event.isCancelled() || !ess.getSettings().getDisableItemPickupWhileAfk())
{
return;
}
final User user = ess.getUser(event.getPlayer());
if (user.isAfk())
{
event.setCancelled(true);
final User user = ess.getUser(event.getPlayer());
user.setInvSee(false);
}
}
}
@@ -24,7 +24,7 @@ public class EssentialsPluginListener implements Listener, IConf
ess.getAlternativeCommandsHandler().addPlugin(event.getPlugin());
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager()))
{
ess.getLogger().log(Level.INFO, "Payment method found (" + ess.getPaymentMethod().getMethod().getName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
ess.getLogger().log(Level.INFO, "Payment method found (" + ess.getPaymentMethod().getMethod().getLongName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
}
}
@@ -2,6 +2,7 @@ package com.earth2me.essentials;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Set;
import java.util.logging.Level;
import org.bukkit.entity.Player;
@@ -11,6 +12,8 @@ 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>();
EssentialsTimer(final IEssentials ess)
{
@@ -21,6 +24,21 @@ public class EssentialsTimer implements Runnable
public void run()
{
final long currentTime = System.currentTimeMillis();
long timeSpent = (currentTime - lastPoll) / 1000;
if (timeSpent == 0)
{
timeSpent = 1;
}
if (history.size() > 10)
{
history.remove();
}
float tps = 100f / timeSpent;
if (tps <= 20)
{
history.add(tps);
}
lastPoll = currentTime;
for (Player player : ess.getServer().getOnlinePlayers())
{
try
@@ -48,6 +66,20 @@ public class EssentialsTimer implements Runnable
}
user.checkMuteTimeout(currentTime);
user.checkJailTimeout(currentTime);
user.resetInvulnerabilityAfterTeleport();
}
}
public float getAverageTPS()
{
float avg = 0;
for (Float f : history)
{
if (f != null)
{
avg += f;
}
}
return avg / history.size();
}
}
@@ -95,7 +95,7 @@ public class EssentialsUpgrade
}
final EssentialsConf conf = new EssentialsConf(configFile);
conf.load();
List<String> lines = conf.getStringList(name, null);
List<String> lines = conf.getStringList(name);
if (lines != null && !lines.isEmpty())
{
if (!file.createNewFile())
@@ -271,18 +271,18 @@ public class EssentialsUpgrade
if (config.hasProperty("powertools"))
{
@SuppressWarnings("unchecked")
final Map<Integer, Object> powertools = (Map<Integer, Object>)config.getProperty("powertools");
final Map<String, Object> powertools = config.getConfigurationSection("powertools").getValues(false);
if (powertools == null)
{
continue;
}
for (Map.Entry<Integer, Object> entry : powertools.entrySet())
for (Map.Entry<String, Object> entry : powertools.entrySet())
{
if (entry.getValue() instanceof String)
{
List<String> temp = new ArrayList<String>();
temp.add((String)entry.getValue());
((Map<Integer, Object>)powertools).put(entry.getKey(), temp);
((Map<String, Object>)powertools).put(entry.getKey(), temp);
}
}
config.save();
@@ -332,7 +332,7 @@ public class EssentialsUpgrade
config.setProperty("homes.home", defloc);
}
List<String> worlds = config.getKeys("home.worlds");
Set<String> worlds = config.getConfigurationSection("home.worlds").getKeys(false);
Location loc;
String worldName;
@@ -381,7 +381,7 @@ public class EssentialsUpgrade
}
final EssentialsConf usersConfig = new EssentialsConf(usersFile);
usersConfig.load();
for (String username : usersConfig.getKeys(null))
for (String username : usersConfig.getKeys(false))
{
final User user = new User(new OfflinePlayer(username, ess), ess);
final String nickname = usersConfig.getString(username + ".nickname");
@@ -389,7 +389,7 @@ public class EssentialsUpgrade
{
user.setNickname(nickname);
}
final List<String> mails = usersConfig.getStringList(username + ".mail", null);
final List<String> mails = usersConfig.getStringList(username + ".mail");
if (mails != null && !mails.isEmpty())
{
user.setMails(mails);
@@ -701,7 +701,7 @@ public class EssentialsUpgrade
if (!config.hasProperty("spawns"))
{
final Spawns spawns = new Spawns();
List<String> keys = config.getKeys();
Set<String> keys = config.getKeys(false);
for (String group : keys)
{
Location loc = getFakeLocation(config, group);
@@ -730,7 +730,7 @@ public class EssentialsUpgrade
doneFile.setProperty("updateSpawnsToNewSpawnsConfig", true);
doneFile.save();
}
private void updateJailsToNewJailsConfig()
{
if (doneFile.getBoolean("updateJailsToNewJailsConfig", false))
@@ -748,7 +748,7 @@ public class EssentialsUpgrade
if (!config.hasProperty("jails"))
{
final com.earth2me.essentials.settings.Jails jails = new com.earth2me.essentials.settings.Jails();
List<String> keys = config.getKeys();
Set<String> keys = config.getKeys(false);
for (String jailName : keys)
{
Location loc = getFakeLocation(config, jailName);
@@ -778,6 +778,17 @@ public class EssentialsUpgrade
doneFile.save();
}
private void warnMetrics()
{
if (doneFile.getBoolean("warnMetrics", false))
{
return;
}
ess.getSettings().setMetricsEnabled(false);
doneFile.setProperty("warnMetrics", true);
doneFile.save();
}
public void beforeSettings()
{
if (!ess.getDataFolder().exists())
@@ -800,5 +811,6 @@ public class EssentialsUpgrade
deleteOldItemsCsv();
updateSpawnsToNewSpawnsConfig();
updateJailsToNewJailsConfig();
warnMetrics();
}
}
@@ -114,6 +114,7 @@ public class I18n implements II18n
{
currentLocale = new Locale(parts[0], parts[1], parts[2]);
}
ResourceBundle.clearCache();
Logger.getLogger("Minecraft").log(Level.INFO, String.format("Using locale %s", currentLocale.toString()));
customBundle = ResourceBundle.getBundle(MESSAGES, currentLocale, new FileResClassLoader(I18n.class.getClassLoader(), ess));
localeBundle = ResourceBundle.getBundle(MESSAGES, currentLocale);
@@ -1,14 +1,17 @@
package com.earth2me.essentials;
import com.earth2me.essentials.api.IJails;
import com.earth2me.essentials.metrics.Metrics;
import com.earth2me.essentials.perm.PermissionsHandler;
import com.earth2me.essentials.register.payment.Methods;
import java.util.List;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitScheduler;
/**
* @deprecated This will be moved to the api package soon
*/
@@ -64,4 +67,12 @@ public interface IEssentials extends Plugin
ItemDb getItemDb();
UserMap getUserMap();
Metrics getMetrics();
void setMetrics(Metrics metrics);
EssentialsTimer getTimer();
List<String> getVanishedPlayers();
}
@@ -2,11 +2,13 @@ package com.earth2me.essentials;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.signs.EssentialsSign;
import com.earth2me.essentials.textreader.IText;
import java.text.MessageFormat;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.EventPriority;
@@ -14,12 +16,12 @@ public interface ISettings extends IConf
{
boolean areSignsDisabled();
String format(String format, IUser user);
String getAnnounceNewPlayerFormat(IUser user);
IText getAnnounceNewPlayerFormat();
boolean getAnnounceNewPlayers();
String getNewPlayerKit();
String getBackupCommand();
long getBackupInterval();
@@ -35,14 +37,14 @@ public interface ISettings extends IConf
String getCurrencySymbol();
int getOversizedStackSize();
int getDefaultStackSize();
double getHealCooldown();
Object getKit(String name);
Map<String, Object> getKit(String name);
Map<String, Object> getKits();
ConfigurationSection getKits();
String getLocale();
@@ -66,7 +68,7 @@ public interface ISettings extends IConf
boolean getRespawnAtHome();
List getMultipleHomes();
Set getMultipleHomes();
int getHomeLimit(String set);
@@ -101,7 +103,7 @@ public interface ISettings extends IConf
boolean isTradeInStacks(int id);
List<Integer> itemSpawnBlacklist();
List<EssentialsSign> enabledSigns();
boolean permissionBasedItemSpawn();
@@ -116,12 +118,18 @@ public interface ISettings extends IConf
double getMaxMoney();
double getMinMoney();
boolean isEcoLogEnabled();
boolean isEcoLogUpdateEnabled();
boolean removeGodOnDisconnect();
boolean changeDisplayName();
boolean changePlayerListName();
boolean isPlayerCommand(String string);
boolean useBukkitPermissions();
@@ -138,23 +146,39 @@ public interface ISettings extends IConf
boolean getFreezeAfkPlayers();
boolean cancelAfkOnMove();
boolean areDeathMessagesEnabled();
public void setDebug(boolean debug);
Set<String> getNoGodWorlds();
boolean getUpdateBedAtDaytime();
boolean getRepairEnchanted();
boolean isWorldTeleportPermissions();
boolean getIsWorldTeleportPermissions();
boolean isWorldHomePermissions();
boolean registerBackInListener();
boolean getDisableItemPickupWhileAfk();
EventPriority getRespawnPriority();
long getTpaAcceptCancellation();
boolean isMetricsEnabled();
void setMetricsEnabled(boolean metricsEnabled);
long getTeleportInvulnerability();
boolean isTeleportInvulnerability();
long getLoginAttackDelay();
int getSignUsePerSecond();
}
@@ -1,10 +1,8 @@
package com.earth2me.essentials;
import com.earth2me.essentials.commands.IEssentialsCommand;
import java.net.InetSocketAddress;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.PlayerInventory;
/**
@@ -32,6 +30,8 @@ public interface IUser extends Player
void takeMoney(double value);
void giveMoney(double value);
boolean canAfford(double value);
String getGroup();
@@ -9,12 +9,16 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
@@ -26,21 +30,20 @@ import org.bukkit.plugin.PluginManager;
public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.settings.Jails> implements IJails
{
private static final transient Logger LOGGER = Bukkit.getLogger();
private static transient boolean enabled = false;
public Jails(final IEssentials ess)
{
super(ess, com.earth2me.essentials.settings.Jails.class);
reloadConfig();
registerListeners();
}
private void registerListeners()
{
enabled = true;
final PluginManager pluginManager = ess.getServer().getPluginManager();
final JailBlockListener blockListener = new JailBlockListener();
final JailPlayerListener playerListener = new JailPlayerListener();
final JailListener blockListener = new JailListener();
pluginManager.registerEvents(blockListener, ess);
pluginManager.registerEvents(playerListener, ess);
}
@Override
@@ -49,6 +52,24 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
return new File(ess.getDataFolder(), "jail.yml");
}
@Override
public void finishRead()
{
if (enabled == false && getCount() > 0)
{
registerListeners();
}
}
@Override
public void finishWrite()
{
if (enabled == false)
{
registerListeners();
}
}
@Override
public Location getJail(final String jailName) throws Exception
{
@@ -115,7 +136,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
acquireReadLock();
try
{
if (!(user.getBase() instanceof OfflinePlayer))
if (user.isOnline())
{
Location loc = getJail(jail);
user.getTeleport().now(loc, false, TeleportCause.COMMAND);
@@ -146,10 +167,23 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
}
private class JailBlockListener implements Listener
@Override
public int getCount()
{
@EventHandler(priority = EventPriority.LOW)
try
{
return getList().size();
}
catch (Exception ex)
{
return 0;
}
}
private class JailListener implements Listener
{
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent event)
{
final User user = ess.getUser(event.getPlayer());
@@ -159,7 +193,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
}
@EventHandler(priority = EventPriority.LOW)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockPlace(final BlockPlaceEvent event)
{
final User user = ess.getUser(event.getPlayer());
@@ -169,7 +203,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
}
@EventHandler(priority = EventPriority.LOW)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockDamage(final BlockDamageEvent event)
{
final User user = ess.getUser(event.getPlayer());
@@ -178,12 +212,26 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityDamageByEntity(final EntityDamageByEntityEvent event)
{
if (event.getCause() != DamageCause.ENTITY_ATTACK || event.getEntity().getType() != EntityType.PLAYER)
{
return;
}
final Entity damager = event.getDamager();
if (damager.getType() == EntityType.PLAYER)
{
final User user = ess.getUser(damager);
if (user != null && user.isJailed())
{
event.setCancelled(true);
}
}
}
private class JailPlayerListener implements Listener
{
@EventHandler(priority = EventPriority.LOW)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerInteract(final PlayerInteractEvent event)
{
final User user = ess.getUser(event.getPlayer());
@@ -193,7 +241,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
}
@EventHandler(priority = EventPriority.HIGH)
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerRespawn(final PlayerRespawnEvent event)
{
final User user = ess.getUser(event.getPlayer());
@@ -246,7 +294,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
user.sendMessage(_("jailMessage"));
}
@EventHandler(priority = EventPriority.HIGH)
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerJoin(final PlayerJoinEvent event)
{
final User user = ess.getUser(event.getPlayer());
+92 -29
View File
@@ -1,10 +1,14 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import static com.earth2me.essentials.I18n.capitalCase;
import com.earth2me.essentials.commands.NoChargeException;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import java.util.*;
import java.util.logging.Level;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
@@ -15,60 +19,74 @@ public class Kit
{
try
{
final Map<String, Object> kits = ess.getSettings().getKits();
final ConfigurationSection kits = ess.getSettings().getKits();
final StringBuilder list = new StringBuilder();
for (String kiteItem : kits.keySet())
for (String kiteItem : kits.getKeys(false))
{
if (user.isAuthorized("essentials.kit." + kiteItem.toLowerCase(Locale.ENGLISH)))
if (user == null || user.isAuthorized("essentials.kit." + kiteItem.toLowerCase(Locale.ENGLISH)))
{
list.append(" ").append(kiteItem);
list.append(" ").append(capitalCase(kiteItem));
}
}
return list.toString();
return list.toString().trim();
}
catch (Exception ex)
{
throw new Exception(_("kitError"));
throw new Exception(_("kitError"), ex);
}
}
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws NoChargeException
{
final Calendar time = new GregorianCalendar();
// Take the current time, and remove the delay from it.
final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L;
final Calendar c = new GregorianCalendar();
c.add(Calendar.SECOND, -(int)delay);
c.add(Calendar.MILLISECOND, -(int)((delay * 1000.0) % 1000.0));
final long mintime = c.getTimeInMillis();
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 == null || lastTime < mintime)
if (lastTime == null || lastTime < earliestLong)
{
final Calendar now = new GregorianCalendar();
user.setKitTimestamp(kitName, now.getTimeInMillis());
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
{
final Calendar future = new GregorianCalendar();
future.setTimeInMillis(lastTime);
future.add(Calendar.SECOND, (int)delay);
future.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
user.sendMessage(_("kitTimed", Util.formatDateDiff(future.getTimeInMillis())));
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())));
throw new NoChargeException();
}
}
public static List<String> getItems(final User user, final Map<String, Object> els) throws Exception
public static List<String> getItems(final User user, final Map<String, Object> kit) throws Exception
{
if (kit == null)
{
throw new Exception(_("kitError2"));
}
try
{
return (List<String>)els.get("items");
return (List<String>)kit.get("items");
}
catch (Exception e)
{
user.sendMessage(_("kitError2"));
throw new Exception(_("kitErrorHelp"));
throw new Exception(_("kitErrorHelp"), e);
}
}
@@ -79,18 +97,55 @@ public class Kit
boolean spew = false;
for (String d : items)
{
final String[] parts = d.split("[^0-9]+", 3);
final int id = Material.getMaterial(Integer.parseInt(parts[0])).getId();
final int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1;
final short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0;
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);
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);
}
}
}
final Map<Integer, ItemStack> overfilled;
if (user.isAuthorized("essentials.oversizedstacks"))
{
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), new ItemStack(id, amount, data));
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
}
else
{
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, new ItemStack(id, amount, data));
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, 0, stack);
}
for (ItemStack itemStack : overfilled.values())
{
@@ -107,7 +162,15 @@ public class Kit
catch (Exception e)
{
user.updateInventory();
throw new Exception(_("kitError2"));
if (ess.getSettings().isDebug())
{
ess.getLogger().log(Level.WARNING, e.getMessage());
}
else
{
ess.getLogger().log(Level.WARNING, e.getMessage());
}
throw new Exception(_("kitError2"), e);
}
}
}
+32 -29
View File
@@ -1,6 +1,7 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@@ -9,40 +10,42 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public enum Mob
{
CHICKEN("Chicken", Enemies.FRIENDLY, CreatureType.CHICKEN),
COW("Cow", Enemies.FRIENDLY, CreatureType.COW),
CREEPER("Creeper", Enemies.ENEMY, CreatureType.CREEPER),
GHAST("Ghast", Enemies.ENEMY, CreatureType.GHAST),
GIANT("Giant", Enemies.ENEMY, CreatureType.GIANT),
PIG("Pig", Enemies.FRIENDLY, CreatureType.PIG),
PIGZOMB("PigZombie", Enemies.NEUTRAL, CreatureType.PIG_ZOMBIE),
SHEEP("Sheep", Enemies.FRIENDLY, "", CreatureType.SHEEP),
SKELETON("Skeleton", Enemies.ENEMY, CreatureType.SKELETON),
SLIME("Slime", Enemies.ENEMY, CreatureType.SLIME),
SPIDER("Spider", Enemies.ENEMY, CreatureType.SPIDER),
SQUID("Squid", Enemies.FRIENDLY, CreatureType.SQUID),
ZOMBIE("Zombie", Enemies.ENEMY, CreatureType.ZOMBIE),
WOLF("Wolf", Enemies.NEUTRAL, CreatureType.WOLF),
CAVESPIDER("CaveSpider", Enemies.ENEMY, CreatureType.CAVE_SPIDER),
ENDERMAN("Enderman", Enemies.ENEMY, "", CreatureType.ENDERMAN),
SILVERFISH("Silverfish", Enemies.ENEMY, "", CreatureType.SILVERFISH),
ENDERDRAGON("EnderDragon", Enemies.ENEMY, CreatureType.ENDER_DRAGON),
VILLAGER("Villager", Enemies.FRIENDLY, CreatureType.VILLAGER),
BLAZE("Blaze", Enemies.ENEMY, CreatureType.BLAZE),
MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, CreatureType.MUSHROOM_COW),
MAGMACUBE("MagmaCube", Enemies.ENEMY, CreatureType.MAGMA_CUBE),
SNOWMAN("Snowman", Enemies.FRIENDLY, "", CreatureType.SNOWMAN);
CHICKEN("Chicken", Enemies.FRIENDLY, EntityType.CHICKEN),
COW("Cow", Enemies.FRIENDLY, EntityType.COW),
CREEPER("Creeper", Enemies.ENEMY, EntityType.CREEPER),
GHAST("Ghast", Enemies.ENEMY, EntityType.GHAST),
GIANT("Giant", Enemies.ENEMY, EntityType.GIANT),
PIG("Pig", Enemies.FRIENDLY, EntityType.PIG),
PIGZOMB("PigZombie", Enemies.NEUTRAL, EntityType.PIG_ZOMBIE),
SHEEP("Sheep", Enemies.FRIENDLY, "", EntityType.SHEEP),
SKELETON("Skeleton", Enemies.ENEMY, EntityType.SKELETON),
SLIME("Slime", Enemies.ENEMY, EntityType.SLIME),
SPIDER("Spider", Enemies.ENEMY, EntityType.SPIDER),
SQUID("Squid", Enemies.FRIENDLY, EntityType.SQUID),
ZOMBIE("Zombie", Enemies.ENEMY, EntityType.ZOMBIE),
WOLF("Wolf", Enemies.NEUTRAL, EntityType.WOLF),
CAVESPIDER("CaveSpider", Enemies.ENEMY, EntityType.CAVE_SPIDER),
ENDERMAN("Enderman", Enemies.ENEMY, "", EntityType.ENDERMAN),
SILVERFISH("Silverfish", Enemies.ENEMY, "", EntityType.SILVERFISH),
ENDERDRAGON("EnderDragon", Enemies.ENEMY, EntityType.ENDER_DRAGON),
VILLAGER("Villager", Enemies.FRIENDLY, EntityType.VILLAGER),
BLAZE("Blaze", Enemies.ENEMY, EntityType.BLAZE),
MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, EntityType.MUSHROOM_COW),
MAGMACUBE("MagmaCube", Enemies.ENEMY, EntityType.MAGMA_CUBE),
SNOWMAN("Snowman", Enemies.FRIENDLY, "", EntityType.SNOWMAN),
OCELOT("Ocelot", Enemies.NEUTRAL, EntityType.OCELOT),
IRONGOLEM("IronGolem", Enemies.NEUTRAL, EntityType.IRON_GOLEM);
public static final Logger logger = Logger.getLogger("Minecraft");
private Mob(String n, Enemies en, String s, CreatureType type)
private Mob(String n, Enemies en, String s, EntityType type)
{
this.suffix = s;
this.name = n;
@@ -50,7 +53,7 @@ public enum Mob
this.bukkitType = type;
}
private Mob(String n, Enemies en, CreatureType type)
private Mob(String n, Enemies en, EntityType type)
{
this.name = n;
this.type = en;
@@ -59,7 +62,7 @@ public enum Mob
public String suffix = "s";
final public String name;
final public Enemies type;
final private CreatureType bukkitType;
final private EntityType bukkitType;
private static final Map<String, Mob> hashMap = new HashMap<String, Mob>();
static
@@ -71,7 +74,7 @@ public enum Mob
}
public static Set<String> getMobList() {
return hashMap.keySet();
return Collections.unmodifiableSet(hashMap.keySet());
}
public LivingEntity spawn(final Player player, final Server server, final Location loc) throws MobException
@@ -99,7 +102,7 @@ public enum Mob
final protected String type;
}
public CreatureType getType()
public EntityType getType()
{
return bukkitType;
}
@@ -1,25 +1,31 @@
package com.earth2me.essentials;
import com.earth2me.essentials.craftbukkit.OfflineBedLocation;
import static com.earth2me.essentials.I18n._;
import java.net.InetSocketAddress;
import java.util.*;
import lombok.Delegate;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.conversations.Conversation;
import org.bukkit.conversations.ConversationAbandonedEvent;
import org.bukkit.entity.*;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.InventoryView.Property;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.map.MapView;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
public class OfflinePlayer implements Player
{
private final transient IEssentials ess;
@@ -170,11 +176,6 @@ public class OfflinePlayer implements Player
return false;
}
public boolean isPlayer()
{
return false;
}
@Override
public int getRemainingAir()
{
@@ -664,18 +665,6 @@ public class OfflinePlayer implements Player
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getExperience()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setExperience(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getLevel()
{
@@ -857,4 +846,209 @@ public class OfflinePlayer implements Player
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void hidePlayer(Player player)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void showPlayer(Player player)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean canSee(Player player)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean addPotionEffect(PotionEffect pe)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean addPotionEffect(PotionEffect pe, boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean addPotionEffects(Collection<PotionEffect> clctn)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean hasPotionEffect(PotionEffectType pet)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void removePotionEffect(PotionEffectType pet)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Collection<PotionEffect> getActivePotionEffects()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T extends Projectile> T launchProjectile(Class<? extends T> arg0)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public EntityType getType()
{
return EntityType.PLAYER;
}
@Override
public <T> void playEffect(Location lctn, Effect effect, T t)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean setWindowProperty(Property prprt, int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public InventoryView getOpenInventory()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public InventoryView openInventory(Inventory invntr)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public InventoryView openWorkbench(Location lctn, boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public InventoryView openEnchanting(Location lctn, boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void openInventory(InventoryView iv)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void closeInventory()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ItemStack getItemOnCursor()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setItemOnCursor(ItemStack is)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setMetadata(String string, MetadataValue mv)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<MetadataValue> getMetadata(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean hasMetadata(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void removeMetadata(String string, Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isConversing()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void acceptConversationInput(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean beginConversation(Conversation c)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void abandonConversation(Conversation c)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void sendMessage(String[] strings)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isBlocking()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void abandonConversation(Conversation arg0, ConversationAbandonedEvent arg1)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isFlying()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setFlying(boolean arg0)
{
throw new UnsupportedOperationException("Not supported yet.");
}
}
@@ -4,12 +4,16 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.signs.EssentialsSign;
import com.earth2me.essentials.signs.Signs;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.SimpleTextInput;
import java.io.File;
import java.text.MessageFormat;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.MemoryConfiguration;
import org.bukkit.event.EventPriority;
import org.bukkit.inventory.ItemStack;
@@ -19,6 +23,7 @@ public class Settings implements ISettings
private final transient EssentialsConf config;
private final static Logger logger = Logger.getLogger("Minecraft");
private final transient IEssentials ess;
private boolean metricsEnabled = true;
public Settings(IEssentials ess)
{
@@ -41,15 +46,15 @@ public class Settings implements ISettings
}
@Override
public List<String> getMultipleHomes()
public Set<String> getMultipleHomes()
{
return config.getKeys("sethome-multiple");
return config.getConfigurationSection("sethome-multiple").getKeys(false);
}
@Override
public int getHomeLimit(final User user)
{
final List<String> homeList = getMultipleHomes();
final Set<String> homeList = getMultipleHomes();
if (homeList == null)
{
//TODO: Replace this code to remove backwards compat, after settings are automatically updated
@@ -112,7 +117,7 @@ public class Settings implements ISettings
@Override
public boolean isCommandDisabled(String label)
{
for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0)))
for (String c : config.getStringList("disabled-commands"))
{
if (!c.equalsIgnoreCase(label))
{
@@ -132,7 +137,7 @@ public class Settings implements ISettings
@Override
public boolean isCommandRestricted(String label)
{
for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0)))
for (String c : config.getStringList("restricted-commands"))
{
if (!c.equalsIgnoreCase(label))
{
@@ -146,7 +151,7 @@ public class Settings implements ISettings
@Override
public boolean isPlayerCommand(String label)
{
for (String c : config.getStringList("player-commands", new ArrayList<String>(0)))
for (String c : config.getStringList("player-commands"))
{
if (!c.equalsIgnoreCase(label))
{
@@ -160,9 +165,7 @@ public class Settings implements ISettings
@Override
public boolean isCommandOverridden(String name)
{
List<String> defaultList = new ArrayList<String>(1);
defaultList.add("god");
for (String c : config.getStringList("overridden-commands", defaultList))
for (String c : config.getStringList("overridden-commands"))
{
if (!c.equalsIgnoreCase(name))
{
@@ -207,25 +210,45 @@ public class Settings implements ISettings
{
return config.getDouble("heal-cooldown", 0);
}
private ConfigurationSection kits;
@Override
public Object getKit(String name)
public ConfigurationSection _getKits()
{
Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits");
for (Map.Entry<String, Object> entry : kits.entrySet())
if (config.isConfigurationSection("kits"))
{
if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_')))
final ConfigurationSection section = config.getConfigurationSection("kits");
final ConfigurationSection newSection = new MemoryConfiguration();
for (String kitItem : section.getKeys(false))
{
return entry.getValue();
if (section.isConfigurationSection(kitItem))
{
newSection.set(kitItem.toLowerCase(Locale.ENGLISH), section.getConfigurationSection(kitItem));
}
}
return newSection;
}
return null;
}
@Override
public Map<String, Object> getKits()
public ConfigurationSection getKits()
{
return (Map<String, Object>)config.getProperty("kits");
return kits;
}
@Override
public Map<String, Object> getKit(String name)
{
name = name.replace('.', '_').replace('/', '_');
if (config.isConfigurationSection("kits"))
{
final ConfigurationSection kits = getKits();
if (kits.isConfigurationSection(name))
{
return kits.getConfigurationSection(name).getValues(true);
}
}
return null;
}
@Override
@@ -250,7 +273,7 @@ public class Settings implements ISettings
{
}
return ChatColor.getByCode(Integer.parseInt(colorName, 16));
return ChatColor.getByChar(colorName);
}
@Override
@@ -280,7 +303,7 @@ public class Settings implements ISettings
@Override
public boolean areSignsDisabled()
{
return enabledSigns.isEmpty();
return !signsEnabled;
}
@Override
@@ -304,13 +327,13 @@ public class Settings implements ISettings
{
String format = config.getString("chat.group-formats." + (group == null ? "Default" : group),
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
format = Util.replaceColor(format);
format = Util.replaceFormat(format);
format = format.replace("{DISPLAYNAME}", "%1$s");
format = format.replace("{GROUP}", "{0}");
format = format.replace("{MESSAGE}", "%2$s");
format = format.replace("{WORLDNAME}", "{1}");
format = format.replace("{SHORTWORLDNAME}", "{2}");
format = format.replaceAll("\\{(\\D*)\\}", "\\[$1\\]");
format = format.replaceAll("\\{(\\D*?)\\}", "\\[$1\\]");
mFormat = new MessageFormat(format);
chatFormats.put(group, mFormat);
}
@@ -324,15 +347,15 @@ public class Settings implements ISettings
}
@Override
public String getAnnounceNewPlayerFormat(IUser user)
public IText getAnnounceNewPlayerFormat()
{
return format(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!"), user);
return new SimpleTextInput(Util.replaceFormat(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")));
}
@Override
public String format(String format, IUser user)
public String getNewPlayerKit()
{
return format.replace('&', '§').replace("§§", "&").replace("{PLAYER}", user.getDisplayName()).replace("{DISPLAYNAME}", user.getDisplayName()).replace("{GROUP}", user.getGroup()).replace("{USERNAME}", user.getName()).replace("{ADDRESS}", user.getAddress().toString());
return config.getString("newbies.kit", "");
}
@Override
@@ -357,24 +380,32 @@ public class Settings implements ISettings
public void reloadConfig()
{
config.load();
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds", Collections.<String>emptyList()));
enabledSigns = getEnabledSigns();
itemSpawnBl = getItemSpawnBlacklist();
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds"));
enabledSigns = _getEnabledSigns();
teleportInvulnerability = _isTeleportInvulnerability();
disableItemPickupWhileAfk = _getDisableItemPickupWhileAfk();
registerBackInListener = _registerBackInListener();
cancelAfkOnMove = _cancelAfkOnMove();
getFreezeAfkPlayers = _getFreezeAfkPlayers();
itemSpawnBl = _getItemSpawnBlacklist();
loginAttackDelay = _getLoginAttackDelay();
signUsePerSecond = _getSignUsePerSecond();
kits = _getKits();
chatFormats.clear();
}
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
@Override
public List<Integer> itemSpawnBlacklist()
{
return itemSpawnBl;
}
private List<Integer> getItemSpawnBlacklist()
private List<Integer> _getItemSpawnBlacklist()
{
final List<Integer> epItemSpwn = new ArrayList<Integer>();
if (ess.getItemDb() == null) {
if (ess.getItemDb() == null)
{
logger.log(Level.FINE, "Aborting ItemSpawnBL read, itemDB not yet loaded.");
return epItemSpwn;
}
@@ -384,7 +415,7 @@ public class Settings implements ISettings
if (itemName.isEmpty())
{
continue;
}
}
try
{
final ItemStack iStack = ess.getItemDb().get(itemName);
@@ -397,26 +428,31 @@ public class Settings implements ISettings
}
return epItemSpwn;
}
private List<EssentialsSign> enabledSigns = new ArrayList<EssentialsSign>();
private boolean signsEnabled = false;
@Override
public List<EssentialsSign> enabledSigns()
{
return enabledSigns;
}
private List<EssentialsSign> getEnabledSigns()
private List<EssentialsSign> _getEnabledSigns()
{
List<EssentialsSign> newSigns = new ArrayList<EssentialsSign>();
for (String signName : config.getStringList("enabledSigns", null))
for (String signName : config.getStringList("enabledSigns"))
{
signName = signName.trim().toUpperCase(Locale.ENGLISH);
if (signName.isEmpty())
{
continue;
}
if (signName.equals("COLOR") || signName.equals("COLOUR"))
{
signsEnabled = true;
continue;
}
try
{
newSigns.add(Signs.valueOf(signName).getSign());
@@ -424,7 +460,9 @@ public class Settings implements ISettings
catch (Exception ex)
{
logger.log(Level.SEVERE, _("unknownItemInList", signName, "enabledSigns"));
continue;
}
signsEnabled = true;
}
return newSigns;
}
@@ -538,6 +576,22 @@ public class Settings implements ISettings
}
return max;
}
private final static double MINMONEY = -10000000000000.0;
@Override
public double getMinMoney()
{
double min = config.getDouble("min-money", MINMONEY);
if (min > 0)
{
min = -min;
}
if (min < MINMONEY)
{
min = MINMONEY;
}
return min;
}
@Override
public boolean isEcoLogEnabled()
@@ -545,6 +599,12 @@ public class Settings implements ISettings
return config.getBoolean("economy-log-enabled", false);
}
@Override
public boolean isEcoLogUpdateEnabled()
{
return config.getBoolean("economy-log-update-enabled", false);
}
@Override
public boolean removeGodOnDisconnect()
{
@@ -557,6 +617,12 @@ public class Settings implements ISettings
return config.getBoolean("change-displayname", true);
}
@Override
public boolean changePlayerListName()
{
return config.getBoolean("change-playerlist", false);
}
@Override
public boolean useBukkitPermissions()
{
@@ -592,19 +658,36 @@ public class Settings implements ISettings
{
return config.getLong("auto-afk-kick", -1);
}
private boolean getFreezeAfkPlayers;
@Override
public boolean getFreezeAfkPlayers()
{
return getFreezeAfkPlayers;
}
private boolean _getFreezeAfkPlayers()
{
return config.getBoolean("freeze-afk-players", false);
}
private boolean cancelAfkOnMove;
@Override
public boolean cancelAfkOnMove()
{
return cancelAfkOnMove;
}
private boolean _cancelAfkOnMove()
{
return config.getBoolean("cancel-afk-on-move", true);
}
@Override
public boolean areDeathMessagesEnabled()
{
return config.getBoolean("death-messages", true);
}
private Set<String> noGodWorlds = new HashSet<String>();
@Override
@@ -626,21 +709,39 @@ public class Settings implements ISettings
}
@Override
public boolean getIsWorldTeleportPermissions()
public boolean isWorldTeleportPermissions()
{
return config.getBoolean("world-teleport-permissions", false);
}
@Override
public boolean isWorldHomePermissions()
{
return config.getBoolean("world-home-permissions", false);
}
private boolean registerBackInListener;
@Override
public boolean registerBackInListener()
{
return registerBackInListener;
}
private boolean _registerBackInListener()
{
return config.getBoolean("register-back-in-listener", false);
}
private boolean disableItemPickupWhileAfk;
@Override
public boolean getDisableItemPickupWhileAfk()
{
return config.getBoolean("disable-item-pickup-while-afk", true);
return disableItemPickupWhileAfk;
}
private boolean _getDisableItemPickupWhileAfk()
{
return config.getBoolean("disable-item-pickup-while-afk", false);
}
@Override
@@ -675,4 +776,62 @@ public class Settings implements ISettings
{
return config.getLong("tpa-accept-cancellation", 0);
}
@Override
public boolean isMetricsEnabled()
{
return metricsEnabled;
}
@Override
public void setMetricsEnabled(boolean metricsEnabled)
{
this.metricsEnabled = metricsEnabled;
}
private boolean teleportInvulnerability;
@Override
public long getTeleportInvulnerability()
{
return config.getLong("teleport-invulnerability", 0) * 1000;
}
private boolean _isTeleportInvulnerability()
{
return (config.getLong("teleport-invulnerability", 0) > 0);
}
@Override
public boolean isTeleportInvulnerability()
{
return teleportInvulnerability;
}
private long loginAttackDelay;
private long _getLoginAttackDelay()
{
return config.getLong("login-attack-delay", 0) * 1000;
}
@Override
public long getLoginAttackDelay()
{
return loginAttackDelay;
}
private int signUsePerSecond;
private int _getSignUsePerSecond()
{
final int perSec = config.getInt("sign-use-per-second", 4);
return perSec > 0 ? perSec : 1;
}
@Override
public int getSignUsePerSecond()
{
return signUsePerSecond;
}
}
@@ -1,6 +1,5 @@
package com.earth2me.essentials;
import com.earth2me.essentials.craftbukkit.FakeExplosion;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -46,8 +45,12 @@ public class TNTExplodeListener implements Listener, Runnable
{
return;
}
FakeExplosion.createExplosion(event, ess.getServer(), ess.getServer().getOnlinePlayers());
if (event.blockList().size() < 1)
{
return;
}
event.setCancelled(true);
event.getLocation().getWorld().createExplosion(event.getLocation(), 0F);
}
@Override
@@ -2,7 +2,6 @@ package com.earth2me.essentials;
import com.earth2me.essentials.api.ITeleport;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.logging.Logger;
@@ -146,23 +145,39 @@ public class Teleport implements Runnable, ITeleport
public void cooldown(boolean check) throws Exception
{
Calendar now = new GregorianCalendar();
final Calendar time = new GregorianCalendar();
if (user.getLastTeleportTimestamp() > 0)
{
double cooldown = ess.getSettings().getTeleportCooldown();
Calendar cooldownTime = new GregorianCalendar();
cooldownTime.setTimeInMillis(user.getLastTeleportTimestamp());
cooldownTime.add(Calendar.SECOND, (int)cooldown);
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
if (cooldownTime.after(now) && !user.isAuthorized("essentials.teleport.cooldown.bypass"))
// 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.
final long earliestLong = earliestTime.getTimeInMillis();
// When was the last teleport used?
final Long lastTime = user.getLastTeleportTimestamp();
if (lastTime > time.getTimeInMillis())
{
throw new Exception(_("timeBeforeTeleport", Util.formatDateDiff(cooldownTime.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.setLastTeleportTimestamp(time.getTimeInMillis());
return;
}
else if (lastTime > earliestLong && !user.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())));
}
}
// if justCheck is set, don't update lastTeleport; we're just checking
if (!check)
{
user.setLastTeleportTimestamp(now.getTimeInMillis());
user.setLastTeleportTimestamp(time.getTimeInMillis());
}
}
@@ -190,7 +205,7 @@ public class Teleport implements Runnable, ITeleport
{
cancel(false);
}
public void teleport(Location loc, Trade chargeFor) throws Exception
{
teleport(new Target(loc), chargeFor, TeleportCause.PLUGIN);
@@ -278,13 +293,8 @@ public class Teleport implements Runnable, ITeleport
now(new Target(user.getLastLocation()), TeleportCause.COMMAND);
}
public void home(IUser user, String home, Trade chargeFor) throws Exception
public void home(Location loc, Trade chargeFor) throws Exception
{
final Location loc = user.getHome(home);
if (loc == null)
{
throw new NotEnoughArgumentsException();
}
teleport(new Target(loc), chargeFor, TeleportCause.COMMAND);
}
}
@@ -13,12 +13,14 @@ import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;
public class Trade
{
private final transient String command;
private final transient String fallbackCommand;
private final transient Double money;
private final transient ItemStack itemStack;
private final transient Integer exp;
@@ -26,27 +28,33 @@ public class Trade
public Trade(final String command, final IEssentials ess)
{
this(command, null, null, null, ess);
this(command, null, null, null, null, ess);
}
public Trade(final String command, final String fallback, final IEssentials ess)
{
this(command, fallback, null, null, null, ess);
}
public Trade(final double money, final IEssentials ess)
{
this(null, money, null, null, ess);
this(null, null, money, null, null, ess);
}
public Trade(final ItemStack items, final IEssentials ess)
{
this(null, null, items, null, ess);
}
public Trade(final int exp, final IEssentials ess)
{
this(null, null, null, exp, ess);
this(null, null, null, items, null, ess);
}
private Trade(final String command, final Double money, final ItemStack item, final Integer exp, final IEssentials ess)
public Trade(final int exp, final IEssentials ess)
{
this(null, null, null, null, exp, ess);
}
private Trade(final String command, final String fallback, final Double money, final ItemStack item, final Integer exp, final IEssentials ess)
{
this.command = command;
this.fallbackCommand = fallback;
this.money = money;
this.itemStack = item;
this.exp = exp;
@@ -55,11 +63,9 @@ public class Trade
public void isAffordableFor(final IUser user) throws ChargeException
{
final double mon = user.getMoney();
if (getMoney() != null
&& mon < getMoney()
&& getMoney() > 0
&& !user.isAuthorized("essentials.eco.loan"))
&& !user.canAfford(getMoney()))
{
throw new ChargeException(_("notEnoughMoney"));
}
@@ -70,18 +76,17 @@ public class Trade
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
}
double money;
if (command != null && !command.isEmpty()
&& !user.isAuthorized("essentials.nocommandcost.all")
&& !user.isAuthorized("essentials.nocommandcost." + command)
&& mon < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
&& 0 < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
&& !user.isAuthorized("essentials.eco.loan"))
&& 0 < (money = getCommandCost(user))
&& !user.canAfford(money))
{
throw new ChargeException(_("notEnoughMoney"));
}
if (exp != null && exp > 0
&& SetExpFix.getTotalExperience(user) < exp) {
if (exp != null && exp > 0
&& SetExpFix.getTotalExperience(user) < exp)
{
throw new ChargeException(_("notEnoughExperience"));
}
}
@@ -103,9 +108,25 @@ public class Trade
if (dropItems)
{
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
final Location loc = user.getLocation();
for (ItemStack itemStack : leftOver.values())
{
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
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++)
{
final ItemStack stack = itemStack.clone();
stack.setAmount(maxStackSize);
itemStacks[i] = loc.getWorld().dropItem(loc, stack);
}
if (leftover > 0)
{
final ItemStack stack = itemStack.clone();
stack.setAmount(leftover);
itemStacks[stacks] = loc.getWorld().dropItem(loc, stack);
}
}
}
else
@@ -125,8 +146,7 @@ public class Trade
{
if (getMoney() != null)
{
final double mon = user.getMoney();
if (mon < getMoney() && getMoney() > 0 && !user.isAuthorized("essentials.eco.loan"))
if (!user.canAfford(getMoney()) && getMoney() > 0)
{
throw new ChargeException(_("notEnoughMoney"));
}
@@ -141,13 +161,10 @@ public class Trade
InventoryWorkaround.removeItem(user.getInventory(), true, true, getItemStack());
user.updateInventory();
}
if (command != null && !command.isEmpty()
&& !user.isAuthorized("essentials.nocommandcost.all")
&& !user.isAuthorized("essentials.nocommandcost." + command))
if (command != null)
{
final double mon = user.getMoney();
final double cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
if (mon < cost && cost > 0 && !user.isAuthorized("essentials.eco.loan"))
final double cost = getCommandCost(user);
if (!user.canAfford(cost) && cost > 0)
{
throw new ChargeException(_("notEnoughMoney"));
}
@@ -173,16 +190,33 @@ public class Trade
{
return itemStack;
}
public Integer getExperience()
{
return exp;
}
public Double getCommandCost(final IUser user)
{
double cost = 0d;
if (command != null && !command.isEmpty()
&& !user.isAuthorized("essentials.nocommandcost.all")
&& !user.isAuthorized("essentials.nocommandcost." + command))
{
cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
if (cost == 0.0 && fallbackCommand != null && !fallbackCommand.isEmpty())
{
cost = ess.getSettings().getCommandCost(fallbackCommand.charAt(0) == '/' ? fallbackCommand.substring(1) : fallbackCommand);
}
}
return cost;
}
private static FileWriter fw = null;
public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess)
{
if (!ess.getSettings().isEcoLogEnabled())
if ((loc == null && !ess.getSettings().isEcoLogUpdateEnabled())
|| (loc != null && !ess.getSettings().isEcoLogEnabled()))
{
return;
}
+197 -62
View File
@@ -7,7 +7,6 @@ import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -18,12 +17,15 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
private CommandSender replyTo = null;
private transient User teleportRequester;
private transient boolean teleportRequestHere;
private transient boolean vanished;
private transient final Teleport teleport;
private transient long teleportRequestTime;
private transient long lastOnlineActivity;
private transient long lastThrottledAction;
private transient long lastActivity = System.currentTimeMillis();
private boolean hidden = false;
private transient Location afkPosition = null;
private boolean invSee = false;
private static final Logger logger = Logger.getLogger("Minecraft");
User(final Player base, final IEssentials ess)
@@ -57,6 +59,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
@Override
public boolean isAuthorized(final String node)
{
if (ess.getSettings().isDebug())
{
ess.getLogger().log(Level.INFO, "checking if " + base.getName() + " has " + node);
}
if (base instanceof OfflinePlayer)
{
return false;
@@ -72,7 +78,15 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return false;
}
return ess.getPermissionsHandler().hasPermission(base, node);
try
{
return ess.getPermissionsHandler().hasPermission(base, node);
}
catch (Exception ex)
{
ess.getLogger().log(Level.SEVERE, "Permission System Error: " + ess.getPermissionsHandler().getName() + " returned: " + ex.getMessage());
return false;
}
}
public void healCooldown() throws Exception
@@ -106,10 +120,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return;
}
setMoney(getMoney() + value);
sendMessage(_("addedToAccount", Util.formatCurrency(value, ess)));
sendMessage(_("addedToAccount", Util.displayCurrency(value, ess)));
if (initiator != null)
{
initiator.sendMessage(_("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
initiator.sendMessage(_("addedToOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
}
}
@@ -123,8 +137,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
setMoney(getMoney() - value);
reciever.setMoney(reciever.getMoney() + value);
sendMessage(_("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
reciever.sendMessage(_("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
sendMessage(_("moneySentTo", Util.displayCurrency(value, ess), reciever.getDisplayName()));
reciever.sendMessage(_("moneyRecievedFrom", Util.displayCurrency(value, ess), getDisplayName()));
}
else
{
@@ -145,17 +159,27 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return;
}
setMoney(getMoney() - value);
sendMessage(_("takenFromAccount", Util.formatCurrency(value, ess)));
sendMessage(_("takenFromAccount", Util.displayCurrency(value, ess)));
if (initiator != null)
{
initiator.sendMessage(_("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
initiator.sendMessage(_("takenFromOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
}
}
@Override
public boolean canAfford(final double cost)
{
return canAfford(cost, true);
}
public boolean canAfford(final double cost, final boolean permcheck)
{
final double mon = getMoney();
return mon >= cost || isAuthorized("essentials.eco.loan");
if (!permcheck || isAuthorized("essentials.eco.loan"))
{
return (mon - cost) >= ess.getSettings().getMinMoney();
}
return cost <= mon;
}
public void dispose()
@@ -178,7 +202,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
@Override
public int compareTo(final User other)
{
return Util.stripColor(this.getDisplayName()).compareToIgnoreCase(Util.stripColor(other.getDisplayName()));
return Util.stripFormat(this.getDisplayName()).compareToIgnoreCase(Util.stripFormat(other.getDisplayName()));
}
@Override
@@ -236,92 +260,107 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return teleportRequester;
}
public boolean isTeleportRequestHere()
public boolean isTpRequestHere()
{
return teleportRequestHere;
}
public String getNick(boolean addprefixsuffix)
public String getNick(final boolean longnick)
{
final StringBuilder nickname = new StringBuilder();
final StringBuilder prefix = new StringBuilder();
String nickname;
String suffix = "";
final String nick = getNickname();
if (ess.getSettings().isCommandDisabled("nick") || nick == null || nick.isEmpty() || nick.equals(getName()))
{
nickname.append(getName());
nickname = getName();
}
else
{
nickname.append(ess.getSettings().getNicknamePrefix()).append(nick);
nickname = ess.getSettings().getNicknamePrefix() + nick;
}
if (isOp())
{
try
{
nickname.insert(0, ess.getSettings().getOperatorColor().toString());
nickname.append("§f");
final String opPrefix = ess.getSettings().getOperatorColor().toString();
if (opPrefix.length() > 0)
{
prefix.insert(0, opPrefix);
suffix = "§f";
}
}
catch (Exception e)
{
}
}
if (addprefixsuffix && ess.getSettings().addPrefixSuffix())
if (ess.getSettings().addPrefixSuffix())
{
if (!ess.getSettings().disablePrefix())
{
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
nickname.insert(0, prefix);
final String ptext = ess.getPermissionsHandler().getPrefix(base).replace('&', '§');
prefix.insert(0, ptext);
suffix = "§f";
}
if (!ess.getSettings().disableSuffix())
{
final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
nickname.append(suffix);
if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
{
nickname.append("§f");
}
}
else
{
nickname.append("§f");
final String stext = ess.getPermissionsHandler().getSuffix(base).replace('&', '§');
suffix = stext + "§f";
suffix = suffix.replace("§f§f", "§f");
}
}
return nickname.toString();
final String strPrefix = prefix.toString();
String output = strPrefix + nickname + suffix;
if (!longnick && output.length() > 16)
{
output = strPrefix + nickname;
}
if (!longnick && output.length() > 16)
{
output = Util.lastCode(strPrefix) + nickname;
}
if (!longnick && output.length() > 16)
{
output = Util.lastCode(strPrefix) + nickname.substring(0, 14);
}
if (output.charAt(output.length() - 1) == '§') {
output = output.substring(0, output.length() - 1);
}
return output;
}
public void setDisplayNick()
{
String name = getNick(true);
setDisplayName(name);
if (name.length() > 16)
if (base.isOnline() && ess.getSettings().changeDisplayName())
{
name = getNick(false);
}
if (name.length() > 16)
{
name = name.substring(0, name.charAt(15) == '§' ? 15 : 16);
}
try
{
setPlayerListName(name);
}
catch (IllegalArgumentException e)
{
logger.log(Level.INFO, "Playerlist for " + name + " was not updated. Use a shorter displayname prefix.");
setDisplayName(getNick(true));
if (ess.getSettings().changePlayerListName())
{
String name = getNick(false);
try
{
setPlayerListName(name);
}
catch (IllegalArgumentException e)
{
if (ess.getSettings().isDebug())
{
logger.log(Level.INFO, "Playerlist for " + name + " was not updated. Name clashed with another online player.");
}
}
}
}
}
@Override
public String getDisplayName()
{
if (!(base instanceof OfflinePlayer) && ess.getSettings().changeDisplayName())
{
setDisplayNick();
}
return super.getDisplayName() == null ? super.getName() : super.getDisplayName();
}
@Override
public Teleport getTeleport()
{
return teleport;
@@ -379,6 +418,15 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
}
super.setMoney(value);
Trade.log("Update", "Set", "API", getName(), new Trade(value, ess), null, null, null, ess);
}
public void updateMoneyCache(final double value)
{
if (ess.getPaymentMethod().hasMethod() && super.getMoney() != value)
{
super.setMoney(value);
}
}
@Override
@@ -413,6 +461,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
public void setHidden(final boolean hidden)
{
this.hidden = hidden;
if (hidden == true)
{
setLastLogout(getLastOnlineActivity());
}
}
//Returns true if status expired during this check
@@ -468,6 +520,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
setAfk(false);
if (broadcast && !isHidden())
{
setDisplayNick();
ess.broadcastMessage(this, _("userIsNotAway", getDisplayName()));
}
}
@@ -500,6 +553,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
setAfk(true);
if (!isHidden())
{
setDisplayNick();
ess.broadcastMessage(this, _("userIsAway", getDisplayName()));
}
}
@@ -510,16 +564,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return afkPosition;
}
@Override
public boolean toggleGodModeEnabled()
{
if (!isGodModeEnabled())
{
setFoodLevel(20);
}
return super.toggleGodModeEnabled();
}
@Override
public boolean isGodModeEnabled()
{
@@ -532,6 +576,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return super.isGodModeEnabled();
}
@Override
public String getGroup()
{
return ess.getPermissionsHandler().getGroup(base);
@@ -555,4 +600,94 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
return teleportRequestTime;
}
public boolean isInvSee()
{
return invSee;
}
public void setInvSee(final boolean set)
{
invSee = set;
}
private transient long teleportInvulnerabilityTimestamp = 0;
public void enableInvulnerabilityAfterTeleport()
{
final long time = ess.getSettings().getTeleportInvulnerability();
if (time > 0)
{
teleportInvulnerabilityTimestamp = System.currentTimeMillis() + time;
}
}
public void resetInvulnerabilityAfterTeleport()
{
if (teleportInvulnerabilityTimestamp != 0
&& teleportInvulnerabilityTimestamp < System.currentTimeMillis())
{
teleportInvulnerabilityTimestamp = 0;
}
}
public boolean hasInvulnerabilityAfterTeleport()
{
return teleportInvulnerabilityTimestamp != 0 && teleportInvulnerabilityTimestamp >= System.currentTimeMillis();
}
public boolean isVanished()
{
return vanished;
}
public void setVanished(final boolean set)
{
vanished = set;
if (set)
{
for (Player p : ess.getServer().getOnlinePlayers())
{
if (!ess.getUser(p).isAuthorized("essentials.vanish.see"))
{
p.hidePlayer(getBase());
}
}
setHidden(true);
ess.getVanishedPlayers().add(getName());
}
else
{
for (Player p : ess.getServer().getOnlinePlayers())
{
p.showPlayer(getBase());
}
setHidden(false);
ess.getVanishedPlayers().remove(getName());
}
}
public void toggleVanished()
{
final boolean set = !vanished;
this.setVanished(set);
}
public boolean checkSignThrottle() {
if (isSignThrottled()) {
return true;
}
updateThrottle();
return false;
}
public boolean isSignThrottled()
{
final long minTime = lastThrottledAction + (1000 / ess.getSettings().getSignUsePerSecond());
return (System.currentTimeMillis() < minTime);
}
public void updateThrottle()
{
lastThrottledAction = System.currentTimeMillis();;
}
}
@@ -1,10 +1,9 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.io.File;
import java.util.*;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -13,7 +12,6 @@ public abstract class UserData extends PlayerExtension implements IConf
{
protected final transient IEssentials ess;
private final EssentialsConf config;
private static final Logger logger = Logger.getLogger("Minecraft");
protected UserData(Player base, IEssentials ess)
{
@@ -41,10 +39,9 @@ public abstract class UserData extends PlayerExtension implements IConf
lastHealTimestamp = _getLastHealTimestamp();
jail = _getJail();
mails = _getMails();
savedInventory = _getSavedInventory();
teleportEnabled = getTeleportEnabled();
ignoredPlayers = getIgnoredPlayers();
godmode = getGodModeEnabled();
godmode = _getGodModeEnabled();
muted = getMuted();
muteTimeout = _getMuteTimeout();
jailed = getJailed();
@@ -58,6 +55,7 @@ public abstract class UserData extends PlayerExtension implements IConf
isNPC = _isNPC();
arePowerToolsEnabled = _arePowerToolsEnabled();
kitTimestamps = _getKitTimestamps();
nickname = _getNickname();
}
private double money;
@@ -94,17 +92,11 @@ public abstract class UserData extends PlayerExtension implements IConf
private Map<String, Object> _getHomes()
{
Object o = config.getProperty("homes");
if (o instanceof Map)
if (config.isConfigurationSection("homes"))
{
return (Map<String, Object>)o;
return config.getConfigurationSection("homes").getValues(false);
}
else
{
return new HashMap<String, Object>();
}
return new HashMap<String, Object>();
}
public Location getHome(String name) throws Exception
@@ -154,7 +146,7 @@ public abstract class UserData extends PlayerExtension implements IConf
public List<String> getHomes()
{
return new ArrayList(homes.keySet());
return new ArrayList<String>(homes.keySet());
}
public void setHome(String name, Location loc)
@@ -181,8 +173,7 @@ public abstract class UserData extends PlayerExtension implements IConf
}
else
{
//TODO: move this message to messages file
throw new Exception("Home " + name + " doesn't exist");
throw new Exception(_("invalidHome", name));
}
}
@@ -194,14 +185,21 @@ public abstract class UserData extends PlayerExtension implements IConf
}
return false;
}
private String nickname;
public String getNickname()
public String _getNickname()
{
return config.getString("nickname");
}
public String getNickname()
{
return nickname;
}
public void setNickname(String nick)
{
nickname = nick;
config.setProperty("nickname", nick);
config.save();
}
@@ -209,7 +207,7 @@ public abstract class UserData extends PlayerExtension implements IConf
private List<Integer> _getUnlimited()
{
return config.getIntList("unlimited", new ArrayList<Integer>());
return config.getIntegerList("unlimited");
}
public List<Integer> getUnlimited()
@@ -235,22 +233,15 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("unlimited", unlimited);
config.save();
}
private Map<Integer, Object> powertools;
private Map<String, Object> powertools;
@SuppressWarnings("unchecked")
private Map<Integer, Object> _getPowertools()
private Map<String, Object> _getPowertools()
{
Object o = config.getProperty("powertools");
if (o instanceof Map)
if (config.isConfigurationSection("powertools"))
{
return (Map<Integer, Object>)o;
return config.getConfigurationSection("powertools").getValues(false);
}
else
{
return new HashMap<Integer, Object>();
}
return new HashMap<String, Object>();
}
public void clearAllPowertools()
@@ -260,25 +251,27 @@ public abstract class UserData extends PlayerExtension implements IConf
config.save();
}
@SuppressWarnings("unchecked")
public List<String> getPowertool(ItemStack stack)
{
return (List<String>)powertools.get(stack.getTypeId());
return (List<String>)powertools.get("" + stack.getTypeId());
}
@SuppressWarnings("unchecked")
public List<String> getPowertool(int id)
{
return (List<String>)powertools.get(id);
return (List<String>)powertools.get("" + id);
}
public void setPowertool(ItemStack stack, List<String> commandList)
{
if (commandList == null || commandList.isEmpty())
{
powertools.remove(stack.getTypeId());
powertools.remove("" + stack.getTypeId());
}
else
{
powertools.put(stack.getTypeId(), commandList);
powertools.put("" + stack.getTypeId(), commandList);
}
config.setProperty("powertools", powertools);
config.save();
@@ -383,7 +376,7 @@ public abstract class UserData extends PlayerExtension implements IConf
private List<String> _getMails()
{
return config.getStringList("mail", new ArrayList<String>());
return config.getStringList("mail");
}
public List<String> getMails()
@@ -411,50 +404,6 @@ public abstract class UserData extends PlayerExtension implements IConf
mails.add(mail);
setMails(mails);
}
private ItemStack[] savedInventory;
public ItemStack[] getSavedInventory()
{
return savedInventory;
}
private ItemStack[] _getSavedInventory()
{
int size = config.getInt("inventory.size", 0);
if (size < 1 || (getInventory() != null && size > getInventory().getSize()))
{
return null;
}
ItemStack[] is = new ItemStack[size];
for (int i = 0; i < size; i++)
{
is[i] = config.getItemStack("inventory." + i);
}
return is;
}
public void setSavedInventory(ItemStack[] is)
{
if (is == null || is.length == 0)
{
savedInventory = null;
config.removeProperty("inventory");
}
else
{
savedInventory = is;
config.setProperty("inventory.size", is.length);
for (int i = 0; i < is.length; i++)
{
if (is[i] == null || is[i].getType() == Material.AIR)
{
continue;
}
config.setProperty("inventory." + i, is[i]);
}
}
config.save();
}
private boolean teleportEnabled;
private boolean getTeleportEnabled()
@@ -491,7 +440,7 @@ public abstract class UserData extends PlayerExtension implements IConf
public List<String> getIgnoredPlayers()
{
return config.getStringList("ignore", new ArrayList<String>());
return config.getStringList("ignore");
}
public void setIgnoredPlayers(List<String> players)
@@ -509,26 +458,37 @@ public abstract class UserData extends PlayerExtension implements IConf
config.save();
}
public boolean isIgnoredPlayer(String name)
@Deprecated
public boolean isIgnoredPlayer(final String userName)
{
return ignoredPlayers.contains(name.toLowerCase(Locale.ENGLISH));
final IUser user = ess.getUser(userName);
if (user == null || !user.isOnline())
{
return false;
}
return isIgnoredPlayer(user);
}
public void setIgnoredPlayer(String name, boolean set)
public boolean isIgnoredPlayer(IUser user)
{
return (ignoredPlayers.contains(user.getName().toLowerCase(Locale.ENGLISH)) && !user.isAuthorized("essentials.chat.ignoreexempt"));
}
public void setIgnoredPlayer(IUser user, boolean set)
{
if (set)
{
ignoredPlayers.add(name.toLowerCase(Locale.ENGLISH));
ignoredPlayers.add(user.getName().toLowerCase(Locale.ENGLISH));
}
else
{
ignoredPlayers.remove(name.toLowerCase(Locale.ENGLISH));
ignoredPlayers.remove(user.getName().toLowerCase(Locale.ENGLISH));
}
setIgnoredPlayers(ignoredPlayers);
}
private boolean godmode;
private boolean getGodModeEnabled()
private boolean _getGodModeEnabled()
{
return config.getBoolean("godmode", false);
}
@@ -544,16 +504,9 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("godmode", set);
config.save();
}
public boolean toggleGodModeEnabled()
{
boolean ret = !isGodModeEnabled();
setGodModeEnabled(ret);
return ret;
}
private boolean muted;
private boolean getMuted()
public boolean getMuted()
{
return config.getBoolean("muted", false);
}
@@ -569,13 +522,6 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("muted", set);
config.save();
}
public boolean toggleMuted()
{
boolean ret = !isMuted();
setMuted(ret);
return ret;
}
private long muteTimeout;
private long _getMuteTimeout()
@@ -645,7 +591,7 @@ public abstract class UserData extends PlayerExtension implements IConf
public void setBanReason(String reason)
{
config.setProperty("ban.reason", reason);
config.setProperty("ban.reason", Util.sanitizeString(reason));
config.save();
}
@@ -671,10 +617,16 @@ public abstract class UserData extends PlayerExtension implements IConf
return lastLogin;
}
public void setLastLogin(long time)
private void _setLastLogin(long time)
{
lastLogin = time;
config.setProperty("timestamps.login", time);
}
public void setLastLogin(long time)
{
_setLastLogin(time);
_setLastLoginAddress(base.getAddress().getAddress().getHostAddress());
config.save();
}
private long lastLogout;
@@ -707,11 +659,10 @@ public abstract class UserData extends PlayerExtension implements IConf
return lastLoginAddress;
}
public void setLastLoginAddress(String address)
private void _setLastLoginAddress(String address)
{
lastLoginAddress = address;
config.setProperty("ipAddress", address);
config.save();
}
private boolean afk;
@@ -739,7 +690,6 @@ public abstract class UserData extends PlayerExtension implements IConf
return ret;
}
private boolean newplayer;
private String geolocation;
private String _getGeoLocation()
@@ -831,16 +781,12 @@ public abstract class UserData extends PlayerExtension implements IConf
private Map<String, Object> _getKitTimestamps()
{
final Object map = config.getProperty("timestamps.kits");
if (map instanceof Map)
if (config.isConfigurationSection("timestamps.kits"))
{
return (Map<String, Object>)map;
}
else
{
return new HashMap<String, Object>();
return config.getConfigurationSection("timestamps.kits").getValues(false);
}
return new HashMap<String, Object>();
}
public Long getKitTimestamp(final String name)
@@ -61,7 +61,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
{
try
{
return users.get(Util.sanitizeFileName(name));
return users.get(name);
}
catch (ExecutionException ex)
{
@@ -76,18 +76,31 @@ public class UserMap extends CacheLoader<String, User> implements IConf
@Override
public User load(final String name) throws Exception
{
String sanitizedName = Util.sanitizeFileName(name);
if (!sanitizedName.equals(name))
{
User user = getUser(sanitizedName);
if (user == null)
{
throw new Exception("User not found!");
}
else
{
return user;
}
}
for (Player player : ess.getServer().getOnlinePlayers())
{
if (player.getName().equalsIgnoreCase(name))
{
keys.add(Util.sanitizeFileName(name));
keys.add(sanitizedName);
return new User(player, ess);
}
}
final File userFile = getUserFile(name);
final File userFile = getUserFile2(sanitizedName);
if (userFile.exists())
{
keys.add(Util.sanitizeFileName(name));
keys.add(sanitizedName);
return new User(new OfflinePlayer(name, ess), ess);
}
throw new Exception("User not found!");
@@ -103,6 +116,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
{
keys.remove(Util.sanitizeFileName(name));
users.invalidate(Util.sanitizeFileName(name));
users.invalidate(name);
}
public Set<String> getAllUniqueUsers()
@@ -114,10 +128,15 @@ public class UserMap extends CacheLoader<String, User> implements IConf
{
return keys.size();
}
public File getUserFile(final String name)
{
return getUserFile2(Util.sanitizeFileName(name));
}
private File getUserFile2(final String name)
{
final File userFolder = new File(ess.getDataFolder(), "userdata");
return new File(userFolder, Util.sanitizeFileName(name) + ".yml");
return new File(userFolder, name + ".yml");
}
}
+128 -16
View File
@@ -22,11 +22,12 @@ public class 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]");;
private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
public static String sanitizeFileName(final String name)
{
return INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
final String newName = INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
return newName;
}
public static String sanitizeString(final String string)
@@ -79,11 +80,17 @@ public class Util
_("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)]);
}
}
@@ -91,7 +98,7 @@ public class Util
{
return "now";
}
return sb.toString();
return sb.toString().trim();
}
private static int dateDiff(int type, Calendar fromDate, Calendar toDate, boolean future)
@@ -208,6 +215,12 @@ public class Util
{
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
@@ -241,6 +254,7 @@ public class Util
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());
@@ -248,8 +262,10 @@ public class Util
AIR_MATERIALS.add(Material.PUMPKIN_STEM.getId());
AIR_MATERIALS.add(Material.MELON_STEM.getId());
AIR_MATERIALS.add(Material.VINE.getId());
AIR_MATERIALS.add(Material.NETHER_WARTS.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)
{
@@ -292,7 +308,7 @@ public class Util
while (isBlockUnsafe(world, x, y, z))
{
y += 1;
if (y >= 127)
if (y >= world.getHighestBlockYAt(x, z))
{
x += 1;
break;
@@ -303,8 +319,8 @@ public class Util
y -= 1;
if (y <= 1)
{
y = 127;
x += 1;
y = world.getHighestBlockYAt(x, z);
if (x - 32 > loc.getBlockX())
{
throw new Exception(_("holeInFloor"));
@@ -421,11 +437,11 @@ public class Util
}
return is;
}
private static DecimalFormat df = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
private static DecimalFormat dFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
public static String formatCurrency(final double value, final IEssentials ess)
public static String formatAsCurrency(final double value)
{
String str = ess.getSettings().getCurrencySymbol() + df.format(value);
String str = dFormat.format(value);
if (str.endsWith(".00"))
{
str = str.substring(0, str.length() - 3);
@@ -433,6 +449,16 @@ public class Util
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;
@@ -484,26 +510,112 @@ public class Util
}
return buf.toString();
}
private static transient final Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-FKa-fk]");
private static transient final Pattern EASY_COLOR_PATTERN = Pattern.compile("&([0-9a-fk])");
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 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 stripColor(final String input)
public static String stripFormat(final String input)
{
if (input == null)
{
return null;
}
return VANILLA_COLOR_PATTERN.matcher(input).replaceAll("");
return VANILLA_PATTERN.matcher(input).replaceAll("");
}
public static String replaceColor(final String input)
public static String replaceFormat(final String input)
{
if (input == null)
{
return null;
}
return REPLACE_PATTERN.matcher(input).replaceAll("\u00a7$1");
}
return EASY_COLOR_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");
}
}
@@ -1,6 +1,7 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.commands.WarpNotFoundException;
import java.io.File;
import java.util.*;
import java.util.logging.Level;
@@ -48,7 +49,7 @@ public class Warps implements IConf
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp));
if (conf == null)
{
throw new Exception(_("warpNotExist"));
throw new WarpNotFoundException();
}
return conf.getLocation(null, server);
}
@@ -115,6 +115,10 @@ public final class Economy
{
throw new UserDoesNotExistException(name);
}
if (balance < ess.getSettings().getMinMoney())
{
throw new NoLoanPermittedException();
}
if (balance < 0.0 && !user.isAuthorized("essentials.eco.loan"))
{
throw new NoLoanPermittedException();
@@ -245,7 +249,7 @@ public final class Economy
{
throw new RuntimeException(noCallBeforeLoad);
}
return Util.formatCurrency(amount, ess);
return Util.displayCurrency(amount, ess);
}
/**
@@ -10,6 +10,8 @@ public interface IJails extends IReload
Collection<String> getList() throws Exception;
int getCount();
void removeJail(String jail) throws Exception;
void sendToJail(com.earth2me.essentials.IUser user, String jail) throws Exception;
@@ -31,6 +31,7 @@ public class Commandafk extends EssentialsCommand
private void toggleAfk(User user)
{
user.setDisplayNick();
if (!user.toggleAfk())
{
//user.sendMessage(_("markedAsNotAway"));
@@ -17,8 +17,11 @@ public class Commandantioch extends EssentialsCommand
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
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.");
if (args.length > 0)
{
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);
loc.getWorld().spawn(loc, TNTPrimed.class);
@@ -16,9 +16,15 @@ public class Commandback extends EssentialsCommand
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (user.getWorld() != user.getLastLocation().getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + user.getLastLocation().getWorld().getName()))
{
throw new Exception(_("noPerm", "essentials.world." + user.getLastLocation().getWorld().getName()));
}
final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
user.sendMessage(_("backUsageMsg"));
user.getTeleport().back(charge);
throw new NoChargeException();
}
}
@@ -19,7 +19,12 @@ public class Commandbackup extends EssentialsCommand
final Backup backup = ess.getBackup();
if (backup == null)
{
throw new Exception();
throw new Exception(_("backupDisabled"));
}
final String command = ess.getSettings().getBackupCommand();
if (command == null || "".equals(command) || "save-all".equalsIgnoreCase(command))
{
throw new Exception(_("backupDisabled"));
}
backup.run();
sender.sendMessage(_("backupStarted"));
@@ -21,7 +21,7 @@ public class Commandbalance extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
sender.sendMessage(_("balance", Util.formatCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
sender.sendMessage(_("balance", Util.displayCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
}
@Override
@@ -32,6 +32,6 @@ public class Commandbalance extends EssentialsCommand
|| user.isAuthorized("essentials.balance.other"))
? user
: getPlayer(server, args, 0, true)).getMoney();
user.sendMessage(_("balance", Util.formatCurrency(bal, ess)));
user.sendMessage(_("balance", Util.displayCurrency(bal, ess)));
}
}
@@ -105,14 +105,18 @@ public class Commandbalancetop extends EssentialsCommand
{
if (force || cacheage <= System.currentTimeMillis() - CACHETIME)
{
cache.getLines().clear();
cache.getLines().clear();
final Map<String, Double> balances = new HashMap<String, Double>();
double totalMoney = 0d;
for (String u : ess.getUserMap().getAllUniqueUsers())
{
final User user = ess.getUserMap().getUser(u);
if (user != null)
{
balances.put(user.getDisplayName(), user.getMoney());
final double userMoney = user.getMoney();
user.updateMoneyCache(userMoney);
totalMoney += userMoney;
balances.put(user.getDisplayName(), userMoney);
}
}
@@ -125,10 +129,12 @@ public class Commandbalancetop extends EssentialsCommand
return -entry1.getValue().compareTo(entry2.getValue());
}
});
cache.getLines().add(_("serverTotal", Util.displayCurrency(totalMoney, ess)));
int pos = 1;
for (Map.Entry<String, Double> entry : sortedEntries)
{
cache.getLines().add(pos + ". " + entry.getKey() + ", " + Util.formatCurrency(entry.getValue(), ess));
cache.getLines().add(pos + ". " + entry.getKey() + ", " + Util.displayCurrency(entry.getValue(), ess));
pos++;
}
cacheage = System.currentTimeMillis();
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -24,7 +23,7 @@ public class Commandban extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final User user = getPlayer(server, args, 0, true);
if (user.getBase() instanceof OfflinePlayer)
if (!user.isOnline())
{
if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
@@ -41,20 +40,21 @@ public class Commandban extends EssentialsCommand
return;
}
}
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
String banReason;
if (args.length > 1)
{
banReason = getFinalArg(args, 1);
user.setBanReason(banReason);
banReason = _("banFormat", getFinalArg(args, 1), senderName);
}
else
{
banReason = _("defaultBanReason");
banReason = _("banFormat", _("defaultBanReason"), senderName);
}
user.setBanReason(banReason);
user.setBanned(true);
user.kickPlayer(banReason);
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
for (Player onlinePlayer : server.getOnlinePlayers())
{
@@ -27,6 +27,10 @@ public class Commandbigtree extends EssentialsCommand
{
tree = TreeType.BIG_TREE;
}
else if (args.length > 0 && args[0].equalsIgnoreCase("jungle"))
{
tree = TreeType.JUNGLE;
}
else
{
throw new NotEnoughArgumentsException();
@@ -1,10 +1,14 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
public class Commandbreak extends EssentialsCommand
@@ -29,8 +33,10 @@ public class Commandbreak extends EssentialsCommand
}
if (block.getType() == Material.BEDROCK && !user.isAuthorized("essentials.break.bedrock"))
{
throw new Exception("You are not allowed to destroy bedrock."); //TODO: Translation
throw new Exception(_("noBreakBedrock"));
}
//final List<ItemStack> list = (List<ItemStack>)block.getDrops();
//final BlockBreakEvent event = new BlockBreakEvent(block, user.getBase(), list);
final BlockBreakEvent event = new BlockBreakEvent(block, user.getBase());
server.getPluginManager().callEvent(event);
if (event.isCancelled())
@@ -1,6 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -20,6 +21,6 @@ public class Commandbroadcast extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
ess.broadcastMessage(null, _("broadcast", getFinalArg(args, 0)));
ess.broadcastMessage(null, _("broadcast", Util.replaceFormat(getFinalArg(args, 0))));
}
}
@@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import java.util.Locale;
import org.bukkit.Server;
@@ -33,7 +34,31 @@ public class Commandeco extends EssentialsCommand
throw new NotEnoughArgumentsException(ex);
}
if (args[1].contentEquals("*"))
if (args[1].contentEquals("**"))
{
for (String sUser : ess.getUserMap().getAllUniqueUsers())
{
final User player = ess.getUser(sUser);
switch (cmd)
{
case GIVE:
player.giveMoney(amount);
break;
case TAKE:
if (player.canAfford(amount, false))
{
player.takeMoney(amount);
}
break;
case RESET:
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
break;
}
}
}
else if (args[1].contentEquals("*"))
{
for (Player onlinePlayer : server.getOnlinePlayers())
{
@@ -45,6 +70,10 @@ public class Commandeco extends EssentialsCommand
break;
case TAKE:
if (!player.canAfford(amount, false))
{
throw new Exception(_("notEnoughMoney"));
}
player.takeMoney(amount);
break;
@@ -64,6 +93,10 @@ public class Commandeco extends EssentialsCommand
break;
case TAKE:
if (!player.canAfford(amount, false))
{
throw new Exception(_("notEnoughMoney"));
}
player.takeMoney(amount, sender);
break;
@@ -2,13 +2,18 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.metrics.Metrics;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
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.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
@@ -35,6 +40,14 @@ public class Commandessentials extends EssentialsCommand
{
run_nya(server, sender, commandLabel, args);
}
else if (args[0].equalsIgnoreCase("moo"))
{
run_moo(server, sender, commandLabel, args);
}
else if (args[0].equalsIgnoreCase("opt-out"))
{
run_optout(server, sender, commandLabel, args);
}
else {
run_reload(server, sender, commandLabel, args);
}
@@ -44,7 +57,7 @@ public class Commandessentials extends EssentialsCommand
{
sender.sendMessage("Essentials " + ess.getDescription().getVersion());
sender.sendMessage("/<command> <reload/debug>");
sender.sendMessage(_("blockList"));
final StringBuilder disabledCommands = new StringBuilder();
for (Map.Entry<String, String> entry : ess.getAlternativeCommandsHandler().disabledCommands().entrySet())
{
@@ -53,7 +66,10 @@ public class Commandessentials extends EssentialsCommand
}
disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue());
}
sender.sendMessage(disabledCommands.toString());
if (disabledCommands.length() > 0) {
sender.sendMessage(_("blockList"));
sender.sendMessage(disabledCommands.toString());
}
}
private void run_debug(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
@@ -144,7 +160,6 @@ public class Commandessentials extends EssentialsCommand
}
}
}, 20, 2);
return;
}
private void stopTune()
@@ -159,4 +174,31 @@ 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?\"..." } );
else
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | | |", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } );
}
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 {
metrics.disable();
}
sender.sendMessage("Anonymous Metrics are now: " + (metrics.isOptOut() ? "disabled" : "enabled"));
}
catch (IOException ex)
{
sender.sendMessage("Unable to modify 'plugins/PluginMetrics/config.yml': " + ex.getMessage());
}
}
}
@@ -0,0 +1,143 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.craftbukkit.SetExpFix;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandexp extends EssentialsCommand
{
public Commandexp()
{
super("exp");
}
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length == 0)
{
showExp(user, user);
}
else if (args[0].equalsIgnoreCase("set") && user.isAuthorized("essentials.exp.set"))
{
if (args.length == 3 && user.isAuthorized("essentials.exp.set.others"))
{
expMatch(server, user, args[1], args[2], false);
}
else
{
setExp(user, user, args[1], false);
}
}
else if (args[0].equalsIgnoreCase("give") && user.isAuthorized("essentials.exp.give"))
{
if (args.length == 3 && user.isAuthorized("essentials.exp.give.others"))
{
expMatch(server, user, args[1], args[2], true);
}
else
{
setExp(user, user, args[1], true);
}
}
else
{
String match = args[0].trim();
if (args.length == 2)
{
match = args[1].trim();
}
if (match.equalsIgnoreCase("show") || !user.isAuthorized("essentials.exp.others"))
{
showExp(user, user);
}
else
{
showMatch(server, user, match);
}
}
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
else if (args.length > 2 && args[0].equalsIgnoreCase("set"))
{
expMatch(server, sender, args[1], args[2], false);
}
else if (args.length > 2 && args[0].equalsIgnoreCase("give"))
{
expMatch(server, sender, args[1], args[2], true);
}
else
{
String match = args[0].trim();
if (args.length == 2)
{
match = args[1].trim();
}
showMatch(server, sender, match);
}
}
private void showMatch(final Server server, final CommandSender sender, final String match) throws NotEnoughArgumentsException
{
boolean foundUser = false;
for (Player matchPlayer : server.matchPlayer(match))
{
foundUser = true;
final User target = ess.getUser(matchPlayer);
showExp(sender, target);
}
if (!foundUser)
{
throw new NotEnoughArgumentsException(_("playerNotFound"));
}
}
private void expMatch(final Server server, final CommandSender sender, final String match, final String amount, final boolean toggle) throws NotEnoughArgumentsException
{
boolean foundUser = false;
for (Player matchPlayer : server.matchPlayer(match))
{
final User target = ess.getUser(matchPlayer);
setExp(sender, target, amount, toggle);
foundUser = true;
}
if (!foundUser)
{
throw new NotEnoughArgumentsException(_("playerNotFound"));
}
}
private void showExp(final CommandSender sender, final User target)
{
final int totalExp = SetExpFix.getTotalExperience(target);
final int expLeft = (int)Util.roundDouble(((((3.5 * target.getLevel()) + 6.7) - (totalExp - ((1.75 * (target.getLevel() * target.getLevel())) + (5.00 * target.getLevel())))) + 1));
sender.sendMessage(_("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target), target.getLevel(), expLeft));
}
private void setExp(final CommandSender sender, final User target, final String strAmount, final boolean give)
{
Long amount = Long.parseLong(strAmount);
if (give)
{
amount += SetExpFix.getTotalExperience(target);
}
if (amount > Integer.MAX_VALUE)
{
amount = (long)Integer.MAX_VALUE;
}
SetExpFix.setTotalExperience(target, amount.intValue());
sender.sendMessage(_("expSet", target.getDisplayName(), amount));
}
}
@@ -0,0 +1,77 @@
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 Commandfly extends EssentialsCommand
{
public Commandfly()
{
super("fly");
}
@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);
}
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.fly.others"))
{
flyOtherPlayers(server, user, args);
return;
}
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);
}
}
else
{
player.setAllowFlight(!player.getAllowFlight());
}
if (!player.getAllowFlight())
{
player.setFlying(false);
}
sender.sendMessage(_("flyMode", _(player.getAllowFlight() ? "enabled" : "disabled"), player.getDisplayName()));
}
}
}
@@ -24,15 +24,15 @@ public class Commandgamemode extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
gamemodeOtherPlayers(server, sender, args[0]);
gamemodeOtherPlayers(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().isEmpty() && user.isAuthorized("essentials.gamemode.others"))
if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.gamemode.others"))
{
gamemodeOtherPlayers(server, user, args[0]);
gamemodeOtherPlayers(server, user, args);
return;
}
@@ -40,9 +40,9 @@ 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 String name)
private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final String[] args)
{
for (Player matchPlayer : server.matchPlayer(name))
for (Player matchPlayer : server.matchPlayer(args[0]))
{
final User player = ess.getUser(matchPlayer);
if (player.isHidden())
@@ -50,7 +50,21 @@ public class Commandgamemode extends EssentialsCommand
continue;
}
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
if (args.length > 1)
{
if (args[1].contains("creat") || args[1].equalsIgnoreCase("1"))
{
player.setGameMode(GameMode.CREATIVE);
}
else
{
player.setGameMode(GameMode.SURVIVAL);
}
}
else
{
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
}
sender.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName()));
}
}
@@ -1,6 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
@@ -16,6 +17,21 @@ 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();
ChatColor color;
if (tps >= 18)
{
color = ChatColor.GREEN;
}
else if (tps >= 15)
{
color = ChatColor.YELLOW;
}
else
{
color = ChatColor.RED;
}
sender.sendMessage(_("tps", "" + color + tps));
sender.sendMessage(_("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
sender.sendMessage(_("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
sender.sendMessage(_("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
@@ -12,21 +12,23 @@ public class Commandgetpos extends EssentialsCommand
{
super("getpos");
}
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length > 0 && user.isAuthorized("essentials.getpos.others"))
{
final User otherUser = getPlayer(server, args, 0);
outputPosition(user, otherUser.getLocation(), user.getLocation());
}
else
{
outputPosition(user, user.getLocation(), null);
if (!otherUser.isHidden() || user.isAuthorized("essentials.list.hidden"))
{
outputPosition(user, otherUser.getLocation(), user.getLocation());
return;
}
}
outputPosition(user, user.getLocation(), null);
}
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
@@ -37,7 +39,7 @@ public class Commandgetpos extends EssentialsCommand
final User user = getPlayer(server, args, 0);
outputPosition(sender, user.getLocation(), null);
}
//TODO: Translate
private void outputPosition(final CommandSender sender, final Location coords, final Location distance)
{
@@ -1,7 +1,9 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -19,7 +21,6 @@ public class Commandgive extends EssentialsCommand
super("give");
}
//TODO: move these messages to message file
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
@@ -39,12 +40,17 @@ public class Commandgive extends EssentialsCommand
: (!ess.getUser(sender).isAuthorized("essentials.itemspawn.exempt")
&& !ess.getUser(sender).canSpawnItem(stack.getTypeId()))))
{
throw new Exception(ChatColor.RED + "You are not allowed to spawn the item " + itemname);
throw new Exception(_("cantSpawnItem", itemname));
}
final User giveTo = getPlayer(server, args, 0);
if (args.length > 2 && Integer.parseInt(args[2]) > 0)
if (args.length > 3 && Util.isInt(args[2]) && Util.isInt(args[3]))
{
stack.setAmount(Integer.parseInt(args[2]));
stack.setDurability(Short.parseShort(args[3]));
}
else if (args.length > 2 && Integer.parseInt(args[2]) > 0)
{
stack.setAmount(Integer.parseInt(args[2]));
}
@@ -59,7 +65,7 @@ public class Commandgive extends EssentialsCommand
if (args.length > 3)
{
for (int i = 3; i < args.length; i++)
for (int i = Util.isInt(args[3]) ? 4 : 3; i < args.length; i++)
{
final String[] split = args[i].split("[:+',;.]", 2);
if (split.length < 1)
@@ -82,9 +88,10 @@ public class Commandgive extends EssentialsCommand
if (stack.getType() == Material.AIR)
{
throw new Exception(ChatColor.RED + "You can't give air.");
throw new Exception(_("cantSpawnItem", "Air"));
}
//TODO: TL this.
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
if (giveTo.isAuthorized("essentials.oversizedstacks"))
@@ -22,31 +22,53 @@ public class Commandgod extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
godOtherPlayers(server, sender, args[0]);
godOtherPlayers(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().isEmpty() && user.isAuthorized("essentials.god.others"))
if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.god.others"))
{
godOtherPlayers(server, user, args[0]);
godOtherPlayers(server, user, args);
return;
}
user.sendMessage(_("godMode", (user.toggleGodModeEnabled() ? _("enabled") : _("disabled"))));
user.setGodModeEnabled(!user.isGodModeEnabled());
user.sendMessage(_("godMode", (user.isGodModeEnabled() ? _("enabled") : _("disabled"))));
}
private void godOtherPlayers(final Server server, final CommandSender sender, final String name)
private void godOtherPlayers(final Server server, final CommandSender sender, final String[] args)
{
for (Player matchPlayer : server.matchPlayer(name))
for (Player matchPlayer : server.matchPlayer(args[0]))
{
final User player = ess.getUser(matchPlayer);
if (player.isHidden())
{
continue;
}
final boolean enabled = player.toggleGodModeEnabled();
if (args.length > 1)
{
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
{
player.setGodModeEnabled(true);
}
else
{
player.setGodModeEnabled(false);
}
}
else
{
player.setGodModeEnabled(!player.isGodModeEnabled());
}
final boolean enabled = player.isGodModeEnabled();
if (enabled)
{
player.setFoodLevel(20);
}
player.sendMessage(_("godMode", (enabled ? _("enabled") : _("disabled"))));
sender.sendMessage(_("godMode", _(enabled ? "godEnabledFor" : "godDisabledFor", matchPlayer.getDisplayName())));
}
@@ -0,0 +1,63 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
public class Commandhat extends EssentialsCommand
{
public Commandhat()
{
super("hat");
}
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length > 0 && (args[0].contains("rem") || args[0].contains("off") || args[0].equalsIgnoreCase("0")))
{
final PlayerInventory inv = user.getInventory();
final ItemStack head = inv.getHelmet();
if (head == null || head.getType() == Material.AIR)
{
user.sendMessage(_("hatEmpty"));
}
else
{
final ItemStack air = new ItemStack(Material.AIR);
inv.setHelmet(air);
InventoryWorkaround.addItem(user.getInventory(), true, head);
user.sendMessage(_("hatRemoved"));
}
}
else
{
if (user.getItemInHand().getType() != Material.AIR)
{
final ItemStack hand = user.getItemInHand();
if (hand.getType().getMaxDurability() == 0)
{
final PlayerInventory inv = user.getInventory();
final ItemStack head = inv.getHelmet();
inv.removeItem(hand);
inv.setHelmet(hand);
inv.setItemInHand(head);
user.sendMessage(_("hatPlaced"));
}
else
{
user.sendMessage(_("hatArmor"));
}
}
else
{
user.sendMessage(_("hatFail"));
}
}
}
}
@@ -4,6 +4,7 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.textreader.*;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -21,6 +22,7 @@ public class Commandhelp extends EssentialsCommand
IText output;
String pageStr = args.length > 0 ? args[0] : null;
String chapterPageStr = args.length > 1 ? args[1] : null;
String command = commandLabel;
final IText input = new TextInput(user, "help", false, ess);
if (input.getLines().isEmpty())
@@ -31,7 +33,12 @@ public class Commandhelp extends EssentialsCommand
}
else
{
output = new HelpInput(user, pageStr, ess);
if (pageStr.length() > 26)
{
pageStr = pageStr.substring(0, 25);
}
output = new HelpInput(user, pageStr.toLowerCase(Locale.ENGLISH), ess);
command = command.concat(" ").concat(pageStr);
pageStr = chapterPageStr;
}
chapterPageStr = null;
@@ -41,7 +48,7 @@ public class Commandhelp extends EssentialsCommand
output = new KeywordReplacer(input, user, ess);
}
final TextPager pager = new TextPager(output);
pager.showPage(pageStr, chapterPageStr, commandLabel, user);
pager.showPage(pageStr, chapterPageStr, command, user);
}
@Override
@@ -22,8 +22,8 @@ public class Commandhelpop extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
final String message = _("helpOp", user.getDisplayName(), Util.stripColor(getFinalArg(args, 0)));
user.setDisplayNick();
final String message = _("helpOp", user.getDisplayName(), Util.stripFormat(getFinalArg(args, 0)));
logger.log(Level.INFO, message);
for (Player onlinePlayer : server.getOnlinePlayers())
{
@@ -54,7 +54,7 @@ public class Commandhome extends EssentialsCommand
throw new NoChargeException();
}
}
user.getTeleport().home(player, homeName.toLowerCase(Locale.ENGLISH), charge);
goHome(user, player, homeName.toLowerCase(Locale.ENGLISH), charge);
}
catch (NotEnoughArgumentsException e)
{
@@ -80,7 +80,7 @@ public class Commandhome extends EssentialsCommand
}
else if (homes.size() == 1 && player.equals(user))
{
user.getTeleport().home(player, homes.get(0), charge);
goHome(user, player, homes.get(0), charge);
}
else
{
@@ -93,4 +93,19 @@ public class Commandhome extends EssentialsCommand
}
throw new NoChargeException();
}
private void goHome(final User user, final User player, final String home, final Trade charge) throws Exception
{
final Location loc = player.getHome(home);
if (loc == null)
{
throw new NotEnoughArgumentsException();
}
if (user.getWorld() != loc.getWorld() && ess.getSettings().isWorldHomePermissions()
&& !user.isAuthorized("essentials.world." + loc.getWorld().getName()))
{
throw new Exception(_("noPerm", "essentials.world." + loc.getWorld().getName()));
}
user.getTeleport().home(loc, charge);
}
}
@@ -32,15 +32,14 @@ public class Commandignore extends EssentialsCommand
{
throw new Exception(_("playerNotFound"));
}
final String name = player.getName();
if (user.isIgnoredPlayer(name))
if (user.isIgnoredPlayer(player))
{
user.setIgnoredPlayer(name, false);
user.setIgnoredPlayer(player, false);
user.sendMessage(_("unignorePlayer", player.getName()));
}
else
{
user.setIgnoredPlayer(name, true);
user.setIgnoredPlayer(player, true);
user.sendMessage(_("ignorePlayer", player.getName()));
}
}
@@ -17,41 +17,12 @@ public class Commandinvsee extends EssentialsCommand
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1 && user.getSavedInventory() == null)
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
User invUser = user;
if (args.length == 1)
{
invUser = getPlayer(server, args, 0);
}
if (invUser == user && user.getSavedInventory() != null)
{
invUser.getInventory().setContents(user.getSavedInventory());
user.setSavedInventory(null);
user.sendMessage(_("invRestored"));
throw new NoChargeException();
}
if (user.getSavedInventory() == null)
{
user.setSavedInventory(user.getInventory().getContents());
}
ItemStack[] invUserStack = invUser.getInventory().getContents();
final int userStackLength = user.getInventory().getContents().length;
if (invUserStack.length < userStackLength)
{
invUserStack = Arrays.copyOf(invUserStack, userStackLength);
}
if (invUserStack.length > userStackLength)
{
throw new Exception(_("invBigger"));
}
user.getInventory().setContents(invUserStack);
user.sendMessage(_("invSee", invUser.getDisplayName()));
user.sendMessage(_("invSeeHelp"));
throw new NoChargeException();
final User invUser = getPlayer(server, args, 0);
user.setInvSee(true);
user.openInventory(invUser.getInventory());
}
}
@@ -36,41 +36,46 @@ public class Commanditem extends EssentialsCommand
{
throw new Exception(_("cantSpawnItem", itemname));
}
if (args.length > 1 && Integer.parseInt(args[1]) > 0)
try
{
stack.setAmount(Integer.parseInt(args[1]));
}
else if (ess.getSettings().getDefaultStackSize() > 0)
{
stack.setAmount(ess.getSettings().getDefaultStackSize());
}
else if (ess.getSettings().getOversizedStackSize() > 0 && user.isAuthorized("essentials.oversizedstacks"))
{
stack.setAmount(ess.getSettings().getOversizedStackSize());
}
if (args.length > 2)
{
for (int i = 2; i < args.length; i++)
if (args.length > 1 && Integer.parseInt(args[1]) > 0)
{
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);
stack.setAmount(Integer.parseInt(args[1]));
}
else if (ess.getSettings().getDefaultStackSize() > 0)
{
stack.setAmount(ess.getSettings().getDefaultStackSize());
}
else if (ess.getSettings().getOversizedStackSize() > 0 && user.isAuthorized("essentials.oversizedstacks"))
{
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 (stack.getType() == Material.AIR)
@@ -1,5 +1,7 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -33,5 +35,15 @@ public class Commanditemdb extends EssentialsCommand
itemStack = ess.getItemDb().get(args[0]);
}
sender.sendMessage(itemStack.getType().toString() + "- " + itemStack.getTypeId() + ":" + Integer.toString(itemStack.getData().getData()));
if (itemStack.getType() != Material.AIR)
{
int maxuses = itemStack.getType().getMaxDurability();
int durability = ((maxuses + 1) - itemStack.getDurability());
if (maxuses != 0)
{
sender.sendMessage(_("durability", Integer.toString(durability)));
}
}
}
}
@@ -37,5 +37,6 @@ public class Commandjump extends EssentialsCommand
final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
user.getTeleport().teleport(loc, charge, TeleportCause.COMMAND);
throw new NoChargeException();
}
}
@@ -24,7 +24,7 @@ public class Commandkick extends EssentialsCommand
}
final User user = getPlayer(server, args, 0);
if (user.isAuthorized("essentials.kick.exempt"))
if (sender instanceof Player && user.isAuthorized("essentials.kick.exempt"))
{
throw new Exception(_("kickExempt"));
}
@@ -27,5 +27,6 @@ public class Commandkickall extends EssentialsCommand
onlinePlayer.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : _("kickDefault"));
}
}
sender.sendMessage(_("kickedAll"));
}
}
@@ -24,15 +24,14 @@ public class Commandkill extends EssentialsCommand
for (Player matchPlayer : server.matchPlayer(args[0]))
{
final EntityDamageEvent ede = new EntityDamageEvent(matchPlayer, sender instanceof Player && ((Player)sender).getName().equals(matchPlayer.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, 1000);
final EntityDamageEvent ede = new EntityDamageEvent(matchPlayer, sender instanceof Player && ((Player)sender).getName().equals(matchPlayer.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, Short.MAX_VALUE);
server.getPluginManager().callEvent(ede);
if (ede.isCancelled() && !sender.hasPermission("essentials.kill.force"))
{
continue;
}
matchPlayer.damage(1000);
matchPlayer.setHealth(0);
matchPlayer.damage(Short.MAX_VALUE);
sender.sendMessage(_("kill", matchPlayer.getDisplayName()));
}
}
@@ -16,6 +16,7 @@ import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
import org.bukkit.entity.NPC;
import org.bukkit.entity.Ocelot;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Snowman;
@@ -61,7 +62,7 @@ public class Commandkillall extends EssentialsCommand
}
catch (NumberFormatException e)
{
throw new Exception(_("numberRequired"));
throw new Exception(_("numberRequired"), e);
}
}
}
@@ -121,11 +122,18 @@ public class Commandkillall extends EssentialsCommand
continue;
}
}
if(entity instanceof Ocelot)
{
if (((Ocelot)entity).isTamed())
{
continue;
}
}
if (animals)
{
if (entity instanceof Animals || entity instanceof NPC || entity instanceof Snowman || entity instanceof WaterMob)
{
EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST);
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
ess.getServer().getPluginManager().callEvent(event);
entity.remove();
numKills++;
@@ -135,7 +143,7 @@ public class Commandkillall extends EssentialsCommand
{
if (entity instanceof Monster || entity instanceof ComplexLivingEntity || entity instanceof Flying || entity instanceof Slime)
{
EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST);
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
ess.getServer().getPluginManager().callEvent(event);
entity.remove();
numKills++;
@@ -143,14 +151,14 @@ public class Commandkillall extends EssentialsCommand
}
else if (all)
{
EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST);
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
ess.getServer().getPluginManager().callEvent(event);
entity.remove();
numKills++;
}
else if (entityClass != null && entityClass.isAssignableFrom(entity.getClass()))
{
EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST);
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
ess.getServer().getPluginManager().callEvent(event);
entity.remove();
numKills++;
@@ -4,6 +4,7 @@ import com.earth2me.essentials.*;
import static com.earth2me.essentials.I18n._;
import java.util.*;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
public class Commandkit extends EssentialsCommand
@@ -19,38 +20,63 @@ public class Commandkit extends EssentialsCommand
if (args.length < 1)
{
final String kitList = Kit.listKits(ess, user);
if (kitList.length() > 0)
{
user.sendMessage(_("kits", kitList));
}
else
{
user.sendMessage(_("noKits"));
}
user.sendMessage(kitList.length() > 0 ? _("kits", kitList) : _("noKits"));
throw new NoChargeException();
}
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));
giveKit(userTo, user, kitName);
}
else
{
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH));
giveKit(user, user, kitName);
}
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
final String kitList = Kit.listKits(ess, null);
sender.sendMessage(kitList.length() > 0 ? _("kits", kitList) : _("noKits"));
throw new NoChargeException();
}
else
{
final User userTo = getPlayer(server, args, 1, true);
final String kitName = args[0].toLowerCase(Locale.ENGLISH);
final Object kit = ess.getSettings().getKit(kitName);
if (!user.isAuthorized("essentials.kit." + kitName))
{
throw new Exception(_("noKitPermission", "essentials.kit." + kitName));
}
final Map<String, Object> els = (Map<String, Object>)kit;
final List<String> items = Kit.getItems(user, els);
Kit.checkTime(user, kitName, els);
final Trade charge = new Trade("kit-" + kitName, ess);
charge.isAffordableFor(user);
Kit.expandItems(ess, user, items);
charge.charge(user);
user.sendMessage(_("kitGive", kitName));
final Map<String, Object> kit = ess.getSettings().getKit(kitName);
final List<String> items = Kit.getItems(userTo, kit);
Kit.expandItems(ess, userTo, items);
sender.sendMessage(_("kitGive", kitName));
}
}
private void giveKit(User userTo, User userFrom, String kitName) throws Exception
{
final Map<String, Object> kit = ess.getSettings().getKit(kitName);
if (!userFrom.isAuthorized("essentials.kit." + kitName))
{
throw new Exception(_("noKitPermission", "essentials.kit." + kitName));
}
final List<String> items = Kit.getItems(userTo, kit);
Kit.checkTime(userFrom, kitName, kit);
final Trade charge = new Trade("kit-" + kitName, ess);
charge.isAffordableFor(userFrom);
Kit.expandItems(ess, userTo, items);
charge.charge(userFrom);
userTo.sendMessage(_("kitGive", kitName));
}
}
@@ -0,0 +1,44 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Mob;
import com.earth2me.essentials.User;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.entity.Ocelot;
public class Commandkittycannon extends EssentialsCommand
{
private static Random random = new Random();
public Commandkittycannon()
{
super("kittycannon");
}
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
final Mob cat = Mob.OCELOT;
final Ocelot ocelot = (Ocelot)cat.spawn(user, server, user.getEyeLocation());
if (ocelot == null)
{
return;
}
final int i = random.nextInt(Ocelot.Type.values().length);
ocelot.setCatType(Ocelot.Type.values()[i]);
ocelot.setTamed(true);
ocelot.setVelocity(user.getEyeLocation().getDirection().multiply(2));
ess.scheduleSyncDelayedTask(new Runnable()
{
@Override
public void run()
{
final Location loc = ocelot.getLocation();
ocelot.remove();
loc.getWorld().createExplosion(loc, 0F);
}
}, 20);
}
}
@@ -23,11 +23,11 @@ public class Commandlightning extends EssentialsCommand
if (sender instanceof Player)
{
user = ess.getUser(((Player)sender));
}
if (args.length < 1 & user != null)
{
user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation());
return;
if ((args.length < 1 || user != null && !user.isAuthorized("essentials.lightning.others")))
{
user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation());
return;
}
}
if (server.matchPlayer(args[0]).isEmpty())
@@ -35,7 +35,7 @@ public class Commandlightning extends EssentialsCommand
throw new Exception(_("playerNotFound"));
}
int power = 1;
int power = 5;
if (args.length > 1)
{
try
@@ -50,18 +50,12 @@ public class Commandlightning extends EssentialsCommand
for (Player matchPlayer : server.matchPlayer(args[0]))
{
sender.sendMessage(_("lightningUse", matchPlayer.getDisplayName()));
if (power <= 0)
{
matchPlayer.getWorld().strikeLightningEffect(matchPlayer.getLocation());
}
else
{
LightningStrike strike = matchPlayer.getWorld().strikeLightning(matchPlayer.getLocation());
matchPlayer.damage(power - 1, strike);
}
final LightningStrike strike = matchPlayer.getWorld().strikeLightningEffect(matchPlayer.getLocation());
if (!ess.getUser(matchPlayer).isGodModeEnabled())
{
matchPlayer.setHealth(matchPlayer.getHealth() < 5 ? 0 : matchPlayer.getHealth() - 5);
matchPlayer.damage(power, strike);
}
if (ess.getSettings().warnOnSmite())
{
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.*;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -43,8 +44,10 @@ public class Commandlist extends EssentialsCommand
if (showhidden && playerHidden > 0)
{
online = _("listAmountHidden", server.getOnlinePlayers().length - playerHidden, playerHidden, server.getMaxPlayers());
} else {
online = _("listAmount",server.getOnlinePlayers().length - playerHidden, server.getMaxPlayers());
}
else
{
online = _("listAmount", server.getOnlinePlayers().length - playerHidden, server.getMaxPlayers());
}
sender.sendMessage(online);
@@ -72,7 +75,7 @@ public class Commandlist extends EssentialsCommand
for (String group : groups)
{
final StringBuilder groupString = new StringBuilder();
groupString.append(group).append(": ");
groupString.append(_("listGroupTag", Util.replaceFormat(group)));
final List<User> users = sort.get(group);
Collections.sort(users);
boolean first = true;
@@ -94,6 +97,7 @@ public class Commandlist extends EssentialsCommand
{
groupString.append(_("listHiddenTag"));
}
user.setDisplayNick();
groupString.append(user.getDisplayName());
groupString.append("§f");
}
@@ -135,6 +139,7 @@ public class Commandlist extends EssentialsCommand
{
onlineUsers.append(_("listHiddenTag"));
}
user.setDisplayNick();
onlineUsers.append(user.getDisplayName());
onlineUsers.append("§f");
}
@@ -4,7 +4,6 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -57,9 +56,9 @@ public class Commandmail extends EssentialsCommand
{
throw new Exception(_("playerNeverOnServer", args[1]));
}
if (!u.isIgnoredPlayer(user.getName()))
if (!u.isIgnoredPlayer(user))
{
final String mail = Util.sanitizeString(Util.stripColor(getFinalArg(args, 2)));
final String mail = Util.sanitizeString(Util.stripFormat(getFinalArg(args, 2)));
u.addMail(user.getName() + ": " + mail);
}
user.sendMessage(_("mailSent"));
@@ -71,7 +70,7 @@ public class Commandmail extends EssentialsCommand
{
throw new Exception(_("noPerm", "essentials.mail.sendall"));
}
ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripColor(getFinalArg(args, 1))));
ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripFormat(getFinalArg(args, 1))));
user.sendMessage(_("mailSent"));
return;
}
@@ -27,15 +27,9 @@ public class Commandme extends EssentialsCommand
}
String message = getFinalArg(args, 0);
if (user.isAuthorized("essentials.chat.color"))
{
message = Util.replaceColor(message);
}
else {
message = Util.stripColor(message);
}
message = Util.formatMessage(user, "essentials.chat", message);
user.setDisplayNick();
ess.broadcastMessage(user, _("action", user.getDisplayName(), message));
}
}
@@ -21,11 +21,11 @@ public class Commandmsg extends EssentialsCommand
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length < 2 || args[0].trim().isEmpty() || args[1].trim().isEmpty())
if (args.length < 2 || args[0].trim().length() < 3 || args[1].trim().isEmpty())
{
throw new NotEnoughArgumentsException();
}
String message = getFinalArg(args, 1);
if (sender instanceof Player)
{
@@ -34,18 +34,11 @@ public class Commandmsg extends EssentialsCommand
{
throw new Exception(_("voiceSilenced"));
}
if (user.isAuthorized("essentials.msg.color"))
{
message = Util.replaceColor(message);
}
else
{
message = Util.stripColor(message);
}
message = Util.formatMessage(user, "essentials.msg", message);
}
else
{
message = Util.replaceColor(message);
message = Util.replaceFormat(message);
}
final String translatedMe = _("me");
@@ -88,7 +81,7 @@ public class Commandmsg extends EssentialsCommand
{
sender.sendMessage(_("msgFormat", translatedMe, matchedPlayer.getDisplayName(), message));
final User matchedUser = ess.getUser(matchedPlayer);
if (sender instanceof Player && (matchedUser.isIgnoredPlayer(((Player)sender).getName()) || matchedUser.isHidden()))
if (sender instanceof Player && (matchedUser.isIgnoredPlayer(ess.getUser(sender)) || matchedUser.isHidden()))
{
continue;
}
@@ -28,13 +28,19 @@ public class Commandmute extends EssentialsCommand
throw new Exception(_("muteExempt"));
}
long muteTimestamp = 0;
if (args.length > 1)
{
String time = getFinalArg(args, 1);
final String time = getFinalArg(args, 1);
muteTimestamp = Util.parseDateDiff(time, true);
player.setMuted(true);
}
else
{
player.setMuted(!player.getMuted());
}
player.setMuteTimeout(muteTimestamp);
final boolean muted = player.toggleMuted();
final boolean muted = player.getMuted();
sender.sendMessage(
muted
? (muteTimestamp > 0
@@ -64,11 +64,13 @@ public class Commandnick extends EssentialsCommand
private String formatNickname(final User user, final String nick)
{
if (user == null || user.isAuthorized("essentials.nick.color"))
if (user == null)
{
return nick.replace('&', '\u00a7').replaceAll("\u00a7+k", "");
} else {
return Util.stripColor(nick);
return Util.replaceFormat(nick);
}
else
{
return Util.formatString(user, "essentials.nick", nick);
}
}
@@ -51,7 +51,7 @@ public class Commandnuke extends EssentialsCommand
{
for (int z = -10; z <= 10; z += 5)
{
final Location tntloc = new Location(world, loc.getBlockX() + x, 127, loc.getBlockZ() + z);
final Location tntloc = new Location(world, loc.getBlockX() + x, world.getHighestBlockYAt(loc) + 64, loc.getBlockZ() + z);
final TNTPrimed tnt = world.spawn(tntloc, TNTPrimed.class);
}
}
@@ -22,14 +22,14 @@ public class Commandpay extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
if (args[0] == "")
if (args[0].trim().length() < 3)
{
throw new NotEnoughArgumentsException("You need to specify a player to pay.");
}
double amount = Double.parseDouble(args[1].replaceAll("[^0-9\\.]", ""));
Boolean foundUser = false;
boolean foundUser = false;
for (Player p : server.matchPlayer(args[0]))
{
User u = ess.getUser(p);
@@ -42,9 +42,9 @@ public class Commandpay extends EssentialsCommand
foundUser = true;
}
if (foundUser == false)
if (!foundUser)
{
throw new NoSuchFieldException(_("playerNotFound"));
throw new NotEnoughArgumentsException(_("playerNotFound"));
}
}
}
@@ -1,8 +1,9 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
public class Commandping extends EssentialsCommand
@@ -13,8 +14,16 @@ public class Commandping extends EssentialsCommand
}
@Override
public void run(Server server, User player, String commandLabel, String[] args) throws Exception
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
player.sendMessage(_("pong"));
if (args.length < 1)
{
sender.sendMessage(_("pong"));
}
else
{
sender.sendMessage(Util.replaceFormat(getFinalArg(args, 0)));
}
}
}
@@ -51,26 +51,18 @@ public class Commandpowertool extends EssentialsCommand
{
user.sendMessage(_("powerToolList", Util.joinList(powertools), itemName));
}
return;
throw new NoChargeException();
}
if (command.startsWith("r:"))
{
try
command = command.substring(2);
if (!powertools.contains(command))
{
command = command.substring(2);
if (!powertools.contains(command))
{
throw new Exception(_("powerToolNoSuchCommandAssigned", command, itemName));
}
throw new Exception(_("powerToolNoSuchCommandAssigned", command, itemName));
}
powertools.remove(command);
user.sendMessage(_("powerToolRemove", command, itemName));
}
catch (Exception e)
{
user.sendMessage(e.getMessage());
return;
}
powertools.remove(command);
user.sendMessage(_("powerToolRemove", command, itemName));
}
else
{
@@ -85,7 +77,6 @@ public class Commandpowertool extends EssentialsCommand
{
throw new Exception(_("powerToolAlreadySet", command, itemName));
}
}
else if (powertools != null && !powertools.isEmpty())
{
@@ -110,6 +101,11 @@ public class Commandpowertool extends EssentialsCommand
user.sendMessage(_("powerToolRemoveAll", itemName));
}
if (!user.arePowerToolsEnabled())
{
user.setPowerToolsEnabled(true);
user.sendMessage(_("powerToolsEnabled"));
}
user.setPowertool(itemStack, powertools);
}
}
@@ -55,7 +55,7 @@ public class Commandptime extends EssentialsCommand
Long ticks;
// Parse the target time int ticks from args[0]
String timeParam = args[0];
Boolean relative = true;
boolean relative = true;
if (timeParam.startsWith("@"))
{
relative = false;
@@ -79,7 +79,7 @@ public class Commandptime extends EssentialsCommand
}
catch (NumberFormatException e)
{
throw new NotEnoughArgumentsException();
throw new NotEnoughArgumentsException(e);
}
}
@@ -32,20 +32,13 @@ public class Commandr extends EssentialsCommand
if (sender instanceof Player)
{
User user = ess.getUser(sender);
if (user.isAuthorized("essentials.msg.color"))
{
message = Util.replaceColor(message);
}
else
{
message = Util.stripColor(message);
}
message = Util.formatMessage(user, "essentials.msg", message);
replyTo = user;
senderName = user.getDisplayName();
}
else
{
message = Util.replaceColor(message);
message = Util.replaceFormat(message);
replyTo = Console.getConsoleReplyTo();
senderName = Console.NAME;
}
@@ -62,7 +55,7 @@ public class Commandr extends EssentialsCommand
if (target instanceof Player)
{
User player = ess.getUser(target);
if (player.isIgnoredPlayer(sender instanceof Player ? ((Player)sender).getName() : Console.NAME))
if (sender instanceof Player && player.isIgnoredPlayer(ess.getUser(sender)))
{
return;
}
@@ -31,9 +31,10 @@ public class Commandrealname extends EssentialsCommand
{
continue;
}
final String displayName = Util.stripColor(u.getDisplayName()).toLowerCase(Locale.ENGLISH);
u.setDisplayNick();
final String displayName = Util.stripFormat(u.getDisplayName()).toLowerCase(Locale.ENGLISH);
if (!whois.equals(displayName)
&& !displayName.equals(Util.stripColor(ess.getSettings().getNicknamePrefix()) + whois)
&& !displayName.equals(Util.stripFormat(ess.getSettings().getNicknamePrefix()) + whois)
&& !whois.equalsIgnoreCase(u.getName()))
{
continue;
@@ -9,7 +9,7 @@ import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.*;
//Todo: Fix this up
public class Commandremove extends EssentialsCommand
{
public Commandremove()
@@ -47,7 +47,7 @@ public class Commandremove extends EssentialsCommand
}
catch (NumberFormatException e)
{
throw new Exception(_("numberRequired"));
throw new Exception(_("numberRequired"), e);
}
}
@@ -57,7 +57,7 @@ public class Commandremove extends EssentialsCommand
}
catch (IllegalArgumentException e)
{
throw new NotEnoughArgumentsException(); //TODO: translate and list types
throw new NotEnoughArgumentsException(e); //TODO: translate and list types
}
removeEntities(user, world, toRemove, radius);
@@ -84,7 +84,7 @@ public class Commandremove extends EssentialsCommand
}
catch (IllegalArgumentException e)
{
throw new NotEnoughArgumentsException(); //TODO: translate and list types
throw new NotEnoughArgumentsException(e); //TODO: translate and list types
}
removeEntities(sender, world, toRemove, 0);
}
@@ -92,8 +92,9 @@ public class Commandremove extends EssentialsCommand
protected void removeEntities(final CommandSender sender, final World world, final ToRemove toRemove, int radius) throws Exception
{
int removed = 0;
if (radius > 0) {
radius*=radius;
if (radius > 0)
{
radius *= radius;
}
for (Chunk chunk : world.getLoadedChunks())
{
@@ -130,7 +131,7 @@ public class Commandremove extends EssentialsCommand
removed++;
}
}
else if (toRemove == ToRemove.DROPS)
else if (toRemove == ToRemove.MINECARTS)
{
if (e instanceof Minecart)
{
@@ -53,6 +53,8 @@ public class Commandrepair extends EssentialsCommand
}
else if (args[0].equalsIgnoreCase("all"))
{
final Trade charge = new Trade("repair-all", ess);
charge.isAffordableFor(user);
final List<String> repaired = new ArrayList<String>();
repairItems(user.getInventory().getContents(), user, repaired);
@@ -69,6 +71,7 @@ public class Commandrepair extends EssentialsCommand
{
user.sendMessage(_("repair", Util.joinList(repaired)));
}
charge.charge(user);
}
else
@@ -102,7 +105,7 @@ public class Commandrepair extends EssentialsCommand
continue;
}
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), "repair-item", ess);
try
{
charge.isAffordableFor(user);
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -16,6 +17,17 @@ public class Commandseen extends EssentialsCommand
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
seen(server, sender, args, true, true);
}
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
seen(server, user, args, user.isAuthorized("essentials.seen.banreason"), user.isAuthorized("essentials.seen.extra"));
}
protected void seen(final Server server, final CommandSender sender, final String[] args, final boolean showBan, final boolean extra) throws Exception
{
if (args.length < 1)
{
@@ -23,20 +35,34 @@ public class Commandseen extends EssentialsCommand
}
try
{
User u = getPlayer(server, args, 0);
sender.sendMessage(_("seenOnline", u.getDisplayName(), Util.formatDateDiff(u.getLastLogin())));
User player = getPlayer(server, args, 0);
player.setDisplayNick();
sender.sendMessage(_("seenOnline", player.getDisplayName(), Util.formatDateDiff(player.getLastLogin())));
if (extra)
{
sender.sendMessage(_("whoisIPAddress", player.getAddress().getAddress().toString()));
}
}
catch (NoSuchFieldException e)
{
User u = ess.getOfflineUser(args[0]);
if (u == null)
User player = ess.getOfflineUser(args[0]);
if (player == null)
{
throw new Exception(_("playerNotFound"));
}
sender.sendMessage(_("seenOffline", u.getDisplayName(), Util.formatDateDiff(u.getLastLogout())));
if (u.isBanned())
player.setDisplayNick();
sender.sendMessage(_("seenOffline", player.getName(), Util.formatDateDiff(player.getLastLogout())));
if (player.isBanned())
{
sender.sendMessage(_("whoisBanned", _("true")));
sender.sendMessage(_("whoisBanned", showBan ? player.getBanReason() : _("true")));
}
if (extra)
{
sender.sendMessage(_("whoisIPAddress", player.getLastLoginAddress()));
final Location loc = player.getLastLocation();
if (loc != null) {
sender.sendMessage(_("whoisLocation", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
}
}
}
}
@@ -160,8 +160,8 @@ public class Commandsell extends EssentialsCommand
user.updateInventory();
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess);
user.giveMoney(worth * amount);
user.sendMessage(_("itemSold", Util.formatCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.formatCurrency(worth, ess)));
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess)));
user.sendMessage(_("itemSold", Util.displayCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth, ess)));
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth * amount, ess), amount, Util.displayCurrency(worth, ess)));
}
}
@@ -29,7 +29,8 @@ public class Commandsethome extends EssentialsCommand
{
if (user.isAuthorized("essentials.sethome.multiple"))
{
if ("bed".equals(args[0].toLowerCase(Locale.ENGLISH))) {
if ("bed".equals(args[0].toLowerCase(Locale.ENGLISH)))
{
throw new NotEnoughArgumentsException();
}
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getHomeLimit(user))
@@ -66,7 +67,8 @@ public class Commandsethome extends EssentialsCommand
{
name = "home";
}
if ("bed".equals(name.toLowerCase(Locale.ENGLISH))) {
if ("bed".equals(name.toLowerCase(Locale.ENGLISH)))
{
throw new NotEnoughArgumentsException();
}
usersHome.setHome(name, user.getLocation());
@@ -77,7 +79,7 @@ public class Commandsethome extends EssentialsCommand
{
user.setHome();
}
user.sendMessage(_("homeSet"));
user.sendMessage(_("homeSet", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));
}
}
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@@ -20,7 +21,7 @@ public class Commandsetjail extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
ess.getJails().setJail(args[0], user.getLocation());
user.sendMessage(_("jailSet", args[0]));
user.sendMessage(_("jailSet", Util.sanitizeString(args[0])));
}
}
@@ -2,6 +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.Warps;
import org.bukkit.Location;
import org.bukkit.Server;
@@ -26,7 +28,25 @@ public class Commandsetwarp extends EssentialsCommand
}
final Location loc = user.getLocation();
ess.getWarps().setWarp(args[0], loc);
final Warps warps = ess.getWarps();
Location warpLoc = null;
try
{
warpLoc = warps.getWarp(args[0]);
}
catch (Exception ex)
{
}
if (warpLoc == null || user.isAuthorized("essentials.warp.overwrite." + Util.sanitizeFileName(args[0])))
{
warps.setWarp(args[0], loc);
}
else
{
throw new Exception(_("warpOverwrite"));
}
user.sendMessage(_("warpSet", args[0]));
}
}
@@ -3,6 +3,7 @@ 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.inventory.ItemStack;
@@ -15,6 +16,32 @@ public class Commandsetworth extends EssentialsCommand
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
ItemStack stack;
String price;
if (args.length == 1)
{
stack = user.getInventory().getItemInHand();
price = args[0];
}
else
{
stack = ess.getItemDb().get(args[0]);
price = args[1];
}
ess.getWorth().setPrice(stack, Double.parseDouble(price));
user.sendMessage(_("worthSet"));
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
@@ -23,6 +50,6 @@ public class Commandsetworth extends EssentialsCommand
ItemStack stack = ess.getItemDb().get(args[0]);
ess.getWorth().setPrice(stack, Double.parseDouble(args[1]));
user.sendMessage(_("worthSet"));
sender.sendMessage(_("worthSet"));
}
}
@@ -1,14 +1,13 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.*;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Mob;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.entity.EntityType;
public class Commandspawner extends EssentialsCommand
@@ -32,31 +31,34 @@ public class Commandspawner extends EssentialsCommand
throw new Exception(_("mobSpawnTarget"));
}
String name = args[0];
Mob mob = null;
mob = Mob.fromName(name);
if (mob == null)
{
throw new Exception(_("invalidMob"));
}
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
{
throw new Exception(_("disabledToSpawnMob"));
}
if (!user.isAuthorized("essentials.spawner." + mob.name.toLowerCase(Locale.ENGLISH)))
{
throw new Exception(_("noPermToSpawnMob"));
}
final Trade charge = new Trade("spawner-" + mob.name.toLowerCase(Locale.ENGLISH), ess);
charge.isAffordableFor(user);
try
{
String name = args[0];
Mob mob = null;
mob = Mob.fromName(name);
if (mob == null)
{
user.sendMessage(_("invalidMob"));
return;
}
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
{
throw new Exception(_("unableToSpawnMob"));
}
if (!user.isAuthorized("essentials.spawner." + mob.name.toLowerCase()))
{
throw new Exception(_("unableToSpawnMob"));
}
((CreatureSpawner)target.getBlock().getState()).setCreatureType(mob.getType());
user.sendMessage(_("setSpawner", mob.name));
((CreatureSpawner)target.getBlock().getState()).setSpawnedType(mob.getType());
}
catch (Throwable ex)
{
throw new Exception(_("mobSpawnError"), ex);
}
charge.charge(user);
user.sendMessage(_("setSpawner", mob.name));
}
}
@@ -5,13 +5,14 @@ import com.earth2me.essentials.Mob;
import com.earth2me.essentials.Mob.MobException;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale;
import java.util.Random;
import java.util.*;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.entity.*;
import org.bukkit.entity.Villager.Profession;
import org.bukkit.material.Colorable;
public class Commandspawnmob extends EssentialsCommand
@@ -26,7 +27,20 @@ public class Commandspawnmob extends EssentialsCommand
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException(_("mobsAvailable", Util.joinList(Mob.getMobList())));
final Set<String> mobList = Mob.getMobList();
final Set<String> availableList = new HashSet<String>();
for (String mob : mobList)
{
if (user.isAuthorized("essentials.spawnmob." + mob.toLowerCase()))
{
availableList.add(mob);
}
}
if (availableList.isEmpty())
{
availableList.add(_("none"));
}
throw new NotEnoughArgumentsException(_("mobsAvailable", Util.joinList(availableList)));
}
@@ -79,7 +93,7 @@ public class Commandspawnmob extends EssentialsCommand
User otherUser = null;
if (args.length >= 3)
{
otherUser = getPlayer(ess.getServer(), args, 2);
otherUser = getPlayer(ess.getServer(), args, 2);
}
final Location loc = (otherUser == null) ? block.getLocation() : otherUser.getLocation();
final Location sloc = Util.getSafeDestination(loc);
@@ -89,7 +103,7 @@ public class Commandspawnmob extends EssentialsCommand
}
catch (MobException e)
{
throw new Exception(_("unableToSpawnMob"));
throw new Exception(_("unableToSpawnMob"), e);
}
if (mountType != null)
@@ -115,7 +129,7 @@ public class Commandspawnmob extends EssentialsCommand
}
catch (MobException e)
{
throw new Exception(_("unableToSpawnMob"));
throw new Exception(_("unableToSpawnMob"), e);
}
spawnedMob.setPassenger(spawnedMount);
}
@@ -150,7 +164,7 @@ public class Commandspawnmob extends EssentialsCommand
}
catch (MobException e)
{
throw new Exception(_("unableToSpawnMob"));
throw new Exception(_("unableToSpawnMob"), e);
}
spawnedMob.setPassenger(spawnedMount);
}
@@ -163,7 +177,7 @@ public class Commandspawnmob extends EssentialsCommand
changeMobData(mobMount.getType(), spawnedMount, mountData, user);
}
}
user.sendMessage(args[1] + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned"));
user.sendMessage(mobCount + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned"));
}
catch (MobException e1)
{
@@ -184,9 +198,11 @@ public class Commandspawnmob extends EssentialsCommand
}
}
private void changeMobData(final CreatureType type, final Entity spawned, final String data, final User user) throws Exception
private void changeMobData(final EntityType type, final Entity spawned, String data, final User user) throws Exception
{
if (type == CreatureType.SLIME || type == CreatureType.MAGMA_CUBE)
data = data.toLowerCase(Locale.ENGLISH);
if (spawned instanceof Slime)
{
try
{
@@ -197,35 +213,24 @@ public class Commandspawnmob extends EssentialsCommand
throw new Exception(_("slimeMalformedSize"), e);
}
}
if ((type == CreatureType.SHEEP
|| type == CreatureType.COW
|| type == CreatureType.MUSHROOM_COW
|| type == CreatureType.CHICKEN
|| type == CreatureType.PIG
|| type == CreatureType.WOLF)
&& data.equalsIgnoreCase("baby"))
if (spawned instanceof Ageable && data.contains("baby"))
{
((Animals)spawned).setAge(-24000);
((Ageable)spawned).setBaby();
return;
}
if (type == CreatureType.SHEEP)
if (spawned instanceof Colorable)
{
if (data.toLowerCase(Locale.ENGLISH).contains("baby"))
{
((Sheep)spawned).setAge(-24000);
}
final String color = data.toUpperCase(Locale.ENGLISH).replace("BABY", "");
try
{
if (color.equalsIgnoreCase("random"))
if (color.equals("RANDOM"))
{
Random rand = new Random();
((Sheep)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
final Random rand = new Random();
((Colorable)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
}
else
{
((Sheep)spawned).setColor(DyeColor.valueOf(color));
((Colorable)spawned).setColor(DyeColor.valueOf(color));
}
}
catch (Exception e)
@@ -233,30 +238,45 @@ public class Commandspawnmob extends EssentialsCommand
throw new Exception(_("sheepMalformedColor"), e);
}
}
if (type == CreatureType.WOLF
&& data.toLowerCase(Locale.ENGLISH).startsWith("tamed"))
if (spawned instanceof Tameable && data.contains("tamed"))
{
final Wolf wolf = ((Wolf)spawned);
wolf.setTamed(true);
wolf.setOwner(user);
wolf.setSitting(true);
if (data.equalsIgnoreCase("tamedbaby"))
{
((Animals)spawned).setAge(-24000);
}
final Tameable tameable = ((Tameable)spawned);
tameable.setTamed(true);
tameable.setOwner(user.getBase());
}
if (type == CreatureType.WOLF
&& data.toLowerCase(Locale.ENGLISH).startsWith("angry"))
if (type == EntityType.WOLF
&& data.contains("angry"))
{
((Wolf)spawned).setAngry(true);
if (data.equalsIgnoreCase("angrybaby"))
{
((Animals)spawned).setAge(-24000);
}
}
if (type == CreatureType.CREEPER && data.equalsIgnoreCase("powered"))
if (type == EntityType.CREEPER && data.contains("powered"))
{
((Creeper)spawned).setPowered(true);
}
if (type == EntityType.OCELOT)
{
if (data.contains("siamese"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.SIAMESE_CAT);
}
else if (data.contains("red"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.RED_CAT);
}
else if (data.contains("black"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.BLACK_CAT);
}
}
if (type == EntityType.VILLAGER)
{
for (Profession prof : Villager.Profession.values())
{
if (data.contains(prof.toString().toLowerCase(Locale.ENGLISH)))
{
((Villager)spawned).setProfession(prof);
}
}
}
}
}
@@ -1,6 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
@@ -29,8 +31,12 @@ public class Commandsudo extends EssentialsCommand
System.arraycopy(args, 2, arguments, 0, args.length - 2);
}
//TODO: Translate this.
sender.sendMessage("Running the command as " + user.getDisplayName());
if (user.isAuthorized("essentials.sudo.exempt"))
{
throw new Exception(_("sudoExempt"));
}
sender.sendMessage(_("sudoRun", user.getDisplayName(), command, getFinalArg(arguments, 0)));
final PluginCommand execCommand = ess.getServer().getPluginCommand(command);
if (execCommand != null)
@@ -16,11 +16,11 @@ public class Commandsuicide extends EssentialsCommand
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
EntityDamageEvent ede = new EntityDamageEvent(user, EntityDamageEvent.DamageCause.SUICIDE, 1000);
EntityDamageEvent ede = new EntityDamageEvent(user.getBase(), EntityDamageEvent.DamageCause.SUICIDE, Short.MAX_VALUE);
server.getPluginManager().callEvent(ede);
user.damage(1000);
user.setHealth(0);
user.damage(Short.MAX_VALUE);
user.sendMessage(_("suicideMessage"));
user.setDisplayNick();
ess.broadcastMessage(user,_("suicideSuccess", user.getDisplayName()));
}
}
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@@ -25,7 +24,7 @@ public class Commandtempban extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final User user = getPlayer(server, args, 0, true);
if (user.getBase() instanceof OfflinePlayer)
if (!user.isOnline())
{
if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.tempban.offline"))
@@ -45,12 +44,12 @@ public class Commandtempban extends EssentialsCommand
final String time = getFinalArg(args, 1);
final long banTimestamp = Util.parseDateDiff(time, true);
final String banReason = _("tempBanned", Util.formatDateDiff(banTimestamp));
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
final String banReason = _("tempBanned", Util.formatDateDiff(banTimestamp), senderName);
user.setBanReason(banReason);
user.setBanTimeout(banTimestamp);
user.setBanned(true);
user.kickPlayer(banReason);
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
for (Player onlinePlayer : server.getOnlinePlayers())
{
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.DescParseTickFormat;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.*;
import org.bukkit.Server;
import org.bukkit.World;
@@ -19,16 +20,23 @@ public class Commandtime extends EssentialsCommand
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
final List<String> argList = new ArrayList<String>(Arrays.asList(args));
if ((argList.remove("set") || argList.remove("add")) && Util.isInt(argList.get(0)))
{
ess.getLogger().info("debug edited 0" + argList.get(0).toString());
}
final String[] validArgs = argList.toArray(new String[0]);
// Which World(s) are we interested in?
String worldSelector = null;
if (args.length == 2)
if (validArgs.length == 2)
{
worldSelector = args[1];
worldSelector = validArgs[1];
}
final Set<World> worlds = getWorlds(server, sender, worldSelector);
// If no arguments we are reading the time
if (args.length == 0)
if (validArgs.length == 0)
{
getWorldsTime(sender, worlds);
return;
@@ -45,11 +53,11 @@ public class Commandtime extends EssentialsCommand
long ticks;
try
{
ticks = DescParseTickFormat.parse(args[0]);
ticks = DescParseTickFormat.parse(validArgs[0]);
}
catch (NumberFormatException e)
{
throw new NotEnoughArgumentsException();
throw new NotEnoughArgumentsException(e);
}
setWorldsTime(sender, worlds, ticks);
@@ -1,7 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@@ -28,7 +27,7 @@ public class Commandtogglejail extends EssentialsCommand
if (args.length >= 2 && !player.isJailed())
{
if (player.getBase() instanceof OfflinePlayer)
if (!player.isOnline())
{
if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.togglejail.offline"))
@@ -45,7 +44,7 @@ public class Commandtogglejail extends EssentialsCommand
return;
}
}
if (!(player.getBase() instanceof OfflinePlayer))
if (player.isOnline())
{
ess.getJails().sendToJail(player, args[1]);
}
@@ -96,7 +95,7 @@ public class Commandtogglejail extends EssentialsCommand
player.setJailTimeout(0);
player.sendMessage(_("jailReleasedPlayerNotify"));
player.setJail(null);
if (!(player.getBase() instanceof OfflinePlayer))
if (player.isOnline())
{
player.getTeleport().back();
}
@@ -30,6 +30,11 @@ public class Commandtp extends EssentialsCommand
{
throw new Exception(_("teleportDisabled", player.getDisplayName()));
}
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + player.getWorld().getName()))
{
throw new Exception(_("noPerm", "essentials.world." + player.getWorld().getName()));
}
user.sendMessage(_("teleporting"));
final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
@@ -37,14 +42,26 @@ public class Commandtp extends EssentialsCommand
throw new NoChargeException();
default:
if (!user.isAuthorized("essentials.tpohere"))
if (!user.isAuthorized("essentials.tp.others"))
{
//TODO: Translate this
throw new Exception("You need access to /tpohere to teleport other players.");
throw new Exception(_("noPerm", "essentials.tp.others"));
}
user.sendMessage(_("teleporting"));
final User target = getPlayer(server, args, 0);
final User toPlayer = getPlayer(server, args, 1);
if (!target.isTeleportEnabled())
{
throw new Exception(_("teleportDisabled", target.getDisplayName()));
}
if (!toPlayer.isTeleportEnabled())
{
throw new Exception(_("teleportDisabled", toPlayer.getDisplayName()));
}
if (target.getWorld() != toPlayer.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + toPlayer.getWorld().getName()))
{
throw new Exception(_("noPerm", "essentials.world." + toPlayer.getWorld().getName()));
}
target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND);
target.sendMessage(_("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
break;
@@ -25,7 +25,12 @@ public class Commandtpa extends EssentialsCommand
{
throw new Exception(_("teleportDisabled", player.getDisplayName()));
}
if (!player.isIgnoredPlayer(user.getName()))
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + player.getWorld().getName()))
{
throw new Exception(_("noPerm", "essentials.world." + player.getWorld().getName()));
}
if (!player.isIgnoredPlayer(user))
{
player.requestTeleport(user, false);
player.sendMessage(_("teleportRequest", user.getDisplayName()));
@@ -45,6 +45,11 @@ public class Commandtpaall extends EssentialsCommand
{
continue;
}
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + user.getWorld().getName()))
{
continue;
}
try
{
player.requestTeleport(user, true);
@@ -1,7 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import org.bukkit.Server;
@@ -20,13 +19,26 @@ public class Commandtpaccept extends EssentialsCommand
{
final User target = user.getTeleportRequest();
if (target == null
|| target.getBase() instanceof OfflinePlayer
|| (user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpahere")))
if (target == null || !target.isOnline())
{
throw new Exception(_("noPendingRequest"));
}
if (user.isTpRequestHere() && ((!target.isAuthorized("essentials.tpahere") && !target.isAuthorized("essentials.tpaall"))
|| (user.getWorld() != target.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + user.getWorld().getName()))))
{
throw new Exception(_("noPendingRequest"));
}
if (!user.isTpRequestHere() && (!target.isAuthorized("essentials.tpa")
|| (user.getWorld() != target.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + target.getWorld().getName()))))
{
throw new Exception(_("noPendingRequest"));
}
if (args.length > 0 && !target.getName().contains(args[0]))
{
throw new Exception(_("noPendingRequest"));
@@ -40,7 +52,7 @@ public class Commandtpaccept extends EssentialsCommand
}
final Trade charge = new Trade(this.getName(), ess);
if (user.isTeleportRequestHere())
if (user.isTpRequestHere())
{
charge.isAffordableFor(user);
}
@@ -51,7 +63,7 @@ public class Commandtpaccept extends EssentialsCommand
user.sendMessage(_("requestAccepted"));
target.sendMessage(_("requestAcceptedFrom", user.getDisplayName()));
if (user.isTeleportRequestHere())
if (user.isTpRequestHere())
{
user.getTeleport().teleport(target, charge, TeleportCause.COMMAND);
}
@@ -25,6 +25,11 @@ public class Commandtpahere extends EssentialsCommand
{
throw new Exception(_("teleportDisabled", player.getDisplayName()));
}
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + user.getWorld().getName()))
{
throw new Exception(_("noPerm", "essentials.world." + user.getWorld().getName()));
}
player.requestTeleport(user, true);
player.sendMessage(_("teleportHereRequest", user.getDisplayName()));
player.sendMessage(_("typeTpaccept"));
Loaded 100 of 246 files, more files were not shown because too many files have changed in this diff. Show more