1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-09-06 20:50:46 +02:00

Compare commits

...

1050 Commits

Author SHA1 Message Date
KHobbits
d9e6f2975a Merge branch 'master' into release 2012-01-29 21:44:30 +00:00
KHobbits
2f1d9ad82c Prevent /home bed, if the bed was later destroyed. 2012-01-29 21:44:15 +00:00
KHobbits
d8ac3587ac Merge branch 'master' into release 2012-01-29 21:39:05 +00:00
KHobbits
a2418a68d9 Fixing Kill/suicide in creative mode. 2012-01-29 21:37:38 +00:00
KHobbits
85c4fbdf4f Merge branch 'master' into release 2012-01-29 21:20:56 +00:00
KHobbits
dff8f541fe New craftbukkit
CB 1840, B 1208
2012-01-29 21:06:55 +00:00
KHobbits
d0a5656fa4 Merge remote branch 'remotes/origin/groupmanager' 2012-01-29 20:57:54 +00:00
KHobbits
bc76e87366 Fix boolean fail in /r offline checking. 2012-01-29 20:57:17 +00:00
ElgarL
bf9a67a2e4 updating .gitignore 2012-01-29 11:04:52 +00:00
ElgarL
95885e46c9 Fix players retaining permissions when demoted. 2012-01-29 10:54:24 +00:00
KHobbits
5a7f38fa29 Merge branch 'master' into release 2012-01-29 05:00:04 +00:00
KHobbits
6a5fefb102 Optional second argument to /tpaccept, it will only accept the request if the sender matched that string. 2012-01-29 04:59:30 +00:00
KHobbits
c47c008871 Added kit note.
Fixes #1276
2012-01-29 03:26:44 +00:00
KHobbits
a31f5e219d Kill people the proper way.
Test #1410
2012-01-29 03:23:38 +00:00
KHobbits
9ee78bdaec Switch /near priority to check for int first.
Test #1269
2012-01-29 03:09:59 +00:00
KHobbits
735f9ce212 Make sure player is online when sending a /reply. 2012-01-29 02:57:52 +00:00
KHobbits
417148f5da Merge branch 'master' into release 2012-01-29 01:45:40 +00:00
KHobbits
8f0350570e Merge remote branch 'remotes/origin/groupmanager' 2012-01-29 01:45:03 +00:00
KHobbits
27365d1f1b Prevent disabled sign creation (if any of essentials signs are enabled) 2012-01-29 01:42:55 +00:00
KHobbits
ebb3a77430 Fix sign list format. 2012-01-29 01:38:24 +00:00
KHobbits
b3252168f6 Disable all signs by default. 2012-01-29 01:27:04 +00:00
KHobbits
e1abdbdd37 Added options to enable each sign type 2012-01-29 01:12:38 +00:00
ElgarL
3deff2afe7 silly formatting change to test gitbot 2012-01-28 18:01:17 +00:00
KHobbits
a85cbdd505 Merge branch 'master' into release 2012-01-28 12:59:15 +00:00
KHobbits
c6aa34076a Merge remote branch 'remotes/origin/groupmanager' 2012-01-28 12:58:37 +00:00
ElgarL
92f83dfe73 fix for an iterator error if there is only one element in the array. 2012-01-28 11:59:54 +00:00
ElgarL
00057eaca4 Fixed a bug when pushing superperms in the wrong order. 2012-01-28 11:47:39 +00:00
KHobbits
2f96c9763f Only list bed home if it is set. 2012-01-28 01:39:51 +00:00
KHobbits
137b60c5f2 Allow space as well as : in /delhome 2012-01-28 01:32:15 +00:00
KHobbits
292b7b0546 Stop users from using /sethome bed 2012-01-28 01:09:02 +00:00
KHobbits
d1d31e9769 If bed home is set, give priority when spawning. 2012-01-28 00:57:08 +00:00
KHobbits
f7c6759433 Check bed still exist, for bed homes. 2012-01-28 00:49:22 +00:00
KHobbits
5137502646 Switch website URL's to point at wiki. 2012-01-28 00:20:46 +00:00
ElgarL
9ff8b69282 Properly fix inherited negated nodes. 2012-01-27 13:09:11 +00:00
ElgarL
7f269187c5 do not allow inherited permissions to negate higher perms. 2012-01-27 12:38:00 +00:00
KHobbits
6d34a2aa17 Merge branch 'master' of github.com:essentials/Essentials 2012-01-26 21:21:35 +00:00
KHobbits
9b58b2b9c0 Revert emergency listener to old style
Stops peoples world world burning down if they throw in 2.8, on a 1.0 server.
2012-01-26 21:21:13 +00:00
snowleo
b4d91978c7 Merge branch 'refs/heads/master' into release 2012-01-26 04:51:10 +01:00
snowleo
8aa260ee34 Minor fix to french translation 2012-01-26 04:49:26 +01:00
Léa Gris
25976edc2b i18n added to command nuke 2012-01-26 04:46:00 +01:00
Léa Gris
8e9094a3ef Updated translations to Essentials Dev2.7.191 2012-01-26 04:45:16 +01:00
KHobbits
16bde87982 Merge branch 'master' into release 2012-01-26 00:31:05 +00:00
KHobbits
b8944d0b25 Set min bukkit to 1818 - RB 2012-01-26 00:30:33 +00:00
KHobbits
69209eeb2f Merge remote branch 'remotes/origin/groupmanager' 2012-01-26 00:28:10 +00:00
ElgarL
746eb353a2 Fixed an infinite loop error when using '/manudel' on a logged in
player. It caused setDefaultGroup to trigger a bukkit update when no GM
User existed yet.
2012-01-25 23:44:14 +00:00
ElgarL
3708f2b3bb Trap errors in fetching the mirrors map. 2012-01-25 22:43:07 +00:00
ElgarL
e563405a7d Check for a null player object in the PlayerTeleportEvent. 2012-01-25 22:35:24 +00:00
ElgarL
ae2cf3d95c Fixed subgroups (I broke earlier). 2012-01-25 22:33:22 +00:00
ementalo
270533652b Merge branch 'master' into release 2012-01-25 14:29:05 +00:00
paul.aston
324dd05c97 CB #1818
RB #1200
2012-01-25 14:23:46 +00:00
Paul A.
2a0c3eebbc Merge pull request #43 from essentials/groupmanager
Fix trying to modify an unmodifiable collection breaking superperms.
2012-01-24 17:29:08 -08:00
ElgarL
e1660d47ba Fix trying to modify an unmodifiable collection breaking superperms. 2012-01-25 01:20:44 +00:00
KHobbits
03d640260d Merge branch 'master' into release 2012-01-25 00:04:08 +00:00
KHobbits
da3a6af92d Merge remote branch 'remotes/origin/groupmanager' 2012-01-25 00:02:15 +00:00
ementalo
593cb8d56e Don't try to spawn users who have disconnected before we have a chance to spawn them 2012-01-24 22:43:33 +00:00
ElgarL
f40f5f880b Fix typo/wording in changelog
Allow negation to the * permission node when populating superperms.
2012-01-24 19:41:22 +00:00
ElgarL
8390594682 Allow negations with the * permission node when population superperms. 2012-01-24 19:38:22 +00:00
ElgarL
a13740f638 Fix hasOwnData to return a correct result with new mirroring system 2012-01-24 15:37:21 +00:00
ElgarL
5f19cbf17b Fixed isInList 2012-01-24 15:35:20 +00:00
ElgarL
145b0be2f3 addSubGroup now returns a boolean for success/failure.
'/manuaddsub' now correctly reports if it was able to add the sub
group.
2012-01-24 14:21:07 +00:00
ElgarL
1dab4f95dd Added recursive loop detection for World mirroring (you may not set the
main world as a mirror of another).
Fixed fetching world data so it no longer returns the mirrored world
for groups. Each world data holder now points to the correct data set,
so can be returned as an object.
2012-01-24 14:08:53 +00:00
snowleo
f27b2290dc Merge branch 'refs/heads/master' into release 2012-01-24 03:43:49 +01:00
snowleo
0ea41d9169 Merge branch 'refs/heads/groupmanager' 2012-01-24 03:43:17 +01:00
ementalo
f93769dd1d Add new permission essentials.protect.alerts.notrigger
If user has this permisson they do not trigger EssProtect block alerts
2012-01-23 15:48:56 +00:00
ElgarL
125ea7c701 Fixed infinite loop error on player join.
Optimized code to only update the player logging in instead of all
players online.
2012-01-22 23:46:26 +00:00
ElgarL
6e03ea7b7d Separated all events to be independent classes. 2012-01-21 20:18:40 +00:00
ElgarL
9041596384 Fixed a random null error upon a player portaling. 2012-01-21 19:09:08 +00:00
KHobbits
efda9beece Merge branch 'master' into release 2012-01-21 17:19:12 +00:00
ElgarL
4b61ac9043 Update to new Bukkit Event system.
Update GroupManagerBridge for new event system.
2012-01-21 11:47:08 +00:00
KHobbits
72edfacfb8 Catching throwable leads to madness, lets do this safely. 2012-01-21 00:19:13 +00:00
KHobbits
aa88205d95 Catch errors too, incase the class doesn't exist. 2012-01-21 00:01:43 +00:00
KHobbits
8d441a4cc7 Messages Cleanup 2012-01-20 23:13:37 +00:00
KHobbits
766935871f If vault throws an exception, it should not be enabled. 2012-01-20 23:04:43 +00:00
KHobbits
f5d65371b2 Adding translation keys for [L] and [Spy] 2012-01-20 22:57:35 +00:00
KHobbits
662749be8b Check shout/question messages are longer than 1 character. 2012-01-20 22:54:47 +00:00
snowleo
e46fe381b4 Removing load info, bucket displays that now. 2012-01-20 05:52:35 +01:00
snowleo
04a43eb5d0 New Event code for EssentialsSpawn 2012-01-20 05:34:28 +01:00
snowleo
792f70efa5 Update for new CraftBukkit Event Code
EssentialsSpawn can't be updated yet, because the new event system lacks dynamic priorities.
2012-01-20 05:20:37 +01:00
snowleo
46298ae858 CB#1791 2012-01-20 04:09:35 +01:00
KHobbits
d08b1a5089 Fix EssChat displayname error. 2012-01-19 15:51:55 +00:00
KHobbits
e015cad131 Merge remote branch 'remotes/origin/groupmanager' 2012-01-19 15:34:00 +00:00
KHobbits
008f0d595f Fix Lombok include. 2012-01-19 15:08:37 +00:00
ElgarL
7ee3919175 Fixed text when adding a subgroup to not say the player was moved. 2012-01-19 13:08:57 +00:00
snowleo
2560bdca4a Update of Lombok, fixes memory leak in Netbeans 2012-01-19 13:17:05 +01:00
ElgarL
16d537bd6c Remove debug spam 2012-01-19 12:08:39 +00:00
snowleo
5f04d1867c Cache MessageFormats for Chat 2012-01-19 02:03:20 +01:00
KHobbits
a10f6850e5 Compiled regex is faster. 2012-01-18 23:35:30 +00:00
KHobbits
36bc1adf83 Make sure to clean the chatStore. 2012-01-18 23:08:40 +00:00
KHobbits
cd8cc63113 Reduce duplicate calls in EssentialsChat
Should cut the time down a little.
2012-01-18 22:53:39 +00:00
KHobbits
947bee98a0 Merge remote branch 'remotes/origin/groupmanager' 2012-01-18 20:04:50 +00:00
ElgarL
9c052b5178 Better optimize assembling of a players permissions and allow the * node
to populate all registered superperms.
2012-01-18 16:39:12 +00:00
ElgarL
64af5b465d Added a tidy error message for invalid permission entries in
GlobalGroups.
2012-01-18 01:25:25 +00:00
KHobbits
5c1d49fd0e Merge remote branch 'remotes/origin/groupmanager' 2012-01-17 23:50:05 +00:00
KHobbits
79a13e97a2 Merge remote branch 'remotes/origin/groupmanager' 2012-01-17 23:49:38 +00:00
ElgarL
89c41b0508 v 1.9:
Optimize populating Bukkit perms so we no longer calculate the
child
nodes (Bukkit already does this).
2012-01-17 18:03:16 +00:00
KHobbits
e7fd26ee64 Merge branch 'master' of github.com:essentials/Essentials 2012-01-17 17:40:22 +00:00
KHobbits
8fc6684290 Auto Update GM Version 2012-01-17 17:24:22 +00:00
snowleo
a66ffd8921 Shorter names for enchantment signs. 2012-01-17 01:45:03 +01:00
KHobbits
1f2c669eca Stripping vanilla colour from /helpop and /mail
Adding support for &k in EssChat
Adding support for colour in /msg and /r - New perm: essentials.msg.color
2012-01-16 20:25:36 +00:00
KHobbits
1d5a09a03e Merge branch 'master' of github.com:essentials/Essentials 2012-01-16 19:42:37 +00:00
KHobbits
4435121c84 Stripping vanilla colours from /msg 2012-01-16 19:42:15 +00:00
snowleo
813e66b4f2 Fix /nick command colors 2012-01-16 20:38:53 +01:00
snowleo
26d63f3666 Strip colors from chat, if the user does not have the permission. 2012-01-16 20:29:55 +01:00
KHobbits
0fb07d4cc1 Removing debugging message from player login. 2012-01-16 18:58:44 +00:00
snowleo
cd2f819c29 Cleanup 2012-01-16 19:11:41 +01:00
KHobbits
149ce7d74d Adding support for Vault as a fallback economy method. 2012-01-16 18:00:43 +00:00
KHobbits
c7c7e5e4ce Merge remote branch 'remotes/origin/master' into release 2012-01-16 12:43:09 +00:00
snowleo
f26cccb663 Optimize TextInput to cache motd and info textfiles. 2012-01-16 04:51:27 +01:00
snowleo
81ec87d893 Revert changes to Usermap 2012-01-16 02:12:20 +01:00
snowleo
91563e9dca Optimize Break in Protect 2012-01-16 01:55:04 +01:00
snowleo
359ea194b8 Speed improvements for Move and Interact Event. 2012-01-16 00:50:52 +01:00
ElgarL
1a0b03db4d Removed '- bukkit.command' form the globalgroups permission nodes. 2012-01-15 01:43:42 +00:00
snowleo
c860b1c668 Reload less 2012-01-14 23:25:52 +01:00
snowleo
c584d74852 Temporary fix for Spawns and Jails when Worlds are loaded after Essentials.
This will be replaced by BetterLocation fix in 3.0 branch.
2012-01-14 23:13:58 +01:00
KHobbits
6e82419c15 Allowing use of aliases in help/info/motd, for command suggestions.
Test #1441
2012-01-14 16:53:18 +00:00
KHobbits
3f6b9586b4 Fixing double charges on /home
Test #1426
2012-01-14 16:42:53 +00:00
KHobbits
29d4e09983 Fixing {WorldDate}
Test #1353
2012-01-14 16:36:19 +00:00
KHobbits
f61f80164d Merge branch 'master' into release 2012-01-14 15:52:55 +00:00
KHobbits
f0def90301 Merge remote branch 'remotes/origin/groupmanager' 2012-01-14 15:52:22 +00:00
ElgarL
d0e5685ac0 Catch NullPointerErrors generated by blank permission nodes. 2012-01-14 15:48:55 +00:00
KHobbits
856cef3286 Update Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java 2012-01-14 15:04:16 +00:00
KHobbits
d16fef9f7f Merge branch 'master' into release
~ GM needs testing before release ~
2012-01-14 13:16:33 +00:00
KHobbits
43f1c0f89d Removing debugging messages. 2012-01-13 22:50:48 +00:00
KHobbits
256d202d50 Adjusting default spawn behavior.
Moving option in config file.
2012-01-13 22:41:47 +00:00
snowleo
4884bed117 Merge branch 'refs/heads/groupmanager' 2012-01-13 01:38:54 +01:00
snowleo
3fdde2f764 Add new eggs to items.csv 2012-01-12 23:56:39 +01:00
snowleo
390b17f0d8 Min Bukkit version is 1713 now 2012-01-12 23:43:11 +01:00
snowleo
fe9d5645f6 Added the new Enchantments 2012-01-12 23:42:04 +01:00
snowleo
eb5c88ef08 Netbeans 7.1 stuff 2012-01-12 23:37:39 +01:00
snowleo
6eea852b1d CB#1713 B#1136 2012-01-12 23:36:45 +01:00
ElgarL
768c92e5bf Major, MAJOR changes to support partial/full world mirroring.
You can now mirror groups.yml, users.yml or both files between
different worlds.
2012-01-11 05:51:40 +00:00
ElgarL
2a478fe03d Optimize fetching of Mirrored world data. 2012-01-10 18:40:34 +00:00
ElgarL
58057a771d Changed over to a reflection method for populating superperms as Bukkit
lags when you handle permissions one at a time.
2012-01-09 02:00:58 +00:00
ElgarL
4c485f3147 Fix 'manucheckp' to correctly report if a permission is available from
GroupManager or Bukkit.
2012-01-05 19:43:30 +00:00
ElgarL
7726fd0081 Reload GlobalGroups when you perform a world load.
Changed GlobalGroups to save/load before local groups in the
scheduled data saving/loading
2012-01-03 02:04:48 +00:00
snowleo
9a568992f1 Merge pull request #42 from jjkoletar/patch-1
No sending to all players, must specify target.
2012-01-01 16:38:05 -08:00
Jeremy
283dc9b3c1 No sending to all players, must specify target. 2012-01-01 18:18:29 -06:00
ElgarL
3aba996e97 Changed the way events are raised to prevent variable corruption. 2011-12-29 14:52:42 +00:00
ElgarL
69847af08a Decreased ranks of default users so idiots who don't remove them can't
get 'hacked' when in offline mode.
2011-12-22 17:01:10 +00:00
ElgarL
debcf4714a Delayed GroupManager events so Superperms will be fully updated before
plugins receive the events.
2011-12-20 17:21:55 +00:00
snowleo
4425d53664 Only info not a warning if a file is missing 2011-12-20 12:25:30 +01:00
snowleo
791e8f2d14 Only info not a warning if a file is missing 2011-12-20 12:24:59 +01:00
snowleo
ee5e015a63 Correctly match release and non release versions of bukkit. 2011-12-20 12:20:41 +01:00
snowleo
5d4f22ad84 Correctly match release and non release versions of bukkit. 2011-12-20 12:20:12 +01:00
snowleo
839ce3d526 Fix sending our player object to other plugins. 2011-12-20 11:57:51 +01:00
snowleo
31e80ba698 Fix sending our player object to other plugins. 2011-12-20 11:57:22 +01:00
ElgarL
a2202439bb Expanded GlobalGroups.yml and Groups.yml to include Towny permissions. 2011-12-19 19:22:04 +00:00
ElgarL
7c8c40c790 manpromote and mandemote now correctly sent the notification to the
console if the command was issued there.
2011-12-19 15:44:27 +00:00
snowleo
abd86347c7 Always return an offlineplayer object with the name, that the user wants. 2011-12-19 12:57:09 +01:00
snowleo
5bb7d82fca Fix double names in /balancetop and show display name in balancetop 2011-12-19 12:39:23 +01:00
snowleo
cc06117210 Merge branch 'refs/heads/master' into release 2011-12-19 12:07:28 +01:00
KHobbits
5a092f0e99 Merge branch 'master' of github.com:essentials/Essentials 2011-12-19 10:57:44 +00:00
KHobbits
98cd03ac57 Prevent future warps being named as numbers. 2011-12-19 10:57:18 +00:00
snowleo
8761feb93f More null checks for Jails 2011-12-19 11:53:52 +01:00
KHobbits
cbd5b6c0f4 Merge remote branch 'remotes/origin/master' into release 2011-12-19 05:04:15 +00:00
ElgarL
afe8ecd3df Fixed a typo 2011-12-18 15:21:56 +00:00
ElgarL
244673e1fb Fixed manucheckp on group (missed it in last commit) 2011-12-18 14:35:14 +00:00
ElgarL
de40f7f556 Fixed 'manucheckp' returning a null for the searched node when it's a
group/subgroup.
2011-12-18 14:26:00 +00:00
ElgarL
ac77bbb0b4 Changed ServicesManager registration to lowest from normal. 2011-12-18 04:25:54 +00:00
KHobbits
fec3b61039 Merge branch 'master' of github.com:essentials/Essentials 2011-12-15 20:47:24 +00:00
KHobbits
01530192cf Make powertool use a chat event, instead of just messaging each user. 2011-12-15 20:47:06 +00:00
snowleo
64bc8d1133 Corrected version match for 1597 build version 2011-12-15 10:32:04 +01:00
ElgarL
815a9dcca2 Removed op permissions from admins in the default GloblaGroups.yml. 2011-12-14 16:24:47 +00:00
snowleo
58bebd851c Fix failing override for /enchant /eco /ext 2011-12-14 15:07:08 +01:00
snowleo
867e66e774 Merge branch 'refs/heads/master' into release 2011-12-14 11:56:09 +01:00
snowleo
9eaebadaaa Merge branch 'refs/heads/groupmanager' 2011-12-14 10:03:32 +01:00
ElgarL
8d29a2c578 deleting the contents of GlobalGroups.yml will no longer thrown a
NullPointerException.
2011-12-14 04:26:02 +00:00
KHobbits
2202448cee Read current exp, instead of stored exp.
This means that exp used in enchanting is subtracted from total exp.
2011-12-14 03:41:24 +00:00
snowleo
45ffeaffec Merge branch 'refs/heads/master' into release 2011-12-13 23:52:58 +01:00
snowleo
79861b1f10 Merge branch 'refs/heads/groupmanager' 2011-12-13 23:52:25 +01:00
ElgarL
559400c606 GM now registers with Bukkits ServicesManager. 2011-12-13 18:20:02 +00:00
ElgarL
5b195299ba Update event Action names to be unique 2011-12-13 17:32:39 +00:00
ElgarL
759892078a Added custom events so plugins can now be notified of changes within
GroupManager.
2011-12-13 17:13:53 +00:00
KHobbits
505460349f Fixing killall command definition. 2011-12-13 09:38:20 +00:00
snowleo
f91b622646 Merge branch 'refs/heads/master' into release 2011-12-13 10:32:59 +01:00
snowleo
70bd9bd1f3 Renamed /butcher to /killall and fixes to the code. 2011-12-13 10:28:15 +01:00
snowleo
32564fb4f7 Netbeans 7.1 changes for EssentialsUpdate 2011-12-13 08:46:50 +01:00
snowleo
af4dde2086 Tiny fix to the last commit. 2011-12-13 08:41:28 +01:00
snowleo
15ce04b539 Better exp fix and allow exp on buy and sell signs. 2011-12-13 08:38:15 +01:00
snowleo
907f6c6116 Disabling exp as currency. Normal money will be used. 2011-12-13 07:35:46 +01:00
KHobbits
fc1ccda0fe Update exp trade signs on purchase. 2011-12-13 04:52:09 +00:00
KHobbits
d3dd8208ef Fixing Sell/Buy Signs which use EXP as a currency. 2011-12-13 04:29:16 +00:00
KHobbits
a00f070400 Merge branch 'master' of github.com:essentials/Essentials 2011-12-13 03:12:09 +00:00
KHobbits
faddbd09a4 Update copylibs. 2011-12-13 03:11:11 +00:00
KHobbits
dfa4ecbe4f Inform user that they were healed. 2011-12-13 01:47:58 +00:00
KHobbits
40a9c28699 Merge branch 'master' into release 2011-12-12 23:15:48 +00:00
KHobbits
e37ab86c9b Updating min Bukkit version. 2011-12-12 23:13:39 +00:00
KHobbits
081491d0a1 Merge branch 'master' into release 2011-12-12 23:06:40 +00:00
KHobbits
f936cd5f27 Updating to RB
CraftBukkit #1597 Bukkit #1073
2011-12-12 23:00:21 +00:00
KHobbits
46840a686d Merge remote branch 'remotes/origin/groupmanager'
Adjusting bukkit paths to remove version number.
2011-12-12 22:51:18 +00:00
KHobbits
5f3d783e21 Update Bukkit jars and paths. 2011-12-12 22:45:59 +00:00
ElgarL
0e0b441168 Offline player checks now support partial name matches. 2011-12-12 16:39:15 +00:00
ElgarL
aaf08150e6 Fix classpath for Eclipse 2011-12-12 15:59:34 +00:00
ElgarL
50f215adda Dev Jar files for GM 2011-12-12 15:56:00 +00:00
ElgarL
4b43453a74 Update GM version to 1.7
GM now supports offline players without having to mantogglevalidate
Added craftbukkit-1.0.0-SNAPSHOT.jar to lib (version 1587)
Added bukkit-1.0.0-R1-SNAPSHOT.jar to lib (version 1065)
Updated GM XML's to build using dev bukkit/CB build jars.
2011-12-12 15:53:33 +00:00
KHobbits
3eff598791 Merge branch 'master' of github.com:essentials/Essentials 2011-12-12 00:49:33 +00:00
KHobbits
a7b1c3d534 Switching the item value of brewing stands 2011-12-12 00:48:39 +00:00
snowleo
f8e1f02523 Fix sorting of users in /who 2011-12-11 09:22:27 +01:00
KHobbits
a63c116590 Temp Fix wildcard permissions in bperms. 2011-12-11 06:00:29 +00:00
KHobbits
fad38170a8 Make the version error messages stand out a little more... 2011-12-11 05:49:25 +00:00
KHobbits
aa5f819d7b Added cleanup note
Minecraft server usually shows players around 140-180 range, so changing default /near to 200.
2011-12-10 04:12:22 +00:00
KHobbits
f9905f9953 Make the alt command message, sound less negative/broken. 2011-12-09 22:53:36 +00:00
KHobbits
06c2453941 Update plugin information. 2011-12-09 21:51:31 +00:00
KHobbits
c0e903c1f3 New permissions: essentials.powertool.append. 2011-12-09 21:42:36 +00:00
KHobbits
f99867dd0a Simplify the protect config file examples. 2011-12-09 04:07:53 +00:00
snowleo
de12c5c6d1 Fix broken charge for shout and question 2011-12-09 02:48:57 +01:00
ementalo
95d5217f58 Allow timeout of /tpa /tpahere requests
Adds new config setting tpa-accept-cancellation
Test #781
2011-12-08 23:43:09 +00:00
KHobbits
52b1017bda Merge branch 'master' of github.com:essentials/Essentials 2011-12-08 04:44:34 +00:00
KHobbits
b102c5f3d8 First Refactor of Kits
New sign: [Kit] / <kit name> / [group] / [charge]
2011-12-08 04:44:18 +00:00
snowleo
8d0230d6a8 Merge branch 'refs/heads/master' into release 2011-12-08 05:41:00 +01:00
snowleo
e379ac5d77 Merge branch 'refs/heads/groupmanager' 2011-12-08 04:14:27 +01:00
ElgarL
789a6b9540 Fix manload to properly clone user variables. 2011-12-08 02:28:12 +00:00
KHobbits
221e1d3bb2 Merge branch 'master' of github.com:essentials/Essentials 2011-12-08 02:23:18 +00:00
KHobbits
9410a25cce Adjusting /spawn to not trigger respawn event. 2011-12-08 02:21:10 +00:00
snowleo
ae7d968f5c Fix for Towny using an old method. 2011-12-08 02:23:44 +01:00
snowleo
5002e7a6ad Prevent blockdamage by enderdragon (default true) in EssentialsProtect CB#1566 B#1058 2011-12-08 00:48:53 +01:00
snowleo
13a42d1937 Fix Jails not loaded after server start. 2011-12-07 16:50:16 +01:00
snowleo
46c99e5c6f /home sends the player to bed again before it tries to respawn. 2011-12-07 15:18:50 +01:00
snowleo
02b25120e8 Allow to set the Respawn priority in config. 2011-12-07 15:09:22 +01:00
snowleo
435219bab6 Fix Enchant sign, the user has to hold the item in hand now. A * or "any" in the second line allows to enchant all possible items. 2011-12-07 14:23:56 +01:00
snowleo
766f0a9f13 Use of our Inventory code in enchant sign to be reliable. 2011-12-07 13:44:51 +01:00
snowleo
d60de76d87 New config option disable-item-pickup-while-afk, defaults to true. 2011-12-07 12:10:41 +01:00
snowleo
324cd74826 Banned moved from /whois to /seen 2011-12-07 12:00:01 +01:00
snowleo
e7ebc94a9e SnakeYaml now ignores additional mapping values in files, so it throws less errors. 2011-12-07 11:57:31 +01:00
snowleo
5c02346f85 Fix I18n file not loading from Essentials folder, when the locale is not defined in config. 2011-12-07 11:22:02 +01:00
snowleo
5b539bf034 Fix /mail sendall, fixes #1209 2011-12-07 11:02:10 +01:00
snowleo
879d4913dc /balancetop now has pages instead of max argument
Test #1210
2011-12-07 10:53:06 +01:00
snowleo
ef49d92c49 Null check in new player teleport, fixes #1212 2011-12-07 10:37:34 +01:00
snowleo
719539d63b Missing translation for last commit 2011-12-07 10:35:06 +01:00
snowleo
fdd8fffbb3 Support for experience as trading goods on signs. This will not work until experience is fixed in Bukkit. 2011-12-07 10:31:18 +01:00
snowleo
67a3a55f5a Updated /near and /getpos command, added new argument playername
Test #1214
2011-12-07 10:03:23 +01:00
Khyperia
e8eb1974b8 New feature: IsBanned to /whois 2011-12-07 09:36:11 +08:00
Khyperia
a82d8d1d44 Added new player argument: /spawnmob <mob> [amount] [player]
Test: #821
2011-12-07 09:36:11 +08:00
ementalo
9ca0e51dac Merge branch 'master' of github.com:essentials/Essentials 2011-12-07 01:13:08 +00:00
ementalo
10597cec2f Catch TeleportClause.COMMAND in the teleport listener.
Changed Teleport methods to pass a TeleportClause param
2011-12-07 01:12:36 +00:00
Khyperia
b49a9ef165 New feature: /mail sendall <message>
Test: #649
2011-12-07 08:53:15 +08:00
Khyperia
d573671933 Renamed /find to /itemdb 2011-12-07 08:53:14 +08:00
Khyperia
a0d66ce230 New command: /find <item>
Test #278
Test #293
Test #348
2011-12-07 08:53:14 +08:00
snowleo
854fc05c5b Fix serious bug in Dev2.7.137 - Dev2.7.144: if spawn.yml is not present, the server will run into a deadlock. 2011-12-07 00:08:45 +01:00
ementalo
b9077d91a5 Adding ability to save /back location from teleport events outside essentilals
New config setting to turn this on "register-back-in-listener"
Test #1200
CB#1560 / B#1055
2011-12-06 22:56:38 +00:00
snowleo
ff13279e6c Fixing color in announce-format 2011-12-06 22:02:19 +01:00
snowleo
ce3a7c8719 This is no longer needed 2011-12-06 17:44:02 +01:00
snowleo
9e1571a8e5 More cleanup 2011-12-06 17:42:55 +01:00
snowleo
d2953c99ef Added /jail /ejail alias to plugin.yml 2011-12-06 17:31:35 +01:00
snowleo
72e187cd5c Updated Jails to use the new config classes 2011-12-06 17:28:48 +01:00
snowleo
2851a4634c cleanup 2011-12-06 16:35:30 +01:00
snowleo
58237a796a New Interfaces in api package (WIP) 2011-12-06 16:32:06 +01:00
snowleo
5433a68502 UserBase is abstract 2011-12-06 15:40:35 +01:00
snowleo
a7097df231 Refactoring to create less redundant code 2011-12-06 15:38:14 +01:00
snowleo
51390a9698 Prevent some rare cases of NPE and Deadlocks, better error handling on yaml load 2011-12-06 14:39:52 +01:00
snowleo
019b49ef11 Updated EssentialsSpawn to use the new config code
/spawn and /home now call the PlayerRespawnEvent to make it more compatible with other plugins.
2011-12-06 13:41:29 +01:00
snowleo
f3b278eac2 More work done on config code 2011-12-06 10:37:17 +01:00
snowleo
6fe8e603af Using the correct type of Set in UserMap. 2011-12-06 08:28:41 +01:00
snowleo
6b06adfc23 Check if the item can be enchanted. 2011-12-05 00:20:46 +01:00
Khyperia
2b919faa7b Added {VERSION} to motd
Test #1198
2011-12-05 06:56:20 +08:00
snowleo
b2ffdc9774 utf8 encoding 2011-12-04 23:39:08 +01:00
snowleo
e5aa7f496b Merge remote-tracking branch 'dysp/patch-1'
Conflicts:
	Essentials/src/messages_da.properties
2011-12-04 23:37:01 +01:00
snowleo
cb89fe5358 Readded because of popular demand: default-stack-size for /give and /item, values below 1 return max stack size (or oversized stack size). 2011-12-04 23:21:30 +01:00
snowleo
ad60eb538e Ignore teleport cooldown on /tjail 2011-12-04 22:57:40 +01:00
snowleo
cbc744c85a Added missing steps to items.csv (by andrewkm from ecocitycraft.com) 2011-12-04 22:53:29 +01:00
snowleo
6371a59819 Fix some rare cases, where adding an item to inventory could result in an infinite loop. 2011-12-04 22:45:47 +01:00
snowleo
20bc8840d6 Allow oversized stacks in kits. 2011-12-04 22:33:49 +01:00
snowleo
f12e9f6dfb Enchantements are now stored in one class 2011-12-04 22:28:29 +01:00
snowleo
c8814bd70e Added missing [player] to plugin.yml 2011-12-04 22:10:20 +01:00
snowleo
8417c5e1f0 New permission essentials.spawn.others 2011-12-04 22:09:36 +01:00
snowleo
ec3586c08c Added null check to /break 2011-12-04 22:06:03 +01:00
snowleo
d9c773270b Less use of sqrt 2011-12-04 22:01:50 +01:00
snowleo
dd84f5c331 Merge pull request #35 from khyperia/master
Multiple commits from khyperia
2011-12-04 12:49:52 -08:00
Khyperia
2c2f956068 Added [enchant] sign
Test #1177
2011-12-04 14:58:00 -05:00
Khyperia
ba3ccf7a2c Added /spawn <player>
Test #607
2011-12-03 20:24:35 -05:00
KHobbits
90f87804b1 Show command conflict in debug mode. 2011-12-03 23:38:28 +00:00
KHobbits
ea21e402ec Sort translation files properly. 2011-12-03 21:18:15 +00:00
KHobbits
1066f7a478 New Permission: essentials.world.<worldname>
~ Unsure about the future of this feature, its recommended you don't rely on /world to switch worlds ~
Test #1178
2011-12-03 21:15:53 +00:00
KHobbits
1c03cdb4d0 New command /remove
Test #1193
2011-12-03 21:14:03 +00:00
KHobbits
6d3e1b862e New command: /feed New permission: essentials.feed.others
Test #1191
2011-12-03 20:54:53 +00:00
KHobbits
d4c2443b5f New command: /more
Test #1189
2011-12-03 20:44:44 +00:00
KHobbits
8ce8764f6a New Command /break, and new Permission: essentials.break.bedrock
Test #1188
2011-12-03 20:41:24 +00:00
KHobbits
343618642b Merge pull request #34 from khyperia/master 2011-12-03 12:36:38 -08:00
Khyperia
1cb593dba3 Added per-world permissions for /world 2011-12-03 12:13:42 -05:00
Khyperia
85d743dce5 Merge commit 2011-12-03 11:14:53 -05:00
KHobbits
118b3638eb Small cleanup to checkActivity 2011-12-03 13:50:32 +00:00
Khyperia
dc74239edc Fixed accedental typo 2011-12-02 20:55:43 -05:00
Dysp
647eac32fc The last translation was so poorly done (I suspect the use of google-translate) that I decided to translate it myself. There may be errors due to lack of insigt for the context of the individual sentence. I can easily correct these, if I am notified. 2011-12-03 01:05:12 +01:00
Khyperia
91be153474 Added some commands from request 946 2011-12-02 19:02:12 -05:00
KHobbits
b03a327f9b Patching gamemode and god toggles to not match on ' ' 2011-12-02 21:32:32 +00:00
KHobbits
3b2403b686 items.csv update for crackedstonebrick (id98,2) 2011-12-02 09:28:57 +00:00
KHobbits
16e3830f9e Remove invalid dupe permission from permbukkit example. 2011-12-02 09:23:23 +00:00
KHobbits
73ec9978fb Make the chat formatting config file link to the wiki. 2011-12-02 09:17:20 +00:00
snowleo
055f11c89e Missing language files for last commit 2011-12-02 08:34:28 +01:00
snowleo
1489203aca New config options repair-enchanted (default true) and permission essentials.repair.enchanted 2011-12-02 08:30:52 +01:00
snowleo
1f1b6aff54 Allows to be teleported to bed location of offline players.
Also adds missing return in /home command
2011-12-02 08:19:55 +01:00
snowleo
8d4d8effa0 Null check 2011-12-02 03:27:37 +01:00
snowleo
8591023ad5 Moved block to item conversion to Util class 2011-12-02 03:25:22 +01:00
snowleo
42f4bba320 Added new tags to info.txt 2011-12-02 02:01:48 +01:00
Khyperia
746c80b0d6 Added many new MOTD possibilities + getI18n() to Essentials.java 2011-12-02 08:42:48 +08:00
Khyperia
bbb47fe6d3 Added {DATE} and {TIME} to motd 2011-12-02 08:42:48 +08:00
Khyperia
4c1c3e4852 Added many new MOTD possibilities + getI18n() to Essentials.java 2011-12-01 19:37:12 -05:00
KHobbits
3b0c604de0 Missing command aliases. 2011-12-01 17:32:48 +00:00
KHobbits
7a80a36eab Missing aliases 2011-12-01 17:25:46 +00:00
KHobbits
83a4431bd7 CB#1538 b#1050 2011-12-01 16:20:53 +00:00
KHobbits
c0eec02f0a Show how far away each player is. 2011-12-01 15:58:25 +00:00
KHobbits
c97d069783 Fixing near output. 2011-12-01 15:31:53 +00:00
KHobbits
b0377498f7 Better distance checking. 2011-12-01 15:15:45 +00:00
KHobbits
00d44873ca Command: /near 2011-12-01 14:43:16 +00:00
KHobbits
2a8ccb43ae Fixing spawnmob errors to say the right thing. 2011-12-01 14:43:00 +00:00
KHobbits
f006932639 Merge branch 'master' of github.com:essentials/Essentials
Conflicts:
	Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
	Essentials/src/com/earth2me/essentials/commands/Commandenchant.java
2011-12-01 13:47:06 +00:00
KHobbits
2dc6f8c202 Command Cleanup 2011-12-01 13:42:39 +00:00
snowleo
39851694ad minor changes to items.csv 2011-12-01 04:46:43 +01:00
snowleo
737f7799fc Updated items.csv by michaelwm from ecocitycraft.com 2011-12-01 04:39:51 +01:00
Khyperia
8356624479 Added {DATE} and {TIME} to motd 2011-11-30 21:02:57 -05:00
Khyperia
dde8595c51 Updating to latest 2011-11-30 20:30:21 -05:00
snowleo
909e5bd3f8 Update of Smack to 3.2.1 2011-12-01 02:11:40 +01:00
snowleo
e6e1c7d160 We don't need them anymore. 2011-12-01 01:56:39 +01:00
snowleo
a5f4ada85d This is obsolete too. 2011-12-01 01:41:09 +01:00
snowleo
4f8be31343 Cleanup of the library folder
Also: we don't use the mysql.jar/sqlite.jar anymore, since it is included in craftbukkit. I don't know why this reference in config.yml still exists.
2011-12-01 01:35:48 +01:00
snowleo
40220960f5 We don't need that anymore. 2011-11-30 23:51:41 +01:00
snowleo
3c9f0db3d4 CB#1534 B#1048 2011-11-30 22:59:50 +01:00
snowleo
bd7bd86e62 Allow EssentialsProtect to go into emergency mode, if Essentials core is not present at all. 2011-11-30 21:25:11 +01:00
snowleo
5e2123c91e If Essentials core fails to read one of the configs now, it will disable itself. If other modules detect that Essentials is not enabled, they will be disabled too. EssentialsProtect will go into emergency mode, canceling all events that could hurt your world. Fix the file and either restart or reload the server. 2011-11-30 20:49:11 +01:00
snowleo
15d8ec6026 Removed EnchantmentFix, because it's fixed in CB#1526 2011-11-30 20:49:11 +01:00
KHobbits
a8a9fc3dd6 /spawnmob sheep:<colour> + /spawnmob sheep:baby = /spawnmob sheep:<colour>baby.
And as a nice extra, random: /spawnmob sheep:randombaby 10
2011-11-30 03:58:20 +00:00
KHobbits
1de4a40bf6 Missing an Animal. 2011-11-30 03:44:33 +00:00
snowleo
35f5578436 New config option update-bed-at-daytime that allows players to always set their bed location 2011-11-30 02:51:02 +01:00
snowleo
b8d60674cb Updated readme about format guidelines. 2011-11-30 00:54:44 +01:00
snowleo
a30a28265a Removing old settings.zip 2011-11-30 00:52:55 +01:00
snowleo
f5344b65d3 Fix /balancetop, cache was not cleared 2011-11-30 00:48:51 +01:00
snowleo
37e5260cda Merge branch 'refs/heads/master' into release 2011-11-29 21:55:09 +01:00
snowleo
e169e954ba Merge branch 'refs/heads/groupmanager' 2011-11-29 21:38:00 +01:00
snowleo
5f0936cf44 mirror world_the_end in default config.yml 2011-11-29 21:34:31 +01:00
snowleo
aed160b5fc Using this code until Bukkit fixes spawnCreature() 2011-11-29 19:24:54 +01:00
snowleo
0b2a3fcf7f Output the redirected plugin too. 2011-11-29 18:48:52 +01:00
snowleo
57a0ec9912 Allow joinList to understand Collections. 2011-11-29 18:40:13 +01:00
KHobbits
e5435f24db Merge branch 'master' of github.com:essentials/Essentials 2011-11-29 17:21:46 +00:00
KHobbits
af7eae6201 Adding some debug info to /essentials 2011-11-29 17:21:18 +00:00
snowleo
60067964be Fix NPE in getUser() 2011-11-29 17:39:22 +01:00
KHobbits
cdbae1631d Settings Cleanup. 2011-11-29 16:16:45 +00:00
KHobbits
414d6b79e9 GC: Never force reclaiming RAM on user logout, it will be done automatically, when the time is right.
~ Should reduce player event lag a little bit ~
2011-11-29 16:06:39 +00:00
KHobbits
dd3b1e97b6 Merge branch 'master' of github.com:essentials/Essentials 2011-11-29 13:10:19 +00:00
KHobbits
0c81a68c7b Handle a null handler (GM) 2011-11-29 13:10:00 +00:00
snowleo
183343c388 1TBS? Nope, Allman
This reverts commit a36b755248.
2011-11-29 05:06:07 +01:00
snowleo
a36b755248 New format guidelines? 2011-11-29 04:51:29 +01:00
ElgarL
1838dbc931 globalgroups prefix 'g:' is now not case sensitive. 2011-11-29 02:32:09 +00:00
snowleo
525fefc484 UserMap.getUser() will return null on failure. 2011-11-29 00:36:36 +01:00
snowleo
4bacdb327a Fix NPE when reading old player files 2011-11-29 00:30:06 +01:00
snowleo
19b8031933 Merge branch 'refs/heads/master' into release 2011-11-28 22:42:17 +01:00
snowleo
91cdff955a Fix another bug in /sell 2011-11-28 22:41:26 +01:00
snowleo
8c06b13a77 Allow to set size of MagmaCubes in /spawnmob 2011-11-28 22:06:59 +01:00
snowleo
7db7fd4136 Added info how to read the next page to /info /help /motd /rules 2011-11-28 20:52:15 +01:00
snowleo
99211fd407 Merge branch 'refs/heads/master' into release 2011-11-28 20:28:05 +01:00
snowleo
5e24584bf7 Fix bug in /sell command 2011-11-28 20:24:13 +01:00
snowleo
3d839c2b21 Merge branch 'refs/heads/master' into release 2011-11-28 20:03:09 +01:00
snowleo
9acc7db06f Changes to /sell /give and /item
Material.getMaxStackSize() will now be used in /give and /item
The config option default-stack-size has been removed
New config option oversized-stacksize and permission essentials.oversizedstacks
Fixes bug giving out too many items on /give and /item when a stacksize > 64 is given.
Fixes bug in /sell that ignores enchantments
/sell now uses Material.getMaxStackSize() for /sell egg 2s (will sell 32 instead of 128 now)
2011-11-28 19:55:51 +01:00
snowleo
0354b8d019 Translation of /balancetop 2011-11-28 18:59:33 +01:00
snowleo
eea7785b7f Calculation of /balancetop is now async to prevent slowdown of the server 2011-11-28 18:53:38 +01:00
snowleo
7268e1965d Ignore defaultstacksize from config, just use 64 2011-11-28 17:58:26 +01:00
KHobbits
4614d6d0dd Merge branch 'master' of github.com:essentials/Essentials 2011-11-28 12:56:20 +00:00
KHobbits
4a83d17fec Adding extra mobs to essentials protect, changing some default settings. 2011-11-28 12:55:54 +00:00
snowleo
e8d64aca5e New option for EssProtect: Prevent villager death. 2011-11-28 06:15:51 +01:00
snowleo
e1e7a1cfdb Merge branch 'refs/heads/master' into release 2011-11-28 04:23:38 +01:00
snowleo
b637e494c2 Forgot this again. :D 2011-11-28 04:15:09 +01:00
KHobbits
ccfc3b8d78 Someone said something about wanting Snowmen.
... and MagmaCubes.
Bukkit #1045 CraftBukkit #1522
2011-11-28 03:12:37 +00:00
KHobbits
05c90af1ee Fix empty argument in delhome. 2011-11-28 02:54:19 +00:00
snowleo
6603d0997e Fix broken trade/buy signs because of a wrong cast 2011-11-27 22:36:32 +01:00
snowleo
0ed7f87ee0 Merge branch 'refs/heads/master' into release 2011-11-27 20:59:19 +01:00
snowleo
aceda4c680 Allow enchantments to be removed using /enchant enchantmentname 0 2011-11-27 20:40:39 +01:00
snowleo
67be976d90 New permissions:
essentials.spawnmob.[mobname] and essentials.spawner.[mobname]
2011-11-27 19:59:06 +01:00
snowleo
ec6baa3621 Catch exception instead of checking for null 2011-11-27 19:13:55 +01:00
snowleo
82f864a7f9 Update Essentials/src/messages_fr.properties 2011-11-27 18:56:04 +01:00
snowleo
2a22c04688 Merge pull request #32 from leagris/patch-1
Up to date, more accurate french translation.
2011-11-27 09:55:33 -08:00
Léa Gris
1c6c460a09 Up to date, more accurate french translation. 2011-11-27 17:52:12 +01:00
snowleo
c5251591de Allow /unbanip playername, not just ips 2011-11-27 16:58:47 +01:00
snowleo
ccb4d3a7e8 Don't add the internal bukkit names to the enchantment list, to make it shorter. 2011-11-27 11:43:42 +01:00
snowleo
d5db9d404a Revert to the old behavior of oversized stacks. We might remove or change this in the future. 2011-11-27 10:59:28 +01:00
snowleo
0c0c9573be Updated the enchantment names to match those of the game 2011-11-27 10:48:10 +01:00
snowleo
76a8f794ef Enchantments in CraftBukkit are still broken, but it works with Essentials :) 2011-11-27 10:02:41 +01:00
snowleo
cbba3639b9 Fix Typo 2011-11-27 09:09:04 +01:00
snowleo
8791a8dbb7 Only print stack trace of motd.txt not found, if debug is on. 2011-11-27 09:07:15 +01:00
snowleo
098072517a Added enchantment to /give and /item
Updated plugin.yml
2011-11-27 08:57:21 +01:00
snowleo
b8f9a4b96f Implement correct hashCode() and equals() in EnchantmentLevel 2011-11-27 08:26:52 +01:00
snowleo
9c56b147ee Enchantment Multiplier in future Worth config 2011-11-27 08:18:41 +01:00
snowleo
41e8c4c7b8 Enchantments on Trade signs? Fixes check, so we won't add items that are enchanted. 2011-11-27 07:47:16 +01:00
snowleo
a8a72da15e Added 1.9 material where you can stand 2011-11-27 07:33:03 +01:00
snowleo
9b6c01d071 /spawner without mobname outputs available mobs 2011-11-27 07:32:42 +01:00
snowleo
3c71ae4cd9 Locale.ENGLISH!!1! 2011-11-27 06:23:07 +01:00
snowleo
34edf34ba3 Using the ItemStack.clone() method 2011-11-27 06:10:11 +01:00
snowleo
f250a107e4 CB#1518 B#1042
Support for Enchantments & Removed broken BedFix (in cb now)
2011-11-27 06:01:41 +01:00
KHobbits
d5c852b79d URL went nowhere. 2011-11-27 04:54:48 +00:00
snowleo
65776d6ed2 BedLocationFix for CraftBukkit 2011-11-27 04:46:33 +01:00
snowleo
0234c55ce3 New command /enchant
Permissions for each enchantment: essentials.enchant.[enchantmentname]
For all use *
2011-11-27 04:36:42 +01:00
KHobbits
ee42030307 Merge remote branch 'remotes/origin/groupmanager' 2011-11-27 03:16:32 +00:00
ElgarL
263a3fc80b Added file details in error messages for loading groups/users. 2011-11-27 03:12:28 +00:00
snowleo
a714e39bf4 CB#1512 B#1039 2011-11-27 03:22:39 +01:00
KHobbits
68297b5cf8 Merge branch 'master' of github.com:essentials/Essentials 2011-11-27 01:15:39 +00:00
KHobbits
ae4c10ced6 Fixing optional argument on tppos to use the correct yaw value. 2011-11-27 01:15:14 +00:00
snowleo
b5e9ad02ae arrrgggss 2011-11-27 00:31:14 +01:00
snowleo
c70700f7b8 Fix banning random player (and all other commands where a empty player is given) 2011-11-27 00:23:40 +01:00
snowleo
b21b7b7e15 New behavior of the /home command and beds
- The behavior has been altered to match the vanilla server.
 - Using a bed will no longer create a home in the users file, if config option bed-sethome is set
 - The config option bed-sethome has been removed
 - It's now possible to go to /home bed or /home playername:bed
 - Bed locations stored before installing Essentials will be used
 - Players respawn at their bed location (if set) instead of the spawn, if respawn-at-home is set to false
 - The default value of spawn-if-no-home is set to true
 - If spawn-if-no-home is set and the player has not set a home, he will be either teleported to his bed location (if set) or the spawn, when he uses the /home command
2011-11-26 22:30:40 +01:00
snowleo
f9d14697b6 Forgot to save this file before commit 2011-11-26 17:37:07 +01:00
snowleo
8ed4418d5f Translated /list command 2011-11-26 15:26:48 +01:00
snowleo
4ad19b6fad Cleanup 2011-11-26 00:34:36 +01:00
snowleo
d4685d1d10 Fix ItemDupe bug in bukkit 2011-11-25 22:26:06 +01:00
snowleo
fa73394113 Merge branch 'refs/heads/groupmanager' 2011-11-25 21:12:38 +01:00
ElgarL
b25a8f059b Optimizations include changing the return of comparePermissionString. 2011-11-25 19:33:32 +00:00
ElgarL
0cb77d8a03 Minor optimization for groups 2011-11-25 16:34:34 +00:00
ElgarL
b41c3709ba Raised bukkit perms priority 2011-11-25 16:01:46 +00:00
ElgarL
24a6073488 Fix superperms to pass all tests
http://dev.bukkit.org/server-mods/superpermstest/
2011-11-25 15:49:35 +00:00
snowleo
3daf56c8be Another safety check 2011-11-25 14:02:40 +01:00
snowleo
223028f306 Fix another NPE in AlternativeCommandsHandler 2011-11-25 13:55:09 +01:00
snowleo
7afbad3218 This config option is never read 2011-11-25 13:03:07 +01:00
snowleo
871c0e6b6a Disable god mode automatically in worlds defined by config 2011-11-25 07:12:21 +01:00
snowleo
73d13f5748 Oh no! Angry wolf babies D: 2011-11-25 06:04:19 +01:00
snowleo
03452bda68 Baby wolfs, awwwwh 2011-11-25 05:54:32 +01:00
snowleo
613cb57fdb CB#1501 B#1037
New spawnmob options: cow:baby sheep:baby chicken:baby pig:baby
2011-11-25 05:49:57 +01:00
snowleo
31b9e792bd Fix NPE in AlternativeCommandsHandler on shutdown 2011-11-25 00:22:57 +01:00
ElgarL
cd8ef9361b minimal optimizations 2011-11-24 16:45:57 +00:00
ElgarL
eea381e714 optimize getPermissionList 2011-11-24 16:34:05 +00:00
ElgarL
5a9b573309 More optimization (charAt(0)) 2011-11-24 16:05:41 +00:00
ElgarL
70c235d4f0 remove unused imports. 2011-11-24 16:00:46 +00:00
ElgarL
127681736d rewrite of comparePermissionString (snowleo) 2011-11-24 15:57:21 +00:00
ElgarL
73a7a6a1dd Optimize comparePermissionString 2011-11-24 15:28:32 +00:00
ElgarL
dec7ea1926 remove bukkit perms check from checkUserPermission as it's performed in
checkFullUserPermission
2011-11-24 14:05:25 +00:00
ElgarL
94983c3ca7 Optimize sorting to speedup permission tests. 2011-11-24 13:26:30 +00:00
snowleo
32e43bf167 Show more then 9 lines of motd on login 2011-11-24 05:57:01 +01:00
snowleo
579bbc9f2c Merge branch 'refs/heads/master' into release 2011-11-24 04:26:05 +01:00
KHobbits
af456a73dd New permission essentials.nick.color
Allows control over who can use colour codes in nicknames.
2011-11-23 22:24:31 +00:00
snowleo
b35d5f30f9 Invert pattern 2011-11-23 02:52:08 +01:00
snowleo
8aaaed2ef8 More work on the config code 2011-11-23 02:43:38 +01:00
snowleo
e683ce5751 Merge branch 'refs/heads/groupmanager' 2011-11-22 15:12:20 +01:00
snowleo
b0aaafd08d GM does not need CraftBukkit 2011-11-22 06:02:47 +01:00
KHobbits
212442ab1c Fixing inventory method calls.
Bug report: http://pastie.org/2901587
2011-11-22 04:55:21 +00:00
KHobbits
bf244fff80 Switching priority on help permissions
Bukkit #1488
2011-11-22 04:41:34 +00:00
KHobbits
2620e2ae08 Merge branch 'master' of github.com:essentials/Essentials 2011-11-22 04:00:26 +00:00
KHobbits
d59e2834d1 Rewriting help, to use new classes. 2011-11-22 04:00:04 +00:00
snowleo
63991cb38d Moved all dependency on craftbukkit to one package in the main jar. The rest is now clean bukkit code. Also cleaned PlayerExtension class. 2011-11-22 03:02:08 +01:00
snowleo
94b70e1ee9 Corrected name in items.csv: whitestone => enderstone 2011-11-22 02:25:56 +01:00
ElgarL
fd1c2824ce Stop throwing errors on an empty users file. 2011-11-21 09:51:31 +00:00
snowleo
a5853baf4c Set shooter of Fireball or it will die instantly. 2011-11-21 03:50:31 +01:00
snowleo
90694b15cc Added new creatures to EssProtect prevent spawning
Ghast and Slime default value changed
2011-11-21 03:21:02 +01:00
snowleo
5e4b7f85c8 Cleanup 2011-11-21 03:07:44 +01:00
snowleo
b5bc83e714 Fixing the tests 2011-11-21 03:05:18 +01:00
snowleo
220d68f375 Switch to the new I18n class and format cleanup of all classes 2011-11-21 02:55:26 +01:00
snowleo
e672de949c Merge branch 'refs/heads/master' into release 2011-11-20 21:46:02 +01:00
snowleo
19f5a2340d Fix timeWorldCurrent translation key in /time command 2011-11-20 19:12:20 +01:00
snowleo
1e4a54baca Prevent NPE with creatures that are not added to bucket yet. 2011-11-20 16:50:08 +01:00
snowleo
14cc499421 Fix long prefix breaking setPlayerListName(), because they are too long.
If Essentials detects, that the player name would be too long with prefix and suffix to fit in the player list, it will only update the name without prefix and suffix but with nickname and opcolor.
2011-11-20 16:43:38 +01:00
snowleo
6633b39954 Fix Bukkit version pattern 2011-11-20 16:40:18 +01:00
snowleo
a886645afa Add SmallFireball to EssProtect 2011-11-20 15:43:39 +01:00
snowleo
8c478c76a5 Added option to /fireball command: /fireball small 2011-11-20 14:34:03 +01:00
snowleo
293f2f7cd2 Added new mobs 2011-11-20 14:33:17 +01:00
snowleo
1f6b1f4a2c Added new methods to Fake classes 2011-11-20 14:30:54 +01:00
snowleo
765ec51b32 Added the new items to items.csv 2011-11-20 14:30:21 +01:00
snowleo
c132a75c1a CB# 1467 B#1022 2011-11-20 14:03:00 +01:00
ElgarL
000d060ea6 better groups match checking for globalgroups 2011-11-20 02:27:25 +00:00
ElgarL
317b0833ef Prevent Group.equals tests throwing a NullPointerException for
GlobalGroups.
2011-11-19 20:46:34 +00:00
snowleo
f72762bcb2 Merge branch 'refs/heads/master' into release 2011-11-19 16:04:00 +01:00
KHobbits
4f8319bbb9 Warn in the console if group prefixes are too long.
People using displayname prefixes can set longer chat prefixes in the chat config.
2011-11-18 23:08:16 +00:00
KHobbits
cd9ea163e4 Continuing code cleanup 2011-11-18 22:09:26 +00:00
KHobbits
fc00ff471d Merge branch 'master' of github.com:essentials/Essentials into essmaster 2011-11-18 19:18:06 +00:00
snowleo
85ef892f0e Null checks 2011-11-18 20:15:26 +01:00
KHobbits
2e0fb15952 More code cleanup. 2011-11-18 18:33:22 +00:00
KHobbits
11f02fb947 Code cleanup continues... 2011-11-18 18:11:49 +00:00
KHobbits
e5a8cd88f0 Code cleanup continued. 2011-11-18 17:48:49 +00:00
snowleo
9987568ae8 New I18n code, not used yet 2011-11-18 15:04:22 +01:00
KHobbits
a05f730e76 Little more command cleanup. 2011-11-18 13:48:31 +00:00
KHobbits
5655509c62 Updating gitignore to ignore private files. 2011-11-18 12:10:36 +00:00
KHobbits
a9b77b3486 Updating gamemode to allow essentials.gamemode.other. 2011-11-18 12:08:27 +00:00
KHobbits
37bd9bc9b5 Merge branch 'master' of github.com:essentials/Essentials into essmaster 2011-11-18 12:07:11 +00:00
KHobbits
e54d73704e Command cleanup 2011-11-18 12:06:59 +00:00
KHobbits
e5c77c1aeb Updating web push to just push the zip files. 2011-11-18 12:06:19 +00:00
snowleo
edf0ab756c Updated UserMap to newest Guava-API 2011-11-18 05:29:27 +01:00
snowleo
c96b14a34c Remove useless import 2011-11-18 05:23:38 +01:00
snowleo
3841648eba Update ExecuteTimer to use ns instead of ms for calculations, output is still in ms 2011-11-18 05:13:38 +01:00
snowleo
ffc1640308 Java 1.5 clients will never reach that point, so we can remove it. 2011-11-18 04:22:09 +01:00
snowleo
0bbc1e540b motd and rules are now configured in the files motd.txt and rules.txt, values from config.yml are copied automatically
New features:
Info command now understands the tags from motd and rules
motd and rules are now multipage
On join, only the first page of motd is shown.
2011-11-18 04:18:03 +01:00
snowleo
2a98734d22 Better solution for the alternative commands 2011-11-18 01:43:58 +01:00
snowleo
603d23659b Check for other plugin aliases and run them instead. 2011-11-18 01:01:05 +01:00
snowleo
7ecc3c25b0 Merge branch 'refs/heads/master' into release 2011-11-17 19:06:44 +01:00
snowleo
41c03853ab General fix against overwriting already existing protections 2011-11-17 17:06:06 +01:00
snowleo
adcffba7cf Merge branch 'refs/heads/master' into release 2011-11-17 16:34:39 +01:00
snowleo
2a4c26ee69 Prevent that sign protection in EssProtect can be circumvented by placing signs. 2011-11-17 16:20:31 +01:00
snowleo
8143154826 The data value of leaves changed by 4
0 -> 4, 1 -> 5, 2 -> 6 to make them permanent, items.csv should be updated automatically
2011-11-17 16:14:56 +01:00
snowleo
e271e60144 Merge branch 'refs/heads/master' into release 2011-11-17 15:34:27 +01:00
snowleo
c5c29aef4e Merge branch 'refs/heads/groupmanager' 2011-11-17 15:34:05 +01:00
ElgarL
7b7d1f557f Fixed a crash on reload due to bukkit not unloading plugins before
reloading.
2011-11-17 14:28:33 +00:00
snowleo
af5a86c48c Fix water/lava bucket bug with mobs 2011-11-17 14:23:35 +01:00
ElgarL
022f7ab1d4 Fixed GM holding files open and causing the time stamp to be incorrect.
This caused GM to require a '/mansave force' when it shouldn't be
needed.
2011-11-17 05:46:01 +00:00
snowleo
b9daf6aaa5 Sudo: This would break horrible for offline players and the original player object has to be used. 2011-11-16 04:26:24 +01:00
KHobbits
4be1797592 Sudo Command
This might never make it to release, needs tidying first at least.
2011-11-16 03:00:31 +00:00
KHobbits
c0d046841f Gamemode sign, standard sign permissions. 2011-11-16 00:21:55 +00:00
KHobbits
e4c3f7b115 New permission: essentials.repair.armor
If a player has this permission '/repair all' will also repair equipped armor.
2011-11-15 23:54:26 +00:00
KHobbits
f51b92c99e Updating banip to support offline players. 2011-11-15 23:01:15 +00:00
snowleo
16be86953f Merge branch 'refs/heads/master' into release 2011-11-15 22:52:42 +01:00
snowleo
eda827b244 Merge branch 'refs/heads/groupmanager' 2011-11-15 22:52:05 +01:00
snowleo
27ee7efde5 Cleanup of the /tree commands 2011-11-15 22:51:14 +01:00
snowleo
cccebdd62e null the Essentials object in static EcoApi, so it doesn't leak on /reload.
TODO: Make the eco api non-static
2011-11-15 22:51:14 +01:00
snowleo
d2f3bf94ae Prevent that players are teleported to offline players using /tpa and players that lost their tpahere permission 2011-11-15 22:51:14 +01:00
ElgarL
f4e22a17db Added comments to groups.yml for global groups 2011-11-15 18:17:18 +00:00
KHobbits
b619a54105 Prevent client crash on 'Free air' 2011-11-14 10:11:23 +00:00
snowleo
cd897890be Fix #1106 GeoIP announces players who are hidden, on join. 2011-11-11 03:27:09 +01:00
ElgarL
437d3b41b8 Remove bperms nodes which shouldn't be in globalGroups 2011-11-08 13:03:32 +00:00
KHobbits
1f527cdb9e Merge branch 'essmaster' into essrelease 2011-11-08 05:17:42 +00:00
KHobbits
90c9fe7e65 Merge remote branch 'remotes/ess/groupmanager' into essmaster 2011-11-08 05:16:15 +00:00
ElgarL
e9f942e802 Change to default users as examples 2011-11-07 22:15:58 +00:00
ElgarL
f40260acef Minor optimization for Group loading/clone 2011-11-07 15:33:15 +00:00
ElgarL
ab2e8f94f0 Fix for Users file being flagged as updated when it wasn't. 2011-11-07 01:59:12 +00:00
ElgarL
cf9ef46182 Fixed Group/User reloading
Fixed Group.clone(dataholder)
2011-11-05 15:41:40 +00:00
KHobbits
cc5062828a Extra translation keys. 2011-11-05 00:12:07 +00:00
KHobbits
165d499ef3 Adding op/god mode to whois. 2011-11-04 23:41:39 +00:00
ElgarL
1c7e0e5b9f Fix for file date conflict causing memory data to be wiped. 2011-11-04 23:13:42 +00:00
KHobbits
f0c49019dd Only pull/push data on valid player data. 2011-11-04 23:13:21 +00:00
ElgarL
e7234e621d Optimize notify test so it's not run as often 2011-11-04 18:20:09 +00:00
ElgarL
269947bdae Fix string compares 2011-11-04 18:12:37 +00:00
ElgarL
4ac5551c6b Notification of being moved to the default group only happens if it's a
demotion/promotion (not on join).
2011-11-04 17:51:29 +00:00
KHobbits
05242a7e8f Force displayname update on /list.
Tidy duplicate displayname call.
2011-11-04 16:51:00 +00:00
KHobbits
fd2ec22919 Clear all powertools - /powertool c: 2011-11-04 16:42:03 +00:00
KHobbits
7618754b89 Removing Reloadall Command
Tidy plugin.yml
2011-11-04 16:20:09 +00:00
KHobbits
d8f7c82e2d Start logging players last login address. 2011-11-04 15:28:51 +00:00
KHobbits
fd4c82b0eb Merge remote branch 'remotes/ess/groupmanager' into essmaster 2011-11-04 11:40:33 +00:00
KHobbits
70d1c7d7d7 Merge branch 'master' of github.com:essentials/Essentials into essmaster 2011-11-04 11:40:18 +00:00
KHobbits
894d956ba1 Extra command alias's. 2011-11-04 11:39:31 +00:00
ElgarL
52c2110a2b Fixed up javadoc comment errors 2011-11-04 09:36:11 +00:00
snowleo
8890284b3e Temporary debug mode using /essentials debug 2011-11-04 02:44:00 +01:00
KHobbits
02cc1b9fe9 Merge branch 'master' of github.com:essentials/Essentials into essmaster 2011-11-04 00:45:03 +00:00
KHobbits
6d6a29a99d Alias for 'Everyone' on warp signs. 2011-11-04 00:44:41 +00:00
snowleo
1d95f1c6d2 Fix bug in sign state loop 2011-11-04 01:24:01 +01:00
KHobbits
6e4bf932ec Adding game mode command for quick toggling (/gm /creative /gamemode) 2011-11-03 23:39:13 +00:00
KHobbits
a9a8216f4d Spanish translation 2011-11-03 23:11:04 +00:00
KHobbits
f98eb4a40d Adding gamemode to whois
Fixing exception in unban
2011-11-03 23:10:42 +00:00
KHobbits
51920420ce Allow proper escaping and use of & symbol in nicks (&& = &). 2011-11-03 22:19:33 +00:00
KHobbits
d171cce45d Trim long nicknames for use in tab list
Colour Nicknames
Refactor /nick Command
Fix nickother validity checks.
2011-11-03 22:13:50 +00:00
ElgarL
5560ab4294 Fix for an error in checkFullUserPermission caused by players
disconnecting mid perms update.
2011-11-03 20:42:34 +00:00
ElgarL
87ccd7bf46 Fix for an error in checkFullUserPermission caused by silly requests for
a null perm.
2011-11-03 20:29:30 +00:00
KHobbits
d264c26310 Allow the use of the warp command from the console 2011-11-03 16:17:39 +00:00
ElgarL
e873ebd67d GM will now check to see if it's data files have been changed at each
scheduled save.
	  If the files have been altered (on disc) it will reload, so long as
the in-memory data hasn't changed.
	  If the files on Disc have changed AND there have been changes to it's
in-memory data it will show a warning.
	  You then MUST issue a '/mansave force' to overwrite the disc files,
or a '/manload' to overwrite the memory data.
2011-11-02 22:33:29 +00:00
KHobbits
375636cd36 Code tidy, trigger build id update. 2011-11-01 16:54:36 +00:00
ElgarL
57f9bc06b0 Prevent setting 'minutes' in the config to zero causing an error. 2011-11-01 12:12:32 +00:00
ElgarL
97cae6c0cb Added a config.yml setting of 'validate_toggle' for those who prefer
'mantogglevalidate' to always be off.
2011-10-31 20:41:50 +00:00
ElgarL
1fd02b8a4a Expanded 'canUserBuild()' to include inheritance and subgroups. 2011-10-31 20:20:57 +00:00
ElgarL
9734274ed1 Fixed an error on 'manucheckv'. If the users doesn't have the variable
it fell through causing an exception.
Added checking of subgroups for Info nodes.
2011-10-31 20:07:21 +00:00
ElgarL
3f2916967d Added Info node support to Global Groups. 2011-10-31 17:23:24 +00:00
ElgarL
0731de53b4 Typo's and formatting 2011-10-31 09:14:58 +00:00
ElgarL
0f67d42c99 Global Groups yml and class 2011-10-31 08:34:57 +00:00
ElgarL
34ba8e89bc Added Global Groups
Defined in groupmanager/globalgroups.yml.
Create groups in the yml with a g: prefix, then inherit in the worlds
groups files.
2011-10-31 08:34:07 +00:00
ElgarL
b1c6173995 Fixed GM loading world data files twice at startup.
Improved error reporting for invalid groups.yml
2011-10-31 02:06:25 +00:00
okamosy
dd87dcdd3d Merge branch 'master' of github.com:essentials/Essentials into ess 2011-10-30 21:30:21 +00:00
okamosy
ffd7ba7d5f EssChat update part 1. 2011-10-30 21:29:56 +00:00
KHobbits
4ac03ef15a Debug messages: Execution time on reload/enable.
~ Probably needs removed later?
2011-10-30 05:38:17 +00:00
KHobbits
8daa0e7a9b Removing translations for portal actions. 2011-10-30 01:26:05 +00:00
KHobbits
982c3fef0d Merge branch 'master' of github.com:essentials/Essentials into essmaster 2011-10-30 01:37:40 +01:00
KHobbits
1757badf64 Cleanup last references to portal management in Essentials. 2011-10-30 01:37:18 +01:00
snowleo
5196237c46 XMPP: Don't send messages from spy users back to them. 2011-10-30 00:18:55 +02:00
KHobbits
094a747db3 More message, in /me 2011-10-29 10:36:30 +01:00
KHobbits
284f48f631 Updating actions to allow translations, and colour. 2011-10-29 09:38:32 +01:00
KHobbits
c2c889cab9 Tidy the XML a little and test a library property. 2011-10-29 04:31:56 +01:00
KHobbits
a2619a6e2b More teamcity fixes. 2011-10-29 02:50:57 +01:00
KHobbits
6e16e4724d Merge branch 'master' of github.com:essentials/Essentials into essmaster 2011-10-29 02:49:03 +01:00
KHobbits
9afcba4739 Will teamcity like this change? 2011-10-29 02:48:42 +01:00
KHobbits
c05e8085ed Lets try a adding a few dependencies. 2011-10-29 02:31:05 +01:00
KHobbits
6d86f40ca3 Updating build order. 2011-10-29 02:23:13 +01:00
KHobbits
cc9e7130e8 Adding the handler to the (painful) list of permissions systems we support. 2011-10-29 02:16:29 +01:00
KHobbits
809d18575d File formatting. 2011-10-29 02:09:11 +01:00
KHobbits
56b5a128f5 GM permission handler...
Look mum, no bridge.
2011-10-29 02:06:27 +01:00
KHobbits
8915c29b31 Merge remote branch 'remotes/ess/groupmanager' into essmaster 2011-10-28 22:07:43 +01:00
ElgarL
819c8f3aa9 Fixed GM to recognize Superperm child nodes.
If you add a node like Towny.admin GM will now correctly report on
all child nodes.
2011-10-28 18:43:29 +01:00
snowleo
6c479fceed Removing never used ErrorHandler and UpdateTimer from Essentials Core, they are now in EssentialsUpdate 2011-10-27 18:45:27 +02:00
KHobbits
04de66bc8a Sneaking in an option to disable prefix/suffix selectively.
(This will probably be removed during ess chat rewrite).
2011-10-27 06:17:18 +01:00
KHobbits
32cc1b66a4 Merge branch 'master' of github.com:essentials/Essentials into essmaster 2011-10-27 05:48:45 +01:00
KHobbits
65a588ea20 Altering PEX prefix/suffix. 2011-10-27 05:47:55 +01:00
snowleo
e0a29ed6a0 Don't block /essentialsupdate command after selfupdate 2011-10-27 01:18:59 +02:00
ElgarL
fadfc490a7 v 1.5:
- Fixed opOverrides and bukkit_perms_override to read the correct
entries.
	- Better commenting in config.yml
2011-10-27 00:04:54 +01:00
snowleo
fd7894caae After the selfupdate, check for the bukkit version. We will not automatically update bukkit, so the player is displayed a message, if he tries to update or install. 2011-10-27 00:41:12 +02:00
snowleo
8200fc2a98 Close file input on exception 2011-10-27 00:08:48 +02:00
snowleo
4b6fc99a62 Crop after 15KB and add a note, that it's cropped by the upload. 2011-10-27 00:06:15 +02:00
snowleo
60b9d4fc80 Some cleanup, refactoring of EssentialsHelp class 2011-10-27 00:03:16 +02:00
snowleo
7622c5c510 Abort update text 2011-10-26 22:27:43 +02:00
snowleo
76f8cb96ca Reload after installation 2011-10-26 22:23:30 +02:00
snowleo
f6e56ce0f4 Removing automatic updates
It's a bad idea to automatically overwrite files, without asking the player first.

This would be triggered by the selfupdate after the reload.
2011-10-26 22:17:27 +02:00
snowleo
72596decba The state machine now handles both manual updating and installation. 2011-10-26 22:14:24 +02:00
snowleo
e8b8d26bdb Basic automatic updates downloader 2011-10-26 20:25:09 +02:00
snowleo
d5cb9ab965 Cleanup 2011-10-26 20:24:46 +02:00
snowleo
9914e187e2 Cleanup 2011-10-26 20:23:28 +02:00
snowleo
36fa05f3a6 The work process is done async to the server loop. 2011-10-26 19:54:38 +02:00
snowleo
5641b1173c Abort the installation wizard if a runtime exception happens 2011-10-26 19:46:40 +02:00
snowleo
48f8eb9788 Cleanly resume the installation, if the player quits the game and reconnects
If the installation is already running in background after the wizard, it will not stop, if the player quits the game.
2011-10-26 19:39:01 +02:00
snowleo
7f825750f0 Advanced mode 2011-10-26 18:18:58 +02:00
snowleo
102570958e Allow states to be automatically added to the state map.
They have to have a Constructor that accept the StateMap as argument, otherwise a RuntimeException is thrown.
2011-10-26 17:42:39 +02:00
KHobbits
38b6d79f49 Few more states in EssentialsUpdate 2011-10-26 16:26:26 +01:00
KHobbits
d064c68875 Fixing invsee error. 2011-10-26 06:02:54 +01:00
KHobbits
2bb45022d6 Extra triggers for /sell inventory 2011-10-26 03:32:38 +01:00
KHobbits
dc2e23c85a Improved readability of /sell
~translations need checking~
2011-10-26 03:05:09 +01:00
KHobbits
5a54ef355f Cleanup debug message, code tidy. 2011-10-25 22:18:28 +01:00
KHobbits
9af6bdb1d6 Only prevent AFK heal, if freeze player is enabled. 2011-10-25 16:21:56 +01:00
KHobbits
dca88382ab Fix health event name. 2011-10-24 17:46:53 +01:00
KHobbits
d4a495fb52 Merge branch 'master' of github.com:essentials/Essentials into essmaster 2011-10-24 17:00:05 +01:00
KHobbits
a4556e8cf0 AFK users shouldn't heal from full hunger. 2011-10-24 15:37:44 +01:00
snowleo
c79bb03d5e Cleanup 2011-10-23 23:22:04 +02:00
snowleo
9c793208ad Minor changes because we use a map instead of a list 2011-10-23 23:20:18 +02:00
snowleo
b07b3fc373 Another state added 2011-10-23 23:13:30 +02:00
snowleo
ff92e0bf6f Less chance for C&P error 2011-10-23 23:11:47 +02:00
snowleo
8854b3f565 Moving the link between the states from the constructor of the state machine to the states classes. 2011-10-23 23:08:42 +02:00
KHobbits
6974abea28 Automatically unAFK on interaction. 2011-10-23 21:51:38 +01:00
snowleo
9433acf689 Statemachine for installation wizard (WIP) 2011-10-23 21:45:01 +02:00
snowleo
11e8240c5c Merge branch 'refs/heads/master' into release
Conflicts:
	EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
2011-10-22 11:55:01 +02:00
snowleo
aa922c5b67 Fix Test 2011-10-21 01:36:13 +02:00
snowleo
1a020698d1 Use of lomboks delegate on player wrapping 2011-10-21 01:23:35 +02:00
snowleo
022b8caa18 CB#1337
B#953
2011-10-21 00:12:03 +02:00
snowleo
14c406f7fb Merge branch 'refs/heads/groupmanager' 2011-10-21 00:04:40 +02:00
snowleo
4d877741d4 Cleanup 2011-10-19 18:17:19 +02:00
snowleo
1cbd10a38e Moved all config options to new Settings classes 2011-10-19 17:52:07 +02:00
snowleo
358456c8ea Cleanup 2011-10-19 14:47:32 +02:00
snowleo
1c7dcfc63d Merge pull request #30 from tustin2121/master
Porting Some Player-Only Commands to the Console
2011-10-19 05:38:56 -07:00
Tim P
82b225a261 Minor fixes. Basic testing shows all works. 2011-10-18 23:08:06 -04:00
Tim P
6ab30159fa Made a concerted effort to change the messages.properties in the various languages
to the new format for weather.
- Incidently, there was an error in the _da translation - the message for the key
  weatherSun did not have a "in your world" clause. This is added with the "your
  world" clause changed, like it is everywhere.
2011-10-18 22:01:23 -04:00
Tim P
a86a1990cd Made a couple commands available for the console (ones that make sense to be able to
access from the command line).
2011-10-18 12:12:41 -04:00
KHobbits
625c7d0302 Save the ban reason, not the command name. 2011-10-18 05:35:21 +01:00
KHobbits
27a0552c2a Removing debugging. 2011-10-18 02:21:26 +01:00
KHobbits
7c5674c294 More debugging 2011-10-18 02:11:22 +01:00
KHobbits
f5c442aa5c Adding a debug note. 2011-10-18 01:55:35 +01:00
ElgarL
569af0bcf0 Added data.save.hours setting to config. This allow control over how
long backups are retained.
2011-10-16 08:58:45 +01:00
snowleo
238748f360 Updated german translation by HDS 2011-10-16 09:39:06 +02:00
ElgarL
e049364557 Simplified config.yml while retaining backwards compatibility. 2011-10-16 03:35:55 +01:00
ElgarL
121966436e Fixed reading world mirrors from the config. 2011-10-16 01:23:25 +01:00
snowleo
d3afd7a670 Revert bed fix, because it's fixed in Bukkit now. Thanks to feildmaster 2011-10-15 10:49:51 +02:00
snowleo
9d121af860 Test if objects can be read from yaml in the original sort 2011-10-15 01:15:01 +02:00
snowleo
200ef0c8e2 Correctly fix the N/S direction 2011-10-15 01:15:01 +02:00
KHobbits
6f77a2ba07 Moving apikey outside main file.
Keep the actual key in local repo ;)
2011-10-13 20:45:57 +01:00
KHobbits
db97ce99ef Merge branch 'master' of github.com:essentials/Essentials into essmaster 2011-10-13 17:20:03 +01:00
KHobbits
e7b790861f Made a silly little upload script, for uploading things to dev bukkit. 2011-10-13 17:19:25 +01:00
snowleo
d3aaf3c14a New storage system for settings (WIP) 2011-10-13 01:40:11 +02:00
KHobbits
d732821e06 Merge remote branch 'remotes/ess/groupmanager' into essmaster 2011-10-12 17:10:31 +01:00
snowleo
e628c36172 Cleanup 2011-10-12 12:20:02 +02:00
snowleo
9312871250 Replacing martyr with Pircbot 1.5 2011-10-12 05:00:36 +02:00
snowleo
860d446d28 EssentialsUpdate WIP 2011-10-12 03:14:26 +02:00
ElgarL
03adb56d25 Added a config setting - bukkit_perms_override: false
Enable to allow default Bukkit based permissions to remain enabled,
unless directly negated within GroupManager.
2011-10-12 00:16:53 +01:00
KHobbits
4aecc034c2 Fixing typo in release build. 2011-10-11 22:51:30 +01:00
ElgarL
1543bfd550 v 1.4:
- Updated for Bukkits new YamlConfiguration.
	- Cleared remaining Cast errors cause by object cloning.
2011-10-11 22:05:21 +01:00
KHobbits
a111a07bca Merge branch 'essmaster' into essrelease 2011-10-11 20:06:23 +01:00
KHobbits
9ec398b39b Fixing german translation error. 2011-10-11 20:05:38 +01:00
KHobbits
eb71097546 Merge remote branch 'remotes/ess/master' into essrelease 2011-10-11 17:52:56 +01:00
ElgarL
1bb3eb0d07 Added two new permission nodes - groupmanager.notify.self &
groupmanager.notify.other
	  These allow players/admins to be notified when players are moved
between groups.
2011-10-11 13:10:29 +01:00
snowleo
5395b6f73a Merge branch 'master' into groupmanager 2011-10-11 12:51:53 +02:00
snowleo
5851c5a88b Changes for new Bukkit 2011-10-11 12:49:10 +02:00
snowleo
1c1726cfa4 CB#1317
B#941
2011-10-11 12:49:10 +02:00
ElgarL
a6bafca091 Removed null supression in GroupManager.java 2011-10-11 01:07:52 +01:00
ElgarL
6877f95636 Merge branch 'groupmanager' of
https://elgarl@github.com/essentials/Essentials.git into groupmanager

Conflicts:
	EssentialsGroupManager/src/Changelog.txt
2011-10-11 01:05:48 +01:00
ElgarL
cb41b7ac33 Fixed manudelsub not correctly selecting the group to remove. 2011-10-11 01:03:38 +01:00
KHobbits
d2fa4523ce Changing essentials URL, we should at least give one that works, although bukkitdev would probably be better. 2011-10-11 00:37:03 +01:00
ElgarL
9129386f12 Fixed manudelsub not correctly selecting the group to remove. 2011-10-11 00:34:17 +01:00
KHobbits
c7fcb72d6c Merge remote branch 'remotes/ess/master' into essrelease 2011-10-10 17:21:48 +01:00
snowleo
02ee314ab1 Fix NPE in BUY signs 2011-10-10 11:40:20 +03:00
snowleo
04af8ef329 Merge branch 'master' into release 2011-10-10 00:30:47 +02:00
snowleo
a34c92d55a Fix of the recharge code, also the maximum line length on signs is 15 not 16! 2011-10-10 00:27:55 +02:00
snowleo
4cdf803ab7 Merge branch 'master' into release 2011-10-09 23:52:15 +02:00
snowleo
6012086fa5 Reverting ementalos change on freeze-afk, hopefully fixing the flickering. 2011-10-09 23:45:46 +02:00
snowleo
67c0f57756 Cleanup 2011-10-09 23:31:13 +02:00
snowleo
164070b487 Notch decided that the sun rises north and sets south.
"Corrected" values for /getpos and /compass
2011-10-09 23:23:00 +02:00
snowleo
d658c75cec Prevent that long lines are stored on the sign 2011-10-09 23:00:58 +02:00
snowleo
4c69412501 Allow players to recharge trade signs without breaking them.
Also don't give out items, if their inventory is full.
2011-10-09 22:52:11 +02:00
snowleo
75a0164ea0 Don't spill out items, if inventory is full on buy signs. 2011-10-09 22:25:30 +02:00
KHobbits
9dde04e4b8 Edited Essentials/src/items.csv via GitHub 2011-10-09 22:10:40 +02:00
snowleo
3496df6468 Allow to disable the death messages of minecraft 2011-10-09 20:59:06 +02:00
snowleo
ac794bb2b7 Corrected datavalues for pistons 2011-10-09 20:57:34 +02:00
snowleo
7384991efa Cancel early, not late 2011-10-09 20:14:41 +02:00
snowleo
f3dc846b1b Prevent players with essentials.sleepingignored permission from going to bed. Prevents a bug in bukkit. 2011-10-09 20:10:21 +02:00
snowleo
4595c15bee Merge branch 'master' into release 2011-10-09 17:54:59 +02:00
snowleo
81994160e8 Allow players with essentials.signs.trade.override permission break invalid trade signs. 2011-10-09 17:06:32 +02:00
snowleo
cf59a90c52 Throw RuntimeException instead of NPE, if the api is called before Essentials is loaded. 2011-10-09 16:53:01 +02:00
snowleo
a9a87710f3 Easier version of /banip username 2011-10-09 16:44:35 +02:00
snowleo
5984cd5835 Fix pull request of damage request 2011-10-09 16:43:58 +02:00
snowleo
8fe0887141 Merge pull request #29 from zzbomb/patch-1
Improved to operate like.. "banip <IP|Username>" bans the specified IP or
2011-10-09 07:07:15 -07:00
snowleo
8389a59d54 Merge pull request #27 from feildmaster/patch-1
Fires an event before "killing."
2011-10-09 07:06:45 -07:00
snowleo
010245e1a5 Merge pull request #28 from feildmaster/patch-2
Edited Priority to "High" of chat listener
2011-10-09 07:05:55 -07:00
snowleo
1e3d2fbfd2 Merge branch 'master' into release 2011-10-08 19:43:07 +02:00
snowleo
313df9988d Fix NPE in /repair 2011-10-08 19:41:41 +02:00
zzbomb
16384159e7 Improved to operate like.. "banip <IP|Username>" bans the specified IP or the IP of the user specified. 2011-10-08 10:04:07 -03:00
snowleo
06900e19f0 We can get the console command sender from server object now. 2011-10-06 11:54:09 +02:00
snowleo
57c25bf151 Merge branch 'master' into release 2011-10-04 23:07:30 +02:00
snowleo
55fc8bdd57 Register 1.5 2011-10-04 23:06:06 +02:00
snowleo
ae030b227a Merge branch 'master' into release 2011-10-04 22:20:10 +02:00
snowleo
aaf25d8b9a Merge branch 'master' into groupmanager 2011-10-04 22:19:40 +02:00
snowleo
0645d58594 Since it will be released, it needs a new version number 2011-10-04 22:19:23 +02:00
snowleo
11d22f95cc Removing obsolete Nether portal code.
If you want more control over the worlds, I recommend using Multiverse.
/world command still exists, it can be used to switch between worlds. The default ratio of 8 is used for nether.
2011-10-04 21:58:47 +02:00
snowleo
4f85751694 Merge branch 'master' into release 2011-10-04 21:34:28 +02:00
snowleo
65a78a6ea9 Null check for probably corrupted worlds 2011-10-04 21:33:09 +02:00
ElgarL
9f52931191 Comment config.yml to prevent creation of world4 data files 2011-10-04 15:59:26 +01:00
KHobbits
93d0ab7906 Updating Readme 2011-10-04 15:56:43 +01:00
KHobbits
6b0d0daa2e Merge branch 'essmaster' into essrelease 2011-10-04 14:40:12 +01:00
KHobbits
9718e654ac Nick length patch 2011-10-04 14:39:40 +01:00
KHobbits
4d5121c21d Revert "Less dupe code on last commit."
This reverts commit 531f40ceee.
2011-10-04 10:27:58 +01:00
KHobbits
531f40ceee Less dupe code on last commit. 2011-10-04 10:16:35 +01:00
KHobbits
b672d38db8 Fix for /tjail not teleporting users back due to cooldown. 2011-10-04 10:13:44 +01:00
KHobbits
401498a4f7 Merge branch 'essmaster' into essrelease 2011-10-04 09:51:51 +01:00
KHobbits
acdad5c6ac Merge branch 'essmaster' into groupmanager 2011-10-04 09:43:34 +01:00
KHobbits
1a0aa7970b Updating bPermissions 2011-10-04 09:43:00 +01:00
KHobbits
579b30c8f7 Updating bpermissions to latest. 2011-10-04 09:39:02 +01:00
KHobbits
c1fa543524 Adding unjail alias to tjail. 2011-10-04 09:23:44 +01:00
KHobbits
0297d22fac FoodLevelChange event, update. 2011-10-04 09:05:04 +01:00
KHobbits
608ebfdb4a Add hunger replenish to /heal (Do we want to add a toggle?) 2011-10-04 08:34:06 +01:00
KHobbits
da337284e5 Adding list name to /nick support. 2011-10-04 07:21:09 +01:00
KHobbits
0aa9f79629 Removing a few restrictions on manuadd, it shouldnt be a clone of manpromote after all. 2011-10-04 06:55:42 +01:00
KHobbits
9f4d79a756 Updating to CB 1240
Bukkit 875
2011-10-04 06:54:45 +01:00
KHobbits
aa0935c64b Merge remote branch 'remotes/ess/groupmanager' into essmaster 2011-10-03 10:19:31 +01:00
KHobbits
16111b56ad Safe location fix:
x and z needs floor, while y should be round.
2011-10-03 09:58:46 +01:00
feildmaster
4c0fc6e52f Edited Priority to "High"
Adds compatibility to plugins that adds text to the current "format."
2011-10-03 03:45:38 -05:00
feildmaster
7668af15b0 Fires an event before "killing."
Can be made cancel-able.
Could also be written to add "suicide" (if sender == player)
2011-10-03 03:40:42 -05:00
KHobbits
3b9aa445e9 Updating safe teleport locations to include 1.8 blocks. 2011-10-03 08:08:05 +01:00
KHobbits
b2614e363b Fixing mail argument errors. 2011-10-03 06:42:38 +01:00
ElgarL
49e2c38289 Fix for Bukkit passing a null To location on a player Portaling 2011-10-02 18:00:42 +01:00
ElgarL
3030093907 Added the ability to handle unknown worlds at server start.
(GM will create the data files for any worlds it finds which are not
in the config.yml)
2011-10-01 21:07:39 +01:00
ElgarL
0e867df195 Moved events into GMWorldListener
Better error output
2011-10-01 17:58:44 +01:00
ElgarL
bfd6049913 Missed Event class 2011-10-01 17:07:34 +01:00
ElgarL
d2c02569d0 Added event handling to manage new world creation at runtime. 2011-10-01 17:06:14 +01:00
ElgarL
1f6daa7424 Fix for loading of worlds not in the config
Fix for folder creation of unique worlds
2011-10-01 16:22:04 +01:00
ElgarL
30af6f36ce Attempt to stop GM wiping groups/users yml's on a bad shut down. 2011-10-01 13:54:28 +01:00
ElgarL
f712b56671 Rewrote Config loading to use Bukkits Configuration features
Added an opOverride setting in config.
	  If present and set to false, op's will not get overriding permissions
in GroupManager.
	  (one op will not be able to alter another op's settings)
GM will now create all relevant world data files for non mirrored
worlds.
	  (for all worlds named in config.yml)
2011-10-01 13:44:06 +01:00
ElgarL
0462026f33 Fixed an issue with superperms where plugins define perms with
inheritance after the root perms
2011-10-01 11:22:19 +01:00
KHobbits
ea76161ba5 Allow different 'sets' of multiple homes, definable by permission.
- Not sure I like this, but it does seem to work
- changed config key for backwards compatibility (config node sets value on failure).
2011-10-01 10:08:58 +01:00
KHobbits
629dee3a91 Adding MOTD flags to config.yml
Setting config.yml 'warn-on-build-disallow: true' - should reduce number of confused support requests.
2011-10-01 05:02:32 +01:00
KHobbits
f415924811 Patching /unlimited to not give items if player is in creative mode. 2011-10-01 04:57:49 +01:00
KHobbits
4172c563d0 Merge remote branch 'remotes/ess/groupmanager' into essmaster 2011-09-30 20:18:08 +01:00
ElgarL
ab67d0e232 Changed priority if Registered events to lowest. 2011-09-30 08:51:09 +01:00
snowleo
5ea512817a Don't set last location if it's invalid 2011-09-30 02:11:13 +02:00
snowleo
d4c7ea1cd1 Deprecation our TargetBlock class:
There is a function in bukkit that we should use instead
user.getTargetBlock(...)
2011-09-30 01:09:00 +02:00
snowleo
4edf1ad3f5 Kits timeout are now saved in user data 2011-09-30 00:53:25 +02:00
snowleo
6224b07215 Allow the deletion of broken homes 2011-09-30 00:27:53 +02:00
snowleo
a5239ef601 Allow delhome for offline users 2011-09-30 00:15:57 +02:00
snowleo
458068ae87 Fix god mode enabled after afk player quit the game 2011-09-30 00:09:48 +02:00
snowleo
44e920e441 More exceptions thrown 2011-09-29 23:59:25 +02:00
snowleo
f8450e39e3 Correctly throw exceptions if mob spawn protection is on 2011-09-29 23:59:24 +02:00
snowleo
c6e68f72ea Only afk people, if they have essentials.afk permission. 2011-09-29 23:59:24 +02:00
KHobbits
4a52cd7c98 Merge branch 'master' of github.com:essentials/Essentials into essmaster 2011-09-29 22:52:10 +01:00
snowleo
9d68261bac Corrected plurals of new creatures and removed Monster creature, because it can't be spawned anymore 2011-09-29 23:36:49 +02:00
KHobbits
8bb50189bc Merge remote branch 'remotes/ess/master' into essrelease 2011-09-29 00:43:42 +01:00
KHobbits
eb665a059a Merge branch 'essmaster' into essrelease 2011-09-29 00:40:16 +01:00
snowleo
f2407bcc31 Fixing line endings 2011-09-29 01:38:56 +02:00
KHobbits
a8cfbe1eab Merge branch 'master' of github.com:essentials/Essentials into essmaster 2011-09-29 00:34:10 +01:00
KHobbits
03b73072d9 Hiding the nether options, that are going to be removed in a future release. 2011-09-29 00:33:55 +01:00
ementalo
48049f3870 Fix freezeafk so that moving with mouse does not teleport you about. Add check for if some takes the ground away from you 2011-09-29 00:24:52 +01:00
snowleo
d2c553652f Allow both essentials.build and permissions.build in PermissionsBukkit 2011-09-29 01:10:54 +02:00
KHobbits
3dc29be083 Merge branch 'essmaster' into essrelease 2011-09-27 02:01:52 +01:00
KHobbits
ee00fb77d0 Merge remote branch 'remotes/ess/groupmanager' into essmaster 2011-09-27 02:01:18 +01:00
ElgarL
d890418944 Update to 1.2 2011-09-27 01:59:01 +01:00
KHobbits
8e0560ae1a Make sure we don't bounce people with expired tempbans. 2011-09-26 23:37:00 +01:00
KHobbits
82e5447526 Merge branch 'essmaster' into essrelease 2011-09-26 23:06:02 +01:00
KHobbits
8b23f8608d Merge remote branch 'remotes/ess/groupmanager' into essmaster 2011-09-26 22:54:34 +01:00
KHobbits
0dd5134f5a BanIP fixed, work around for isBanned. 2011-09-26 22:37:14 +01:00
ElgarL
a39a904c8a Optimized getAllPlayersPermissions and fixed pushing unknown perms to
superperms.
2011-09-26 21:52:32 +01:00
ElgarL
1d38b72835 Fix for GM not checking inheritance for known superperms nodes. 2011-09-26 21:24:12 +01:00
KHobbits
efcab71969 Updating for register 1.3 2011-09-26 03:20:56 +01:00
KHobbits
41e11a738d Merge remote branch 'remotes/ess/groupmanager' into essmaster 2011-09-25 15:02:01 +01:00
ElgarL
62e1710607 Fixed silly error with isLoaded() 2011-09-25 03:14:38 +01:00
KHobbits
c681befdf2 Merge remote branch 'remotes/ess/groupmanager' into essmaster 2011-09-24 21:41:28 +01:00
ElgarL
2db256678e Fix for if the scheduler fails 2011-09-24 19:18:22 +01:00
ElgarL
a2ca381bbd Forgot to push task 2011-09-24 19:11:59 +01:00
ElgarL
32f5a31ea5 Added a BukkitPermsUpdateTask to only update superperms once on a
load/reload.
2011-09-24 19:10:55 +01:00
KHobbits
87dc671a0d Merge remote branch 'remotes/ess/groupmanager' into essmaster 2011-09-24 17:36:10 +01:00
ElgarL
621f9b4f48 Removed superperms update on plugins unloading. Unneeded and created
undesired lag on shutdown.
2011-09-24 17:33:25 +01:00
KHobbits
3858e1cdd6 Merge remote branch 'remotes/ess/groupmanager' into essmaster 2011-09-24 16:01:04 +01:00
ElgarL
ff7cc5aec9 manulistp <name> + now only lists perms with a value of true 2011-09-24 15:55:53 +01:00
ElgarL
d18a47a643 Final fix for lag on manload 2011-09-24 15:48:01 +01:00
ElgarL
497a08940e manulistp now accepts an additional + to list ALL Superperms
effective permissions (/manulistp <name> +).
manucheckp also outputs superperms results.
2011-09-24 15:26:55 +01:00
KHobbits
bd8fe521cd Adjusting behavior of 'spawn-if-no-home'. 2011-09-24 03:31:20 +01:00
KHobbits
59c93901d3 Minor typing errors in messages.properties 2011-09-24 03:19:05 +01:00
KHobbits
3177f25eb6 Merge remote branch 'remotes/ess/groupmanager' into essmaster 2011-09-24 03:18:25 +01:00
ElgarL
b0fe189156 Fixed wasteful updating of perms on a manload. 2011-09-24 02:53:38 +01:00
ElgarL
8103e822ed Fix for null in PLAYER_TELEPORT for bukkit perms. 2011-09-24 02:47:01 +01:00
KHobbits
c597653ce2 Merge branch 'master' of github.com:essentials/Essentials into essmaster 2011-09-22 17:51:10 +01:00
KHobbits
d9ceb727ef Fix for home names containing invalid characters. 2011-09-22 17:50:42 +01:00
ementalo
2844af0039 Throw correct exceptions Test #943 2011-09-22 17:29:00 +01:00
KHobbits
066f3fd726 Merge branch 'essmaster' into essrelease 2011-09-22 15:29:47 +01:00
KHobbits
e9c0bb2133 Adding extra creature types to prevent spawn setting. 2011-09-22 15:08:55 +01:00
snowleo
f0acf733a5 Merge branch 'master' into release 2011-09-22 10:47:58 +02:00
snowleo
33c6fc1f1f Missing file for last commit 2011-09-22 10:47:39 +02:00
snowleo
91b504cc66 Correctly implement food level on god mode 2011-09-22 10:46:23 +02:00
snowleo
6ea57bcd2f New Methods in Player 2011-09-22 10:39:43 +02:00
snowleo
c92c066a3a CB#1185
B#855
2011-09-22 10:33:30 +02:00
snowleo
caff3c115b BPermissions 1.6.0
Prefix/suffix support for bPermissions
Star permissions are now done by bPermissions
2011-09-22 01:03:54 +02:00
snowleo
517961b26a Merge pull request #26 from codename-B/patch-2
So... it's just some updates.
2011-09-21 15:52:36 -07:00
Ben
85f63d0afe So... it's just some updates. 2011-09-22 00:50:26 +02:00
KHobbits
ecc56351ec Merge pull request #25 from codename-B/patch-1
Edited Essentials/src/examples/bpermissions.yml via GitHub
2011-09-21 13:34:24 -07:00
KHobbits
9b04705ec9 Update to cb #1181 2011-09-21 21:29:31 +01:00
Ben
e786653364 Edited Essentials/src/examples/bpermissions.yml via GitHub 2011-09-21 22:26:30 +02:00
snowleo
e5613d43cc CB#1173
Merge branch 'groupmanager'

Conflicts:
	lib/bukkit-0.0.1-SNAPSHOT.jar
	lib/craftbukkit-0.0.1-SNAPSHOT.jar
2011-09-21 21:38:52 +02:00
ElgarL
ce8f05cd94 - Update to handle 'getDescription().getPermissions(') returning a
list (CB 1172).
2011-09-21 16:23:47 +01:00
snowleo
e52a9c1f6b Merge branch 'groupmanager' 2011-09-21 14:30:27 +02:00
ElgarL
de744fe9e2 - Reverted WorldHolder static change to maintain backward plugin
compatability.
2011-09-21 12:30:11 +01:00
snowleo
a0031d1d45 New config setting: protect.prevent.enderman-pickup
Defaults to false
2011-09-21 02:30:58 +02:00
snowleo
d60dd01f0f Added enderman pickup to sign protection 2011-09-21 02:29:51 +02:00
snowleo
ad3bc2ad98 CB#1163
B#847
2011-09-21 02:10:40 +02:00
snowleo
cf69a6d72c Food for Godmode: There is no event for food yet, so we have to update it manually.
Test #939
2011-09-20 19:29:04 +02:00
snowleo
1a65a31a7e Heal-Signs sets food level to full and removes fire
Test #938
2011-09-20 18:27:26 +02:00
KHobbits
9c998eac2f Merge branch 'master' of github.com:essentials/Essentials into essmaster 2011-09-20 15:13:08 +01:00
ElgarL
2bdc00dc14 All GroupManager commands issued by players are now echoed in the
console.
2011-09-20 14:49:42 +01:00
snowleo
83e8dac6a0 Add missing ; 2011-09-20 15:53:26 +03:00
snowleo
3879d582d3 Merge pull request #24 from eXeC64/master
Fixed bug where players are unable to remove their own chest protection.
2011-09-20 05:44:50 -07:00
KHobbits
1fd5222d40 Merge remote branch 'remotes/ess/groupmanager' into essmaster 2011-09-20 13:36:55 +01:00
Harry Jeffery
fe15bab05f Fixed bug preventing players from removing their own signs 2011-09-20 12:33:42 +01:00
ElgarL
f2dd51cf57 Fix for pushing perms of non superperms supporting plugins 2011-09-20 10:35:05 +01:00
ementalo
ac1f2badc7 do not show socialspy for own actions. Test #732 2011-09-20 00:15:13 +01:00
ElgarL
d3f6e82474 - Push updates to superperms for all valid GM commands. 2011-09-19 22:51:07 +01:00
ementalo
676f941bb8 cleanup of *.properties 2011-09-19 22:48:29 +01:00
ementalo
bd74bd1286 Added new command /powertooltoggle, enables / disables all powertools assigned (does not remove them) Test #919 2011-09-19 22:41:39 +01:00
snowleo
5831cde90e Ignore ComputationExceptions while loading users async 2011-09-18 22:18:54 +02:00
snowleo
b2394048fa Allow yaw & pitch in /tppos 2011-09-18 03:34:05 +02:00
snowleo
4811e46dd6 Updated german translation from ThatGangsta on IRC 2011-09-18 03:29:48 +02:00
snowleo
8d266a3440 Fix GroupBridge build 2011-09-18 02:02:09 +02:00
snowleo
f680fb1b76 Fix GroupBridge build 2011-09-18 01:58:57 +02:00
snowleo
a845f351f8 The correct ant variable from TeamCity 2011-09-18 01:27:39 +02:00
snowleo
997a409b5a Using ant properties 2011-09-18 01:25:04 +02:00
snowleo
a6673c5157 One build file for all configurations 2011-09-18 01:07:43 +02:00
snowleo
5ef7135fc8 Removed PermissionsCommands from BuildAll 2011-09-18 00:50:05 +02:00
snowleo
4c698762c3 Automatic updates for future versions of items.csv
We also update all 1.7.3 versions of items.csv
2011-09-18 00:49:34 +02:00
snowleo
82e389be8f New animals for spawner and spawnmob 2011-09-17 19:50:57 +02:00
snowleo
1df79bc9f4 GroupManager 1.1
Merge branch 'groupmanager'

Conflicts:
	EssentialsGroupManager/src/plugin.yml
	EssentialsGroupManager/src/users.yml
2011-09-17 13:19:47 +02:00
snowleo
ab590af927 New items.csv by andrewkm 2011-09-17 13:17:10 +02:00
snowleo
002e4a2772 New methods in player and server interface. 2011-09-17 13:14:34 +02:00
snowleo
0e9b971280 CB#1137
B#837
2011-09-17 13:10:10 +02:00
ElgarL
73b5fe971f Read from group not user for setting superperms 2011-09-16 20:15:25 +01:00
KHobbits
6398626559 Quickfix: Slightly changing syntax to stop conflict - This needs to be properly addressed 2011-09-15 07:08:05 +02:00
snowleo
828f97c9a8 Merge branch 'bukkitupdate' 2011-09-15 00:34:29 +02:00
snowleo
d6d4752383 Fix getSafePosition once again.
This time: Fix the rare case where the double number is slightly below the actual number (like 1.9999999998)

Also: Fix the case, when the player teleports somewhere in a 2 block high space and on the floor is something like rails.
2011-09-11 04:17:55 +02:00
okamosy
d2bf35dac2 added a clearall option to powertools 2011-09-10 10:39:35 +01:00
okamosy
8d6e3e7c18 Merge branch 'master' of github.com:essentials/Essentials 2011-09-10 09:39:15 +01:00
KHobbits
0b057d8e29 Move 'spawnifnospawn' check to home decision tree. 2011-09-09 14:23:42 +01:00
snowleo
4c6cc5ced0 Updates for banning
Removing the ban workaround

We might remove the ban commands completely.
2011-09-07 22:34:53 +02:00
snowleo
b828222176 CB#1089
B#823
2011-09-07 22:07:31 +02:00
ElgarL
bbab993ef1 Doh, jumped a version 2011-09-06 10:19:11 +01:00
ElgarL
b110ce79cc Final tidy up of superperms for GM 1.2 2011-09-06 10:13:32 +01:00
ElgarL
ab530f35d0 removed unneeded include 2011-09-06 10:12:15 +01:00
ElgarL
0654a76ccc - Fixed BukkitPerms population. Wasn't correctly setting superperms. 2011-09-06 10:11:21 +01:00
snowleo
e8fbdef38b Using the correct player object for dispatching the command on powertool use. 2011-09-05 22:59:37 +02:00
snowleo
96c4dd2ab9 Merge branch 'master' into release 2011-09-05 14:15:07 +02:00
snowleo
998d097d7d Fix afk not disabled after command use 2011-09-05 04:14:02 +02:00
snowleo
df3b9a7ef9 Merge branch 'master' into release 2011-09-04 20:47:46 +02:00
snowleo
fd6f768cca Ignore more local branches 2011-09-04 20:45:59 +02:00
ElgarL
aa085de3e7 Push to Build dev version 2011-09-04 02:09:11 +01:00
ElgarL
2e1c880502 - Fix for an infinite loop bug with the new Bukkit Perms during a new
user creation.
2011-09-03 17:53:34 +01:00
ElgarL
e3756623a1 - Fix for Users.yml containing only 'users:' causing a crash.
- GroupManager will now generate a fresh Users and Groups yml if either
file is empty.
2011-09-03 16:13:43 +01:00
ElgarL
8f28073b29 Minor change to GM's config.yml to make it slightly easier to understand
mirroring
2011-09-03 15:41:23 +01:00
ElgarL
e2024ca2b6 - Invalid groups assigned to players in users.yml will no longer cause
a crash. GM will now set them to the default group instead.
2011-09-03 15:29:44 +01:00
ElgarL
80491513a2 Damn typos 2011-09-03 14:39:10 +01:00
ElgarL
f67e13122d correct typo on setDefaulttWorldHandler 2011-09-03 14:33:47 +01:00
Steve
16e19a7775 - GroupManager will now attempt to select the default world when using
commands instead of failing and telling you to use '/manselect <world>'.
2011-09-03 14:24:32 +01:00
ElgarL
a220b267d4 - Fixed users being able to use 'manuadd' to add users to higher groups
than their own.
	- Added SuperPerms support so GM will update adn provide the
permissions to plugins which only support Bukkit Perms.
	- Added more helpful output to errors on argument lengths.
2011-09-03 11:33:14 +01:00
ElgarL
1153a0eee4 Bukkit Superperms support 2011-09-02 23:07:23 +01:00
snowleo
7d8b0c102c Cross world move check 2011-09-02 17:16:46 +02:00
KHobbits
4abbbcb82b Throwing an error on /sethome if you cant set multiple homes. 2011-09-02 15:58:25 +01:00
snowleo
248e4e2ae2 Disabling update check for now, we have to find a better solution. 2011-09-02 16:28:34 +02:00
snowleo
fb211d722c Prevent that hidden players broadcast afk messages
Prevent that moving players triggers unafk too early, they can now move within a radius of 3 blocks from the position where they went afk.
2011-09-02 16:16:15 +02:00
KHobbits
1b3698283e fix failed edit on github 2011-09-02 09:40:14 +02:00
KHobbits
cccddc3311 Edited Essentials/src/com/earth2me/essentials/perm/Permissions2Handler.java via GitHub 2011-09-02 09:35:26 +02:00
snowleo
70a3a5919e Merge branch 'master' into release 2011-09-02 00:05:05 +02:00
snowleo
fc7a3e091d Restore tempban functionality 2011-09-01 17:55:13 +02:00
snowleo
f6b4daebb5 items.csv changes by andrewkm 2011-09-01 17:54:05 +02:00
snowleo
688d37ee60 Merge branch 'master' into release 2011-09-01 16:35:47 +02:00
snowleo
382bd24046 Prevent afk message after login, also don't show afk message on logout. 2011-09-01 15:29:45 +02:00
snowleo
e0d913dbaf Sample permissions for PermissionsBukkit, PermissionsEx and bPermissions 2011-09-01 13:47:49 +02:00
snowleo
bb1cad1bc1 Copy&Paste Bugs are always stupid 2011-09-01 11:52:52 +02:00
snowleo
d7af679243 Cleanup 2011-08-31 13:03:01 +02:00
snowleo
c8f6ea7f8e Cleaner checkPermissions() 2011-08-31 13:02:21 +02:00
snowleo
d3dd4980a4 Using base instead of our wrapped player for permission check. 2011-08-31 12:51:59 +02:00
Steve
b140f606b4 added PermissionHandler.class and .project/.classpath so this will build
in eclipse
2011-08-31 01:56:31 +01:00
snowleo
057c9cb3f5 Minor rewrite of Permissions package, all the stuff is now in one place. 2011-08-30 23:26:23 +02:00
snowleo
3dcf8bc8fc Merge branch 'master' into release 2011-08-30 09:46:49 +02:00
snowleo
ecc1a0acea Missing nochargeexception in /home and /world 2011-08-30 09:46:31 +02:00
KHobbits
afb951461c Adding throw to prevent double charge. 2011-08-30 03:42:31 +01:00
snowleo
e9a14b204f NoChargeException for teleport commands 2011-08-30 03:15:50 +02:00
snowleo
1cbdbc40a5 /help now supports multiple permissions for a command in plugin.yml
Also minor cleanup
2011-08-30 03:15:10 +02:00
snowleo
5d4aa95fc3 First update check is done 10 minutes after server start. 2011-08-30 02:36:16 +02:00
snowleo
17e11adf9a Catch NPE in /powertool, also cleanup 2011-08-30 01:14:03 +02:00
Steve
3454db3e2b Test commit to see if push works
Updated plugin.yml to alpha-6 for GM
2011-08-29 21:15:33 +01:00
snowleo
7039d613ee Merge branch 'master' into release 2011-08-29 20:43:49 +02:00
snowleo
12e3eb1a23 Fix compatibility issues with Citizens 2011-08-28 23:51:10 +02:00
snowleo
a60f040f7e Cleanup 2011-08-28 14:24:31 +02:00
snowleo
22c277f9ab If PermissionsBukkit or bPermissions is detected, we don't need the config switch. 2011-08-28 14:12:27 +02:00
snowleo
fa423b3dd2 Updates to Plugin listener 2011-08-28 13:57:36 +02:00
snowleo
0c37e091c0 Adding support for two more permission systems. 2011-08-28 13:47:20 +02:00
snowleo
3dd3fa4519 Revert "Testing yaml annotations"
This reverts commit fba4dd2d9a.
2011-08-28 06:24:34 +02:00
snowleo
b559809bfa Another build fix 2011-08-28 06:17:43 +02:00
snowleo
59e45592cf Allow the build server to build again. 2011-08-28 06:16:01 +02:00
snowleo
1fb57cb678 Disabling broken test 2011-08-28 05:21:12 +02:00
snowleo
fba4dd2d9a Testing yaml annotations 2011-08-28 05:12:13 +02:00
snowleo
3ec0dbd404 Oops, these too. 2011-08-27 23:54:23 +02:00
snowleo
5a5dc933ad Forgot this one 2011-08-27 23:38:21 +02:00
snowleo
6427a93d14 Correctly charge for the use of commands.
We now first test, if the user could pay it, do the stuff and then charge him. If the command throws an exception, the user will not be charged.
2011-08-27 23:14:49 +02:00
snowleo
610a713997 Fixes to auto afk 2011-08-27 22:29:57 +02:00
snowleo
347be03b25 Display which permission system is used. 2011-08-27 21:13:33 +02:00
snowleo
322ecdb9fc Less use of Craftbukkit code, so less things will break on MC update.
Added try/catch around the tnt and creeper protection code. The event will now always canceled, even if our fake explosion code fails.
2011-08-27 20:39:54 +02:00
snowleo
033babd586 Cleanup & output result of backup command 2011-08-27 17:50:44 +02:00
snowleo
d3302dea00 Protect detector/powered rails 2011-08-27 17:11:15 +02:00
okamosy
8249a961f6 Merge branch 'master' of github.com:essentials/Essentials 2011-08-27 16:10:47 +01:00
okamosy
41344ce1b0 fixed home commands syntax to match multi-home 2011-08-27 16:10:35 +01:00
snowleo
65be2dba99 Protect detector/powered rails 2011-08-27 17:09:43 +02:00
snowleo
087e600d6d Prevent that wrong ids are used in /kit 2011-08-27 17:01:01 +02:00
snowleo
f18c3c7e1d Disable /nick if change-displayname is disabled
Some translations
2011-08-27 16:56:45 +02:00
snowleo
394a786044 Another fix for /repair 2011-08-27 16:21:29 +02:00
snowleo
14030deb16 Cleanup of repair command and allow different charges for each item. 2011-08-27 16:19:23 +02:00
snowleo
0543a8f8ba Prevent kick for floating while afk & frozen 2011-08-27 15:43:26 +02:00
snowleo
34987d6e07 Fixes for afk 2011-08-27 15:30:56 +02:00
snowleo
631583aef0 Cleanup of EssentialsConf and delete empty files or files that are corrupt. 2011-08-27 15:30:30 +02:00
snowleo
8998168ec2 Auto-AFK, AFK-Kick and freeze afk players 2011-08-27 13:59:49 +02:00
KHobbits
00050d08d4 Powertool fix. 2011-08-27 02:54:45 +01:00
okamosy
aa47499656 Merge branch 'master' of github.com:essentials/Essentials 2011-08-26 21:03:25 +01:00
okamosy
bc93bc6ae7 Cleaned up todo lists 2011-08-26 21:03:09 +01:00
KHobbits
dfd283d998 Merge branch 'master' of github.com:essentials/Essentials into essmaster 2011-08-26 05:14:03 +01:00
KHobbits
016dd10060 Adding essentials.delhome.others to allow people to delete other peoples homes. 2011-08-26 05:13:38 +01:00
snowleo
8281908306 PVP protection for arrows and other projectiles. Needs cleanup. 2011-08-26 04:46:08 +02:00
snowleo
01861e5a64 Correctly catch signs ignition 2011-08-25 17:37:54 +02:00
KHobbits
3d913f9fcc Make home throw an exception if the world doesn't exist.
Add multiverse/missing world support to home upgrade.
2011-08-24 05:18:35 +01:00
KHobbits
6c738294d1 Skip default home if it's invalid. 2011-08-24 03:49:35 +01:00
KHobbits
30f0f78efc Fixing NPE on Entity Listener (Powertool). 2011-08-24 03:09:27 +01:00
KHobbits
8cc249c2d3 Essentials.sethome.others doesn't imply essentials.sethome.multiple.
Restore essentials.home.others permission check.
2011-08-24 02:48:38 +01:00
okamosy
6946488e0d updated to use corrected joinList function. 2011-08-23 23:40:48 +01:00
okamosy
53a73998a2 Updated joinList to properly handle lists of lists. 2011-08-23 23:40:41 +01:00
okamosy
f12a14d7f7 Added util function concat(List) and concat(string, list) to concatenate lists into a string.
Updated powertool to use new concat method.
2011-08-23 23:40:27 +01:00
okamosy
089c2210bd Merge branch 'master' of github.com:khobbits/Essentials 2011-08-23 22:58:48 +01:00
okamosy
1a2fc307fd updated to use corrected joinList function. 2011-08-23 22:58:19 +01:00
KHobbits
38aa85dd0c Join full server patch. 2011-08-23 22:35:15 +01:00
okamosy
c374f474ed Merge branch 'master' of github.com:khobbits/Essentials 2011-08-23 19:48:09 +01:00
okamosy
2a1b19a8a8 Updated joinList to properly handle lists of lists. 2011-08-23 19:47:50 +01:00
KHobbits
325889c466 Merge branch 'master' of github.com:essentials/Essentials 2011-08-23 18:16:33 +01:00
KHobbits
216cc7f681 Fix to repair in plugin.yml 2011-08-23 18:15:45 +01:00
KHobbits
7df5098bf6 Homes tolower.
Max homes fix.
2011-08-23 15:37:09 +01:00
snowleo
27adc21446 midnight = 12am
noon = 12pm
2011-08-23 15:36:54 +01:00
snowleo
5de354af86 midnight = 12am
noon = 12pm
2011-08-23 13:22:11 +02:00
KHobbits
bb32ec9567 Adding delhome
Making sethome allow redefine
2011-08-23 07:04:33 +01:00
KHobbits
6ee7017603 Adding Home upgrade script.
Tidying up home code.
2011-08-23 06:09:34 +01:00
KHobbits
9dc54340f8 Merge branch 'master' of github.com:essentials/Essentials 2011-08-23 03:43:14 +01:00
KHobbits
0592c1fe11 Added multiple homes.
Permissions currently: essentials.sethome.multiple and essentials.sethome.multiple.unlimited
New config setting: multiple-homes (default value 5)
2011-08-23 03:42:32 +01:00
snowleo
90419cdbf5 Update check for Essentials 2011-08-23 02:46:19 +02:00
snowleo
91393e3180 Show filename on yaml error 2011-08-23 01:28:01 +02:00
okamosy
dfdf49ac35 Merge branch 'master' of github.com:khobbits/Essentials 2011-08-22 22:55:55 +01:00
okamosy
d2a3240905 Added util function concat(List) and concat(string, list) to concatenate lists into a string.
Updated powertool to use new concat method.
2011-08-22 22:10:23 +01:00
KHobbits
1138e32292 Merge branch 'master' of github.com:essentials/Essentials 2011-08-22 18:45:46 +01:00
snowleo
256c963370 Merge branch 'master' into release 2011-08-21 21:44:58 +02:00
snowleo
d818f705ad Cleanup 2011-08-21 21:30:01 +02:00
snowleo
1ac033a60e Pages for /warp command 2011-08-21 21:27:36 +02:00
snowleo
af248a1d2e Wait 1 second after deactivation of protect to allow the database to close. 2011-08-21 21:27:22 +02:00
okamosy
c0d21b6044 Removed commented-out code 2011-08-21 20:06:25 +01:00
okamosy
e10675dfdc Completed changing powertool config from tokenized string to lists 2011-08-21 19:33:37 +01:00
snowleo
7b8c2a4575 Merge branch 'master' into release 2011-08-21 20:22:28 +02:00
okamosy
812a357361 added config upgrade for powertools 2011-08-21 19:02:01 +01:00
okamosy
ac20207ea1 Merge branch 'master' of github.com:khobbits/Essentials 2011-08-21 17:53:39 +01:00
okamosy
43d7fb367b converted powertool config to use lists instead of tokenized strings
Powertool update
2011-08-21 17:52:58 +01:00
KHobbits
040e2bee86 Fixing trade sign messages
Unifying tree/spawnmob code for block selection
Adding TL notes
2011-08-21 17:08:32 +01:00
okamosy
6f88e7bb98 Merge branch 'master' of github.com:khobbits/Essentials 2011-08-21 02:53:10 +01:00
okamosy
45f88016fc Added ability to assign multiple powertools to an item
Added option to list commands assigned powertools
2011-08-21 02:50:48 +01:00
KHobbits
5a1ea77019 Merge branch 'master' of github.com:khobbits/Essentials 2011-08-20 21:58:55 +01:00
KHobbits
83fc7de01a Fixing trade message to be more user friendly. 2011-08-20 21:58:26 +01:00
okamosy
d14f278ecf added charge command
fixed formatting
2011-08-20 21:23:44 +01:00
KHobbits
69b76b810c Merge branch 'master' of github.com:khobbits/Essentials 2011-08-20 20:55:21 +01:00
KHobbits
2c787e07ec Switching trade sign flag 2011-08-20 20:54:54 +01:00
okamosy
3e9b27e3ef Added command repair [hand|all]
fixed if statements in commandsell
2011-08-20 20:49:17 +01:00
okamosy
4bc3d5efad Merge branch 'master' of github.com:khobbits/Essentials 2011-08-20 18:11:56 +01:00
okamosy
9791dcc0bc Reformatted ptime and time messages
fixed typo in plugin
2011-08-20 18:09:55 +01:00
KHobbits
84068c18b1 Updating default permissions. 2011-08-20 18:06:43 +01:00
KHobbits
a32b55e28f Translation for tpall + tidy. 2011-08-20 16:44:42 +01:00
KHobbits
8d1262fc91 Check jail first, before setting. 2011-08-19 12:16:28 +01:00
KHobbits
a2f727bebc Success message on /spawner
Switch to use mob class.
2011-08-19 12:06:35 +01:00
snowleo
7f1ba0d6ae Merge branch 'master' into release 2011-08-19 02:32:56 +02:00
snowleo
2b48045a8f Removed unused users map 2011-08-19 02:32:34 +02:00
snowleo
7e5b79aa14 Merge branch 'master' into release 2011-08-19 02:10:36 +02:00
snowleo
a53d8ddef1 Protection signs: First check for ownership, then for allowed users. 2011-08-19 01:43:39 +02:00
snowleo
2690696712 Corrected german translation. 2011-08-19 01:30:10 +02:00
snowleo
086343ee48 Merge branch 'master' into release 2011-08-19 01:06:52 +02:00
snowleo
c79ac59bc0 Added KHobbits to authors 2011-08-19 01:06:15 +02:00
snowleo
a1ad512a80 Merge branch 'master' into release 2011-08-19 00:42:26 +02:00
KHobbits
6a9865cd67 Changing default prefix behavior to be a little smarter. 2011-08-17 17:40:11 +01:00
KHobbits
5d95d1fca6 Adding command cost for !shout and ?question. 2011-08-17 15:28:58 +01:00
KHobbits
2541efb682 Adding instructions to accept tpaall. 2011-08-17 14:27:27 +01:00
KHobbits
8ff405f2fe Adding /tpaall - Teleport here request to all players. 2011-08-17 14:19:47 +01:00
KHobbits
376d206d2b Removing advice to move to perm3 2011-08-15 22:58:50 +02:00
ementalo
6295127589 #RB 1060 Updates 2011-08-15 20:36:43 +01:00
snowleo
1c381fc203 Merge branch 'master' into groupmanager 2011-08-14 22:05:08 +02:00
snowleo
b93d289176 Update Permissions3.jar in lib folder to 3.1.6 2011-08-14 21:57:21 +02:00
snowleo
a2fa666fd5 GroupManager update to Permissions 3.1.6 API done by ElgarL 2011-08-14 21:56:40 +02:00
snowleo
76eb00575b Update Permissions3.jar in lib folder to 3.1.6 2011-08-14 21:55:22 +02:00
KHobbits
81d7be4f77 Merge pull request #22 from okamosy/master
Adding hidden players to tpo/unlimited update
2011-08-11 13:01:01 -07:00
okamosy
b776362be7 Added ability to clear entire list of of unlimited items
Fixed permission bug with per item spawning
General unlimited cleanup
2011-08-11 20:47:51 +01:00
okamosy
65df249510 Added support for teleporting to hidden players
Permission: essentials.teleport.hidden
2011-08-11 15:52:34 +01:00
KHobbits
6fa2b14d65 Merge pull request #1 from okamosy/master
added error message
2011-08-11 07:08:39 -07:00
okamosy
6ec674d0a3 added error message when attempting to pay a user that isn't online 2011-08-11 15:03:08 +01:00
snowleo
93883cfc12 Catch NPE while login of new player 2011-08-11 13:43:04 +02:00
snowleo
2e565f8881 Allow the use of the world spawn in EssentialsSpawn for new players. 2011-08-11 13:32:11 +02:00
KHobbits
b851cd10f2 Fix help for plugins which miss command descriptions. 2011-08-11 06:56:33 +01:00
KHobbits
576b48c08c Todo/alias. 2011-08-11 05:20:43 +01:00
KHobbits
5ca9927987 Fix unbanning players who don't have user files. 2011-08-11 04:38:00 +01:00
KHobbits
a753f322df Updating /help for static ptime. 2011-08-11 03:34:07 +01:00
KHobbits
300ee9c729 Fix sethome/seen for invalid players. 2011-08-11 03:33:45 +01:00
KHobbits
1fbed62c1d Stop searching for tp location after a chunk. 2011-08-11 03:33:09 +01:00
KHobbits
a21d80ecd8 /ptime list output message change 2011-08-11 03:04:57 +01:00
KHobbits
1e7bf9a46c Removing hole in floor, tp cop-out.
This should force the code to find an suitable tp location.
- Not sure how well this will effect performance, but wanted to test it.
2011-08-11 02:59:40 +01:00
KHobbits
19595c5847 Add '@' prefix to time, to fix the time, rather than relative. 2011-08-10 15:06:42 +01:00
KHobbits
47c8217511 Merge diff from krnlyng:
Adjust item spawn, to allow for match native names.
2011-08-10 10:45:24 +01:00
KHobbits
db50d455df Fixing annoying text match. 2011-08-10 12:35:04 +06:00
KHobbits
ec5746dbe6 Fixing omission on last patches. 2011-08-10 12:05:05 +06:00
KHobbits
05ba5c00e6 Patch around broken bukkit method. 2011-08-10 11:36:09 +06:00
KHobbits
bb2b504d7a Trim help message to fit on 1 line.
Added old time alias.
2011-08-10 10:46:33 +06:00
KHobbits
5bb86309f6 Fixing display timezone if the server isn't running GMT+1 2011-08-10 10:41:03 +06:00
KHobbits
abbeb0a212 Added method to list users fixed time. 2011-08-10 05:25:45 +01:00
KHobbits
d9d781a33a Adjust times a little bit to be more realistic? 2011-08-10 04:54:03 +01:00
snowleo
327c15c5be Allow other plugins to use the same first line on signs as essentials. Just make sure that the player, who creates the sign does not have essentials.signs.signname.create or essentials.signs.create.signname permission. 2011-08-08 22:40:54 +02:00
snowleo
858e2a8b89 Reverting some changes to /time command 2011-08-08 18:21:38 +02:00
snowleo
33d37a2f96 Revert "Prevent closing already closed statements"
This reverts commit b9fc6a0b2b.
2011-08-08 18:14:20 +02:00
snowleo
a8f6014a42 Some fixes to the time code by me 2011-08-08 17:51:16 +02:00
snowleo
a117080b32 Some fixes to the time code by me 2011-08-08 17:49:32 +02:00
snowleo
f75390bd3f Correct code format for file DescParseTickFormat 2011-08-08 17:46:12 +02:00
snowleo
b07ba21659 Corrected permission testing a bit 2011-08-08 17:01:03 +02:00
snowleo
a109134b92 Part of oloflarsson new time command
Semi complete awesome time command. This is missing: Help text, I18N.
2011-08-08 17:00:04 +02:00
snowleo
69d3921a6a Fixes to jail 2011-08-08 16:42:56 +02:00
snowleo
ca3369938d Minor cleanup 2011-08-08 16:32:59 +02:00
snowleo
fbd9ee9453 XMPP: Let xmpp users see xmpp messages from other xmpp users. 2011-08-08 16:30:32 +02:00
snowleo
8185b05b5d XMPP: reconnect to server, if connection is broken. 2011-08-08 16:03:00 +02:00
snowleo
b9fc6a0b2b Prevent closing already closed statements 2011-08-08 15:56:23 +02:00
snowleo
62ebf3db41 Fix /spawner with PigZombie 2011-08-08 15:34:32 +02:00
snowleo
a90b16be36 Prevent muted players from using /msg 2011-08-08 15:34:10 +02:00
snowleo
d07ecde47d Fix essentials.joinfullserver 2011-08-08 15:24:38 +02:00
snowleo
5db35458e8 Limiting the length of the name on signs to 13 instead of 14 2011-08-08 15:13:27 +02:00
snowleo
cf4752dad6 Restrict sign protections to valid signs only 2011-08-08 15:07:26 +02:00
snowleo
a085503c84 Users are now loaded async, so we have a new internal structure where they are saved.
I also did some cleanup on the classes that I worked on.

This needs testing, it might break, because it does not behave 100% identical like before.

it's possible that /balancetop now needs more time to finish, if not all users are loaded into memory.
2011-08-08 14:40:40 +02:00
snowleo
9a893f65fe Changes to build-impl by Netbeans 2011-08-08 14:40:39 +02:00
KHobbits
cc273e919c Adding extra alias's to plugin.yml 2011-08-08 10:41:26 +01:00
KHobbits
65702ea0bf Updating register to latest build. 2011-08-08 10:20:04 +01:00
KHobbits
614b7b84f7 Adding new register methods. 2011-08-08 10:17:13 +01:00
KHobbits
a04e0533d6 More register libs 2011-08-08 10:02:18 +01:00
KHobbits
b85a5e9e0d Making /help <string> match the plugin name. 2011-08-08 09:23:48 +01:00
KHobbits
bb6b2c9374 Merge branch 'master' of github.com:essentials/Essentials 2011-07-28 03:49:10 +01:00
KHobbits
df47aad478 Removing failed translation. 2011-07-28 03:47:42 +01:00
KHobbits
9eb73cf854 Merge pull request #21 from khobbits/master
rainbow sheep
2011-07-27 17:20:16 -07:00
KHobbits
12777af61a adding sheep:random to /spawnmob 2011-07-28 01:15:47 +01:00
KHobbits
acb50786c4 Merge pull request #20 from khobbits/master
Ban changes
2011-07-27 06:28:57 -07:00
KHobbits
33f48eae0d Adjusting the config file to mention the help permission 2011-07-27 14:26:04 +01:00
KHobbits
7b18343e75 Adding a permission for unhiding help. 2011-07-27 14:25:41 +01:00
snowleo
9bb2ef9cbe Merge branch 'master' into release 2011-07-27 01:04:37 +02:00
snowleo
beb34a7651 Allow fractions of 1 2011-07-27 01:04:21 +02:00
snowleo
0ac26265e2 Fix for money exploit on trade signs 2011-07-27 01:00:55 +02:00
KHobbits
d6dc6d1d39 fixing lost revision. 2011-07-26 14:28:23 +01:00
KHobbits
0ab8a2760d Adding tempban/kick broadcast permissions and adding a banned by to the broadcast.
Adding tempban/kick broadcast permissions and adding a banned by to the broadcast.
Merge branch 'master' of github.com:khobbits/Essentials

Conflicts:
	Essentials/src/messages.properties
	Essentials/src/messages_da.properties
	Essentials/src/messages_en.properties
	Essentials/src/messages_fr.properties
	Essentials/src/messages_nl.properties
Merge branch 'master' of github.com:khobbits/Essentials
2011-07-26 14:23:14 +01:00
ementalo
8bb4067f06 double quoting ' 2011-07-26 10:35:55 +02:00
ementalo
fe1820134b Merge pull request #19 from khobbits/master
Xesxen's Dutch translation.
2011-07-26 01:34:32 -07:00
KHobbits
7d7c686e6a Edited Essentials/src/plugin.yml via GitHub 2011-07-25 23:25:07 -07:00
KHobbits
0b681c3654 Edited Essentials/src/messages_nl.properties via GitHub 2011-07-25 19:24:14 -07:00
KHobbits
23eeb82ac4 Edited Essentials/src/messages_nl.properties via GitHub 2011-07-25 19:20:42 -07:00
snowleo
edd6adc78f Another obsolete file 2011-07-24 23:33:48 +02:00
snowleo
c9028623ac Removed useless files 2011-07-24 23:30:11 +02:00
snowleo
dd5bcb8762 Edited README.markdown via GitHub 2011-07-24 14:25:12 -07:00
snowleo
bc1c252dca Correcting all line endings to LF 2011-07-24 23:19:12 +02:00
KHobbits
19ba6e5195 Added plural alias for kit & warp 2011-07-24 12:47:59 -07:00
snowleo
864e608582 Added code guidelines to all projects, so we don't need them globally.
Compress jar files
Don't copy lib files into dist folders
Removed vendor names
Changed all java versions to 1.6 to make it consistent.
2011-07-24 04:07:28 +02:00
snowleo
b84785cc82 If add-prefix-suffix is not set in config and EssentialsChat is installed, it will default to true now for backwards compatibility. 2011-07-24 00:41:54 +02:00
561 changed files with 42664 additions and 18553 deletions

8
.classpath Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<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>

16
.gitignore vendored
View File

@@ -25,4 +25,18 @@
/EssentialsProtect/build/
/EssentialsPermissionsCommands/nbproject/private/
/EssentialsPermissionsCommands/build/
/EssentialsPermissionsCommands/dist/
/EssentialsPermissionsCommands/dist/
/Essentials/nbproject/private/
/Essentials/dist/
/Essentials/build/
/YamlAnnotations/
/EssentialsUpdate/nbproject/private/
/EssentialsRelease/
/EssentialsUpdate/dist/
/EssentialsUpdate/build/
/WebPush/apikey.php
/WebPush/nbproject/private
/.idea
*.iml
/EssentialsGroupManager/bin
/EssentialsGroupManager/.externalToolBuilders

17
.project Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Essentials</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -20,10 +20,10 @@ is divided into following sections:
-->
<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="BuildAll-impl">
<fail message="Please build using Ant 1.7.1 or higher.">
<fail message="Please build using Ant 1.8.0 or higher.">
<condition>
<not>
<antversion atleast="1.7.1"/>
<antversion atleast="1.8.0"/>
</not>
</condition>
</fail>
@@ -223,6 +223,7 @@ is divided into following sections:
<property name="javac.fork" value="${jdkBug6558476}"/>
<property name="jar.index" value="false"/>
<property name="jar.index.metainf" value="${jar.index}"/>
<property name="copylibs.rebase" value="true"/>
<available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
</target>
<target name="-post-init">
@@ -409,6 +410,7 @@ is divided into following sections:
<property environment="env"/>
<resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
<java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg value="${profiler.info.jvmargs.agent}"/>
<jvmarg line="${profiler.info.jvmargs}"/>
<env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
@@ -539,7 +541,7 @@ is divided into following sections:
</chainedmapper>
</pathconvert>
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
<copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
<copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
<fileset dir="${build.classes.dir}"/>
<manifest>
<attribute name="Class-Path" value="${jar.classpath}"/>
@@ -636,13 +638,6 @@ is divided into following sections:
<param name="call.target" value="jar"/>
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
</antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-jar.properties}"/>
<param location="${project.EssentialsPermissionsCommands}" name="call.subproject"/>
<param location="${project.EssentialsPermissionsCommands}/build.xml" name="call.script"/>
<param name="call.target" value="jar"/>
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
</antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-jar.properties}"/>
<param location="${project.EssentialsProtect}" name="call.subproject"/>
@@ -927,16 +922,26 @@ is divided into following sections:
-->
<target depends="init" if="have.sources" name="-javadoc-build">
<mkdir dir="${dist.javadoc.dir}"/>
<condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}">
<and>
<isset property="endorsed.classpath.cmd.line.arg"/>
<not>
<equals arg1="${endorsed.classpath.cmd.line.arg}" arg2=""/>
</not>
</and>
</condition>
<javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
<classpath>
<path path="${javac.classpath}"/>
</classpath>
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/*.java"/>
<exclude name="*.java"/>
</fileset>
<arg line="${javadoc.endorsed.classpath.cmd.line.arg}"/>
</javadoc>
<copy todir="${dist.javadoc.dir}">
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
@@ -1135,13 +1140,6 @@ is divided into following sections:
<param name="call.target" value="clean"/>
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
</antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-clean.properties}"/>
<param location="${project.EssentialsPermissionsCommands}" name="call.subproject"/>
<param location="${project.EssentialsPermissionsCommands}/build.xml" name="call.script"/>
<param name="call.target" value="clean"/>
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
</antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-clean.properties}"/>
<param location="${project.EssentialsProtect}" name="call.subproject"/>

View File

@@ -1,8 +1,8 @@
build.xml.data.CRC32=2bd2dd75
build.xml.data.CRC32=51b33957
build.xml.script.CRC32=7a797370
build.xml.stylesheet.CRC32=28e38971@1.43.1.45
build.xml.stylesheet.CRC32=28e38971@1.44.1.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=2bd2dd75
nbproject/build-impl.xml.script.CRC32=769e541b
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
nbproject/build-impl.xml.data.CRC32=51b33957
nbproject/build-impl.xml.script.CRC32=c5170bed
nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46

View File

@@ -3,7 +3,42 @@ annotation.processing.enabled.in.editor=false
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=BuildAll
application.vendor=Paul
application.vendor=
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineArrayInit=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAssignment=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineBinaryOp=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineDisjunctiveCatchTypes=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineParenthesized=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTernaryOp=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTryResources=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterClassHeader=0
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesBeforeClass=2
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indentCasesFromSwitch=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
@@ -27,29 +62,26 @@ dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
includes=**
jar.compress=false
jar.compress=true
javac.classpath=\
${reference.Essentials.jar}:\
${reference.EssentialsChat.jar}:\
${reference.EssentialsProtect.jar}:\
${reference.EssentialsPermissionsCommands.jar}:\
${reference.EssentialsSpawn.jar}:\
${reference.EssentialsGeoIP.jar}:\
${reference.EssentialsXMPP.jar}:\
${reference.EssentialsGroupBridge.jar}:\
${reference.EssentialsXMPP.jar}:\
${reference.EssentialsGroupManager.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
javac.source=1.5
javac.target=1.5
javac.source=1.6
javac.target=1.6
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}:\
${libs.junit.classpath}:\
${libs.junit_4.classpath}
${build.classes.dir}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
@@ -71,7 +103,6 @@ project.EssentialsChat=../EssentialsChat
project.EssentialsGeoIP=../EssentialsGeoIP
project.EssentialsGroupBridge=../EssentialsGroupBridge
project.EssentialsGroupManager=../EssentialsGroupManager
project.EssentialsPermissionsCommands=../EssentialsPermissionsCommands
project.EssentialsProtect=../EssentialsProtect
project.EssentialsSpawn=../EssentialsSpawn
project.EssentialsXMPP=../EssentialsXMPP
@@ -80,7 +111,6 @@ reference.EssentialsChat.jar=${project.EssentialsChat}/dist/EssentialsChat.jar
reference.EssentialsGeoIP.jar=${project.EssentialsGeoIP}/dist/EssentialsGeoIP.jar
reference.EssentialsGroupBridge.jar=${project.EssentialsGroupBridge}/dist/EssentialsGroupBridge.jar
reference.EssentialsGroupManager.jar=${project.EssentialsGroupManager}/dist/EssentialsGroupManager.jar
reference.EssentialsPermissionsCommands.jar=${project.EssentialsPermissionsCommands}/dist/EssentialsPermissionsCommands.jar
reference.EssentialsProtect.jar=${project.EssentialsProtect}/dist/EssentialsProtect.jar
reference.EssentialsSpawn.jar=${project.EssentialsSpawn}/dist/EssentialsSpawn.jar
reference.EssentialsXMPP.jar=${project.EssentialsXMPP}/dist/EssentialsXMPP.jar

View File

@@ -55,14 +55,6 @@
<clean-target>clean</clean-target>
<id>jar</id>
</reference>
<reference>
<foreign-project>EssentialsPermissionsCommands</foreign-project>
<artifact-type>jar</artifact-type>
<script>build.xml</script>
<target>jar</target>
<clean-target>clean</clean-target>
<id>jar</id>
</reference>
<reference>
<foreign-project>EssentialsProtect</foreign-project>
<artifact-type>jar</artifact-type>

View File

@@ -1,7 +0,0 @@
# NetBeans cruft
/build
/dist
/nbproject/private
# Mac cruft
.DS_Store

View File

@@ -1,84 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="Essentials" default="default" basedir=".">
<description>Builds, tests, and runs the project Essentials.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="Essentials-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
<!--target name="-post-jar">
<jar jarfile="${dist.dir}/Essentials.jar">
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
<zipfileset src="${dist.dir}/lib/Register.jar" excludes="META-INF/*" />
<manifest>
<attribute name="Classpath" value="Essentials.jar"/>
</manifest>
</jar>
</target-->
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="Essentials" default="default" basedir=".">
<description>Builds, tests, and runs the project Essentials.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="Essentials-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
<!--target name="-post-jar">
<jar jarfile="${dist.dir}/Essentials.jar">
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
<zipfileset src="${dist.dir}/lib/Register.jar" excludes="META-INF/*" />
<manifest>
<attribute name="Classpath" value="Essentials.jar"/>
</manifest>
</jar>
</target-->
</project>

View File

@@ -20,10 +20,10 @@ is divided into following sections:
-->
<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="Essentials-impl">
<fail message="Please build using Ant 1.7.1 or higher.">
<fail message="Please build using Ant 1.8.0 or higher.">
<condition>
<not>
<antversion atleast="1.7.1"/>
<antversion atleast="1.8.0"/>
</not>
</condition>
</fail>
@@ -223,6 +223,7 @@ is divided into following sections:
<property name="javac.fork" value="${jdkBug6558476}"/>
<property name="jar.index" value="false"/>
<property name="jar.index.metainf" value="${jar.index}"/>
<property name="copylibs.rebase" value="true"/>
<available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
</target>
<target name="-post-init">
@@ -409,6 +410,7 @@ is divided into following sections:
<property environment="env"/>
<resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
<java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg value="${profiler.info.jvmargs.agent}"/>
<jvmarg line="${profiler.info.jvmargs}"/>
<env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
@@ -539,7 +541,7 @@ is divided into following sections:
</chainedmapper>
</pathconvert>
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
<copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
<copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
<fileset dir="${build.classes.dir}"/>
<manifest>
<attribute name="Class-Path" value="${jar.classpath}"/>
@@ -601,6 +603,13 @@ is divided into following sections:
<propertyfile file="${built-jar.properties}">
<entry key="${basedir}" value=""/>
</propertyfile>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-jar.properties}"/>
<param location="${project.EssentialsGroupManager}" name="call.subproject"/>
<param location="${project.EssentialsGroupManager}/build.xml" name="call.script"/>
<param name="call.target" value="jar"/>
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
</antcall>
</target>
<target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
<target depends="init" name="-check-automatic-build">
@@ -864,16 +873,26 @@ is divided into following sections:
-->
<target depends="init" if="have.sources" name="-javadoc-build">
<mkdir dir="${dist.javadoc.dir}"/>
<condition else="" property="javadoc.endorsed.classpath.cmd.line.arg" value="-J${endorsed.classpath.cmd.line.arg}">
<and>
<isset property="endorsed.classpath.cmd.line.arg"/>
<not>
<equals arg1="${endorsed.classpath.cmd.line.arg}" arg2=""/>
</not>
</and>
</condition>
<javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
<classpath>
<path path="${javac.classpath}"/>
</classpath>
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/*.java"/>
<exclude name="*.java"/>
</fileset>
<arg line="${javadoc.endorsed.classpath.cmd.line.arg}"/>
</javadoc>
<copy todir="${dist.javadoc.dir}">
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
@@ -1037,6 +1056,13 @@ is divided into following sections:
<propertyfile file="${built-clean.properties}">
<entry key="${basedir}" value=""/>
</propertyfile>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-clean.properties}"/>
<param location="${project.EssentialsGroupManager}" name="call.subproject"/>
<param location="${project.EssentialsGroupManager}/build.xml" name="call.script"/>
<param name="call.target" value="clean"/>
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
</antcall>
</target>
<target depends="init" name="-do-clean">
<delete dir="${build.dir}"/>

View File

@@ -3,9 +3,9 @@ build.xml.script.CRC32=3233ee78
build.xml.stylesheet.CRC32=28e38971@1.38.2.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=4b596d89
nbproject/build-impl.xml.script.CRC32=4926001b
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
nbproject/build-impl.xml.data.CRC32=a830bc14
nbproject/build-impl.xml.script.CRC32=a9f8842a
nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46
nbproject/profiler-build-impl.xml.data.CRC32=ab78ce15
nbproject/profiler-build-impl.xml.script.CRC32=abda56ed
nbproject/profiler-build-impl.xml.stylesheet.CRC32=f10cf54c@1.11.1

View File

@@ -1 +1,3 @@
DoNotUseThreads
LongVariable
SignatureDeclareThrowsException

View File

@@ -1,9 +1,47 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.run.all.processors=true
annotation.processing.processors.list=lombok.core.AnnotationProcessor
annotation.processing.run.all.processors=false
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=Essentials
application.vendor=Paul
application.vendor=
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineArrayInit=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAssignment=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineBinaryOp=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineDisjunctiveCatchTypes=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineParenthesized=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTernaryOp=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTryResources=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterClassHeader=0
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesBeforeClass=2
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.importGroupsOrder=*
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indentCasesFromSwitch=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.separateImportGroups=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
@@ -27,32 +65,48 @@ dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
file.reference.bPermissions.jar=../lib/bPermissions.jar
file.reference.bukkit.jar=../lib/bukkit.jar
file.reference.craftbukkit.jar=../lib/craftbukkit.jar
file.reference.iCo4.jar=../lib/iCo4.jar
file.reference.iCo5.jar=../lib/iCo5.jar
file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar
file.reference.iCo6.jar=../lib/iCo6.jar
file.reference.lombok.jar=../lib/lombok-0.10.8.jar
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.Vault.jar=../lib/Vault.jar
includes=**
jar.compress=false
jar.archive.disabled=${jnlp.enabled}
jar.compress=true
jar.index=${jnlp.enabled}
javac.classpath=\
${file.reference.Permissions3.jar}:\
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
${file.reference.iCo4.jar}:\
${file.reference.iCo5.jar}:\
${file.reference.iCo6.jar}:\
${file.reference.MultiCurrency.jar}:\
${file.reference.BOSEconomy7.jar}:\
${file.reference.PermissionsEx.jar}
${file.reference.PermissionsEx.jar}:\
${file.reference.bPermissions.jar}:\
${file.reference.PermissionsBukkit-1.2.jar}:\
${file.reference.lombok.jar}:\
${reference.EssentialsGroupManager.jar}:\
${file.reference.bukkit.jar}:\
${file.reference.craftbukkit.jar}:\
${file.reference.Vault.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
javac.source=1.5
javac.target=1.5
javac.source=1.6
javac.target=1.6
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}:\
${file.reference.junit-4.5.jar}
${libs.junit_4.10.classpath}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
@@ -62,13 +116,25 @@ javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.reference.PermissionsEx.jar=../lib/PermissionsEx-javadoc.jar
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
jnlp.codebase.type=no.codebase
jnlp.descriptor=application
jnlp.enabled=false
jnlp.mixed.code=default
jnlp.offline-allowed=false
jnlp.signed=false
jnlp.signing=
jnlp.signing.alias=
jnlp.signing.keystore=
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
mkdist.disabled=true
platform.active=default_platform
project.EssentialsGroupManager=../EssentialsGroupManager
reference.EssentialsGroupManager.jar=../EssentialsGroupManager/dist/EssentialsGroupManager.jar
run.classpath=\
${javac.classpath}:\
${build.classes.dir}

View File

@@ -14,6 +14,15 @@
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
<definitions>../lib/nblibraries.properties</definitions>
</libraries>
<references xmlns="http://www.netbeans.org/ns/ant-project-references/1"/>
<references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
<reference>
<foreign-project>EssentialsGroupManager</foreign-project>
<artifact-type>jar</artifact-type>
<script>build.xml</script>
<target>jar</target>
<clean-target>clean</clean-target>
<id>jar</id>
</reference>
</references>
</configuration>
</project>

View File

@@ -0,0 +1,137 @@
package com.earth2me.essentials;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.command.Command;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.PluginCommandYamlParser;
import org.bukkit.plugin.Plugin;
public class AlternativeCommandsHandler
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private final transient Map<String, List<PluginCommand>> altcommands = new HashMap<String, List<PluginCommand>>();
private final transient Map<String, String> disabledList = new HashMap<String, String>();
private final transient IEssentials ess;
public AlternativeCommandsHandler(final IEssentials ess)
{
this.ess = ess;
for (Plugin plugin : ess.getServer().getPluginManager().getPlugins())
{
if (plugin.isEnabled())
{
addPlugin(plugin);
}
}
}
public final void addPlugin(final Plugin plugin)
{
if (plugin.getDescription().getMain().contains("com.earth2me.essentials"))
{
return;
}
final List<Command> commands = PluginCommandYamlParser.parse(plugin);
final String pluginName = plugin.getDescription().getName().toLowerCase(Locale.ENGLISH);
for (Command command : commands)
{
final PluginCommand pc = (PluginCommand)command;
final List<String> labels = new ArrayList<String>(pc.getAliases());
labels.add(pc.getName());
PluginCommand reg = ess.getServer().getPluginCommand(pluginName + ":" + pc.getName().toLowerCase(Locale.ENGLISH));
if (reg == null)
{
reg = ess.getServer().getPluginCommand(pc.getName().toLowerCase(Locale.ENGLISH));
}
if (reg == null || !reg.getPlugin().equals(plugin))
{
continue;
}
for (String label : labels)
{
List<PluginCommand> plugincommands = altcommands.get(label.toLowerCase(Locale.ENGLISH));
if (plugincommands == null)
{
plugincommands = new ArrayList<PluginCommand>();
altcommands.put(label.toLowerCase(Locale.ENGLISH), plugincommands);
}
boolean found = false;
for (PluginCommand pc2 : plugincommands)
{
if (pc2.getPlugin().equals(plugin))
{
found = true;
}
}
if (!found)
{
plugincommands.add(reg);
}
}
}
}
public void removePlugin(final Plugin plugin)
{
final Iterator<Map.Entry<String, List<PluginCommand>>> iterator = altcommands.entrySet().iterator();
while (iterator.hasNext())
{
final Map.Entry<String, List<PluginCommand>> entry = iterator.next();
final Iterator<PluginCommand> pcIterator = entry.getValue().iterator();
while (pcIterator.hasNext())
{
final PluginCommand pc = pcIterator.next();
if (pc.getPlugin() == null || pc.getPlugin().equals(plugin))
{
pcIterator.remove();
}
}
if (entry.getValue().isEmpty())
{
iterator.remove();
}
}
}
public PluginCommand getAlternative(final String label)
{
final List<PluginCommand> commands = altcommands.get(label);
if (commands == null || commands.isEmpty())
{
return null;
}
if (commands.size() == 1)
{
return commands.get(0);
}
// return the first command that is not an alias
for (PluginCommand command : commands)
{
if (command.getName().equalsIgnoreCase(label))
{
return command;
}
}
// return the first alias
return commands.get(0);
}
public void executed(final String label, final String otherLabel)
{
if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Essentials: Alternative command " + label + " found, using " + otherLabel);
}
disabledList.put(label, otherLabel);
}
public Map<String, String> disabledCommands()
{
return disabledList;
}
}

View File

@@ -1,35 +1,46 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.CraftServer;
public class Backup implements Runnable {
private static final Logger logger = Logger.getLogger("Minecraft");
private final CraftServer server;
private final IEssentials ess;
private boolean running = false;
private int taskId = -1;
private boolean active = false;
public Backup(IEssentials ess) {
public class Backup implements Runnable
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient final Server server;
private transient final IEssentials ess;
private transient boolean running = false;
private transient int taskId = -1;
private transient boolean active = false;
public Backup(final IEssentials ess)
{
this.ess = ess;
server = (CraftServer)ess.getServer();
if (server.getOnlinePlayers().length > 0) {
server = ess.getServer();
if (server.getOnlinePlayers().length > 0)
{
startTask();
}
}
}
void onPlayerJoin() {
void onPlayerJoin()
{
startTask();
}
private void startTask() {
if (!running) {
long interval = ess.getSettings().getBackupInterval()*1200; // minutes -> ticks
if (interval < 1200) {
private void startTask()
{
if (!running)
{
final long interval = ess.getSettings().getBackupInterval() * 1200; // minutes -> ticks
if (interval < 1200)
{
return;
}
taskId = ess.scheduleSyncRepeatingTask(this, interval, interval);
@@ -37,48 +48,87 @@ public class Backup implements Runnable {
}
}
public void run() {
if (active) return;
active = true;
final String command = ess.getSettings().getBackupCommand();
if (command == null || "".equals(command)) {
@Override
public void run()
{
if (active)
{
return;
}
logger.log(Level.INFO, Util.i18n("backupStarted"));
final CommandSender cs = server.getServer().console;
active = true;
final String command = ess.getSettings().getBackupCommand();
if (command == null || "".equals(command))
{
return;
}
LOGGER.log(Level.INFO, _("backupStarted"));
final CommandSender cs = server.getConsoleSender();
server.dispatchCommand(cs, "save-all");
server.dispatchCommand(cs, "save-off");
ess.scheduleAsyncDelayedTask(
new Runnable() {
public void run() {
try {
Process child = Runtime.getRuntime().exec(command);
child.waitFor();
} catch (InterruptedException ex) {
logger.log(Level.SEVERE, null, ex);
} catch (IOException ex) {
logger.log(Level.SEVERE, null, ex);
} finally {
ess.scheduleSyncDelayedTask(
new Runnable() {
public void run() {
server.dispatchCommand(cs, "save-on");
if (server.getOnlinePlayers().length == 0) {
running = false;
if (taskId != -1) {
server.getScheduler().cancelTask(taskId);
new Runnable()
{
@Override
public void run()
{
try
{
final ProcessBuilder childBuilder = new ProcessBuilder(command);
childBuilder.redirectErrorStream(true);
childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile());
final Process child = childBuilder.start();
final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
try
{
child.waitFor();
String line;
do
{
line = reader.readLine();
if (line != null)
{
LOGGER.log(Level.INFO, line);
}
}
while (line != null);
}
finally
{
reader.close();
}
active = false;
logger.log(Level.INFO, Util.i18n("backupFinished"));
}
});
}
}
});
catch (InterruptedException ex)
{
LOGGER.log(Level.SEVERE, null, ex);
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, null, ex);
}
finally
{
ess.scheduleSyncDelayedTask(
new Runnable()
{
@Override
public void run()
{
server.dispatchCommand(cs, "save-on");
if (server.getOnlinePlayers().length == 0)
{
running = false;
if (taskId != -1)
{
server.getScheduler().cancelTask(taskId);
}
}
active = false;
LOGGER.log(Level.INFO, _("backupFinished"));
}
});
}
}
});
}
}

View File

@@ -1,157 +0,0 @@
package com.earth2me.essentials;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.server.ServerConfigurationManager;
import org.bukkit.craftbukkit.CraftServer;
public class BanWorkaround implements IConf
{
private transient final IEssentials ess;
private transient final ServerConfigurationManager scm;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient final Set<String> bans = new HashSet<String>();
private transient final Set<String> bannedIps = new HashSet<String>();
public BanWorkaround(final IEssentials ess)
{
this.ess = ess;
this.scm = ((CraftServer)ess.getServer()).getHandle();
}
public void banByName(final String name)
{
scm.a(name);
reloadConfig();
}
public void unbanByName(String name)
{
scm.b(name);
reloadConfig();
}
public void banByIp(final String ip)
{
scm.c(ip);
reloadConfig();
}
public void unbanByIp(final String ip)
{
scm.d(ip);
reloadConfig();
}
public boolean isNameBanned(final String name)
{
return bans.contains(name.toLowerCase());
}
public boolean isIpBanned(final String ip)
{
return bannedIps.contains(ip.toLowerCase());
}
public void reloadConfig()
{
//I don't like this but it needs to be done until CB fixors
final File file = new File(ess.getDataFolder().getParentFile().getParentFile(), "banned-players.txt");
try
{
if (!file.exists())
{
throw new FileNotFoundException(Util.i18n("bannedPlayersFileNotFound"));
}
final BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
try
{
bans.clear();
while (bufferedReader.ready())
{
final String line = bufferedReader.readLine().trim().toLowerCase();
if (line.length() > 0 && line.charAt(0) == '#')
{
continue;
}
bans.add(line);
}
}
catch (IOException io)
{
LOGGER.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), io);
}
finally
{
try
{
bufferedReader.close();
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), ex);
}
}
}
catch (FileNotFoundException ex)
{
LOGGER.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), ex);
}
final File ipFile = new File(ess.getDataFolder().getParentFile().getParentFile(), "banned-ips.txt");
try
{
if (!ipFile.exists())
{
throw new FileNotFoundException(Util.i18n("bannedIpsFileNotFound"));
}
final BufferedReader bufferedReader = new BufferedReader(new FileReader(ipFile));
try
{
bannedIps.clear();
while (bufferedReader.ready())
{
final String line = bufferedReader.readLine().trim().toLowerCase();
if (line.length() > 0 && line.charAt(0) == '#')
{
continue;
}
bannedIps.add(line);
}
}
catch (IOException io)
{
LOGGER.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), io);
}
finally
{
try
{
bufferedReader.close();
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), ex);
}
}
}
catch (FileNotFoundException ex)
{
LOGGER.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), ex);
}
}
}

View File

@@ -1,51 +0,0 @@
package com.earth2me.essentials;
import org.bukkit.entity.Player;
public class BukkitPermissionsHandler implements IPermissionsHandler
{
public String getGroup(Player base)
{
return "default";
}
public boolean canBuild(Player base, String group)
{
return true;
}
public boolean inGroup(Player base, String group)
{
return false;
}
public boolean hasPermission(Player base, String node)
{
if (base.hasPermission("-" + node))
{
return false;
}
final String[] parts = node.split("\\.");
final StringBuilder sb = new StringBuilder();
for (String part : parts)
{
if (base.hasPermission(sb.toString() + "*"))
{
return true;
}
sb.append(part).append(".");
}
return base.hasPermission(node);
}
public String getPrefix(Player base)
{
return "";
}
public String getSuffix(Player base)
{
return "";
}
}

View File

@@ -2,33 +2,37 @@ package com.earth2me.essentials;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.CraftServer;
public final class Console implements IReplyTo {
public final class Console implements IReplyTo
{
private static Console instance = new Console();
private CommandSender replyTo;
public final static String NAME = "Console";
private Console() {
}
public static CommandSender getCommandSender(Server server) throws Exception {
if (! (server instanceof CraftServer)) {
throw new Exception(Util.i18n("invalidServer"));
}
return ((CraftServer)server).getServer().console;
private Console()
{
}
public void setReplyTo(CommandSender user) {
public static CommandSender getCommandSender(Server server) throws Exception
{
return server.getConsoleSender();
}
@Override
public void setReplyTo(CommandSender user)
{
replyTo = user;
}
public CommandSender getReplyTo() {
@Override
public CommandSender getReplyTo()
{
return replyTo;
}
public static Console getConsoleReplyTo() {
public static Console getConsoleReplyTo()
{
return instance;
}
}

View File

@@ -0,0 +1,298 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.text.SimpleDateFormat;
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.
*
* http://www.minecraftwiki.net/wiki/Day/night_cycle
*
* @author Olof Larsson
*/
public final class DescParseTickFormat
{
// ============================================
// First some information vars. TODO: Should this be in a config file?
// --------------------------------------------
public static final Map<String, Integer> nameToTicks = new LinkedHashMap<String, Integer>();
public static final Set<String> resetAliases = new HashSet<String>();
public static final int ticksAtMidnight = 18000;
public static final int ticksPerDay = 24000;
public static final int ticksPerHour = 1000;
public static final double ticksPerMinute = 1000d / 60d;
public static final double ticksPerSecond = 1000d / 60d / 60d;
private static final SimpleDateFormat SDFTwentyFour = new SimpleDateFormat("HH:mm", Locale.ENGLISH);
private static final SimpleDateFormat SDFTwelve = new SimpleDateFormat("h:mmaa", Locale.ENGLISH);
static
{
SDFTwentyFour.setTimeZone(TimeZone.getTimeZone("GMT"));
SDFTwelve.setTimeZone(TimeZone.getTimeZone("GMT"));
nameToTicks.put("sunrise", 23000);
nameToTicks.put("dawn", 23000);
nameToTicks.put("daystart", 0);
nameToTicks.put("day", 0);
nameToTicks.put("morning", 1000);
nameToTicks.put("midday", 6000);
nameToTicks.put("noon", 6000);
nameToTicks.put("afternoon", 9000);
nameToTicks.put("sunset", 12000);
nameToTicks.put("dusk", 12000);
nameToTicks.put("sundown", 12000);
nameToTicks.put("nightfall", 12000);
nameToTicks.put("nightstart", 14000);
nameToTicks.put("night", 14000);
nameToTicks.put("midnight", 18000);
resetAliases.add("reset");
resetAliases.add("normal");
resetAliases.add("default");
}
private DescParseTickFormat()
{
}
// ============================================
// PARSE. From describing String to int
// --------------------------------------------
public static long parse(String desc) throws NumberFormatException
{
// Only look at alphanumeric and lowercase and : for 24:00
desc = desc.toLowerCase(Locale.ENGLISH).replaceAll("[^A-Za-z0-9:]", "");
// Detect ticks format
try
{
return parseTicks(desc);
}
catch (Exception e)
{
}
// Detect 24-hour format
try
{
return parse24(desc);
}
catch (Exception e)
{
}
// Detect 12-hour format
try
{
return parse12(desc);
}
catch (Exception e)
{
}
// Detect aliases
try
{
return parseAlias(desc);
}
catch (Exception e)
{
}
// Well we failed to understand...
throw new NumberFormatException();
}
public static long parseTicks(String desc) throws NumberFormatException
{
if (!desc.matches("^[0-9]+ti?c?k?s?$"))
{
throw new NumberFormatException();
}
desc = desc.replaceAll("[^0-9]", "");
return Long.parseLong(desc) % 24000;
}
public static long parse24(String desc) throws NumberFormatException
{
if (!desc.matches("^[0-9]{2}[^0-9]?[0-9]{2}$"))
{
throw new NumberFormatException();
}
desc = desc.toLowerCase(Locale.ENGLISH).replaceAll("[^0-9]", "");
if (desc.length() != 4)
{
throw new NumberFormatException();
}
final int hours = Integer.parseInt(desc.substring(0, 2));
final int minutes = Integer.parseInt(desc.substring(2, 4));
return hoursMinutesToTicks(hours, minutes);
}
public static long parse12(String desc) throws NumberFormatException
{
if (!desc.matches("^[0-9]{1,2}([^0-9]?[0-9]{2})?(pm|am)$"))
{
throw new NumberFormatException();
}
int hours = 0;
int minutes = 0;
desc = desc.toLowerCase(Locale.ENGLISH).replaceAll("[^0-9]", "");
if (desc.length() > 4)
{
throw new NumberFormatException();
}
if (desc.length() == 4)
{
hours += Integer.parseInt(desc.substring(0, 2));
minutes += Integer.parseInt(desc.substring(2, 4));
}
else if (desc.length() == 3)
{
hours += Integer.parseInt(desc.substring(0, 1));
minutes += Integer.parseInt(desc.substring(1, 3));
}
else if (desc.length() == 2)
{
hours += Integer.parseInt(desc.substring(0, 2));
}
else if (desc.length() == 1)
{
hours += Integer.parseInt(desc.substring(0, 1));
}
else
{
throw new NumberFormatException();
}
if (desc.endsWith("pm") && hours != 12)
{
hours += 12;
}
if (desc.endsWith("am") && hours == 12)
{
hours -= 12;
}
return hoursMinutesToTicks(hours, minutes);
}
public static long hoursMinutesToTicks(final int hours, final int minutes)
{
long ret = ticksAtMidnight;
ret += (hours) * ticksPerHour;
ret += (minutes / 60.0) * ticksPerHour;
ret %= ticksPerDay;
return ret;
}
public static long parseAlias(final String desc) throws NumberFormatException
{
final Integer ret = nameToTicks.get(desc);
if (ret == null)
{
throw new NumberFormatException();
}
return ret;
}
public static boolean meansReset(final String desc)
{
return resetAliases.contains(desc);
}
// ============================================
// FORMAT. From int to describing String
// --------------------------------------------
public static String format(final long ticks)
{
return _("timeFormat", format24(ticks), format12(ticks), formatTicks(ticks));
}
public static String formatTicks(final long ticks)
{
return (ticks % ticksPerDay) + "ticks";
}
public static String format24(final long ticks)
{
synchronized (SDFTwentyFour)
{
return formatDateFormat(ticks, SDFTwentyFour);
}
}
public static String format12(final long ticks)
{
synchronized (SDFTwelve)
{
return formatDateFormat(ticks, SDFTwelve);
}
}
public static String formatDateFormat(final long ticks, final SimpleDateFormat format)
{
final Date date = ticksToDate(ticks);
return format.format(date);
}
public static Date ticksToDate(long ticks)
{
// Assume the server time starts at 0. It would start on a day.
// But we will simulate that the server started with 0 at midnight.
ticks = ticks - ticksAtMidnight + ticksPerDay;
// How many ingame days have passed since the server start?
final long days = ticks / ticksPerDay;
ticks = ticks - days * ticksPerDay;
// How many hours on the last day?
final long hours = ticks / ticksPerHour;
ticks = ticks - hours * ticksPerHour;
// How many minutes on the last day?
final long minutes = (long)Math.floor(ticks / ticksPerMinute);
final double dticks = ticks - minutes * ticksPerMinute;
// How many seconds on the last day?
final long seconds = (long)Math.floor(dticks / ticksPerSecond);
// Now we create an english GMT calendar (We wan't no daylight savings)
final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ENGLISH);
cal.setLenient(true);
// And we set the time to 0! And append the time that passed!
cal.set(0, Calendar.JANUARY, 1, 0, 0, 0);
cal.add(Calendar.DAY_OF_YEAR, (int)days);
cal.add(Calendar.HOUR_OF_DAY, (int)hours);
cal.add(Calendar.MINUTE, (int)minutes);
cal.add(Calendar.SECOND, (int)seconds + 1); // To solve rounding errors.
return cal.getTime();
}
}

View File

@@ -0,0 +1,83 @@
package com.earth2me.essentials;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.regex.Pattern;
import org.bukkit.enchantments.Enchantment;
public class Enchantments
{
private static final transient Pattern NUMPATTERN = Pattern.compile("\\d+");
private static final Map<String, Enchantment> ENCHANTMENTS = new HashMap<String, Enchantment>();
static
{
ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL);
ENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL);
ENCHANTMENTS.put("sharpness", Enchantment.DAMAGE_ALL);
ENCHANTMENTS.put("arthropodsdamage", Enchantment.DAMAGE_ARTHROPODS);
ENCHANTMENTS.put("ardmg", Enchantment.DAMAGE_ARTHROPODS);
ENCHANTMENTS.put("baneofarthropods", 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("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("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("protection", Enchantment.PROTECTION_ENVIRONMENTAL);
ENCHANTMENTS.put("prot", Enchantment.PROTECTION_ENVIRONMENTAL);
ENCHANTMENTS.put("explosionsprotection", Enchantment.PROTECTION_EXPLOSIONS);
ENCHANTMENTS.put("expprot", Enchantment.PROTECTION_EXPLOSIONS);
ENCHANTMENTS.put("blastprotection", Enchantment.PROTECTION_EXPLOSIONS);
ENCHANTMENTS.put("fallprotection", Enchantment.PROTECTION_FALL);
ENCHANTMENTS.put("fallprot", Enchantment.PROTECTION_FALL);
ENCHANTMENTS.put("featherfalling", Enchantment.PROTECTION_FALL);
ENCHANTMENTS.put("fireprotection", Enchantment.PROTECTION_FIRE);
ENCHANTMENTS.put("fireprot", Enchantment.PROTECTION_FIRE);
ENCHANTMENTS.put("projectileprotection", Enchantment.PROTECTION_PROJECTILE);
ENCHANTMENTS.put("projprot", Enchantment.PROTECTION_PROJECTILE);
ENCHANTMENTS.put("silktouch", Enchantment.SILK_TOUCH);
ENCHANTMENTS.put("waterworker", Enchantment.WATER_WORKER);
ENCHANTMENTS.put("aquaaffinity", Enchantment.WATER_WORKER);
ENCHANTMENTS.put("firearrow", Enchantment.ARROW_FIRE);
ENCHANTMENTS.put("arrowdamage", Enchantment.ARROW_DAMAGE);
ENCHANTMENTS.put("arrowknockback", Enchantment.ARROW_KNOCKBACK);
ENCHANTMENTS.put("arrowkb", Enchantment.ARROW_KNOCKBACK);
ENCHANTMENTS.put("infinitearrows", Enchantment.ARROW_INFINITE);
ENCHANTMENTS.put("infarrows", Enchantment.ARROW_INFINITE);
}
public static Enchantment getByName(String name) {
Enchantment enchantment;
if (NUMPATTERN.matcher(name).matches()) {
enchantment = Enchantment.getById(Integer.parseInt(name));
} else {
enchantment = Enchantment.getByName(name.toUpperCase(Locale.ENGLISH));
}
if (enchantment == null)
{
enchantment = ENCHANTMENTS.get(name.toLowerCase(Locale.ENGLISH));
}
return enchantment;
}
public static Set<Entry<String, Enchantment>> entrySet()
{
return ENCHANTMENTS.entrySet();
}
}

View File

@@ -1,70 +1,84 @@
/*
* Essentials - a bukkit plugin
* Copyright (C) 2011 Essentials Team
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.Economy;
import com.earth2me.essentials.api.IJails;
import com.earth2me.essentials.commands.EssentialsCommand;
import java.io.*;
import java.util.*;
import java.util.logging.*;
import org.bukkit.*;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.commands.NoChargeException;
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
import com.earth2me.essentials.perm.PermissionsHandler;
import com.earth2me.essentials.register.payment.Methods;
import com.earth2me.essentials.signs.SignBlockListener;
import com.earth2me.essentials.signs.SignEntityListener;
import com.earth2me.essentials.signs.SignPlayerListener;
import java.math.BigInteger;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
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.Server;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.*;
import org.bukkit.plugin.java.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.plugin.InvalidDescriptionException;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
import org.yaml.snakeyaml.error.YAMLException;
public class Essentials extends JavaPlugin implements IEssentials
{
public static final int BUKKIT_VERSION = 1000;
public static final int BUKKIT_VERSION = 1818;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
private transient Spawn spawn;
private transient Jail jail;
private transient Jails jails;
private transient Warps warps;
private transient Worth worth;
private transient List<IConf> confList;
private transient Backup backup;
private transient BanWorkaround bans;
private transient ItemDb itemDb;
private transient final Map<String, User> users = new HashMap<String, User>();
private transient EssentialsUpdateTimer updateTimer;
private transient final Methods paymentMethod = new Methods();
private transient final static boolean enableErrorLogging = false;
private transient final EssentialsErrorHandler errorHandler = new EssentialsErrorHandler();
private transient IPermissionsHandler permissionsHandler;
private transient PermissionsHandler permissionsHandler;
private transient AlternativeCommandsHandler alternativeCommandsHandler;
private transient UserMap userMap;
private transient ExecuteTimer execTimer;
private transient I18n i18n;
@Override
public ISettings getSettings()
{
return settings;
@@ -81,143 +95,159 @@ public class Essentials extends JavaPlugin implements IEssentials
{
throw new IOException();
}
LOGGER.log(Level.INFO, Util.i18n("usingTempFolderForTesting"));
i18n = new I18n(this);
i18n.onEnable();
LOGGER.log(Level.INFO, _("usingTempFolderForTesting"));
LOGGER.log(Level.INFO, dataFolder.toString());
this.initialize(null, server, new PluginDescriptionFile(new FileReader(new File("src" + File.separator + "plugin.yml"))), dataFolder, null, null);
settings = new Settings(this);
permissionsHandler = new ConfigPermissionsHandler(this);
i18n.updateLocale("en");
userMap = new UserMap(this);
permissionsHandler = new PermissionsHandler(this, false);
Economy.setEss(this);
}
@Override
public void onEnable()
{
final String[] javaversion = System.getProperty("java.version").split("\\.", 3);
if (javaversion == null || javaversion.length < 2 || Integer.parseInt(javaversion[1]) < 6)
{
LOGGER.log(Level.SEVERE, "Java version not supported! Please install Java 1.6. You have " + System.getProperty("java.version"));
}
if (enableErrorLogging)
{
LOGGER.addHandler(errorHandler);
}
EssentialsUpgrade upgrade = new EssentialsUpgrade(this.getDescription().getVersion(), this);
upgrade.beforeSettings();
confList = new ArrayList<IConf>();
settings = new Settings(this);
confList.add(settings);
upgrade.afterSettings();
Util.updateLocale(settings.getLocale(), this);
spawn = new Spawn(getServer(), this.getDataFolder());
confList.add(spawn);
warps = new Warps(getServer(), this.getDataFolder());
confList.add(warps);
worth = new Worth(this.getDataFolder());
confList.add(worth);
bans = new BanWorkaround(this);
confList.add(bans);
itemDb = new ItemDb(this);
confList.add(itemDb);
reload();
backup = new Backup(this);
execTimer = new ExecuteTimer();
execTimer.start();
i18n = new I18n(this);
i18n.onEnable();
execTimer.mark("I18n1");
final PluginManager pm = getServer().getPluginManager();
for (Plugin plugin : pm.getPlugins())
{
if (plugin.getDescription().getName().startsWith("Essentials")
&& !plugin.getDescription().getVersion().equals(this.getDescription().getVersion()))
{
LOGGER.log(Level.WARNING, Util.format("versionMismatch", plugin.getDescription().getName()));
LOGGER.log(Level.WARNING, _("versionMismatch", plugin.getDescription().getName()));
}
}
final Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*").matcher(getServer().getVersion());
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());
if (versionMatch.matches())
{
final int versionNumber = Integer.parseInt(versionMatch.group(4));
if (versionNumber < BUKKIT_VERSION)
{
LOGGER.log(Level.WARNING, Util.i18n("notRecommendedBukkit"));
LOGGER.log(Level.SEVERE, _("notRecommendedBukkit"));
LOGGER.log(Level.SEVERE, _("requiredBukkit", Integer.toString(BUKKIT_VERSION)));
this.setEnabled(false);
return;
}
}
else
{
LOGGER.log(Level.INFO, Util.i18n("bukkitFormatChanged"));
LOGGER.log(Level.INFO, _("bukkitFormatChanged"));
LOGGER.log(Level.INFO, getServer().getVersion());
LOGGER.log(Level.INFO, getServer().getBukkitVersion());
}
final ServerListener serverListener = new EssentialsPluginListener(this);
pm.registerEvent(Type.PLUGIN_ENABLE, serverListener, Priority.Low, this);
pm.registerEvent(Type.PLUGIN_DISABLE, serverListener, Priority.Low, this);
execTimer.mark("BukkitCheck");
try
{
final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
upgrade.beforeSettings();
execTimer.mark("Upgrade");
confList = new ArrayList<IConf>();
settings = new Settings(this);
confList.add(settings);
execTimer.mark("Settings");
upgrade.afterSettings();
execTimer.mark("Upgrade2");
i18n.updateLocale(settings.getLocale());
userMap = new UserMap(this);
confList.add(userMap);
execTimer.mark("Init(Usermap)");
warps = new Warps(getServer(), this.getDataFolder());
confList.add(warps);
execTimer.mark("Init(Spawn/Warp)");
worth = new Worth(this.getDataFolder());
confList.add(worth);
itemDb = new ItemDb(this);
confList.add(itemDb);
execTimer.mark("Init(Worth/ItemDB)");
reload();
}
catch (YAMLException exception)
{
if (pm.getPlugin("EssentialsUpdate") != null)
{
LOGGER.log(Level.SEVERE, _("essentialsHelp2"));
}
else
{
LOGGER.log(Level.SEVERE, _("essentialsHelp1"));
}
LOGGER.log(Level.SEVERE, exception.toString());
pm.registerEvents(new Listener()
{
@EventHandler(priority = EventPriority.LOW)
public void onPlayerJoin(final PlayerJoinEvent event)
{
event.getPlayer().sendMessage("Essentials failed to load, read the log file.");
}
}, this);
for (Player player : getServer().getOnlinePlayers())
{
player.sendMessage("Essentials failed to load, read the log file.");
}
this.setEnabled(false);
return;
}
backup = new Backup(this);
permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions());
alternativeCommandsHandler = new AlternativeCommandsHandler(this);
final EssentialsPluginListener serverListener = new EssentialsPluginListener(this);
pm.registerEvents(serverListener, this);
confList.add(serverListener);
final EssentialsPlayerListener playerListener = new EssentialsPlayerListener(this);
pm.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Monitor, this);
pm.registerEvent(Type.PLAYER_QUIT, playerListener, Priority.Monitor, this);
pm.registerEvent(Type.PLAYER_CHAT, playerListener, Priority.Lowest, this);
pm.registerEvent(Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Lowest, this);
pm.registerEvent(Type.PLAYER_MOVE, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_LOGIN, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_TELEPORT, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_EGG_THROW, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_BUCKET_EMPTY, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_ANIMATION, playerListener, Priority.High, this);
pm.registerEvents(playerListener, this);
final EssentialsBlockListener blockListener = new EssentialsBlockListener(this);
pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Lowest, this);
pm.registerEvents(blockListener, this);
final SignBlockListener signBlockListener = new SignBlockListener(this);
pm.registerEvent(Type.SIGN_CHANGE, signBlockListener, Priority.Highest, this);
pm.registerEvent(Type.BLOCK_PLACE, signBlockListener, Priority.Low, this);
pm.registerEvent(Type.BLOCK_BREAK, signBlockListener, Priority.Highest, this);
pm.registerEvent(Type.BLOCK_IGNITE, signBlockListener, Priority.Low, this);
pm.registerEvent(Type.BLOCK_BURN, signBlockListener, Priority.Low, this);
pm.registerEvent(Type.BLOCK_PISTON_EXTEND, signBlockListener, Priority.Low, this);
pm.registerEvent(Type.BLOCK_PISTON_RETRACT, signBlockListener, Priority.Low, this);
pm.registerEvents(signBlockListener, this);
final SignPlayerListener signPlayerListener = new SignPlayerListener(this);
pm.registerEvent(Type.PLAYER_INTERACT, signPlayerListener, Priority.Low, this);
pm.registerEvents(signPlayerListener, this);
final SignEntityListener signEntityListener = new SignEntityListener(this);
pm.registerEvent(Type.ENTITY_EXPLODE, signEntityListener, Priority.Low, this);
pm.registerEvents(signEntityListener, this);
final EssentialsEntityListener entityListener = new EssentialsEntityListener(this);
pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Lowest, this);
pm.registerEvent(Type.ENTITY_COMBUST, entityListener, Priority.Lowest, this);
pm.registerEvent(Type.ENTITY_DEATH, entityListener, Priority.Lowest, this);
pm.registerEvents(entityListener, this);
final EssentialsWorldListener worldListener = new EssentialsWorldListener(this);
pm.registerEvents(worldListener, this);
jail = new Jail(this);
final JailPlayerListener jailPlayerListener = new JailPlayerListener(this);
confList.add(jail);
pm.registerEvent(Type.BLOCK_BREAK, jail, Priority.Low, this);
pm.registerEvent(Type.BLOCK_DAMAGE, jail, Priority.Low, this);
pm.registerEvent(Type.BLOCK_PLACE, jail, Priority.Low, this);
pm.registerEvent(Type.PLAYER_INTERACT, jailPlayerListener, Priority.Low, this);
pm.registerEvent(Type.PLAYER_RESPAWN, jailPlayerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_TELEPORT, jailPlayerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_JOIN, jailPlayerListener, Priority.High, this);
//TODO: Check if this should be here, and not above before reload()
jails = new Jails(this);
confList.add(jails);
if (settings.isNetherEnabled() && getServer().getWorlds().size() < 2)
{
getServer().createWorld(settings.getNetherName(), World.Environment.NETHER);
}
pm.registerEvent(Type.ENTITY_EXPLODE, tntListener, Priority.High, this);
pm.registerEvents(tntListener, this);
final EssentialsTimer timer = new EssentialsTimer(this);
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 50);
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
Economy.setEss(this);
if (enableErrorLogging)
execTimer.mark("RegListeners");
final String timeroutput = execTimer.end();
if (getSettings().isDebug())
{
updateTimer = new EssentialsUpdateTimer(this);
getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 50, 50 * 60 * (this.getDescription().getVersion().startsWith("Dev") ? 60 : 360));
LOGGER.log(Level.INFO, "Essentials load " + timeroutput);
}
LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors())));
}
@Override
public void onDisable()
{
i18n.onDisable();
Economy.setEss(null);
Trade.closeLog();
LOGGER.removeHandler(errorHandler);
}
@Override
public void reload()
{
Trade.closeLog();
@@ -225,162 +255,29 @@ public class Essentials extends JavaPlugin implements IEssentials
for (IConf iConf : confList)
{
iConf.reloadConfig();
execTimer.mark("Reload(" + iConf.getClass().getSimpleName() + ")");
}
Util.updateLocale(settings.getLocale(), this);
for (User user : users.values())
{
user.reloadConfig();
}
// for motd
getConfiguration().load();
}
public String[] getMotd(CommandSender sender, String def)
{
return getLines(sender, "motd", def);
}
public String[] getLines(CommandSender sender, String node, String def)
{
List<String> lines = (List<String>)getConfiguration().getProperty(node);
if (lines == null)
{
return new String[0];
}
String[] retval = new String[lines.size()];
if (lines.isEmpty() || lines.get(0) == null)
{
try
{
lines = new ArrayList<String>();
// "[]" in YaML indicates empty array, so respect that
if (!getConfiguration().getString(node, def).equals("[]"))
{
lines.add(getConfiguration().getString(node, def));
retval = new String[lines.size()];
}
}
catch (Throwable ex2)
{
LOGGER.log(Level.WARNING, Util.format("corruptNodeInConfig", node));
return new String[0];
}
}
// if still empty, call it a day
if (lines == null || lines.isEmpty() || lines.get(0) == null)
{
return new String[0];
}
for (int i = 0; i < lines.size(); i++)
{
String m = lines.get(i);
if (m == null)
{
continue;
}
m = m.replace('&', '§').replace("§§", "&");
if (sender instanceof User || sender instanceof Player)
{
User user = getUser(sender);
m = m.replace("{PLAYER}", user.getDisplayName());
m = m.replace("{IP}", user.getAddress().toString());
m = m.replace("{BALANCE}", Double.toString(user.getMoney()));
m = m.replace("{MAILS}", Integer.toString(user.getMails().size()));
m = m.replace("{WORLD}", user.getLocation().getWorld().getName());
}
int playerHidden = 0;
for (Player p : getServer().getOnlinePlayers())
{
if (getUser(p).isHidden())
{
playerHidden++;
}
}
m = m.replace("{ONLINE}", Integer.toString(getServer().getOnlinePlayers().length - playerHidden));
m = m.replace("{UNIQUE}", Integer.toString(users.size()));
if (m.matches(".*\\{PLAYERLIST\\}.*"))
{
StringBuilder online = new StringBuilder();
for (Player p : getServer().getOnlinePlayers())
{
if (getUser(p).isHidden())
{
continue;
}
if (online.length() > 0)
{
online.append(", ");
}
online.append(p.getDisplayName());
}
m = m.replace("{PLAYERLIST}", online.toString());
}
if (sender instanceof Player)
{
try
{
Class User = getClassLoader().loadClass("bukkit.Vandolis.User");
Object vuser = User.getConstructor(User.class).newInstance((Player)sender);
m = m.replace("{RED:BALANCE}", User.getMethod("getMoney").invoke(vuser).toString());
m = m.replace("{RED:BUYS}", User.getMethod("getNumTransactionsBuy").invoke(vuser).toString());
m = m.replace("{RED:SELLS}", User.getMethod("getNumTransactionsSell").invoke(vuser).toString());
}
catch (Throwable ex)
{
m = m.replace("{RED:BALANCE}", "N/A");
m = m.replace("{RED:BUYS}", "N/A");
m = m.replace("{RED:SELLS}", "N/A");
}
}
retval[i] = m + " ";
}
return retval;
i18n.updateLocale(settings.getLocale());
}
@Override
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
public boolean onCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args)
{
return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.");
return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.", null);
}
public boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix)
@Override
public boolean onCommandEssentials(final CommandSender sender, final Command command, final String commandLabel, final String[] args, final ClassLoader classLoader, final String commandPath, final String permissionPrefix, final IEssentialsModule module)
{
// Allow plugins to override the command via onCommand
if (!getSettings().isCommandOverridden(command.getName()) && !commandLabel.startsWith("e"))
if (!getSettings().isCommandOverridden(command.getName()) && (!commandLabel.startsWith("e") || commandLabel.equalsIgnoreCase(command.getName())))
{
for (Plugin p : getServer().getPluginManager().getPlugins())
final PluginCommand pc = alternativeCommandsHandler.getAlternative(commandLabel);
if (pc != null)
{
if (p.getDescription().getMain().contains("com.earth2me.essentials"))
{
continue;
}
PluginDescriptionFile desc = p.getDescription();
if (desc == null)
{
continue;
}
if (desc.getName() == null)
{
continue;
}
PluginCommand pc = getServer().getPluginCommand(desc.getName() + ":" + commandLabel);
if (pc != null)
{
return pc.execute(sender, commandLabel, args);
}
alternativeCommandsHandler.executed(commandLabel, pc.getLabel());
return pc.execute(sender, commandLabel, args);
}
}
@@ -399,7 +296,7 @@ public class Essentials extends JavaPlugin implements IEssentials
final List<String> mail = user.getMails();
if (mail != null && !mail.isEmpty())
{
user.sendMessage(Util.format("youHaveNewMail", mail.size()));
user.sendMessage(_("youHaveNewMail", mail.size()));
}
}
@@ -414,19 +311,20 @@ public class Essentials extends JavaPlugin implements IEssentials
{
cmd = (IEssentialsCommand)classLoader.loadClass(commandPath + command.getName()).newInstance();
cmd.setEssentials(this);
cmd.setEssentialsModule(module);
}
catch (Exception ex)
{
sender.sendMessage(Util.format("commandNotLoaded", commandLabel));
LOGGER.log(Level.SEVERE, Util.format("commandNotLoaded", commandLabel), ex);
sender.sendMessage(_("commandNotLoaded", commandLabel));
LOGGER.log(Level.SEVERE, _("commandNotLoaded", commandLabel), ex);
return true;
}
// Check authorization
if (user != null && !user.isAuthorized(cmd, permissionPrefix))
{
LOGGER.log(Level.WARNING, Util.format("deniedAccessCommand", user.getName()));
user.sendMessage(Util.i18n("noAccessCommand"));
LOGGER.log(Level.WARNING, _("deniedAccessCommand", user.getName()));
user.sendMessage(_("noAccessCommand"));
return true;
}
@@ -443,10 +341,18 @@ public class Essentials extends JavaPlugin implements IEssentials
}
return true;
}
catch (NoChargeException ex)
{
return true;
}
catch (NotEnoughArgumentsException ex)
{
sender.sendMessage(command.getDescription());
sender.sendMessage(command.getUsage().replaceAll("<command>", commandLabel));
if (!ex.getMessage().isEmpty())
{
sender.sendMessage(ex.getMessage());
}
return true;
}
catch (Throwable ex)
@@ -457,70 +363,71 @@ public class Essentials extends JavaPlugin implements IEssentials
}
catch (Throwable ex)
{
LOGGER.log(Level.SEVERE, Util.format("commandFailed", commandLabel), ex);
LOGGER.log(Level.SEVERE, _("commandFailed", commandLabel), ex);
return true;
}
}
@Override
public void showError(final CommandSender sender, final Throwable exception, final String commandLabel)
{
sender.sendMessage(Util.format("errorWithMessage", exception.getMessage()));
final LogRecord logRecord = new LogRecord(Level.WARNING, Util.format("errorCallingCommand", commandLabel));
logRecord.setThrown(exception);
sender.sendMessage(_("errorWithMessage", exception.getMessage()));
if (getSettings().isDebug())
{
LOGGER.log(logRecord);
}
else
{
if (enableErrorLogging)
{
errorHandler.publish(logRecord);
errorHandler.flush();
}
LOGGER.log(Level.WARNING, _("errorCallingCommand", commandLabel), exception);
}
}
public CraftScheduler getScheduler()
@Override
public BukkitScheduler getScheduler()
{
return (CraftScheduler)this.getServer().getScheduler();
return this.getServer().getScheduler();
}
public Jail getJail()
@Override
public IJails getJails()
{
return jail;
return jails;
}
@Override
public Warps getWarps()
{
return warps;
}
@Override
public Worth getWorth()
{
return worth;
}
@Override
public Backup getBackup()
{
return backup;
}
public Spawn getSpawn()
{
return spawn;
}
public User getUser(Object base)
@Override
public User getUser(final Object base)
{
if (base instanceof Player)
{
return getUser((Player)base);
}
if (base instanceof String)
{
final User user = userMap.getUser((String)base);
if (user != null && user.getBase() instanceof OfflinePlayer)
{
((OfflinePlayer)user.getBase()).setName((String)base);
}
return user;
}
return null;
}
private <T extends Player> User getUser(T base)
private <T extends Player> User getUser(final T base)
{
if (base == null)
{
@@ -531,71 +438,73 @@ public class Essentials extends JavaPlugin implements IEssentials
{
return (User)base;
}
User user = userMap.getUser(base.getName());
if (users.containsKey(base.getName().toLowerCase()))
if (user == null)
{
return users.get(base.getName().toLowerCase()).update(base);
user = new User(base, this);
}
User u = new User(base, this);
users.put(u.getName().toLowerCase(), u);
return u;
}
public Map<String, User> getAllUsers()
{
return users;
}
public User getOfflineUser(String name)
{
// Don't create a new offline user, if we already have that user loaded.
User u = users.get(name.toLowerCase());
if (u != null)
else
{
return u;
user.update(base);
}
File userFolder = new File(getDataFolder(), "userdata");
File userFile = new File(userFolder, Util.sanitizeFileName(name) + ".yml");
if (userFile.exists())
{ //Users do not get offline changes saved without being reproccessed as Users! ~ Xeology :)
return getUser((Player)new OfflinePlayer(name, this));
}
return null;
return user;
}
@Override
public User getOfflineUser(final String name)
{
final User user = userMap.getUser(name);
if (user != null && user.getBase() instanceof OfflinePlayer)
{
((OfflinePlayer)user.getBase()).setName(name);
}
return user;
}
@Override
public World getWorld(final String name)
{
if (name.matches("[0-9]+"))
{
final int id = Integer.parseInt(name);
if (id < getServer().getWorlds().size())
final int worldId = Integer.parseInt(name);
if (worldId < getServer().getWorlds().size())
{
return getServer().getWorlds().get(id);
return getServer().getWorlds().get(worldId);
}
}
return getServer().getWorld(name);
}
@Override
public void addReloadListener(final IConf listener)
{
confList.add(listener);
}
@Override
public Methods getPaymentMethod()
{
return paymentMethod;
}
public int broadcastMessage(final String name, final String message)
@Override
public int broadcastMessage(final IUser sender, final String message)
{
Player[] players = getServer().getOnlinePlayers();
if (sender == null)
{
return getServer().broadcastMessage(message);
}
if (sender.isHidden())
{
return 0;
}
final Player[] players = getServer().getOnlinePlayers();
for (Player player : players)
{
User u = getUser(player);
if (!u.isIgnoredPlayer(name))
final User user = getUser(player);
if (!user.isIgnoredPlayer(sender.getName()))
{
player.sendMessage(message);
}
@@ -604,53 +513,105 @@ public class Essentials extends JavaPlugin implements IEssentials
return players.length;
}
public Map<BigInteger, String> getErrors()
{
return errorHandler.getErrors();
}
@Override
public int scheduleAsyncDelayedTask(final Runnable run)
{
return this.getScheduler().scheduleAsyncDelayedTask(this, run);
}
@Override
public int scheduleSyncDelayedTask(final Runnable run)
{
return this.getScheduler().scheduleSyncDelayedTask(this, run);
}
@Override
public int scheduleSyncDelayedTask(final Runnable run, final long delay)
{
return this.getScheduler().scheduleSyncDelayedTask(this, run, delay);
}
@Override
public int scheduleSyncRepeatingTask(final Runnable run, final long delay, final long period)
{
return this.getScheduler().scheduleSyncRepeatingTask(this, run, delay, period);
}
@Override
public TNTExplodeListener getTNTListener()
{
return tntListener;
}
public IPermissionsHandler getPermissionsHandler()
@Override
public PermissionsHandler getPermissionsHandler()
{
return permissionsHandler;
}
public void setPermissionsHandler(IPermissionsHandler handler)
@Override
public AlternativeCommandsHandler getAlternativeCommandsHandler()
{
this.permissionsHandler = handler;
}
public BanWorkaround getBans()
{
return bans;
return alternativeCommandsHandler;
}
@Override
public ItemDb getItemDb()
{
return itemDb;
}
@Override
public UserMap getUserMap()
{
return userMap;
}
@Override
public I18n getI18n()
{
return i18n;
}
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)
{
ess.getJails().onReload();
ess.getWarps().reloadConfig();
for (IConf iConf : ((Essentials)ess).confList)
{
if (iConf instanceof IEssentialsModule) {
iConf.reloadConfig();
}
}
}
@EventHandler(priority = EventPriority.LOW)
public void onWorldUnload(final WorldUnloadEvent event)
{
ess.getJails().onReload();
ess.getWarps().reloadConfig();
for (IConf iConf : ((Essentials)ess).confList)
{
if (iConf instanceof IEssentialsModule) {
iConf.reloadConfig();
}
}
}
@Override
public void run()
{
ess.reload();
}
}
}

View File

@@ -1,24 +1,24 @@
package com.earth2me.essentials;
import java.util.logging.Logger;
import org.bukkit.Material;
import org.bukkit.event.block.BlockListener;
import org.bukkit.GameMode;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
public class EssentialsBlockListener extends BlockListener
public class EssentialsBlockListener implements Listener
{
private final IEssentials ess;
private static final Logger logger = Logger.getLogger("Minecraft");
private final transient IEssentials ess;
public EssentialsBlockListener(IEssentials ess)
public EssentialsBlockListener(final IEssentials ess)
{
this.ess = ess;
}
@Override
public void onBlockPlace(BlockPlaceEvent event)
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockPlace(final BlockPlaceEvent event)
{
if (event.isCancelled())
{
@@ -27,77 +27,18 @@ public class EssentialsBlockListener extends BlockListener
final User user = ess.getUser(event.getPlayer());
// Do not rely on getItemInHand();
// http://leaky.bukkit.org/issues/663
final ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short)0, event.getBlockPlaced().getData());
switch (is.getType())
final ItemStack is = Util.convertBlockToItem(event.getBlockPlaced());
if (is == null)
{
case WOODEN_DOOR:
is.setType(Material.WOOD_DOOR);
is.setDurability((short)0);
break;
case IRON_DOOR_BLOCK:
is.setType(Material.IRON_DOOR);
is.setDurability((short)0);
break;
case SIGN_POST:
case WALL_SIGN:
is.setType(Material.SIGN);
is.setDurability((short)0);
break;
case CROPS:
is.setType(Material.SEEDS);
is.setDurability((short)0);
break;
case CAKE_BLOCK:
is.setType(Material.CAKE);
is.setDurability((short)0);
break;
case BED_BLOCK:
is.setType(Material.BED);
is.setDurability((short)0);
break;
case REDSTONE_WIRE:
is.setType(Material.REDSTONE);
is.setDurability((short)0);
break;
case REDSTONE_TORCH_OFF:
case REDSTONE_TORCH_ON:
is.setType(Material.REDSTONE_TORCH_ON);
is.setDurability((short)0);
break;
case DIODE_BLOCK_OFF:
case DIODE_BLOCK_ON:
is.setType(Material.DIODE);
is.setDurability((short)0);
break;
case DOUBLE_STEP:
is.setType(Material.STEP);
break;
case TORCH:
case RAILS:
case LADDER:
case WOOD_STAIRS:
case COBBLESTONE_STAIRS:
case LEVER:
case STONE_BUTTON:
case FURNACE:
case DISPENSER:
case PUMPKIN:
case JACK_O_LANTERN:
case WOOD_PLATE:
case STONE_PLATE:
case PISTON_STICKY_BASE:
case PISTON_BASE:
is.setDurability((short)0);
break;
case FIRE:
return;
}
boolean unlimitedForUser = user.hasUnlimited(is);
if (unlimitedForUser)
if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL)
{
ess.scheduleSyncDelayedTask(
new Runnable()
{
@Override
public void run()
{
user.getInventory().addItem(is);

View File

@@ -1,11 +1,10 @@
package com.earth2me.essentials;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import static com.earth2me.essentials.I18n._;
import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -13,18 +12,19 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.config.Configuration;
public class EssentialsConf extends Configuration
{
private static final Logger logger = Logger.getLogger("Minecraft");
private File configFile;
private String templateName = null;
private Class<?> resourceClass = EssentialsConf.class;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient File configFile;
private transient String templateName = null;
private transient Class<?> resourceClass = EssentialsConf.class;
public EssentialsConf(File configFile)
public EssentialsConf(final File configFile)
{
super(configFile);
this.configFile = configFile;
@@ -42,33 +42,79 @@ public class EssentialsConf extends Configuration
{
if (!configFile.getParentFile().mkdirs())
{
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
}
}
// This will delete files where the first character is 0. In most cases they are broken.
if (configFile.exists() && configFile.length() != 0)
{
try
{
final InputStream input = new FileInputStream(configFile);
try
{
if (input.read() == 0)
{
input.close();
configFile.delete();
}
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, null, ex);
}
finally
{
try
{
input.close();
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, null, ex);
}
}
}
catch (FileNotFoundException ex)
{
LOGGER.log(Level.SEVERE, null, ex);
}
}
if (!configFile.exists())
{
if (templateName != null)
{
logger.log(Level.INFO, Util.format("creatingConfigFromTemplate", configFile.toString()));
LOGGER.log(Level.INFO, _("creatingConfigFromTemplate", configFile.toString()));
createFromTemplate();
}
else
{
try
{
logger.log(Level.INFO, Util.format("creatingEmptyConfig", configFile.toString()));
LOGGER.log(Level.INFO, _("creatingEmptyConfig", configFile.toString()));
if (!configFile.createNewFile())
{
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()));
}
}
catch (IOException ex)
{
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()), ex);
LOGGER.log(Level.SEVERE, _("failedToCreateConfig", configFile.toString()), ex);
}
}
}
super.load();
try
{
super.load();
}
catch (RuntimeException e)
{
LOGGER.log(Level.SEVERE, "File broken: " + configFile.toString());
throw e;
}
if (this.root == null)
{
this.root = new HashMap<String, Object>();
@@ -84,7 +130,7 @@ public class EssentialsConf extends Configuration
istr = resourceClass.getResourceAsStream(templateName);
if (istr == null)
{
logger.log(Level.SEVERE, Util.format("couldNotFindTemplate", templateName));
LOGGER.log(Level.SEVERE, _("couldNotFindTemplate", templateName));
return;
}
ostr = new FileOutputStream(configFile);
@@ -99,8 +145,7 @@ public class EssentialsConf extends Configuration
}
catch (IOException ex)
{
logger.log(Level.SEVERE, Util.format("failedToWriteConfig", configFile.toString()), ex);
return;
LOGGER.log(Level.SEVERE, _("failedToWriteConfig", configFile.toString()), ex);
}
finally
{
@@ -124,12 +169,12 @@ public class EssentialsConf extends Configuration
}
catch (IOException ex)
{
logger.log(Level.SEVERE, Util.format("failedToCloseConfig", configFile.toString()), ex);
LOGGER.log(Level.SEVERE, _("failedToCloseConfig", configFile.toString()), ex);
}
}
}
public void setTemplateName(String templateName)
public void setTemplateName(final String templateName)
{
this.templateName = templateName;
}
@@ -139,101 +184,119 @@ public class EssentialsConf extends Configuration
return configFile;
}
public void setTemplateName(String templateName, Class<?> resClass)
public void setTemplateName(final String templateName, final Class<?> resClass)
{
this.templateName = templateName;
this.resourceClass = resClass;
}
public boolean hasProperty(String path)
public boolean hasProperty(final String path)
{
return getProperty(path) != null;
}
public Location getLocation(String path, Server server)
public Location getLocation(final String path, final Server server) throws Exception
{
String worldName = getString((path != null ? path + "." : "") + "world");
final String worldName = getString((path == null ? "" : path + ".") + "world");
if (worldName == null || worldName.isEmpty())
{
return null;
}
World world = server.getWorld(worldName);
final World world = server.getWorld(worldName);
if (world == null)
{
return null;
throw new Exception(_("invalidWorld"));
}
return new Location(world,
getDouble((path != null ? path + "." : "") + "x", 0),
getDouble((path != null ? path + "." : "") + "y", 0),
getDouble((path != null ? path + "." : "") + "z", 0),
(float)getDouble((path != null ? path + "." : "") + "yaw", 0),
(float)getDouble((path != null ? path + "." : "") + "pitch", 0));
getDouble((path == null ? "" : path + ".") + "x", 0),
getDouble((path == null ? "" : path + ".") + "y", 0),
getDouble((path == null ? "" : path + ".") + "z", 0),
(float)getDouble((path == null ? "" : path + ".") + "yaw", 0),
(float)getDouble((path == null ? "" : path + ".") + "pitch", 0));
}
public void setProperty(String path, Location loc)
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());
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());
}
public ItemStack getItemStack(String path)
public ItemStack getItemStack(final String path)
{
return new ItemStack(
final ItemStack stack = new ItemStack(
Material.valueOf(getString(path + ".type", "AIR")),
getInt(path + ".amount", 1),
(short)getInt(path + ".damage", 0)/*,
(byte)getInt(path + ".data", 0)*/);
(short)getInt(path + ".damage", 0));
final List<String> enchants = getKeys(path + ".enchant");
if (enchants != null)
{
for (String enchant : enchants)
{
final Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH));
if (enchantment == null)
{
continue;
}
final int level = getInt(path + ".enchant." + enchant, enchantment.getStartLevel());
stack.addUnsafeEnchantment(enchantment, level);
}
}
return stack;
/*
* ,
* (byte)getInt(path + ".data", 0)
*/
}
public void setProperty(String path, ItemStack stack)
public void setProperty(final String path, final ItemStack stack)
{
Map<String, Object> map = new HashMap<String, Object>();
final Map<String, Object> map = new HashMap<String, Object>();
map.put("type", stack.getType().toString());
map.put("amount", stack.getAmount());
map.put("damage", stack.getDurability());
Map<Enchantment, Integer> enchantments = stack.getEnchantments();
if (!enchantments.isEmpty())
{
Map<String, Integer> enchant = new HashMap<String, Integer>();
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet())
{
enchant.put(entry.getKey().getName().toLowerCase(Locale.ENGLISH), entry.getValue());
}
map.put("enchant", enchant);
}
// getData().getData() is broken
//map.put("data", stack.getDurability());
setProperty(path, map);
}
public long getLong(String path, long def)
public long getLong(final String path, final long def)
{
Number num;
try
{
num = (Number)getProperty(path);
final Number num = (Number)getProperty(path);
return num == null ? def : num.longValue();
}
catch(ClassCastException ex)
catch (ClassCastException ex)
{
return def;
}
if (num == null)
{
return def;
}
return num.longValue();
}
@Override
public double getDouble(String path, double def)
public double getDouble(final String path, final double def)
{
Number num;
try
{
num = (Number)getProperty(path);
Number num = (Number)getProperty(path);
return num == null ? def : num.doubleValue();
}
catch(ClassCastException ex)
catch (ClassCastException ex)
{
return def;
}
if (num == null)
{
return def;
}
return num.doubleValue();
}
}

View File

@@ -1,19 +1,20 @@
package com.earth2me.essentials;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import static com.earth2me.essentials.I18n._;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityListener;
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.inventory.ItemStack;
public class EssentialsEntityListener extends EntityListener
public class EssentialsEntityListener implements Listener
{
private final IEssentials ess;
@@ -22,7 +23,7 @@ public class EssentialsEntityListener extends EntityListener
this.ess = ess;
}
@Override
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageEvent event)
{
if (event instanceof EntityDamageByEntityEvent)
@@ -34,30 +35,47 @@ public class EssentialsEntityListener extends EntityListener
{
User defender = ess.getUser(eDefend);
User attacker = ess.getUser(eAttack);
attacker.updateActivity(true);
ItemStack is = attacker.getItemInHand();
String command = attacker.getPowertool(is);
if (command != null && !command.isEmpty())
List<String> commandList = attacker.getPowertool(is);
if (commandList != null && !commandList.isEmpty())
{
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
for (String command : commandList)
{
if (command != null && !command.isEmpty())
{
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
event.setCancelled(true);
return;
}
}
}
}
if (eDefend instanceof Animals && eAttack instanceof Player)
{
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);
return;
}
}
}
if (event instanceof EntityDamageEvent || event instanceof EntityDamageByBlockEvent || event instanceof EntityDamageByProjectileEvent)
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{
CraftPlayer player = (CraftPlayer)event.getEntity();
player.getHandle().fireTicks = 0;
player.setRemainingAir(player.getMaximumAir());
event.setCancelled(true);
}
final Player player = (Player)event.getEntity();
player.setFireTicks(0);
player.setRemainingAir(player.getMaximumAir());
event.setCancelled(true);
}
}
@Override
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityCombust(EntityCombustEvent event)
{
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
@@ -66,17 +84,41 @@ public class EssentialsEntityListener extends EntityListener
}
}
@Override
public void onEntityDeath(EntityDeathEvent event)
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDeath(final EntityDeathEvent event)
{
if (event.getEntity() instanceof Player)
if (event instanceof PlayerDeathEvent)
{
User user = ess.getUser(event.getEntity());
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(Util.i18n("backAfterDeath"));
user.sendMessage(_("backAfterDeath"));
}
if (!ess.getSettings().areDeathMessagesEnabled())
{
pdevent.setDeathMessage("");
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onFoodLevelChange(FoodLevelChangeEvent event)
{
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityRegainHealth(EntityRegainHealthEvent event)
{
if (event.getRegainReason() == RegainReason.SATIATED && event.getEntity() instanceof Player
&& ess.getUser(event.getEntity()).isAfk() && ess.getSettings().getFreezeAfkPlayers())
{
event.setCancelled(true);
}
}
}

View File

@@ -1,128 +0,0 @@
package com.earth2me.essentials;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
class EssentialsErrorHandler extends Handler
{
private final Map<BigInteger, String> errors = new HashMap<BigInteger, String>();
private final List<LogRecord> records = new LinkedList<LogRecord>();
public EssentialsErrorHandler()
{
}
@Override
public void publish(LogRecord lr)
{
if (lr.getThrown() == null || lr.getLevel().intValue() < Level.WARNING.intValue())
{
return;
}
synchronized (records)
{
records.add(lr);
}
}
@Override
public void flush()
{
synchronized (records)
{
sortRecords();
}
}
@Override
public void close() throws SecurityException
{
synchronized (records)
{
sortRecords();
}
}
private void sortRecords()
{
for (LogRecord lr : records)
{
try
{
if (lr.getThrown() == null)
{
return;
}
Throwable tr = lr.getThrown();
StackTraceElement[] elements = tr.getStackTrace();
if (elements == null || elements.length <= 0)
{
return;
}
boolean essentialsFound = false;
for (StackTraceElement stackTraceElement : elements)
{
if (stackTraceElement.getClassName().contains("com.earth2me.essentials"))
{
essentialsFound = true;
break;
}
}
if (!essentialsFound && tr.getCause() != null)
{
Throwable cause = tr.getCause();
StackTraceElement[] elements2 = cause.getStackTrace();
if (elements2 != null)
{
for (StackTraceElement stackTraceElement : elements2)
{
if (stackTraceElement.getClassName().contains("com.earth2me.essentials"))
{
essentialsFound = true;
break;
}
}
}
}
StringBuilder sb = new StringBuilder();
sb.append("[").append(lr.getLevel().getName()).append("] ").append(lr.getMessage()).append("\n");
sb.append(tr.getMessage()).append("\n");
for (StackTraceElement stackTraceElement : tr.getStackTrace())
{
sb.append(stackTraceElement.toString()).append("\n");
}
if (tr.getCause() != null && tr.getCause().getStackTrace() != null)
{
sb.append(tr.getCause().getMessage()).append("\n");
for (StackTraceElement stackTraceElement : tr.getCause().getStackTrace())
{
sb.append(stackTraceElement.toString()).append("\n");
}
}
String errorReport = sb.toString();
byte[] bytesOfMessage = errorReport.getBytes("UTF-8");
MessageDigest md = MessageDigest.getInstance("MD5");
BigInteger bi = new BigInteger(md.digest(bytesOfMessage));
errors.put(bi, errorReport);
}
catch (Throwable t)
{
//Ignore all exceptions inside the exception handler
}
}
records.clear();
}
Map<BigInteger, String> getErrors()
{
return errors;
}
}

View File

@@ -1,38 +1,32 @@
package com.earth2me.essentials;
import java.util.ArrayList;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.KeywordReplacer;
import com.earth2me.essentials.textreader.TextInput;
import com.earth2me.essentials.textreader.TextPager;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
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.World;
import org.bukkit.block.Block;
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.player.PlayerAnimationEvent;
import org.bukkit.event.player.PlayerAnimationType;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerEggThrowEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.ItemStack;
public class EssentialsPlayerListener extends PlayerListener
public class EssentialsPlayerListener implements Listener
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private final transient Server server;
@@ -44,27 +38,26 @@ public class EssentialsPlayerListener extends PlayerListener
this.server = parent.getServer();
}
@Override
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerRespawn(final PlayerRespawnEvent event)
{
final User user = ess.getUser(event.getPlayer());
user.setDisplayName(user.getNick());
updateCompass(user);
if (ess.getSettings().changeDisplayName())
{
user.setDisplayName(user.getNick());
user.setDisplayNick();
}
}
@Override
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerChat(final PlayerChatEvent event)
{
final User user = ess.getUser(event.getPlayer());
if (user.isMuted())
{
event.setCancelled(true);
user.sendMessage(Util.i18n("playerMuted"));
LOGGER.info(Util.format("mutedUserSpeaks", user.getName()));
user.sendMessage(_("playerMuted"));
LOGGER.info(_("mutedUserSpeaks", user.getName()));
}
final Iterator<Player> it = event.getRecipients().iterator();
while (it.hasNext())
@@ -75,18 +68,14 @@ public class EssentialsPlayerListener extends PlayerListener
it.remove();
}
}
if (user.isAfk())
{
user.setAfk(false);
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
}
user.updateActivity(true);
if (ess.getSettings().changeDisplayName())
{
user.setDisplayName(user.getNick());
user.setDisplayNick();
}
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerMove(final PlayerMoveEvent event)
{
if (event.isCancelled())
@@ -95,117 +84,32 @@ public class EssentialsPlayerListener extends PlayerListener
}
final User user = ess.getUser(event.getPlayer());
if (user.isAfk())
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers())
{
user.setAfk(false);
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
}
if (!ess.getSettings().getNetherPortalsEnabled())
{
return;
}
final Block block = event.getPlayer().getWorld().getBlockAt(event.getTo().getBlockX(), event.getTo().getBlockY(), event.getTo().getBlockZ());
final List<World> worlds = server.getWorlds();
if (block.getType() == Material.PORTAL && worlds.size() > 1 && user.isAuthorized("essentials.portal"))
{
if (user.getJustPortaled())
{
return;
}
World nether = server.getWorld(ess.getSettings().getNetherName());
if (nether == null)
{
for (World world : worlds)
{
if (world.getEnvironment() == World.Environment.NETHER)
{
nether = world;
break;
}
}
if (nether == null)
{
return;
}
}
final World world = user.getWorld() == nether ? worlds.get(0) : nether;
double factor;
if (user.getWorld().getEnvironment() == World.Environment.NETHER && world.getEnvironment() == World.Environment.NORMAL)
{
factor = ess.getSettings().getNetherRatio();
}
else if (user.getWorld().getEnvironment() == World.Environment.NORMAL && world.getEnvironment() == World.Environment.NETHER)
{
factor = 1.0 / ess.getSettings().getNetherRatio();
}
else
{
factor = 1.0;
}
Location loc = event.getTo();
int x = loc.getBlockX();
int y = loc.getBlockY();
int z = loc.getBlockZ();
if (user.getWorld().getBlockAt(x, y, z - 1).getType() == Material.PORTAL)
{
z--;
}
if (user.getWorld().getBlockAt(x - 1, y, z).getType() == Material.PORTAL)
{
x--;
}
x = (int)(x * factor);
z = (int)(z * factor);
loc = new Location(world, x + .5, y, z + .5);
Block dest = world.getBlockAt(x, y, z);
NetherPortal portal = NetherPortal.findPortal(dest);
if (portal == null)
{
if (world.getEnvironment() == World.Environment.NETHER || ess.getSettings().getGenerateExitPortals())
{
portal = NetherPortal.createPortal(dest);
LOGGER.info(Util.format("userCreatedPortal", event.getPlayer().getName()));
user.sendMessage(Util.i18n("generatingPortal"));
loc = portal.getSpawn();
}
}
else
{
LOGGER.info(Util.format("userUsedPortal", event.getPlayer().getName()));
user.sendMessage(Util.i18n("usingPortal"));
loc = portal.getSpawn();
}
event.setFrom(loc);
event.setTo(loc);
final Location from = event.getFrom();
final Location to = event.getTo().clone();
to.setX(from.getX());
to.setY(from.getY());
to.setZ(from.getZ());
try
{
user.getTeleport().now(loc, new Trade("portal", ess));
event.setTo(Util.getSafeDestination(to));
}
catch (Exception ex)
{
user.sendMessage(ex.getMessage());
event.setTo(to);
}
user.setJustPortaled(true);
user.sendMessage(Util.i18n("teleportingPortal"));
event.setCancelled(true);
return;
}
user.setJustPortaled(false);
final Location afk = user.getAfkPosition();
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
{
user.updateActivity(true);
}
}
@Override
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(final PlayerQuitEvent event)
{
final User user = ess.getUser(event.getPlayer());
@@ -218,55 +122,22 @@ public class EssentialsPlayerListener extends PlayerListener
user.getInventory().setContents(user.getSavedInventory());
user.setSavedInventory(null);
}
user.updateActivity(false);
user.dispose();
if (!ess.getSettings().getReclaimSetting())
{
return;
}
final Thread thread = new Thread(new Runnable()
{
public void run()
{
try
{
Thread.sleep(1000);
Runtime rt = Runtime.getRuntime();
double mem = rt.freeMemory();
rt.runFinalization();
rt.gc();
mem = rt.freeMemory() - mem;
mem /= 1024 * 1024;
LOGGER.log(Level.INFO, Util.format("freedMemory", mem));
}
catch (InterruptedException ex)
{
return;
}
}
});
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
@Override
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(final PlayerJoinEvent event)
{
ess.getBackup().onPlayerJoin();
final User user = ess.getUser(event.getPlayer());
//we do not know the ip address on playerlogin so we need to do this here.
if (user.isIpBanned())
{
final String banReason = user.getBanReason();
user.kickPlayer(banReason != null && !banReason.isEmpty() ? banReason : Util.i18n("defaultBanReason"));
return;
}
if (ess.getSettings().changeDisplayName())
{
user.setDisplayName(user.getNick());
user.setDisplayNick();
}
user.setAfk(false);
user.setLastLoginAddress(user.getAddress().getAddress().getHostAddress());
user.updateActivity(false);
if (user.isAuthorized("essentials.sleepingignored"))
{
user.setSleepingIgnored(true);
@@ -274,13 +145,23 @@ public class EssentialsPlayerListener extends PlayerListener
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
{
for (String m : ess.getMotd(user, null))
try
{
if (m == null)
final IText input = new TextInput(user, "motd", true, ess);
final IText output = new KeywordReplacer(input, user, ess);
final TextPager pager = new TextPager(output, true);
pager.showPage("1", null, "motd", user);
}
catch (IOException ex)
{
if (ess.getSettings().isDebug())
{
continue;
LOGGER.log(Level.WARNING, ex.getMessage(), ex);
}
else
{
LOGGER.log(Level.WARNING, ex.getMessage());
}
user.sendMessage(m);
}
}
@@ -289,37 +170,43 @@ public class EssentialsPlayerListener extends PlayerListener
final List<String> mail = user.getMails();
if (mail.isEmpty())
{
user.sendMessage(Util.i18n("noNewMail"));
user.sendMessage(_("noNewMail"));
}
else
{
user.sendMessage(Util.format("youHaveNewMail", mail.size()));
user.sendMessage(_("youHaveNewMail", mail.size()));
}
}
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerLogin(final PlayerLoginEvent event)
{
if (event.getResult() != Result.ALLOWED)
if (event.getResult() != Result.ALLOWED && event.getResult() != Result.KICK_FULL && event.getResult() != Result.KICK_BANNED)
{
return;
}
final User user = ess.getUser(event.getPlayer());
User user = ess.getUser(event.getPlayer());
user.setNPC(false);
if (user.isBanned())
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 : Util.i18n("defaultBanReason"));
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, Util.i18n("serverFull"));
event.disallow(Result.KICK_FULL, _("serverFull"));
return;
}
event.allow();
user.setLastLogin(System.currentTimeMillis());
updateCompass(user);
@@ -327,31 +214,155 @@ public class EssentialsPlayerListener extends PlayerListener
private void updateCompass(final User user)
{
try
Location loc = user.getHome(user.getLocation());
if (loc == null)
{
user.setCompassTarget(user.getHome(user.getLocation()));
loc = user.getBedSpawnLocation();
}
catch (Exception ex)
if (loc != null)
{
user.setCompassTarget(loc);
}
}
@Override
public void onPlayerTeleport(PlayerTeleportEvent event)
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerTeleport(final PlayerTeleportEvent event)
{
if (event.isCancelled())
{
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())
{
user.setLastLocation();
}
if (ess.getSettings().changeDisplayName())
{
user.setDisplayNick();
}
updateCompass(user);
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerEggThrow(final PlayerEggThrowEvent event)
{
final User user = ess.getUser(event.getPlayer());
final ItemStack stack = new ItemStack(Material.EGG, 1);
if (user.hasUnlimited(stack))
{
user.getInventory().addItem(stack);
user.updateInventory();
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
{
final User user = ess.getUser(event.getPlayer());
if (user.hasUnlimited(new ItemStack(event.getBucket())))
{
event.getItemStack().setType(event.getBucket());
ess.scheduleSyncDelayedTask(new Runnable()
{
@Override
public void run()
{
user.updateInventory();
}
});
}
}
@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)
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
{
if (event.isCancelled())
{
return;
}
final User user = ess.getUser(event.getPlayer());
if (ess.getSettings().changeDisplayName())
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))
{
user.setDisplayName(user.getNick());
for (Player player : ess.getServer().getOnlinePlayers())
{
User spyer = ess.getUser(player);
if (spyer.isSocialSpyEnabled() && !user.equals(spyer))
{
player.sendMessage(user.getDisplayName() + " : " + event.getMessage());
}
}
}
if (!cmd.equalsIgnoreCase("afk"))
{
user.updateActivity(true);
}
updateCompass(user);
}
@Override
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
{
if (ess.getSettings().getNoGodWorlds().contains(event.getPlayer().getLocation().getWorld().getName()))
{
User user = ess.getUser(event.getPlayer());
if (user.isGodModeEnabledRaw())
{
user.sendMessage(_("noGodWorldWarning"));
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerInteract(final PlayerInteractEvent event)
{
if (event.isCancelled())
@@ -363,114 +374,23 @@ public class EssentialsPlayerListener extends PlayerListener
return;
}
if (ess.getSettings().getBedSetsHome() && event.getClickedBlock().getType() == Material.BED_BLOCK)
if (ess.getSettings().getUpdateBedAtDaytime() && event.getClickedBlock().getType() == Material.BED_BLOCK)
{
try
{
final User user = ess.getUser(event.getPlayer());
user.setHome();
user.sendMessage(Util.i18n("homeSetToBed"));
}
catch (Throwable ex)
{
}
event.getPlayer().setBedSpawnLocation(event.getClickedBlock().getLocation());
}
}
@Override
public void onPlayerEggThrow(final PlayerEggThrowEvent event)
@EventHandler(priority = EventPriority.LOW)
public void onPlayerPickupItem(PlayerPickupItemEvent event)
{
final User user = ess.getUser(event.getPlayer());
final ItemStack is = new ItemStack(Material.EGG, 1);
if (user.hasUnlimited(is))
{
user.getInventory().addItem(is);
user.updateInventory();
}
}
@Override
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
{
final User user = ess.getUser(event.getPlayer());
if (user.hasUnlimited(new ItemStack(event.getBucket())))
{
event.getItemStack().setType(event.getBucket());
ess.scheduleSyncDelayedTask(new Runnable()
{
public void run()
{
user.updateInventory();
}
});
}
}
@Override
public void onPlayerAnimation(final PlayerAnimationEvent event)
{
usePowertools(event);
}
private void usePowertools(final PlayerAnimationEvent event)
{
if (event.getAnimationType() != PlayerAnimationType.ARM_SWING)
if (event.isCancelled() || !ess.getSettings().getDisableItemPickupWhileAfk())
{
return;
}
final User user = ess.getUser(event.getPlayer());
final ItemStack is = user.getItemInHand();
if (is == null || is.getType() == Material.AIR)
{
return;
}
final String command = user.getPowertool(is);
if (command == null || command.isEmpty())
{
return;
}
if (command.matches(".*\\{player\\}.*"))
{
//user.sendMessage("Click a player to use this command");
return;
}
if (command.startsWith("c:"))
{
for (Player p : server.getOnlinePlayers())
{
p.sendMessage(user.getDisplayName() + ":" + command.substring(2));
}
}
else
{
user.getServer().dispatchCommand(user, command);
}
}
@Override
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
{
if (event.isCancelled())
{
return;
}
final User user = ess.getUser(event.getPlayer());
final String cmd = event.getMessage().toLowerCase().split(" ")[0].replace("/", "").toLowerCase();
final List<String> commands = Arrays.asList("msg", "r", "mail", "m", "t", "emsg", "tell", "er", "reply", "ereply", "email");
if (commands.contains(cmd))
{
for (Player player : ess.getServer().getOnlinePlayers())
{
if (ess.getUser(player).isSocialSpyEnabled())
{
player.sendMessage(user.getDisplayName() + " : " + event.getMessage());
}
}
}
if (user.isAfk())
{
user.setAfk(false);
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
event.setCancelled(true);
}
}
}

View File

@@ -1,81 +1,50 @@
package com.earth2me.essentials;
import com.earth2me.essentials.register.payment.Methods;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
public class EssentialsPluginListener extends ServerListener
public class EssentialsPluginListener implements Listener, IConf
{
private final transient IEssentials ess;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
public EssentialsPluginListener(final IEssentials ess)
{
this.ess = ess;
}
@Override
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(final PluginEnableEvent event)
{
checkPermissions();
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(event.getPlugin()))
ess.getPermissionsHandler().checkPermissions();
ess.getAlternativeCommandsHandler().addPlugin(event.getPlugin());
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager()))
{
LOGGER.log(Level.INFO, "[Essentials] Payment method found (" + ess.getPaymentMethod().getMethod().getName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
ess.getLogger().log(Level.INFO, "Payment method found (" + ess.getPaymentMethod().getMethod().getName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
}
}
@Override
public void onPluginDisable(PluginDisableEvent event)
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(final PluginDisableEvent event)
{
checkPermissions();
ess.getPermissionsHandler().checkPermissions();
ess.getAlternativeCommandsHandler().removePlugin(event.getPlugin());
// Check to see if the plugin thats being disabled is the one we are using
if (ess.getPaymentMethod() != null && ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().checkDisabled(event.getPlugin()))
{
LOGGER.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments.");
ess.getPaymentMethod().reset();
ess.getLogger().log(Level.INFO, "Payment method was disabled. No longer accepting payments.");
}
}
private void checkPermissions()
{
final PluginManager pm = ess.getServer().getPluginManager();
final Plugin permissionsExPlugin = pm.getPlugin("PermissionsEx");
if (permissionsExPlugin == null || !permissionsExPlugin.isEnabled())
{
final Plugin permissionsPlugin = pm.getPlugin("Permissions");
if (permissionsPlugin == null || !permissionsPlugin.isEnabled())
{
if (ess.getSettings().useBukkitPermissions())
{
ess.setPermissionsHandler(new BukkitPermissionsHandler());
}
else
{
ess.setPermissionsHandler(new ConfigPermissionsHandler(ess));
}
}
else
{
if (permissionsPlugin.getDescription().getVersion().charAt(0) == '3')
{
ess.setPermissionsHandler(new Permissions3Handler(permissionsPlugin));
}
else
{
ess.setPermissionsHandler(new Permissions2Handler(permissionsPlugin));
}
}
}
else
{
ess.setPermissionsHandler(new PermissionsExHandler());
}
@Override
public void reloadConfig()
{
ess.getPermissionsHandler().setUseSuperperms(ess.getSettings().useBukkitPermissions());
ess.getPermissionsHandler().checkPermissions();
}
}

View File

@@ -1,79 +1,45 @@
package com.earth2me.essentials;
import java.io.File;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.bukkit.entity.Player;
public class EssentialsTimer implements Runnable, IConf
public class EssentialsTimer implements Runnable
{
private final IEssentials ess;
private final Set<User> allUsers = new HashSet<User>();
EssentialsTimer(IEssentials ess)
private final transient IEssentials ess;
private final transient Set<User> onlineUsers = new HashSet<User>();
EssentialsTimer(final IEssentials ess)
{
this.ess = ess;
File userdir = new File(ess.getDataFolder(), "userdata");
if (!userdir.exists()) {
return;
}
for (String string : userdir.list())
{
if (!string.endsWith(".yml")) {
continue;
}
String name = string.substring(0, string.length()-4);
User u = ess.getUser(new OfflinePlayer(name, ess));
allUsers.add(u);
}
}
@Override
public void run()
{
long currentTime = System.currentTimeMillis();
final long currentTime = System.currentTimeMillis();
for (Player player : ess.getServer().getOnlinePlayers())
{
User u = ess.getUser(player);
allUsers.add(u);
u.setLastActivity(currentTime);
final User user = ess.getUser(player);
onlineUsers.add(user);
user.setLastOnlineActivity(currentTime);
user.checkActivity();
}
for (User user: allUsers) {
if (user.getBanTimeout() > 0 && user.getBanTimeout() < currentTime) {
user.setBanTimeout(0);
ess.getBans().unbanByName(user.getName());
}
if (user.getMuteTimeout() > 0 && user.getMuteTimeout() < currentTime && user.isMuted()) {
user.setMuteTimeout(0);
user.sendMessage(Util.i18n("canTalkAgain"));
user.setMuted(false);
}
if (user.getJailTimeout() > 0 && user.getJailTimeout() < currentTime && user.isJailed()) {
user.setJailTimeout(0);
user.setJailed(false);
user.sendMessage(Util.i18n("haveBeenReleased"));
user.setJail(null);
try
{
user.getTeleport().back();
}
catch (Exception ex)
{
}
}
if (user.getLastActivity() < currentTime && user.getLastActivity() > user.getLastLogout()) {
user.setLastLogout(user.getLastActivity());
}
}
}
public void reloadConfig()
{
for (User user : allUsers)
final Iterator<User> iterator = onlineUsers.iterator();
while (iterator.hasNext())
{
user.reloadConfig();
final User user = iterator.next();
if (user.getLastOnlineActivity() < currentTime && user.getLastOnlineActivity() > user.getLastLogout())
{
user.setLastLogout(user.getLastOnlineActivity());
iterator.remove();
continue;
}
user.checkMuteTimeout(currentTime);
user.checkJailTimeout(currentTime);
}
}
}

View File

@@ -1,68 +0,0 @@
package com.earth2me.essentials;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.logging.Level;
import java.util.logging.Logger;
class EssentialsUpdateTimer implements Runnable
{
private URL url;
private final Essentials ess;
private static final Logger logger = Logger.getLogger("Minecraft");
public EssentialsUpdateTimer(Essentials ess)
{
this.ess = ess;
try
{
url = new URL("http://127.0.0.1:8080/check");
}
catch (MalformedURLException ex)
{
logger.log(Level.SEVERE, "Invalid url!", ex);
}
}
public void run()
{
try
{
StringBuilder sb = new StringBuilder();
sb.append("v=").append(URLEncoder.encode(ess.getDescription().getVersion(),"UTF-8"));
sb.append("&b=").append(URLEncoder.encode(ess.getServer().getVersion(),"UTF-8"));
sb.append("&jv=").append(URLEncoder.encode(System.getProperty("java.version"),"UTF-8"));
sb.append("&l=").append(URLEncoder.encode(Util.getCurrentLocale().toString(),"UTF-8"));
sb.append("&on=").append(URLEncoder.encode(System.getProperty("os.name"),"UTF-8"));
sb.append("&ov=").append(URLEncoder.encode(System.getProperty("os.version"),"UTF-8"));
for (BigInteger bigInteger : ess.getErrors().keySet())
{
sb.append("&e[]=").append(bigInteger.toString(36));
}
URLConnection conn = url.openConnection();
conn.setConnectTimeout(10000);
conn.setDoOutput(true);
conn.connect();
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(sb.toString());
wr.flush();
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String ret = br.readLine();
wr.close();
br.close();
logger.log(Level.INFO, ret);
}
catch (IOException ex)
{
logger.log(Level.SEVERE, "Failed to open connection", ex);
}
}
}

View File

@@ -1,13 +1,17 @@
package com.earth2me.essentials;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.List;
import com.earth2me.essentials.craftbukkit.FakeWorld;
import com.earth2me.essentials.settings.Spawns;
import com.earth2me.essentials.storage.YamlStorageWriter;
import static com.earth2me.essentials.I18n._;
import java.io.*;
import java.math.BigInteger;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
@@ -16,63 +20,114 @@ import org.bukkit.inventory.ItemStack;
public class EssentialsUpgrade
{
private static boolean alreadyRun = false;
private final static Logger logger = Logger.getLogger("Minecraft");
private final IEssentials ess;
private final static Logger LOGGER = Logger.getLogger("Minecraft");
private final transient IEssentials ess;
private final transient EssentialsConf doneFile;
EssentialsUpgrade(String version, IEssentials essentials)
EssentialsUpgrade(final IEssentials essentials)
{
ess = essentials;
if (alreadyRun)
if (!ess.getDataFolder().exists())
{
return;
ess.getDataFolder().mkdirs();
}
alreadyRun = true;
doneFile = new EssentialsConf(new File(ess.getDataFolder(), "upgrades-done.yml"));
doneFile.load();
}
private void moveWorthValuesToWorthYml()
{
if (doneFile.getBoolean("moveWorthValuesToWorthYml", false))
{
return;
}
try
{
File configFile = new File(ess.getDataFolder(), "config.yml");
final File configFile = new File(ess.getDataFolder(), "config.yml");
if (!configFile.exists())
{
return;
}
EssentialsConf conf = new EssentialsConf(configFile);
final EssentialsConf conf = new EssentialsConf(configFile);
conf.load();
Worth w = new Worth(ess.getDataFolder());
final Worth worth = new Worth(ess.getDataFolder());
boolean found = false;
for (Material mat : Material.values())
{
int id = mat.getId();
double value = conf.getDouble("worth-" + id, Double.NaN);
final int id = mat.getId();
final double value = conf.getDouble("worth-" + id, Double.NaN);
if (!Double.isNaN(value))
{
found = true;
w.setPrice(new ItemStack(mat, 1, (short)0, (byte)0), value);
worth.setPrice(new ItemStack(mat, 1, (short)0, (byte)0), value);
}
}
if (found)
{
removeLinesFromConfig(configFile, "\\s*#?\\s*worth-[0-9]+.*", "# Worth values have been moved to worth.yml");
}
doneFile.setProperty("moveWorthValuesToWorthYml", true);
doneFile.save();
}
catch (Throwable e)
{
logger.log(Level.SEVERE, Util.i18n("upgradingFilesError"), e);
LOGGER.log(Level.SEVERE, _("upgradingFilesError"), e);
}
}
private void moveMotdRulesToFile(String name)
{
if (doneFile.getBoolean("move" + name + "ToFile", false))
{
return;
}
try
{
final File file = new File(ess.getDataFolder(), name + ".txt");
if (file.exists())
{
return;
}
final File configFile = new File(ess.getDataFolder(), "config.yml");
if (!configFile.exists())
{
return;
}
final EssentialsConf conf = new EssentialsConf(configFile);
conf.load();
List<String> lines = conf.getStringList(name, null);
if (lines != null && !lines.isEmpty())
{
if (!file.createNewFile())
{
throw new IOException("Failed to create file " + file);
}
PrintWriter writer = new PrintWriter(file);
for (String line : lines)
{
writer.println(line);
}
writer.close();
}
doneFile.setProperty("move" + name + "ToFile", true);
doneFile.save();
}
catch (Throwable e)
{
LOGGER.log(Level.SEVERE, _("upgradingFilesError"), e);
}
}
private void removeLinesFromConfig(File file, String regex, String info) throws Exception
{
boolean needUpdate = false;
BufferedReader br = new BufferedReader(new FileReader(file));
File tempFile = File.createTempFile("essentialsupgrade", ".tmp.yml", ess.getDataFolder());
BufferedWriter bw = new BufferedWriter(new FileWriter(tempFile));
final BufferedReader bReader = new BufferedReader(new FileReader(file));
final File tempFile = File.createTempFile("essentialsupgrade", ".tmp.yml", ess.getDataFolder());
final BufferedWriter bWriter = new BufferedWriter(new FileWriter(tempFile));
do
{
String line = br.readLine();
final String line = bReader.readLine();
if (line == null)
{
break;
@@ -81,8 +136,8 @@ public class EssentialsUpgrade
{
if (!needUpdate && info != null)
{
bw.write(info, 0, info.length());
bw.newLine();
bWriter.write(info, 0, info.length());
bWriter.newLine();
}
needUpdate = true;
}
@@ -90,45 +145,51 @@ public class EssentialsUpgrade
{
if (line.endsWith("\r\n"))
{
bw.write(line, 0, line.length() - 2);
bWriter.write(line, 0, line.length() - 2);
}
else if (line.endsWith("\r") || line.endsWith("\n"))
{
bw.write(line, 0, line.length() - 1);
bWriter.write(line, 0, line.length() - 1);
}
else
{
bw.write(line, 0, line.length());
bWriter.write(line, 0, line.length());
}
bw.newLine();
bWriter.newLine();
}
}
while (true);
br.close();
bw.close();
bReader.close();
bWriter.close();
if (needUpdate)
{
if (!file.renameTo(new File(file.getParentFile(), file.getName().concat("." + System.currentTimeMillis() + ".upgradebackup"))))
{
throw new Exception(Util.i18n("configFileMoveError"));
throw new Exception(_("configFileMoveError"));
}
if (!tempFile.renameTo(file))
{
throw new Exception(Util.i18n("configFileRenameError"));
throw new Exception(_("configFileRenameError"));
}
} else {
}
else
{
tempFile.delete();
}
}
private void updateUsersToNewDefaultHome()
{
File userdataFolder = new File(ess.getDataFolder(), "userdata");
if (doneFile.getBoolean("updateUsersToNewDefaultHome", false))
{
return;
}
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
if (!userdataFolder.exists() || !userdataFolder.isDirectory())
{
return;
}
File[] userFiles = userdataFolder.listFiles();
final File[] userFiles = userdataFolder.listFiles();
for (File file : userFiles)
{
@@ -136,15 +197,16 @@ public class EssentialsUpgrade
{
continue;
}
EssentialsConf config = new EssentialsConf(file);
final EssentialsConf config = new EssentialsConf(file);
try
{
config.load();
if (config.hasProperty("home") && !config.hasProperty("home.default"))
{
@SuppressWarnings("unchecked")
List<Object> vals = (List<Object>)config.getProperty("home");
if (vals == null) {
final List<Object> vals = (List<Object>)config.getProperty("home");
if (vals == null)
{
continue;
}
World world = ess.getServer().getWorlds().get(0);
@@ -154,7 +216,7 @@ public class EssentialsUpgrade
}
if (world != null)
{
Location loc = new Location(
final Location loc = new Location(
world,
((Number)vals.get(0)).doubleValue(),
((Number)vals.get(1)).doubleValue(),
@@ -162,7 +224,7 @@ public class EssentialsUpgrade
((Number)vals.get(3)).floatValue(),
((Number)vals.get(4)).floatValue());
String worldName = world.getName().toLowerCase();
final String worldName = world.getName().toLowerCase(Locale.ENGLISH);
if (worldName != null && !worldName.isEmpty())
{
config.removeProperty("home");
@@ -175,30 +237,159 @@ public class EssentialsUpgrade
}
catch (RuntimeException ex)
{
logger.log(Level.INFO, "File: "+file.toString());
LOGGER.log(Level.INFO, "File: " + file.toString());
throw ex;
}
}
doneFile.setProperty("updateUsersToNewDefaultHome", true);
doneFile.save();
}
private void updateUsersPowerToolsFormat()
{
if (doneFile.getBoolean("updateUsersPowerToolsFormat", false))
{
return;
}
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
if (!userdataFolder.exists() || !userdataFolder.isDirectory())
{
return;
}
final File[] userFiles = userdataFolder.listFiles();
for (File file : userFiles)
{
if (!file.isFile() || !file.getName().endsWith(".yml"))
{
continue;
}
final EssentialsConf config = new EssentialsConf(file);
try
{
config.load();
if (config.hasProperty("powertools"))
{
@SuppressWarnings("unchecked")
final Map<Integer, Object> powertools = (Map<Integer, Object>)config.getProperty("powertools");
if (powertools == null)
{
continue;
}
for (Map.Entry<Integer, 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);
}
}
config.save();
}
}
catch (RuntimeException ex)
{
LOGGER.log(Level.INFO, "File: " + file.toString());
throw ex;
}
}
doneFile.setProperty("updateUsersPowerToolsFormat", true);
doneFile.save();
}
private void updateUsersHomesFormat()
{
if (doneFile.getBoolean("updateUsersHomesFormat", false))
{
return;
}
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
if (!userdataFolder.exists() || !userdataFolder.isDirectory())
{
return;
}
final File[] userFiles = userdataFolder.listFiles();
for (File file : userFiles)
{
if (!file.isFile() || !file.getName().endsWith(".yml"))
{
continue;
}
final EssentialsConf config = new EssentialsConf(file);
try
{
config.load();
if (config.hasProperty("home") && config.hasProperty("home.default"))
{
@SuppressWarnings("unchecked")
final String defworld = (String)config.getProperty("home.default");
final Location defloc = getFakeLocation(config, "home.worlds." + defworld);
if (defloc != null)
{
config.setProperty("homes.home", defloc);
}
List<String> worlds = config.getKeys("home.worlds");
Location loc;
String worldName;
if (worlds == null)
{
continue;
}
for (String world : worlds)
{
if (defworld.equalsIgnoreCase(world))
{
continue;
}
loc = getFakeLocation(config, "home.worlds." + world);
if (loc == null)
{
continue;
}
worldName = loc.getWorld().getName().toLowerCase(Locale.ENGLISH);
if (worldName != null && !worldName.isEmpty())
{
config.setProperty("homes." + worldName, loc);
}
}
config.removeProperty("home");
config.save();
}
}
catch (RuntimeException ex)
{
LOGGER.log(Level.INFO, "File: " + file.toString());
throw ex;
}
}
doneFile.setProperty("updateUsersHomesFormat", true);
doneFile.save();
}
private void moveUsersDataToUserdataFolder()
{
File usersFile = new File(ess.getDataFolder(), "users.yml");
final File usersFile = new File(ess.getDataFolder(), "users.yml");
if (!usersFile.exists())
{
return;
}
EssentialsConf usersConfig = new EssentialsConf(usersFile);
final EssentialsConf usersConfig = new EssentialsConf(usersFile);
usersConfig.load();
for (String username : usersConfig.getKeys(null))
{
User user = new User(new OfflinePlayer(username, ess), ess);
String nickname = usersConfig.getString(username + ".nickname");
final User user = new User(new OfflinePlayer(username, ess), ess);
final String nickname = usersConfig.getString(username + ".nickname");
if (nickname != null && !nickname.isEmpty() && !nickname.equals(username))
{
user.setNickname(nickname);
}
List<String> mails = usersConfig.getStringList(username + ".mail", null);
final List<String> mails = usersConfig.getStringList(username + ".mail", null);
if (mails != null && !mails.isEmpty())
{
user.setMails(mails);
@@ -206,8 +397,9 @@ public class EssentialsUpgrade
if (!user.hasHome())
{
@SuppressWarnings("unchecked")
List<Object> vals = (List<Object>)usersConfig.getProperty(username + ".home");
if (vals != null) {
final List<Object> vals = (List<Object>)usersConfig.getProperty(username + ".home");
if (vals != null)
{
World world = ess.getServer().getWorlds().get(0);
if (vals.size() > 5)
{
@@ -215,12 +407,12 @@ public class EssentialsUpgrade
}
if (world != null)
{
user.setHome(new Location(world,
((Number)vals.get(0)).doubleValue(),
((Number)vals.get(1)).doubleValue(),
((Number)vals.get(2)).doubleValue(),
((Number)vals.get(3)).floatValue(),
((Number)vals.get(4)).floatValue()), true);
user.setHome("home", new Location(world,
((Number)vals.get(0)).doubleValue(),
((Number)vals.get(1)).doubleValue(),
((Number)vals.get(2)).doubleValue(),
((Number)vals.get(3)).floatValue(),
((Number)vals.get(4)).floatValue()));
}
}
}
@@ -230,40 +422,56 @@ public class EssentialsUpgrade
private void convertWarps()
{
File warpsFolder = new File(ess.getDataFolder(), "warps");
final File warpsFolder = new File(ess.getDataFolder(), "warps");
if (!warpsFolder.exists())
{
warpsFolder.mkdirs();
}
File[] listOfFiles = warpsFolder.listFiles();
final File[] listOfFiles = warpsFolder.listFiles();
if (listOfFiles.length >= 1)
{
for (int i = 0; i < listOfFiles.length; i++)
{
String filename = listOfFiles[i].getName();
final String filename = listOfFiles[i].getName();
if (listOfFiles[i].isFile() && filename.endsWith(".dat"))
{
try
{
BufferedReader rx = new BufferedReader(new FileReader(listOfFiles[i]));
final BufferedReader rx = new BufferedReader(new FileReader(listOfFiles[i]));
double x, y, z;
float yaw, pitch;
String worldName;
try
{
if (!rx.ready()) continue;
if (!rx.ready())
{
continue;
}
x = Double.parseDouble(rx.readLine().trim());
if (!rx.ready()) continue;
if (!rx.ready())
{
continue;
}
y = Double.parseDouble(rx.readLine().trim());
if (!rx.ready()) continue;
if (!rx.ready())
{
continue;
}
z = Double.parseDouble(rx.readLine().trim());
if (!rx.ready()) continue;
if (!rx.ready())
{
continue;
}
yaw = Float.parseFloat(rx.readLine().trim());
if (!rx.ready()) continue;
if (!rx.ready())
{
continue;
}
pitch = Float.parseFloat(rx.readLine().trim());
worldName = rx.readLine();
}
finally {
finally
{
rx.close();
}
World w = null;
@@ -285,61 +493,61 @@ public class EssentialsUpgrade
w = w1;
}
}
Location loc = new Location(w, x, y, z, yaw, pitch);
final Location loc = new Location(w, x, y, z, yaw, pitch);
ess.getWarps().setWarp(filename.substring(0, filename.length() - 4), loc);
if (!listOfFiles[i].renameTo(new File(warpsFolder, filename + ".old")))
{
throw new Exception(Util.format("fileRenameError", filename));
throw new Exception(_("fileRenameError", filename));
}
}
catch (Exception ex)
{
logger.log(Level.SEVERE, null, ex);
LOGGER.log(Level.SEVERE, null, ex);
}
}
}
}
File warpFile = new File(ess.getDataFolder(), "warps.txt");
final File warpFile = new File(ess.getDataFolder(), "warps.txt");
if (warpFile.exists())
{
try
{
BufferedReader rx = new BufferedReader(new FileReader(warpFile));
try
final BufferedReader rx = new BufferedReader(new FileReader(warpFile));
try
{
for (String[] parts = new String[0]; rx.ready(); parts = rx.readLine().split(":"))
{
if (parts.length < 6)
for (String[] parts = new String[0]; rx.ready(); parts = rx.readLine().split(":"))
{
continue;
}
String name = parts[0];
double x = Double.parseDouble(parts[1].trim());
double y = Double.parseDouble(parts[2].trim());
double z = Double.parseDouble(parts[3].trim());
float yaw = Float.parseFloat(parts[4].trim());
float pitch = Float.parseFloat(parts[5].trim());
if (name.isEmpty())
{
continue;
}
World w = null;
for (World world : ess.getServer().getWorlds())
{
if (world.getEnvironment() != World.Environment.NETHER)
if (parts.length < 6)
{
w = world;
break;
continue;
}
final String name = parts[0];
final double x = Double.parseDouble(parts[1].trim());
final double y = Double.parseDouble(parts[2].trim());
final double z = Double.parseDouble(parts[3].trim());
final float yaw = Float.parseFloat(parts[4].trim());
final float pitch = Float.parseFloat(parts[5].trim());
if (name.isEmpty())
{
continue;
}
World w = null;
for (World world : ess.getServer().getWorlds())
{
if (world.getEnvironment() != World.Environment.NETHER)
{
w = world;
break;
}
}
final Location loc = new Location(w, x, y, z, yaw, pitch);
ess.getWarps().setWarp(name, loc);
if (!warpFile.renameTo(new File(ess.getDataFolder(), "warps.txt.old")))
{
throw new Exception(_("fileRenameError", "warps.txt"));
}
}
Location loc = new Location(w, x, y, z, yaw, pitch);
ess.getWarps().setWarp(name, loc);
if (!warpFile.renameTo(new File(ess.getDataFolder(), "warps.txt.old")))
{
throw new Exception(Util.format("fileRenameError", "warps.txt"));
}
}
}
finally
{
@@ -348,52 +556,60 @@ public class EssentialsUpgrade
}
catch (Exception ex)
{
logger.log(Level.SEVERE, null, ex);
LOGGER.log(Level.SEVERE, null, ex);
}
}
}
private void sanitizeAllUserFilenames()
{
File usersFolder = new File(ess.getDataFolder(), "userdata");
if (doneFile.getBoolean("sanitizeAllUserFilenames", false))
{
return;
}
final File usersFolder = new File(ess.getDataFolder(), "userdata");
if (!usersFolder.exists())
{
return;
}
File[] listOfFiles = usersFolder.listFiles();
final File[] listOfFiles = usersFolder.listFiles();
for (int i = 0; i < listOfFiles.length; i++)
{
String filename = listOfFiles[i].getName();
final String filename = listOfFiles[i].getName();
if (!listOfFiles[i].isFile() || !filename.endsWith(".yml"))
{
continue;
}
String sanitizedFilename = Util.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml";
final String sanitizedFilename = Util.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml";
if (sanitizedFilename.equals(filename))
{
continue;
}
File tmpFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename + ".tmp");
File newFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename);
if (!listOfFiles[i].renameTo(tmpFile)) {
logger.log(Level.WARNING, Util.format("userdataMoveError", filename, sanitizedFilename));
final File tmpFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename + ".tmp");
final File newFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename);
if (!listOfFiles[i].renameTo(tmpFile))
{
LOGGER.log(Level.WARNING, _("userdataMoveError", filename, sanitizedFilename));
continue;
}
if (newFile.exists())
{
logger.log(Level.WARNING, Util.format("duplicatedUserdata", filename, sanitizedFilename));
LOGGER.log(Level.WARNING, _("duplicatedUserdata", filename, sanitizedFilename));
continue;
}
if (!tmpFile.renameTo(newFile)) {
logger.log(Level.WARNING, Util.format("userdataMoveBackError", sanitizedFilename, sanitizedFilename));
if (!tmpFile.renameTo(newFile))
{
LOGGER.log(Level.WARNING, _("userdataMoveBackError", sanitizedFilename, sanitizedFilename));
}
}
doneFile.setProperty("sanitizeAllUserFilenames", true);
doneFile.save();
}
private World getFakeWorld(String name)
private World getFakeWorld(final String name)
{
File bukkitDirectory = ess.getDataFolder().getParentFile().getParentFile();
File worldDirectory = new File(bukkitDirectory, name);
final File bukkitDirectory = ess.getDataFolder().getParentFile().getParentFile();
final File worldDirectory = new File(bukkitDirectory, name);
if (worldDirectory.exists() && worldDirectory.isDirectory())
{
return new FakeWorld(worldDirectory.getName(), World.Environment.NORMAL);
@@ -401,6 +617,167 @@ public class EssentialsUpgrade
return null;
}
public Location getFakeLocation(EssentialsConf config, String path)
{
String worldName = config.getString((path != null ? path + "." : "") + "world");
if (worldName == null || worldName.isEmpty())
{
return null;
}
World world = getFakeWorld(worldName);
if (world == null)
{
return null;
}
return new Location(world,
config.getDouble((path != null ? path + "." : "") + "x", 0),
config.getDouble((path != null ? path + "." : "") + "y", 0),
config.getDouble((path != null ? path + "." : "") + "z", 0),
(float)config.getDouble((path != null ? path + "." : "") + "yaw", 0),
(float)config.getDouble((path != null ? path + "." : "") + "pitch", 0));
}
private void deleteOldItemsCsv()
{
if (doneFile.getBoolean("deleteOldItemsCsv", false))
{
return;
}
final File file = new File(ess.getDataFolder(), "items.csv");
if (file.exists())
{
try
{
final Set<BigInteger> oldconfigs = new HashSet<BigInteger>();
oldconfigs.add(new BigInteger("66ec40b09ac167079f558d1099e39f10", 16)); // sep 1
oldconfigs.add(new BigInteger("34284de1ead43b0bee2aae85e75c041d", 16)); // crlf
oldconfigs.add(new BigInteger("c33bc9b8ee003861611bbc2f48eb6f4f", 16)); // jul 24
oldconfigs.add(new BigInteger("6ff17925430735129fc2a02f830c1daa", 16)); // crlf
MessageDigest digest = ManagedFile.getDigest();
final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
final DigestInputStream dis = new DigestInputStream(bis, digest);
final byte[] buffer = new byte[1024];
try
{
while (dis.read(buffer) != -1)
{
}
}
finally
{
dis.close();
}
BigInteger hash = new BigInteger(1, digest.digest());
if (oldconfigs.contains(hash) && !file.delete())
{
throw new IOException("Could not delete file " + file.toString());
}
doneFile.setProperty("deleteOldItemsCsv", true);
doneFile.save();
}
catch (IOException ex)
{
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
}
}
}
private void updateSpawnsToNewSpawnsConfig()
{
if (doneFile.getBoolean("updateSpawnsToNewSpawnsConfig", false))
{
return;
}
final File configFile = new File(ess.getDataFolder(), "spawn.yml");
if (configFile.exists())
{
final EssentialsConf config = new EssentialsConf(configFile);
try
{
config.load();
if (!config.hasProperty("spawns"))
{
final Spawns spawns = new Spawns();
List<String> keys = config.getKeys();
for (String group : keys)
{
Location loc = getFakeLocation(config, group);
spawns.getSpawns().put(group.toLowerCase(Locale.ENGLISH), loc);
}
if (!configFile.renameTo(new File(ess.getDataFolder(), "spawn.yml.old")))
{
throw new Exception(_("fileRenameError", "spawn.yml"));
}
PrintWriter writer = new PrintWriter(configFile);
try
{
new YamlStorageWriter(writer).save(spawns);
}
finally
{
writer.close();
}
}
}
catch (Exception ex)
{
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
}
}
doneFile.setProperty("updateSpawnsToNewSpawnsConfig", true);
doneFile.save();
}
private void updateJailsToNewJailsConfig()
{
if (doneFile.getBoolean("updateJailsToNewJailsConfig", false))
{
return;
}
final File configFile = new File(ess.getDataFolder(), "jail.yml");
if (configFile.exists())
{
final EssentialsConf config = new EssentialsConf(configFile);
try
{
config.load();
if (!config.hasProperty("jails"))
{
final com.earth2me.essentials.settings.Jails jails = new com.earth2me.essentials.settings.Jails();
List<String> keys = config.getKeys();
for (String jailName : keys)
{
Location loc = getFakeLocation(config, jailName);
jails.getJails().put(jailName.toLowerCase(Locale.ENGLISH), loc);
}
if (!configFile.renameTo(new File(ess.getDataFolder(), "jail.yml.old")))
{
throw new Exception(_("fileRenameError", "jail.yml"));
}
PrintWriter writer = new PrintWriter(configFile);
try
{
new YamlStorageWriter(writer).save(jails);
}
finally
{
writer.close();
}
}
}
catch (Exception ex)
{
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
}
}
doneFile.setProperty("updateJailsToNewJailsConfig", true);
doneFile.save();
}
public void beforeSettings()
{
if (!ess.getDataFolder().exists())
@@ -408,6 +785,8 @@ public class EssentialsUpgrade
ess.getDataFolder().mkdirs();
}
moveWorthValuesToWorthYml();
moveMotdRulesToFile("motd");
moveMotdRulesToFile("rules");
}
public void afterSettings()
@@ -416,5 +795,10 @@ public class EssentialsUpgrade
updateUsersToNewDefaultHome();
moveUsersDataToUserdataFolder();
convertWarps();
updateUsersPowerToolsFormat();
updateUsersHomesFormat();
deleteOldItemsCsv();
updateSpawnsToNewSpawnsConfig();
updateJailsToNewJailsConfig();
}
}

View File

@@ -0,0 +1,89 @@
package com.earth2me.essentials;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class ExecuteTimer
{
private final transient List<ExecuteRecord> times;
private final transient DecimalFormat decimalFormat = new DecimalFormat("#0.000", DecimalFormatSymbols.getInstance(Locale.US));
public ExecuteTimer()
{
times = new ArrayList<ExecuteRecord>();
}
public void start()
{
times.clear();
mark("start");
}
public void mark(final String label)
{
if (!times.isEmpty() || "start".equals(label))
{
times.add(new ExecuteRecord(label, System.nanoTime()));
}
}
public String end()
{
final StringBuilder output = new StringBuilder();
output.append("execution time: ");
String mark;
long time0 = 0;
long time1 = 0;
long time2 = 0;
double duration;
for (ExecuteRecord pair : times)
{
mark = (String)pair.getMark();
time2 = (Long)pair.getTime();
if (time1 > 0)
{
duration = (time2 - time1)/1000000.0;
output.append(mark).append(": ").append(decimalFormat.format(duration)).append("ms - ");
}
else
{
time0 = time2;
}
time1 = time2;
}
duration = (time1 - time0)/1000000.0;
output.append("Total: ").append(decimalFormat.format(duration)).append("ms");
times.clear();
return output.toString();
}
static private class ExecuteRecord
{
private final String mark;
private final long time;
public ExecuteRecord(final String mark, final long time)
{
this.mark = mark;
this.time = time;
}
public String getMark()
{
return mark;
}
public long getTime()
{
return time;
}
}
}

View File

@@ -0,0 +1,175 @@
package com.earth2me.essentials;
import com.earth2me.essentials.api.II18n;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.MessageFormat;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
public class I18n implements II18n
{
private static I18n instance;
private static final String MESSAGES = "messages";
private final transient Locale defaultLocale = Locale.getDefault();
private transient Locale currentLocale = defaultLocale;
private transient ResourceBundle customBundle;
private transient ResourceBundle localeBundle;
private final transient ResourceBundle defaultBundle;
private final transient Map<String, MessageFormat> messageFormatCache = new HashMap<String, MessageFormat>();
private final transient IEssentials ess;
public I18n(final IEssentials ess)
{
this.ess = ess;
customBundle = ResourceBundle.getBundle(MESSAGES, defaultLocale, new FileResClassLoader(I18n.class.getClassLoader(), ess));
localeBundle = ResourceBundle.getBundle(MESSAGES, defaultLocale);
defaultBundle = ResourceBundle.getBundle(MESSAGES, Locale.ENGLISH);
}
public void onEnable()
{
instance = this;
}
public void onDisable()
{
instance = null;
}
public Locale getCurrentLocale()
{
return currentLocale;
}
public String translate(final String string)
{
try
{
try
{
return customBundle.getString(string);
}
catch (MissingResourceException ex)
{
return localeBundle.getString(string);
}
}
catch (MissingResourceException ex)
{
Logger.getLogger("Minecraft").log(Level.WARNING, String.format("Missing translation key \"%s\" in translation file %s", ex.getKey(), localeBundle.getLocale().toString()), ex);
return defaultBundle.getString(string);
}
}
public static String _(final String string, final Object... objects)
{
if (instance == null) {
return "";
}
if (objects.length == 0)
{
return instance.translate(string);
}
else
{
return instance.format(string, objects);
}
}
public String format(final String string, final Object... objects)
{
final String format = translate(string);
MessageFormat messageFormat = messageFormatCache.get(format);
if (messageFormat == null)
{
messageFormat = new MessageFormat(format);
messageFormatCache.put(format, messageFormat);
}
return messageFormat.format(objects);
}
public void updateLocale(final String loc)
{
if (loc == null || loc.isEmpty())
{
return;
}
final String[] parts = loc.split("[_\\.]");
if (parts.length == 1)
{
currentLocale = new Locale(parts[0]);
}
if (parts.length == 2)
{
currentLocale = new Locale(parts[0], parts[1]);
}
if (parts.length == 3)
{
currentLocale = new Locale(parts[0], parts[1], parts[2]);
}
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);
}
public static String capitalCase(final String input)
{
return input == null || input.length() == 0
? input
: input.toUpperCase(Locale.ENGLISH).charAt(0)
+ input.toLowerCase(Locale.ENGLISH).substring(1);
}
private static class FileResClassLoader extends ClassLoader
{
private final transient File dataFolder;
public FileResClassLoader(final ClassLoader classLoader, final IEssentials ess)
{
super(classLoader);
this.dataFolder = ess.getDataFolder();
}
@Override
public URL getResource(final String string)
{
final File file = new File(dataFolder, string);
if (file.exists())
{
try
{
return file.toURI().toURL();
}
catch (MalformedURLException ex)
{
}
}
return super.getResource(string);
}
@Override
public InputStream getResourceAsStream(final String string)
{
final File file = new File(dataFolder, string);
if (file.exists())
{
try
{
return new FileInputStream(file);
}
catch (FileNotFoundException ex)
{
}
}
return super.getResourceAsStream(string);
}
}
}

View File

@@ -1,5 +1,9 @@
package com.earth2me.essentials;
/**
* @deprecated New interface will be IReload in api package
*/
@Deprecated
public interface IConf {
public void reloadConfig();
}

View File

@@ -1,39 +1,41 @@
package com.earth2me.essentials;
import com.earth2me.essentials.api.IJails;
import com.earth2me.essentials.perm.PermissionsHandler;
import com.earth2me.essentials.register.payment.Methods;
import java.util.Map;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitScheduler;
/**
* @deprecated This will be moved to the api package soon
*/
@Deprecated
public interface IEssentials extends Plugin
{
void addReloadListener(IConf listener);
void reload();
boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix);
boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix, IEssentialsModule module);
User getUser(Object base);
I18n getI18n();
User getOfflineUser(String name);
World getWorld(String name);
int broadcastMessage(String name, String message);
int broadcastMessage(IUser sender, String message);
ISettings getSettings();
CraftScheduler getScheduler();
BukkitScheduler getScheduler();
String[] getMotd(CommandSender sender, String def);
String[] getLines(CommandSender sender, String node, String def);
Jail getJail();
IJails getJails();
Warps getWarps();
@@ -41,8 +43,6 @@ public interface IEssentials extends Plugin
Backup getBackup();
Spawn getSpawn();
Methods getPaymentMethod();
int scheduleAsyncDelayedTask(Runnable run);
@@ -53,17 +53,15 @@ public interface IEssentials extends Plugin
int scheduleSyncRepeatingTask(final Runnable run, long delay, long period);
BanWorkaround getBans();
TNTExplodeListener getTNTListener();
IPermissionsHandler getPermissionsHandler();
PermissionsHandler getPermissionsHandler();
void setPermissionsHandler(IPermissionsHandler handler);
AlternativeCommandsHandler getAlternativeCommandsHandler();
void showError(final CommandSender sender, final Throwable exception, final String commandLabel);
Map<String, User> getAllUsers();
ItemDb getItemDb();
UserMap getUserMap();
}

View File

@@ -0,0 +1,6 @@
package com.earth2me.essentials;
public interface IEssentialsModule
{
}

View File

@@ -1,14 +1,17 @@
package com.earth2me.essentials;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.signs.EssentialsSign;
import java.text.MessageFormat;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.event.EventPriority;
public interface ISettings extends IConf
{
boolean areSignsDisabled();
String format(String format, IUser user);
@@ -21,9 +24,7 @@ public interface ISettings extends IConf
long getBackupInterval();
boolean getBedSetsHome();
String getChatFormat(String group);
MessageFormat getChatFormat(String group);
int getChatRadius();
@@ -33,10 +34,10 @@ public interface ISettings extends IConf
String getCurrencySymbol();
int getOversizedStackSize();
int getDefaultStackSize();
boolean getGenerateExitPortals();
double getHealCooldown();
Object getKit(String name);
@@ -45,12 +46,6 @@ public interface ISettings extends IConf
String getLocale();
String getNetherName();
boolean getNetherPortalsEnabled();
double getNetherRatio();
String getNewbieSpawn();
String getNicknamePrefix();
@@ -69,10 +64,14 @@ public interface ISettings extends IConf
String getProtectString(final String configName);
boolean getReclaimSetting();
boolean getRespawnAtHome();
List getMultipleHomes();
int getHomeLimit(String set);
int getHomeLimit(User user);
boolean getSortListByGroups();
int getSpawnMobLimit();
@@ -99,37 +98,63 @@ public interface ISettings extends IConf
boolean isEcoDisabled();
boolean isNetherEnabled();
boolean isTradeInStacks(int id);
List<Integer> itemSpawnBlacklist();
List<EssentialsSign> enabledSigns();
boolean permissionBasedItemSpawn();
void reloadConfig();
boolean showNonEssCommandsInHelp();
boolean spawnIfNoHome();
boolean use1to1RatioInNether();
boolean warnOnBuildDisallow();
boolean warnOnSmite();
double getMaxMoney();
boolean isEcoLogEnabled();
boolean removeGodOnDisconnect();
boolean changeDisplayName();
boolean isPlayerCommand(String string);
public boolean useBukkitPermissions();
boolean useBukkitPermissions();
public boolean addPrefixSuffix();
boolean addPrefixSuffix();
boolean disablePrefix();
boolean disableSuffix();
long getAutoAfk();
long getAutoAfkKick();
boolean getFreezeAfkPlayers();
boolean areDeathMessagesEnabled();
public void setDebug(boolean debug);
Set<String> getNoGodWorlds();
boolean getUpdateBedAtDaytime();
boolean getRepairEnchanted();
boolean getIsWorldTeleportPermissions();
boolean registerBackInListener();
boolean getDisableItemPickupWhileAfk();
EventPriority getRespawnPriority();
long getTpaAcceptCancellation();
}

View File

@@ -7,22 +7,18 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.PlayerInventory;
public interface IUser
/**
* @deprecated This will be moved to the api package soon
*/
@Deprecated
public interface IUser extends Player
{
int getHealth();
Location getLocation();
boolean isOnline();
void sendMessage(String string);
long getLastTeleportTimestamp();
boolean isAuthorized(String node);
boolean isAuthorized(IEssentialsCommand cmd);
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
void setLastTeleportTimestamp(long time);
@@ -37,19 +33,17 @@ public interface IUser
void giveMoney(double value);
PlayerInventory getInventory();
void updateInventory();
String getGroup();
void setLastLocation();
Location getHome(Location location);
Location getHome(String name) throws Exception;
String getName();
Location getHome(Location loc) throws Exception;
InetSocketAddress getAddress();
boolean isHidden();
String getDisplayName();
Teleport getTeleport();
void setJail(String jail);
}

View File

@@ -1,130 +1,65 @@
package com.earth2me.essentials;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.earth2me.essentials.api.IItemDb;
import static com.earth2me.essentials.I18n._;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public class ItemDb implements IConf
public class ItemDb implements IConf, IItemDb
{
private final transient IEssentials ess;
public ItemDb(IEssentials ess)
public ItemDb(final IEssentials ess)
{
this.ess = ess;
file = new ManagedFile("items.csv", ess);
}
private final static Logger LOGGER = Logger.getLogger("Minecraft");
private final transient Map<String, Integer> items = new HashMap<String, Integer>();
private final transient Map<String, Short> durabilities = new HashMap<String, Short>();
private final transient ManagedFile file;
@Override
public void reloadConfig()
{
final File file = new File(ess.getDataFolder(), "items.csv");
final List<String> lines = file.getLines();
if (!file.exists())
if (lines.isEmpty())
{
final InputStream res = ItemDb.class.getResourceAsStream("/items.csv");
FileWriter tx = null;
try
{
tx = new FileWriter(file);
for (int i = 0; (i = res.read()) > 0;)
{
tx.write(i);
}
tx.flush();
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, Util.i18n("itemsCsvNotLoaded"), ex);
return;
}
finally
{
try
{
res.close();
}
catch (Exception ex)
{
}
try
{
if (tx != null)
{
tx.close();
}
}
catch (Exception ex)
{
}
}
return;
}
BufferedReader rx = null;
try
{
rx = new BufferedReader(new FileReader(file));
durabilities.clear();
items.clear();
durabilities.clear();
items.clear();
for (int i = 0; rx.ready(); i++)
for (String line : lines)
{
line = line.trim().toLowerCase(Locale.ENGLISH);
if (line.length() > 0 && line.charAt(0) == '#')
{
try
{
final String line = rx.readLine().trim().toLowerCase();
if (line.startsWith("#"))
{
continue;
}
final String[] parts = line.split("[^a-z0-9]");
if (parts.length < 2)
{
continue;
}
final int numeric = Integer.parseInt(parts[1]);
durabilities.put(parts[0].toLowerCase(), parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0);
items.put(parts[0].toLowerCase(), numeric);
}
catch (Exception ex)
{
LOGGER.warning(Util.format("parseError", "items.csv", i));
}
continue;
}
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, Util.i18n("itemsCsvNotLoaded"), ex);
}
finally
{
if (rx != null) {
try
{
rx.close();
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
}
final String[] parts = line.split("[^a-z0-9]");
if (parts.length < 2)
{
continue;
}
final int numeric = Integer.parseInt(parts[1]);
durabilities.put(parts[0].toLowerCase(Locale.ENGLISH), parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0);
items.put(parts[0].toLowerCase(Locale.ENGLISH), numeric);
}
}
public ItemStack get(final String id, final int quantity) throws Exception
{
final ItemStack retval = get(id.toLowerCase());
final ItemStack retval = get(id.toLowerCase(Locale.ENGLISH));
retval.setAmount(quantity);
return retval;
}
@@ -145,12 +80,12 @@ public class ItemDb implements IConf
}
else if (id.matches("^[^:+',;.]+[:+',;.]\\d+$"))
{
itemname = id.split("[:+',;.]")[0].toLowerCase();
itemname = id.split("[:+',;.]")[0].toLowerCase(Locale.ENGLISH);
metaData = Short.parseShort(id.split("[:+',;.]")[1]);
}
else
{
itemname = id.toLowerCase();
itemname = id.toLowerCase(Locale.ENGLISH);
}
if (itemname != null)
@@ -163,19 +98,24 @@ public class ItemDb implements IConf
metaData = durabilities.get(itemname);
}
}
else if (Material.getMaterial(itemname) != null)
{
itemid = Material.getMaterial(itemname).getId();
metaData = 0;
}
else
{
throw new Exception(Util.format("unknownItemName", id));
throw new Exception(_("unknownItemName", id));
}
}
final Material mat = Material.getMaterial(itemid);
if (mat == null)
{
throw new Exception(Util.format("unknownItemId", itemid));
throw new Exception(_("unknownItemId", itemid));
}
final ItemStack retval = new ItemStack(mat);
retval.setAmount(ess.getSettings().getDefaultStackSize());
retval.setAmount(mat.getMaxStackSize());
retval.setDurability(metaData);
return retval;
}

View File

@@ -1,97 +0,0 @@
package com.earth2me.essentials;
import java.io.File;
import java.util.List;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent;
public class Jail extends BlockListener implements IConf
{
private static final Logger logger = Logger.getLogger("Minecraft");
private final EssentialsConf config;
private final IEssentials ess;
public Jail(IEssentials ess)
{
this.ess = ess;
config = new EssentialsConf(new File(ess.getDataFolder(), "jail.yml"));
config.load();
}
public void setJail(Location loc, String jailName) throws Exception
{
config.setProperty(jailName.toLowerCase(), loc);
config.save();
}
public Location getJail(String jailName) throws Exception
{
if (config.getProperty(jailName.toLowerCase()) == null)
{
throw new Exception(Util.i18n("jailNotExist"));
}
Location loc = config.getLocation(jailName.toLowerCase(), ess.getServer());
return loc;
}
public void sendToJail(User user, String jail) throws Exception
{
if (!(user.getBase() instanceof OfflinePlayer))
{
user.getTeleport().now(getJail(jail));
}
user.setJail(jail);
}
public void delJail(String jail) throws Exception
{
config.removeProperty(jail.toLowerCase());
config.save();
}
public List<String> getJails() throws Exception
{
return config.getKeys(null);
}
public void reloadConfig()
{
config.load();
}
@Override
public void onBlockBreak(BlockBreakEvent event)
{
User user = ess.getUser(event.getPlayer());
if (user.isJailed())
{
event.setCancelled(true);
}
}
@Override
public void onBlockPlace(BlockPlaceEvent event)
{
User user = ess.getUser(event.getPlayer());
if (user.isJailed())
{
event.setCancelled(true);
}
}
@Override
public void onBlockDamage(BlockDamageEvent event)
{
User user = ess.getUser(event.getPlayer());
if (user.isJailed())
{
event.setCancelled(true);
}
}
}

View File

@@ -1,84 +0,0 @@
package com.earth2me.essentials;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
public class JailPlayerListener extends PlayerListener
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private final IEssentials ess;
public JailPlayerListener(IEssentials parent)
{
this.ess = parent;
}
@Override
public void onPlayerInteract(PlayerInteractEvent event)
{
final User user = ess.getUser(event.getPlayer());
if (user.isJailed())
{
event.setCancelled(true);
}
}
@Override
public void onPlayerRespawn(PlayerRespawnEvent event)
{
final User user = ess.getUser(event.getPlayer());
if (user.isJailed() && user.getJail() != null && !user.getJail().isEmpty())
{
try
{
event.setRespawnLocation(ess.getJail().getJail(user.getJail()));
}
catch (Exception ex)
{
}
}
}
@Override
public void onPlayerTeleport(PlayerTeleportEvent event)
{
final User user = ess.getUser(event.getPlayer());
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
{
return;
}
try
{
event.setTo(ess.getJail().getJail(user.getJail()));
}
catch (Exception ex)
{
LOGGER.log(Level.WARNING, Util.i18n("returnPlayerToJailError"), ex);
}
user.sendMessage(Util.i18n("jailMessage"));
}
@Override
public void onPlayerJoin(final PlayerJoinEvent event)
{
User u = ess.getUser(event.getPlayer());
if (u.isJailed())
{
try
{
ess.getJail().sendToJail(u, u.getJail());
}
catch (Exception ex)
{
LOGGER.log(Level.WARNING, Util.i18n("returnPlayerToJailError"), ex);
}
u.sendMessage(Util.i18n("jailMessage"));
}
}
}

View File

@@ -0,0 +1,254 @@
package com.earth2me.essentials;
import com.earth2me.essentials.api.IJails;
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
import static com.earth2me.essentials.I18n._;
import java.io.File;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.*;
import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
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();
public Jails(final IEssentials ess)
{
super(ess, com.earth2me.essentials.settings.Jails.class);
reloadConfig();
registerListeners();
}
private void registerListeners()
{
final PluginManager pluginManager = ess.getServer().getPluginManager();
final JailBlockListener blockListener = new JailBlockListener();
final JailPlayerListener playerListener = new JailPlayerListener();
pluginManager.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Low, ess);
pluginManager.registerEvent(Type.BLOCK_DAMAGE, blockListener, Priority.Low, ess);
pluginManager.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Low, ess);
pluginManager.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Low, ess);
pluginManager.registerEvent(Type.PLAYER_RESPAWN, playerListener, Priority.High, ess);
pluginManager.registerEvent(Type.PLAYER_TELEPORT, playerListener, Priority.High, ess);
pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.High, ess);
}
@Override
public File getStorageFile()
{
return new File(ess.getDataFolder(), "jail.yml");
}
@Override
public Location getJail(final String jailName) throws Exception
{
acquireReadLock();
try
{
if (getData().getJails() == null || jailName == null
|| !getData().getJails().containsKey(jailName.toLowerCase(Locale.ENGLISH)))
{
throw new Exception(_("jailNotExist"));
}
Location loc = getData().getJails().get(jailName.toLowerCase(Locale.ENGLISH));
if (loc == null || loc.getWorld() == null)
{
throw new Exception(_("jailNotExist"));
}
return loc;
}
finally
{
unlock();
}
}
@Override
public Collection<String> getList() throws Exception
{
acquireReadLock();
try
{
if (getData().getJails() == null)
{
return Collections.emptyList();
}
return new ArrayList<String>(getData().getJails().keySet());
}
finally
{
unlock();
}
}
@Override
public void removeJail(final String jail) throws Exception
{
acquireWriteLock();
try
{
if (getData().getJails() == null)
{
return;
}
getData().getJails().remove(jail.toLowerCase(Locale.ENGLISH));
}
finally
{
unlock();
}
}
@Override
public void sendToJail(final IUser user, final String jail) throws Exception
{
acquireReadLock();
try
{
if (!(user.getBase() instanceof OfflinePlayer))
{
Location loc = getJail(jail);
user.getTeleport().now(loc, false, TeleportCause.COMMAND);
}
user.setJail(jail);
}
finally
{
unlock();
}
}
@Override
public void setJail(final String jailName, final Location loc) throws Exception
{
acquireWriteLock();
try
{
if (getData().getJails() == null)
{
getData().setJails(new HashMap<String, Location>());
}
getData().getJails().put(jailName.toLowerCase(Locale.ENGLISH), loc);
}
finally
{
unlock();
}
}
private class JailBlockListener extends BlockListener
{
@Override
public void onBlockBreak(final BlockBreakEvent event)
{
final User user = ess.getUser(event.getPlayer());
if (user.isJailed())
{
event.setCancelled(true);
}
}
@Override
public void onBlockPlace(final BlockPlaceEvent event)
{
final User user = ess.getUser(event.getPlayer());
if (user.isJailed())
{
event.setCancelled(true);
}
}
@Override
public void onBlockDamage(final BlockDamageEvent event)
{
final User user = ess.getUser(event.getPlayer());
if (user.isJailed())
{
event.setCancelled(true);
}
}
}
private class JailPlayerListener extends PlayerListener
{
@Override
public void onPlayerInteract(final PlayerInteractEvent event)
{
final User user = ess.getUser(event.getPlayer());
if (user.isJailed())
{
event.setCancelled(true);
}
}
@Override
public void onPlayerRespawn(final PlayerRespawnEvent event)
{
final User user = ess.getUser(event.getPlayer());
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
{
return;
}
try
{
event.setRespawnLocation(getJail(user.getJail()));
}
catch (Exception ex)
{
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex);
}
}
@Override
public void onPlayerTeleport(final PlayerTeleportEvent event)
{
final User user = ess.getUser(event.getPlayer());
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
{
return;
}
try
{
event.setTo(getJail(user.getJail()));
}
catch (Exception ex)
{
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex);
}
user.sendMessage(_("jailMessage"));
}
@Override
public void onPlayerJoin(final PlayerJoinEvent event)
{
final User user = ess.getUser(event.getPlayer());
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
{
return;
}
try
{
sendToJail(user, user.getJail());
}
catch (Exception ex)
{
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex);
}
user.sendMessage(_("jailMessage"));
}
}
}

View File

@@ -0,0 +1,113 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.commands.NoChargeException;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import java.util.*;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public class Kit
{
//TODO: Convert this to use one of the new text classes?
public static String listKits(final IEssentials ess, final User user) throws Exception
{
try
{
final Map<String, Object> kits = ess.getSettings().getKits();
final StringBuilder list = new StringBuilder();
for (String kiteItem : kits.keySet())
{
if (user.isAuthorized("essentials.kit." + kiteItem.toLowerCase(Locale.ENGLISH)))
{
list.append(" ").append(kiteItem);
}
}
return list.toString();
}
catch (Exception ex)
{
throw new Exception(_("kitError"));
}
}
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws NoChargeException
{
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 Long lastTime = user.getKitTimestamp(kitName);
if (lastTime == null || lastTime < mintime)
{
final Calendar now = new GregorianCalendar();
user.setKitTimestamp(kitName, now.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())));
throw new NoChargeException();
}
}
public static List<String> getItems(final User user, final Map<String, Object> els) throws Exception
{
try
{
return (List<String>)els.get("items");
}
catch (Exception e)
{
user.sendMessage(_("kitError2"));
throw new Exception(_("kitErrorHelp"));
}
}
public static void expandItems(final IEssentials ess, final User user, final List<String> items) throws Exception
{
try
{
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 Map<Integer, ItemStack> overfilled;
if (user.isAuthorized("essentials.oversizedstacks"))
{
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), new ItemStack(id, amount, data));
}
else
{
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, new ItemStack(id, amount, data));
}
for (ItemStack itemStack : overfilled.values())
{
user.getWorld().dropItemNaturally(user.getLocation(), itemStack);
spew = true;
}
}
user.updateInventory();
if (spew)
{
user.sendMessage(_("kitInvFull"));
}
}
catch (Exception e)
{
user.updateInventory();
throw new Exception(_("kitError2"));
}
}
}

View File

@@ -0,0 +1,227 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.io.*;
import java.math.BigInteger;
import java.security.DigestInputStream;
import java.security.DigestOutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.Bukkit;
public class ManagedFile
{
private final static int BUFFERSIZE = 1024 * 8;
private final transient File file;
public ManagedFile(final String filename, final IEssentials ess)
{
file = new File(ess.getDataFolder(), filename);
if (file.exists())
{
try
{
if (checkForVersion(file, ess.getDescription().getVersion()) && !file.delete())
{
throw new IOException("Could not delete file " + file.toString());
}
}
catch (IOException ex)
{
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
}
}
if (!file.exists())
{
try
{
copyResourceAscii("/" + filename, file);
}
catch (IOException ex)
{
Bukkit.getLogger().log(Level.SEVERE, _("itemsCsvNotLoaded"), ex);
}
}
}
public static void copyResourceAscii(final String resourceName, final File file) throws IOException
{
final InputStreamReader reader = new InputStreamReader(ManagedFile.class.getResourceAsStream(resourceName));
try
{
final MessageDigest digest = getDigest();
final DigestOutputStream digestStream = new DigestOutputStream(new FileOutputStream(file), digest);
try
{
final OutputStreamWriter writer = new OutputStreamWriter(digestStream);
try
{
final char[] buffer = new char[BUFFERSIZE];
do
{
final int length = reader.read(buffer);
if (length >= 0)
{
writer.write(buffer, 0, length);
}
else
{
break;
}
}
while (true);
writer.write("\n");
writer.flush();
final BigInteger hashInt = new BigInteger(1, digest.digest());
digestStream.on(false);
digestStream.write('#');
digestStream.write(hashInt.toString(16).getBytes());
}
finally
{
writer.close();
}
}
finally
{
digestStream.close();
}
}
finally
{
reader.close();
}
}
public static boolean checkForVersion(final File file, final String version) throws IOException
{
if (file.length() < 33)
{
return false;
}
final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
try
{
final byte[] buffer = new byte[(int)file.length()];
int position = 0;
do
{
final int length = bis.read(buffer, position, Math.min((int)file.length() - position, BUFFERSIZE));
if (length < 0)
{
break;
}
position += length;
}
while (position < file.length());
final ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
if (bais.skip(file.length() - 33) != file.length() - 33)
{
return false;
}
final BufferedReader reader = new BufferedReader(new InputStreamReader(bais));
try
{
String hash = reader.readLine();
if (hash != null && hash.matches("#[a-f0-9]{32}"))
{
hash = hash.substring(1);
bais.reset();
final String versionline = reader.readLine();
if (versionline != null && versionline.matches("#version: .+"))
{
final String versioncheck = versionline.substring(10);
if (!versioncheck.equalsIgnoreCase(version))
{
bais.reset();
final MessageDigest digest = getDigest();
final DigestInputStream digestStream = new DigestInputStream(bais, digest);
try
{
final byte[] bytes = new byte[(int)file.length() - 33];
digestStream.read(bytes);
final BigInteger correct = new BigInteger(hash, 16);
final BigInteger test = new BigInteger(1, digest.digest());
if (correct.equals(test))
{
return true;
}
else
{
Bukkit.getLogger().warning("File " + file.toString() + " has been modified by user and file version differs, please update the file manually.");
}
}
finally
{
digestStream.close();
}
}
}
}
}
finally
{
reader.close();
}
}
finally
{
bis.close();
}
return false;
}
public static MessageDigest getDigest() throws IOException
{
try
{
return MessageDigest.getInstance("MD5");
}
catch (NoSuchAlgorithmException ex)
{
throw new IOException(ex);
}
}
public List<String> getLines()
{
try
{
final BufferedReader reader = new BufferedReader(new FileReader(file));
try
{
final List<String> lines = new ArrayList<String>();
do
{
final String line = reader.readLine();
if (line == null)
{
break;
}
else
{
lines.add(line);
}
}
while (true);
return lines;
}
finally
{
reader.close();
}
}
catch (IOException ex)
{
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
return Collections.emptyList();
}
}
}

View File

@@ -1,7 +1,10 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
@@ -26,9 +29,17 @@ public enum Mob
SPIDER("Spider", Enemies.ENEMY, CreatureType.SPIDER),
SQUID("Squid", Enemies.FRIENDLY, CreatureType.SQUID),
ZOMBIE("Zombie", Enemies.ENEMY, CreatureType.ZOMBIE),
MONSTER("Monster", Enemies.ENEMY, CreatureType.MONSTER),
WOLF("Wolf", Enemies.NEUTRAL, CreatureType.WOLF);
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);
public static final Logger logger = Logger.getLogger("Minecraft");
private Mob(String n, Enemies en, String s, CreatureType type)
@@ -45,7 +56,6 @@ public enum Mob
this.type = en;
this.bukkitType = type;
}
public String suffix = "s";
final public String name;
final public Enemies type;
@@ -56,17 +66,20 @@ public enum Mob
{
for (Mob mob : Mob.values())
{
hashMap.put(mob.name, mob);
hashMap.put(mob.name.toLowerCase(Locale.ENGLISH), mob);
}
}
public static Set<String> getMobList() {
return hashMap.keySet();
}
public LivingEntity spawn(final Player player, final Server server, final Location loc) throws MobException
{
final LivingEntity entity = player.getWorld().spawnCreature(loc, this.bukkitType);
final LivingEntity entity = player.getWorld().spawn(loc, (Class<? extends LivingEntity>)this.bukkitType.getEntityClass());
if (entity == null)
{
logger.log(Level.WARNING, Util.i18n("unableToSpawnMob"));
logger.log(Level.WARNING, _("unableToSpawnMob"));
throw new MobException();
}
return entity;
@@ -79,21 +92,26 @@ public enum Mob
NEUTRAL("neutral"),
ENEMY("enemy");
private Enemies(final String t)
private Enemies(final String type)
{
this.type = t;
this.type = type;
}
final protected String type;
}
public CreatureType getType()
{
return bukkitType;
}
public static Mob fromName(final String name)
{
return hashMap.get(name.toLowerCase(Locale.ENGLISH));
}
public static class MobException extends Exception
{
private static final long serialVersionUID = 1L;
}
public static Mob fromName(String n)
{
return hashMap.get(n);
}
}

View File

@@ -1,167 +0,0 @@
/**
* @author SpaceManiac
* @licent MIT
* @origin https://github.com/SpaceManiac/Nether/blob/master/org/innectis/Nether/NetherPortal.java
*/
package com.earth2me.essentials;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.Location;
import org.bukkit.Material;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
public class NetherPortal
{
private Block block;
public NetherPortal(Block b)
{
block = b;
}
public Block getBlock()
{
return block;
}
public void setBlock(Block b)
{
block = b;
}
// Return a random spawnable location
public Location getSpawn()
{
if (block.getWorld().getBlockAt(block.getX() + 1, block.getY(), block.getZ()).getType().equals(Material.PORTAL)
|| block.getWorld().getBlockAt(block.getX() - 1, block.getY(), block.getZ()).getType().equals(Material.PORTAL))
{
// portal is in X direction
return new Location(block.getWorld(), block.getX() + 1,
block.getY(), block.getZ() + 1 - 2 * Math.round(Math.random()));
}
else
{
// portal is in Z direction
return new Location(block.getWorld(), block.getX() + 1 - 2 * Math.round(Math.random()),
block.getY(), block.getZ() + 1);
}
}
// ==============================
// Find a nearby portal within 16 blocks of the given block
// Not guaranteed to be the nearest
public static NetherPortal findPortal(Block dest)
{
World world = dest.getWorld();
// Get list of columns in a circle around the block
ArrayList<Block> columns = new ArrayList<Block>();
for (int x = dest.getX() - 16; x <= dest.getX() + 16; ++x)
{
for (int z = dest.getZ() - 16; z <= dest.getZ() + 16; ++z)
{
int dx = dest.getX() - x, dz = dest.getZ() - z;
if (dx * dx + dz * dz <= 256)
{
columns.add(world.getBlockAt(x, 0, z));
}
}
}
// For each column try to find a portal block
for (Block col : columns)
{
for (int y = 127; y >= 0; --y)
{
Block b = world.getBlockAt(col.getX(), y, col.getZ());
if (b.getType().equals(Material.PORTAL) && Math.abs(dest.getY() - y) <= 16)
{
// Huzzah!
return new NetherPortal(b);
}
}
}
// Nope!
return null;
}
// Create a new portal at the specified block, fudging position if needed
// Will occasionally end up making portals in bad places, but let's hope not
public static NetherPortal createPortal(Block dest)
{
World world = dest.getWorld();
// Try not to spawn within water or lava
Material m = dest.getType();
while (((m.equals(Material.LAVA) || m.equals(Material.WATER) || m.equals(Material.STATIONARY_LAVA)
|| m.equals(Material.STATIONARY_WATER) || m.equals(Material.SAND) || m.equals(Material.GRAVEL))) &&
dest.getY() < 120)
{
dest = world.getBlockAt(dest.getX(), dest.getY() + 4, dest.getZ());
m = dest.getType();
}
// Not too high or too low overall
if (dest.getY() > 120)
{
dest = world.getBlockAt(dest.getX(), 120, dest.getZ());
}
else if (dest.getY() < 8)
{
dest = world.getBlockAt(dest.getX(), 8, dest.getZ());
}
// Create the physical portal
// For now, don't worry about direction
int x = dest.getX(), y = dest.getY(), z = dest.getZ();
Logger.getLogger("Minecraft").log(Level.INFO, Util.format("creatingPortal", x, y, z));
// Clear area around portal
ArrayList<Block> columns = new ArrayList<Block>();
for (int x2 = x - 4; x2 <= x + 4; ++x2)
{
for (int z2 = z - 4; z2 <= z + 4; ++z2)
{
double dx = x + 0.5f - x2, dz = z - z2;
if (dx * dx + dz * dz <= 13)
{
columns.add(world.getBlockAt(x2, 0, z2));
}
}
}
// Clear area around portal
for (Block col : columns)
{
// Stone platform
world.getBlockAt(col.getX(), y - 1, col.getZ()).setType(Material.STONE);
for (int yd = 0; yd < 4; ++yd)
{
world.getBlockAt(col.getX(), y + yd, col.getZ()).setType(Material.AIR);
}
}
// Build obsidian frame
for (int xd = -1; xd < 3; ++xd)
{
for (int yd = -1; yd < 4; ++yd)
{
if (xd == -1 || yd == -1 || xd == 2 || yd == 3)
{
world.getBlockAt(x + xd, y + yd, z).setType(Material.OBSIDIAN);
}
}
}
// Set it alight!
dest.setType(Material.FIRE);
return new NetherPortal(dest);
}
}

View File

@@ -1,29 +1,18 @@
package com.earth2me.essentials;
import com.earth2me.essentials.craftbukkit.OfflineBedLocation;
import static com.earth2me.essentials.I18n._;
import java.net.InetSocketAddress;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Achievement;
import org.bukkit.Effect;
import org.bukkit.Instrument;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Note;
import org.bukkit.Server;
import org.bukkit.Statistic;
import org.bukkit.World;
import java.util.*;
import lombok.Delegate;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball;
import org.bukkit.entity.Vehicle;
import org.bukkit.entity.*;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.map.MapView;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
@@ -33,118 +22,123 @@ import org.bukkit.util.Vector;
public class OfflinePlayer implements Player
{
private final String name;
final transient IEssentials ess;
private Location location = new Location(null, 0, 0, 0, 0, 0);
private World world;
private UUID uniqueId = UUID.randomUUID();
private final transient IEssentials ess;
private transient Location location = new Location(null, 0, 0, 0, 0, 0);
private transient World world;
private final transient UUID uniqueId = UUID.randomUUID();
@Delegate(types = org.bukkit.OfflinePlayer.class)
private transient org.bukkit.OfflinePlayer base;
public OfflinePlayer(String name, IEssentials ess)
public OfflinePlayer(final String name, final IEssentials ess)
{
this.name = name;
this.ess = ess;
this.world = ess.getServer().getWorlds().get(0);
this.base = ess.getServer().getOfflinePlayer(name);
}
public boolean isOnline()
{
return false;
}
public boolean isOp()
{
return false;
}
public void sendMessage(String string)
@Override
public void sendMessage(final String string)
{
}
@Override
public String getDisplayName()
{
return name;
return base.getName();
}
@Override
public void setDisplayName(String string)
{
}
@Override
public void setCompassTarget(Location lctn)
{
}
@Override
public InetSocketAddress getAddress()
{
return null;
}
@Override
public void kickPlayer(String string)
{
}
public String getName()
{
return name;
}
@Override
public PlayerInventory getInventory()
{
return null;
}
@Override
public ItemStack getItemInHand()
{
return null;
}
@Override
public void setItemInHand(ItemStack is)
{
}
@Override
public int getHealth()
{
return 0;
}
@Override
public void setHealth(int i)
{
}
@Override
public Egg throwEgg()
{
return null;
}
@Override
public Snowball throwSnowball()
{
return null;
}
@Override
public Arrow shootArrow()
{
return null;
}
@Override
public boolean isInsideVehicle()
{
return false;
}
@Override
public boolean leaveVehicle()
{
return false;
}
@Override
public Vehicle getVehicle()
{
return null;
}
@Override
public Location getLocation()
{
return location;
}
@Override
public World getWorld()
{
return world;
@@ -164,11 +158,13 @@ public class OfflinePlayer implements Player
{
}
@Override
public int getEntityId()
{
return -1;
}
@Override
public boolean performCommand(String string)
{
return false;
@@ -179,91 +175,109 @@ public class OfflinePlayer implements Player
return false;
}
@Override
public int getRemainingAir()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setRemainingAir(int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public int getMaximumAir()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setMaximumAir(int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean isSneaking()
{
return false;
}
@Override
public void setSneaking(boolean bln)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void updateInventory()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void chat(String string)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public double getEyeHeight()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public double getEyeHeight(boolean bln)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public List<Block> getLineOfSight(HashSet<Byte> hs, int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public Block getTargetBlock(HashSet<Byte> hs, int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public List<Block> getLastTwoTargetBlocks(HashSet<Byte> hs, int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public int getFireTicks()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public int getMaxFireTicks()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setFireTicks(int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void remove()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public Server getServer()
{
return ess == null ? null : ess.getServer();
@@ -271,309 +285,576 @@ public class OfflinePlayer implements Player
public Vector getMomentum()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
public void setMomentum(Vector vector)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setVelocity(Vector vector)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public Vector getVelocity()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void damage(int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void damage(int i, Entity entity)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public Location getEyeLocation()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void sendRawMessage(String string)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public Location getCompassTarget()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public int getMaximumNoDamageTicks()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setMaximumNoDamageTicks(int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public int getLastDamage()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setLastDamage(int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public int getNoDamageTicks()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setNoDamageTicks(int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean teleport(Location lctn)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean teleport(Entity entity)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public Entity getPassenger()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean setPassenger(Entity entity)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean isEmpty()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean eject()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void saveData()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void loadData()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean isSleeping()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public int getSleepTicks()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public List<Entity> getNearbyEntities(double d, double d1, double d2)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean isDead()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public float getFallDistance()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setFallDistance(float f)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setSleepingIgnored(boolean bln)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean isSleepingIgnored()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void awardAchievement(Achievement a)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void incrementStatistic(Statistic ststc)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void incrementStatistic(Statistic ststc, int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void incrementStatistic(Statistic ststc, Material mtrl)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void incrementStatistic(Statistic ststc, Material mtrl, int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void playNote(Location lctn, byte b, byte b1)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void sendBlockChange(Location lctn, Material mtrl, byte b)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void sendBlockChange(Location lctn, int i, byte b)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void setLastDamageCause(EntityDamageEvent ede)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public EntityDamageEvent getLastDamageCause()
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public void playEffect(Location lctn, Effect effect, int i)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
throw new UnsupportedOperationException(_("notSupportedYet"));
}
@Override
public boolean sendChunkChange(Location lctn, int i, int i1, int i2, byte[] bytes)
{
return true;
}
@Override
public UUID getUniqueId()
{
return uniqueId;
}
@Override
public void playNote(Location lctn, Instrument i, Note note)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setPlayerTime(long l, boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public long getPlayerTime()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public long getPlayerTimeOffset()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isPlayerTimeRelative()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void resetPlayerTime()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isPermissionSet(String string)
{
return false;
}
@Override
public boolean isPermissionSet(Permission prmsn)
{
return false;
}
@Override
public boolean hasPermission(String string)
{
return false;
}
@Override
public boolean hasPermission(Permission prmsn)
{
return false;
}
@Override
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public PermissionAttachment addAttachment(Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln, int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public PermissionAttachment addAttachment(Plugin plugin, int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void removeAttachment(PermissionAttachment pa)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void recalculatePermissions()
{
}
@Override
public Set<PermissionAttachmentInfo> getEffectivePermissions()
{
throw new UnsupportedOperationException("Not supported yet.");
}
public void setOp(boolean bln)
@Override
public void sendMap(MapView mv)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public GameMode getGameMode()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setGameMode(GameMode gm)
{
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()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setLevel(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getTotalExperience()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setTotalExperience(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public float getExhaustion()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setExhaustion(float f)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public float getSaturation()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setSaturation(float f)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getFoodLevel()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setFoodLevel(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isSprinting()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setSprinting(boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setPlayerListName(String name)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getPlayerListName()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getTicksLived()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setTicksLived(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getMaxHealth()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void giveExp(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public float getExp()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setExp(float f)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean teleport(Location lctn, TeleportCause tc)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean teleport(Entity entity, TeleportCause tc)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Player getKiller()
{
throw new UnsupportedOperationException("Not supported yet.");
}
void setName(final String name)
{
if (!this.base.getName().equalsIgnoreCase(name))
{
this.base = ess.getServer().getOfflinePlayer(name);
}
}
@Override
public void sendPluginMessage(Plugin plugin, String string, byte[] bytes)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Set<String> getListeningPluginChannels()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setAllowFlight(boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean getAllowFlight()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setBedSpawnLocation(Location lctn)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void playEffect(EntityEffect ee)
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -1,78 +1,38 @@
package com.earth2me.essentials;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.IInventory;
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
import lombok.Delegate;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permissible;
import org.bukkit.permissions.ServerOperator;
public class PlayerExtension extends PlayerWrapper
public class PlayerExtension implements Player
{
protected final IEssentials ess;
public PlayerExtension(Player base, IEssentials ess)
@Delegate(types =
{
super(base);
this.ess = ess;
Player.class, Entity.class, CommandSender.class, ServerOperator.class,
HumanEntity.class, ConfigurationSerializable.class, LivingEntity.class,
Permissible.class
})
protected Player base;
public PlayerExtension(final Player base)
{
this.base = base;
}
public boolean isBanned()
public final Player getBase()
{
return ess.getBans().isNameBanned(this.getName());
return base;
}
public boolean isIpBanned()
public final Player setBase(final Player base)
{
return ess.getBans().isIpBanned(getAddress().getAddress().getHostAddress());
}
public float getCorrectedYaw()
{
float angle = (getLocation().getYaw() - 90.0f) % 360.0f;
if (angle < 0) {
angle += 360.0f;
}
return angle;
}
public void showInventory(IInventory inventory)
{
getHandle().a(inventory);
}
public void showInventory(CraftInventoryPlayer inventory)
{
showInventory((IInventory)inventory.getInventory());
}
public TargetBlock getTarget()
{
return new TargetBlock(getBase());
}
public String getGroup()
{
return ess.getPermissionsHandler().getGroup(base);
}
public boolean inGroup(String group)
{
return ess.getPermissionsHandler().inGroup(base, group);
}
public boolean canBuild()
{
return ess.getPermissionsHandler().canBuild(base, getGroup());
}
public EntityPlayer getHandle()
{
return getCraftPlayer().getHandle();
}
public CraftPlayer getCraftPlayer()
{
return (CraftPlayer)base;
return this.base = base;
}
}

View File

@@ -1,627 +0,0 @@
package com.earth2me.essentials;
import java.net.InetSocketAddress;
import java.util.*;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.*;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.*;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector;
public class PlayerWrapper implements Player
{
protected Player base;
public PlayerWrapper(Player base)
{
this.base = base;
}
public final Player getBase()
{
return base;
}
public final Player setBase(Player base)
{
return this.base = base;
}
@Override
public void setDisplayName(String string)
{
base.setDisplayName(string);
}
@Override
public void setCompassTarget(Location lctn)
{
base.setCompassTarget(lctn);
}
@Override
public InetSocketAddress getAddress()
{
return base.getAddress();
}
@Override
public void kickPlayer(String string)
{
base.kickPlayer(string);
}
@Override
public String getName()
{
return base.getName();
}
@Override
public PlayerInventory getInventory()
{
return base.getInventory();
}
@Override
public ItemStack getItemInHand()
{
return base.getItemInHand();
}
@Override
public void setItemInHand(ItemStack is)
{
base.setItemInHand(is);
}
@Override
public int getHealth()
{
return base.getHealth();
}
@Override
public void setHealth(int i)
{
base.setHealth(i);
}
@Override
public Egg throwEgg()
{
return base.throwEgg();
}
@Override
public Snowball throwSnowball()
{
return base.throwSnowball();
}
@Override
public Arrow shootArrow()
{
return base.shootArrow();
}
@Override
public boolean isInsideVehicle()
{
return base.isInsideVehicle();
}
@Override
public boolean leaveVehicle()
{
return base.leaveVehicle();
}
@Override
public Vehicle getVehicle()
{
return base.getVehicle();
}
@Override
public Location getLocation()
{
return base.getLocation();
}
@Override
public World getWorld()
{
return base.getWorld();
}
@Override
public Server getServer()
{
return base.getServer();
}
@Override
public boolean isOnline()
{
return base.isOnline();
}
@Override
public boolean isOp()
{
return base.isOp();
}
@Override
public boolean teleport(Location lctn)
{
return base.teleport(lctn);
}
@Override
public boolean teleport(Entity entity)
{
return base.teleport(entity);
}
@Override
public void sendMessage(String string)
{
base.sendMessage(string);
}
@Override
public void setVelocity(Vector vector)
{
base.setVelocity(vector);
}
@Override
public Vector getVelocity()
{
return base.getVelocity();
}
@Override
public double getEyeHeight()
{
return base.getEyeHeight();
}
@Override
public double getEyeHeight(boolean bln)
{
return base.getEyeHeight(bln);
}
@Override
public List<Block> getLineOfSight(HashSet<Byte> hs, int i)
{
return base.getLineOfSight(hs, i);
}
@Override
public Block getTargetBlock(HashSet<Byte> hs, int i)
{
return base.getTargetBlock(hs, i);
}
@Override
public List<Block> getLastTwoTargetBlocks(HashSet<Byte> hs, int i)
{
return base.getLastTwoTargetBlocks(hs, i);
}
@Override
public int getFireTicks()
{
return base.getFireTicks();
}
@Override
public int getMaxFireTicks()
{
return base.getMaxFireTicks();
}
@Override
public void setFireTicks(int i)
{
base.setFireTicks(i);
}
@Override
public void remove()
{
base.remove();
}
/**
* This is not deprecated because the underlying method isn't really deprecated; rather, it's just "imperfect". By
* We will continue to use this method even after the underlying CraftBukkit method is changed, so do not deprecate
* it. Chances are Bukkit will also choose to un-deprecate this method at some point.
*/
@Override
public void updateInventory()
{
base.updateInventory();
}
@Override
public void chat(String string)
{
base.chat(string);
}
@Override
public boolean isSneaking()
{
return base.isSneaking();
}
@Override
public void setSneaking(boolean bln)
{
base.setSneaking(bln);
}
@Override
public int getEntityId()
{
return base.getEntityId();
}
@Override
public boolean performCommand(String string)
{
return base.performCommand(string);
}
@Override
public int getRemainingAir()
{
return base.getRemainingAir();
}
@Override
public void setRemainingAir(int i)
{
base.setRemainingAir(i);
}
@Override
public int getMaximumAir()
{
return base.getMaximumAir();
}
@Override
public void setMaximumAir(int i)
{
base.setMaximumAir(i);
}
@Override
public String getDisplayName()
{
if (base.getDisplayName() != null)
return base.getDisplayName();
else
return base.getName();
}
@Override
public void damage(int i)
{
base.damage(i);
}
@Override
public void damage(int i, Entity entity)
{
base.damage(i, entity);
}
@Override
public Location getEyeLocation()
{
return base.getEyeLocation();
}
@Override
public void sendRawMessage(String string) {
base.sendRawMessage(string);
}
@Override
public Location getCompassTarget()
{
return base.getCompassTarget();
}
@Override
public int getMaximumNoDamageTicks()
{
return base.getMaximumNoDamageTicks();
}
@Override
public void setMaximumNoDamageTicks(int i)
{
base.setMaximumNoDamageTicks(i);
}
@Override
public int getLastDamage()
{
return base.getLastDamage();
}
@Override
public void setLastDamage(int i)
{
base.setLastDamage(i);
}
@Override
public int getNoDamageTicks()
{
return base.getNoDamageTicks();
}
@Override
public void setNoDamageTicks(int i)
{
base.setNoDamageTicks(i);
}
@Override
public Entity getPassenger()
{
return base.getPassenger();
}
@Override
public boolean setPassenger(Entity entity)
{
return base.setPassenger(entity);
}
@Override
public boolean isEmpty()
{
return base.isEmpty();
}
@Override
public boolean eject()
{
return base.eject();
}
@Override
@Deprecated
public void teleportTo(Location lctn)
{
base.teleportTo(lctn);
}
@Override
@Deprecated
public void teleportTo(Entity entity)
{
base.teleportTo(entity);
}
public void saveData()
{
base.saveData();
}
public void loadData()
{
base.loadData();
}
public boolean isSleeping()
{
return base.isSleeping();
}
public int getSleepTicks()
{
return base.getSleepTicks();
}
public List<Entity> getNearbyEntities(double d, double d1, double d2)
{
return base.getNearbyEntities(d, d1, d2);
}
public boolean isDead()
{
return base.isDead();
}
public float getFallDistance()
{
return base.getFallDistance();
}
public void setFallDistance(float f)
{
base.setFallDistance(f);
}
public void setSleepingIgnored(boolean bln)
{
base.setSleepingIgnored(bln);
}
public boolean isSleepingIgnored()
{
return base.isSleepingIgnored();
}
public void awardAchievement(Achievement a)
{
base.awardAchievement(a);
}
public void incrementStatistic(Statistic ststc)
{
base.incrementStatistic(ststc);
}
public void incrementStatistic(Statistic ststc, int i)
{
base.incrementStatistic(ststc, i);
}
public void incrementStatistic(Statistic ststc, Material mtrl)
{
base.incrementStatistic(ststc, mtrl);
}
public void incrementStatistic(Statistic ststc, Material mtrl, int i)
{
base.incrementStatistic(ststc, mtrl, i);
}
public void playNote(Location lctn, byte b, byte b1)
{
base.playNote(lctn, b, b1);
}
public void sendBlockChange(Location lctn, Material mtrl, byte b)
{
base.sendBlockChange(lctn, mtrl, b);
}
public void sendBlockChange(Location lctn, int i, byte b)
{
base.sendBlockChange(lctn, i, b);
}
public void setLastDamageCause(EntityDamageEvent ede)
{
base.setLastDamageCause(ede);
}
public EntityDamageEvent getLastDamageCause()
{
return base.getLastDamageCause();
}
public void playEffect(Location lctn, Effect effect, int i)
{
base.playEffect(lctn, effect, i);
}
public boolean sendChunkChange(Location lctn, int i, int i1, int i2, byte[] bytes)
{
return base.sendChunkChange(lctn, i, i1, i2, bytes);
}
public UUID getUniqueId()
{
return base.getUniqueId();
}
public void playNote(Location lctn, Instrument i, Note note)
{
base.playNote(lctn, i, note);
}
public void setPlayerTime(long l, boolean bln)
{
base.setPlayerTime(l, bln);
}
public long getPlayerTime()
{
return base.getPlayerTime();
}
public long getPlayerTimeOffset()
{
return base.getPlayerTimeOffset();
}
public boolean isPlayerTimeRelative()
{
return base.isPlayerTimeRelative();
}
public void resetPlayerTime()
{
base.resetPlayerTime();
}
public boolean isPermissionSet(String string)
{
return base.isPermissionSet(string);
}
public boolean isPermissionSet(Permission prmsn)
{
return base.isPermissionSet(prmsn);
}
public boolean hasPermission(String string)
{
return base.hasPermission(string);
}
public boolean hasPermission(Permission prmsn)
{
return base.hasPermission(prmsn);
}
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln)
{
return base.addAttachment(plugin, string, bln);
}
public PermissionAttachment addAttachment(Plugin plugin)
{
return base.addAttachment(plugin);
}
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln, int i)
{
return base.addAttachment(plugin, string, bln, i);
}
public PermissionAttachment addAttachment(Plugin plugin, int i)
{
return base.addAttachment(plugin, i);
}
public void removeAttachment(PermissionAttachment pa)
{
throw new UnsupportedOperationException("Not supported yet.");
}
public void recalculatePermissions()
{
base.recalculatePermissions();
}
public Set<PermissionAttachmentInfo> getEffectivePermissions()
{
return base.getEffectivePermissions();
}
public void setOp(boolean bln)
{
base.setOp(bln);
}
}

View File

@@ -1,13 +1,16 @@
package com.earth2me.essentials;
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 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 com.earth2me.essentials.commands.IEssentialsCommand;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.bukkit.event.EventPriority;
import org.bukkit.inventory.ItemStack;
@@ -32,9 +35,42 @@ public class Settings implements ISettings
}
@Override
public boolean getBedSetsHome()
public boolean getUpdateBedAtDaytime()
{
return config.getBoolean("bed-sethome", false);
return config.getBoolean("update-bed-at-daytime", true);
}
@Override
public List<String> getMultipleHomes()
{
return config.getKeys("sethome-multiple");
}
@Override
public int getHomeLimit(final User user)
{
final List<String> homeList = getMultipleHomes();
if (homeList == null)
{
//TODO: Replace this code to remove backwards compat, after settings are automatically updated
// return getHomeLimit("default");
return config.getInt("multiple-homes", 5);
}
int limit = getHomeLimit("default");
for (String set : homeList)
{
if (user.isAuthorized("essentials.sethome.multiple." + set) && (limit < getHomeLimit(set)))
{
limit = getHomeLimit(set);
}
}
return limit;
}
@Override
public int getHomeLimit(final String set)
{
return config.getInt("sethome-multiple." + set, config.getInt("sethome-multiple.default", 3));
}
@Override
@@ -49,24 +85,24 @@ public class Settings implements ISettings
return config.getDouble("teleport-delay", 0);
}
@Override
public int getOversizedStackSize()
{
return config.getInt("oversized-stacksize", 64);
}
@Override
public int getDefaultStackSize()
{
return config.getInt("default-stack-size", 64);
return config.getInt("default-stack-size", -1);
}
@Override
public int getStartingBalance()
{
return config.getInt("starting-balance", 0);
}
@Override
public boolean getNetherPortalsEnabled()
{
return isNetherEnabled() && config.getBoolean("nether.portals-enabled", false);
}
@Override
public boolean isCommandDisabled(final IEssentialsCommand cmd)
{
@@ -78,10 +114,13 @@ public class Settings implements ISettings
{
for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0)))
{
if (!c.equalsIgnoreCase(label)) continue;
if (!c.equalsIgnoreCase(label))
{
continue;
}
return true;
}
return config.getBoolean("disable-" + label.toLowerCase(), false);
return config.getBoolean("disable-" + label.toLowerCase(Locale.ENGLISH), false);
}
@Override
@@ -95,18 +134,24 @@ public class Settings implements ISettings
{
for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0)))
{
if (!c.equalsIgnoreCase(label)) continue;
if (!c.equalsIgnoreCase(label))
{
continue;
}
return true;
}
return config.getBoolean("restrict-" + label.toLowerCase(), false);
return config.getBoolean("restrict-" + label.toLowerCase(Locale.ENGLISH), false);
}
@Override
public boolean isPlayerCommand(String label)
{
for (String c : config.getStringList("player-commands", new ArrayList<String>(0)))
{
if (!c.equalsIgnoreCase(label)) continue;
if (!c.equalsIgnoreCase(label))
{
continue;
}
return true;
}
return false;
@@ -120,10 +165,12 @@ public class Settings implements ISettings
for (String c : config.getStringList("overridden-commands", defaultList))
{
if (!c.equalsIgnoreCase(name))
{
continue;
}
return true;
}
return config.getBoolean("override-" + name.toLowerCase(), false);
return config.getBoolean("override-" + name.toLowerCase(Locale.ENGLISH), false);
}
@Override
@@ -137,7 +184,9 @@ public class Settings implements ISettings
{
double cost = config.getDouble("command-costs." + label, 0.0);
if (cost == 0.0)
{
cost = config.getDouble("cost-" + label, 0.0);
}
return cost;
}
@@ -150,13 +199,13 @@ public class Settings implements ISettings
@Override
public double getTeleportCooldown()
{
return config.getDouble("teleport-cooldown", 60);
return config.getDouble("teleport-cooldown", 0);
}
@Override
public double getHealCooldown()
{
return config.getDouble("heal-cooldown", 60);
return config.getDouble("heal-cooldown", 0);
}
@Override
@@ -165,13 +214,14 @@ public class Settings implements ISettings
Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits");
for (Map.Entry<String, Object> entry : kits.entrySet())
{
if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_'))) {
if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_')))
{
return entry.getValue();
}
}
return null;
}
@Override
public Map<String, Object> getKits()
{
@@ -184,13 +234,17 @@ public class Settings implements ISettings
String colorName = config.getString("ops-name-color", null);
if (colorName == null)
{
return ChatColor.RED;
if("none".equalsIgnoreCase(colorName) || colorName.isEmpty())
}
if ("none".equalsIgnoreCase(colorName) || colorName.isEmpty())
{
throw new Exception();
}
try
{
return ChatColor.valueOf(colorName.toUpperCase());
return ChatColor.valueOf(colorName.toUpperCase(Locale.ENGLISH));
}
catch (IllegalArgumentException ex)
{
@@ -199,41 +253,23 @@ public class Settings implements ISettings
return ChatColor.getByCode(Integer.parseInt(colorName, 16));
}
@Override
public boolean getReclaimSetting()
{
return config.getBoolean("reclaim-onlogout", true);
}
@Override
public String getNetherName()
{
return config.getString("nether.folder", "nether");
}
@Override
public boolean isNetherEnabled()
{
return config.getBoolean("nether.enabled", true);
}
@Override
public int getSpawnMobLimit()
{
return config.getInt("spawnmob-limit", 10);
}
@Override
public boolean showNonEssCommandsInHelp()
{
return config.getBoolean("non-ess-in-help", true);
}
@Override
public boolean hidePermissionlessHelp()
public boolean hidePermissionlessHelp()
{
return config.getBoolean("hide-permissionless-help", true);
}
}
@Override
public int getProtectCreeperMaxHeight()
@@ -244,7 +280,7 @@ public class Settings implements ISettings
@Override
public boolean areSignsDisabled()
{
return config.getBoolean("signs-disabled", false);
return enabledSigns.isEmpty();
}
@Override
@@ -258,18 +294,27 @@ public class Settings implements ISettings
{
return config.getString("backup.command", null);
}
private Map<String, MessageFormat> chatFormats = new HashMap<String, MessageFormat>();
@Override
public String getChatFormat(String group)
public MessageFormat getChatFormat(String group)
{
return config.getString("chat.group-formats." + (group == null ? "Default" : group),
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
}
@Override
public boolean getGenerateExitPortals()
{
return config.getBoolean("nether.generate-exit-portals", true);
MessageFormat mFormat = chatFormats.get(group);
if (mFormat == null)
{
String format = config.getString("chat.group-formats." + (group == null ? "Default" : group),
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
format = Util.replaceColor(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\\]");
mFormat = new MessageFormat(format);
chatFormats.put(group, mFormat);
}
return mFormat;
}
@Override
@@ -295,12 +340,13 @@ public class Settings implements ISettings
{
return config.getString("newbies.spawnpoint", "default");
}
@Override
public boolean getPerWarpPermission()
public boolean getPerWarpPermission()
{
return config.getBoolean("per-warp-permission", false);
}
@Override
public boolean getSortListByGroups()
{
@@ -308,29 +354,76 @@ public class Settings implements ISettings
}
@Override
public void reloadConfig() {
public void reloadConfig()
{
config.load();
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds", Collections.<String>emptyList()));
enabledSigns = getEnabledSigns();
itemSpawnBl = getItemSpawnBlacklist();
chatFormats.clear();
}
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
@Override
public List<Integer> itemSpawnBlacklist()
{
return itemSpawnBl;
}
private List<Integer> getItemSpawnBlacklist()
{
final List<Integer> epItemSpwn = new ArrayList<Integer>();
for (String itemName : config.getString("item-spawn-blacklist", "").split(",")) {
for (String itemName : config.getString("item-spawn-blacklist", "").split(","))
{
itemName = itemName.trim();
if (itemName.isEmpty()) {
if (itemName.isEmpty())
{
continue;
}
try
{
final ItemStack iStack = ess.getItemDb().get(itemName);
epItemSpwn.add(iStack.getTypeId());
}
ItemStack is;
try {
is = ess.getItemDb().get(itemName);
epItemSpwn.add(is.getTypeId());
} catch (Exception ex) {
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "item-spawn-blacklist"));
catch (Exception ex)
{
logger.log(Level.SEVERE, _("unknownItemInList", itemName, "item-spawn-blacklist"));
}
}
return epItemSpwn;
}
private List<EssentialsSign> enabledSigns = new ArrayList<EssentialsSign>();
@Override
public List<EssentialsSign> enabledSigns()
{
return enabledSigns;
}
private List<EssentialsSign> getEnabledSigns()
{
List<EssentialsSign> newSigns = new ArrayList<EssentialsSign>();
for (String signName : config.getStringList("enabledSigns", null))
{
signName = signName.trim().toUpperCase(Locale.ENGLISH);
if (signName.isEmpty())
{
continue;
}
try
{
newSigns.add(Signs.valueOf(signName).getSign());
}
catch (Exception ex)
{
logger.log(Level.SEVERE, _("unknownItemInList", signName, "enabledSigns"));
}
}
return newSigns;
}
@Override
public boolean spawnIfNoHome()
@@ -343,34 +436,20 @@ public class Settings implements ISettings
{
return config.getBoolean("protect.disable.warn-on-build-disallow", false);
}
private boolean debug = false;
@Override
public boolean use1to1RatioInNether()
{
return config.getBoolean("nether.use-1to1-ratio", false);
}
@Override
public double getNetherRatio()
{
if (config.getBoolean("nether.use-1to1-ratio", false)) {
return 1.0;
}
return config.getDouble("nether.ratio", 16.0);
}
@Override
public boolean isDebug()
{
return config.getBoolean("debug", false);
return debug || config.getBoolean("debug", false);
}
@Override
public boolean warnOnSmite()
{
return config.getBoolean("warn-on-smite" ,true);
return config.getBoolean("warn-on-smite", true);
}
@Override
public boolean permissionBasedItemSpawn()
{
@@ -404,24 +483,29 @@ public class Settings implements ISettings
@Override
public boolean getProtectPreventSpawn(final String creatureName)
{
return config.getBoolean("protect.prevent.spawn."+creatureName, false);
return config.getBoolean("protect.prevent.spawn." + creatureName, false);
}
@Override
public List<Integer> getProtectList(final String configName)
{
final List<Integer> list = new ArrayList<Integer>();
for (String itemName : config.getString(configName, "").split(",")) {
for (String itemName : config.getString(configName, "").split(","))
{
itemName = itemName.trim();
if (itemName.isEmpty()) {
if (itemName.isEmpty())
{
continue;
}
ItemStack itemStack;
try {
try
{
itemStack = ess.getItemDb().get(itemName);
list.add(itemStack.getTypeId());
} catch (Exception ex) {
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, configName));
}
catch (Exception ex)
{
logger.log(Level.SEVERE, _("unknownItemInList", itemName, configName));
}
}
return list;
@@ -438,39 +522,153 @@ public class Settings implements ISettings
{
return config.getBoolean(configName, def);
}
private final static double MAXMONEY = 10000000000000.0;
@Override
public double getMaxMoney()
{
double max = config.getDouble("max-money", MAXMONEY);
if (Math.abs(max) > MAXMONEY) {
if (Math.abs(max) > MAXMONEY)
{
max = max < 0 ? -MAXMONEY : MAXMONEY;
}
return max;
}
@Override
public boolean isEcoLogEnabled()
{
return config.getBoolean("economy-log-enabled", false);
}
@Override
public boolean removeGodOnDisconnect()
{
return config.getBoolean("remove-god-on-disconnect", false);
}
@Override
public boolean changeDisplayName()
{
return config.getBoolean("change-displayname", true);
}
@Override
public boolean useBukkitPermissions()
{
return config.getBoolean("use-bukkit-permissions", false);
}
@Override
public boolean addPrefixSuffix()
{
return config.getBoolean("add-prefix-suffix", false);
return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat"));
}
@Override
public boolean disablePrefix()
{
return config.getBoolean("disablePrefix", false);
}
@Override
public boolean disableSuffix()
{
return config.getBoolean("disableSuffix", false);
}
@Override
public long getAutoAfk()
{
return config.getLong("auto-afk", 300);
}
@Override
public long getAutoAfkKick()
{
return config.getLong("auto-afk-kick", -1);
}
@Override
public boolean getFreezeAfkPlayers()
{
return config.getBoolean("freeze-afk-players", false);
}
@Override
public boolean areDeathMessagesEnabled()
{
return config.getBoolean("death-messages", true);
}
private Set<String> noGodWorlds = new HashSet<String>();
@Override
public Set<String> getNoGodWorlds()
{
return noGodWorlds;
}
@Override
public void setDebug(final boolean debug)
{
this.debug = debug;
}
@Override
public boolean getRepairEnchanted()
{
return config.getBoolean("repair-enchanted", true);
}
@Override
public boolean getIsWorldTeleportPermissions()
{
return config.getBoolean("world-teleport-permissions", false);
}
@Override
public boolean registerBackInListener()
{
return config.getBoolean("register-back-in-listener", false);
}
@Override
public boolean getDisableItemPickupWhileAfk()
{
return config.getBoolean("disable-item-pickup-while-afk", true);
}
@Override
public EventPriority getRespawnPriority()
{
String priority = config.getString("respawn-listener-priority", "normal").toLowerCase(Locale.ENGLISH);
if ("lowest".equals(priority))
{
return EventPriority.LOWEST;
}
if ("low".equals(priority))
{
return EventPriority.LOW;
}
if ("normal".equals(priority))
{
return EventPriority.NORMAL;
}
if ("high".equals(priority))
{
return EventPriority.HIGH;
}
if ("highest".equals(priority))
{
return EventPriority.HIGHEST;
}
return EventPriority.NORMAL;
}
@Override
public long getTpaAcceptCancellation()
{
return config.getLong("tpa-accept-cancellation", 0);
}
}

View File

@@ -1,87 +0,0 @@
package com.earth2me.essentials;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.World.Environment;
public class Spawn implements IConf {
private static final Logger logger = Logger.getLogger("Minecraft");
private final EssentialsConf config;
private final Server server;
public Spawn(Server server, File dataFolder) {
File configFile = new File(dataFolder, "spawn.yml");
this.server = server;
config = new EssentialsConf(configFile);
config.load();
}
public void setSpawn(Location loc, String group) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("world", loc.getWorld().getName());
map.put("x", loc.getX());
map.put("y", loc.getY());
map.put("z", loc.getZ());
map.put("yaw", loc.getYaw());
map.put("pitch", loc.getPitch());
config.setProperty(group, map);
config.save();
if ("default".equals(group)) {
loc.getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
}
}
public Location getSpawn(String group) {
if (config.getProperty(group) == null) {
group = "default";
}
if (config.getProperty(group) == null) {
for (World w : server.getWorlds()) {
if (w.getEnvironment() != Environment.NORMAL) {
continue;
}
return w.getSpawnLocation();
}
}
String worldId = config.getString(group + ".world", "");
World world = server.getWorlds().get(server.getWorlds().size() > 1 ? 1 : 0);
for (World w : server.getWorlds()) {
if (w.getEnvironment() != Environment.NORMAL) {
continue;
}
world = w;
break;
}
for (World w : server.getWorlds()) {
if (!w.getName().equals(worldId)) {
continue;
}
world = w;
break;
}
double x = config.getDouble(group + ".x", config.getDouble("default.x", 0));
double y = config.getDouble(group + ".y", config.getDouble("default.y", 0));
double z = config.getDouble(group + ".z", config.getDouble("default.z", 0));
float yaw = (float) config.getDouble(group + ".yaw", config.getDouble("default.yaw", 0));
float pitch = (float) config.getDouble(group + ".pitch", config.getDouble("default.pitch", 0));
Location retval = new Location(world, x, y, z, yaw, pitch);
if (y < 1) {
retval.setY(world.getHighestBlockYAt(retval));
}
return retval;
}
public void reloadConfig() {
config.load();
}
}

View File

@@ -1,29 +1,22 @@
package com.earth2me.essentials;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.minecraft.server.ChunkPosition;
import net.minecraft.server.Packet60Explosion;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import com.earth2me.essentials.craftbukkit.FakeExplosion;
import org.bukkit.entity.LivingEntity;
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.EntityExplodeEvent;
import org.bukkit.event.entity.EntityListener;
public class TNTExplodeListener extends EntityListener implements Runnable
public class TNTExplodeListener implements Listener, Runnable
{
private final IEssentials ess;
private boolean enabled = false;
private int timer = -1;
private final transient IEssentials ess;
private transient boolean enabled = false;
private transient int timer = -1;
public TNTExplodeListener(IEssentials ess)
public TNTExplodeListener(final IEssentials ess)
{
super();
this.ess = ess;
}
@@ -35,13 +28,14 @@ public class TNTExplodeListener extends EntityListener implements Runnable
timer = ess.scheduleSyncDelayedTask(this, 1000);
return;
}
if (timer != -1) {
if (timer != -1)
{
ess.getScheduler().cancelTask(timer);
timer = ess.scheduleSyncDelayedTask(this, 1000);
}
}
@Override
@EventHandler(priority = EventPriority.LOW)
public void onEntityExplode(final EntityExplodeEvent event)
{
if (!enabled)
@@ -52,29 +46,11 @@ public class TNTExplodeListener extends EntityListener implements Runnable
{
return;
}
final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
final Player[] players = ess.getServer().getOnlinePlayers();
final List<ChunkPosition> blocksUnderPlayers = new ArrayList<ChunkPosition>(players.length);
final Location loc = event.getLocation();
for (Player player : players)
{
if (player.getWorld().equals(loc.getWorld()))
{
blocksUnderPlayers.add(new ChunkPosition(player.getLocation().getBlockX(), player.getLocation().getBlockY() - 1, player.getLocation().getBlockZ()));
}
}
for (Block block : event.blockList())
{
final ChunkPosition cp = new ChunkPosition(block.getX(), block.getY(), block.getZ());
if (!blocksUnderPlayers.contains(cp))
{
set.add(cp);
}
}
((CraftServer)ess.getServer()).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0F, set));
FakeExplosion.createExplosion(event, ess.getServer(), ess.getServer().getOnlinePlayers());
event.setCancelled(true);
}
@Override
public void run()
{
enabled = false;

View File

@@ -1,526 +0,0 @@
package com.earth2me.essentials;
import java.util.List;
import org.bukkit.block.Block;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
/**
* Original authors: toi & Raphfrk
*/
public class TargetBlock
{
private transient final Location location;
private transient final double viewHeight;
private transient final int maxDistance;
private transient final int[] blockToIgnore;
private transient final double checkDistance;
private transient double curDistance;
private transient double targetPositionX;
private transient double targetPositionY;
private transient double targetPositionZ;
private transient int itargetPositionX;
private transient int itargetPositionY;
private transient int itargetPositionZ;
private transient int prevPositionX;
private transient int prevPositionY;
private transient int prevPositionZ;
private transient final double offsetX;
private transient final double offsetY;
private transient final double offsetZ;
/**
* Constructor requiring a player, uses default values
*
* @param player Player to work with
*/
public TargetBlock(final Player player)
{
this(player.getLocation(), 300, 1.65, 0.2, null);
}
/**
* Constructor requiring a location, uses default values
*
* @param loc Location to work with
*/
public TargetBlock(final Location loc)
{
this(loc, 300, 0, 0.2, null);
}
/**
* Constructor requiring a player, max distance and a checking distance
*
* @param player Player to work with
* @param maxDistance How far it checks for blocks
* @param checkDistance How often to check for blocks, the smaller the more precise
*/
public TargetBlock(final Player player, final int maxDistance, final double checkDistance)
{
this(player.getLocation(), maxDistance, 1.65, checkDistance, null);
}
/**
* Constructor requiring a location, max distance and a checking distance
*
* @param loc What location to work with
* @param maxDistance How far it checks for blocks
* @param checkDistance How often to check for blocks, the smaller the more precise
*/
public TargetBlock(final Location loc, final int maxDistance, final double checkDistance)
{
this(loc, maxDistance, 0, checkDistance, null);
}
/**
* Constructor requiring a player, max distance, checking distance and an array of blocks to ignore
*
* @param player What player to work with
* @param maxDistance How far it checks for blocks
* @param checkDistance How often to check for blocks, the smaller the more precise
* @param blocksToIgnore Integer array of what block ids to ignore while checking for viable targets
*/
public TargetBlock(final Player player, final int maxDistance, final double checkDistance, final int[] blocksToIgnore)
{
this(player.getLocation(), maxDistance, 1.65, checkDistance, blocksToIgnore);
}
/**
* Constructor requiring a location, max distance, checking distance and an array of blocks to ignore
*
* @param loc What location to work with
* @param maxDistance How far it checks for blocks
* @param checkDistance How often to check for blocks, the smaller the more precise
* @param blocksToIgnore Array of what block ids to ignore while checking for viable targets
*/
public TargetBlock(final Location loc, final int maxDistance, final double checkDistance, final int[] blocksToIgnore)
{
this(loc, maxDistance, 0, checkDistance, blocksToIgnore);
}
/**
* Constructor requiring a player, max distance, checking distance and an array of blocks to ignore
*
* @param player What player to work with
* @param maxDistance How far it checks for blocks
* @param checkDistance How often to check for blocks, the smaller the more precise
* @param blocksToIgnore String ArrayList of what block ids to ignore while checking for viable targets
*/
public TargetBlock(final Player player, final int maxDistance, final double checkDistance, final List<String> blocksToIgnore)
{
this(player.getLocation(), maxDistance, 1.65, checkDistance, TargetBlock.convertStringArraytoIntArray(blocksToIgnore));
}
/**
* Constructor requiring a location, max distance, checking distance and an array of blocks to ignore
*
* @param loc What location to work with
* @param maxDistance How far it checks for blocks
* @param checkDistance How often to check for blocks, the smaller the more precise
* @param blocksToIgnore String ArrayList of what block ids to ignore while checking for viable targets
*/
public TargetBlock(final Location loc, final int maxDistance, final double checkDistance, final List<String> blocksToIgnore)
{
this(loc, maxDistance, 0, checkDistance, TargetBlock.convertStringArraytoIntArray(blocksToIgnore));
}
/**
* Set the values, all constructors uses this function
*
* @param loc Location of the view
* @param maxDistance How far it checks for blocks
* @param viewPos Where the view is positioned in y-axis
* @param checkDistance How often to check for blocks, the smaller the more precise
* @param blocksToIgnore Ids of blocks to ignore while checking for viable targets
*/
private TargetBlock(final Location loc, final int maxDistance, final double viewHeight, final double checkDistance, final int[] blocksToIgnore)
{
this.location = loc;
this.maxDistance = maxDistance;
this.viewHeight = viewHeight;
this.checkDistance = checkDistance;
if (blocksToIgnore == null || blocksToIgnore.length == 0)
{
this.blockToIgnore = new int[0];
}
else
{
this.blockToIgnore = new int[blocksToIgnore.length];
System.arraycopy(blocksToIgnore, 0, this.blockToIgnore, 0, this.blockToIgnore.length);
}
final double xRotation = (loc.getYaw() + 90) % 360;
final double yRotation = loc.getPitch() * -1;
final double hypotenuse = (checkDistance * Math.cos(Math.toRadians(yRotation)));
offsetX = hypotenuse * Math.cos(Math.toRadians(xRotation));
offsetY = checkDistance * Math.sin(Math.toRadians(yRotation));
offsetZ = hypotenuse * Math.sin(Math.toRadians(xRotation));
reset();
}
/**
* Call this to reset checking position to allow you to check for a new target with the same TargetBlock instance.
*/
public final void reset()
{
targetPositionX = location.getX();
targetPositionY = location.getY() + viewHeight;
targetPositionZ = location.getZ();
itargetPositionX = (int)Math.floor(targetPositionX);
itargetPositionY = (int)Math.floor(targetPositionY);
itargetPositionZ = (int)Math.floor(targetPositionZ);
prevPositionX = itargetPositionX;
prevPositionY = itargetPositionY;
prevPositionZ = itargetPositionZ;
this.curDistance = 0;
}
/**
* Gets the distance to a block. Measures from the block underneath the player to the targetblock
* Should only be used when passing player as an constructor parameter
*
* @return double
*/
public double getDistanceToBlock()
{
final double blockUnderPlayerX = Math.floor(location.getX() + 0.5);
final double blockUnderPlayerY = Math.floor(location.getY() - 0.5);
final double blockUnderPlayerZ = Math.floor(location.getZ() + 0.5);
final Block block = getTargetBlock();
final double distX = block.getX() - blockUnderPlayerX;
final double distY = block.getY() - blockUnderPlayerY;
final double distZ = block.getZ() - blockUnderPlayerZ;
return Math.sqrt(distX*distX + distY*distY + distZ*distZ);
}
/**
* Gets the rounded distance to a block. Measures from the block underneath the player to the targetblock
* Should only be used when passing player as an constructor parameter
*
* @return int
*/
public int getDistanceToBlockRounded()
{
return (int)Math.round(getDistanceToBlock());
}
/**
* Gets the floored x distance to a block.
*
* @return int
*/
public int getXDistanceToBlock()
{
return (int)Math.floor(getTargetBlock().getX() - location.getBlockX() + 0.5);
}
/**
* Gets the floored y distance to a block
*
* @return int
*/
public int getYDistanceToBlock()
{
return (int)Math.floor(getTargetBlock().getY() - location.getBlockY() + viewHeight);
}
/**
* Gets the floored z distance to a block
*
* @return int
*/
public int getZDistanceToBlock()
{
return (int)Math.floor(getTargetBlock().getZ() - location.getBlockZ() + 0.5);
}
/**
* Returns the block at the sight. Returns null if out of range or if no viable target was found
*
* @return Block
*/
public Block getTargetBlock()
{
this.reset();
Block block;
do
{
block = getNextBlock();
}
while (block != null && ((block.getTypeId() == 0) || this.blockIsIgnored(block.getTypeId())));
return block;
}
/**
* Sets the type of the block at the sight. Returns false if the block wasn't set.
*
* @param typeID ID of type to set the block to
* @return boolean
*/
public boolean setTargetBlock(final int typeID)
{
return setTargetBlock(Material.getMaterial(typeID));
}
/**
* Sets the type of the block at the sight. Returns false if the block wasn't set.
*
* @param type Material to set the block to
* @return boolean
*/
@SuppressWarnings("empty-statement")
public boolean setTargetBlock(final Material type)
{
if (type == null)
{
return false;
}
final Block block = getTargetBlock();
if (block != null)
{
block.setType(type);
return true;
}
return false;
}
/**
* Sets the type of the block at the sight. Returns false if the block wasn't set.
* Observe! At the moment this function is using the built-in enumerator function .valueOf(String) but would preferably be changed to smarter function, when implemented
*
* @param type Name of type to set the block to
* @return boolean
*/
public boolean setTargetBlock(final String type)
{
return setTargetBlock(Material.valueOf(type));
}
/**
* Returns the block attached to the face at the sight. Returns null if out of range or if no viable target was found
*
* @return Block
*/
public Block getFaceBlock()
{
final Block block = getTargetBlock();
if (block == null)
{
return null;
}
return getPreviousBlock();
}
/**
* Sets the type of the block attached to the face at the sight. Returns false if the block wasn't set.
*
* @param typeID
* @return boolean
*/
public boolean setFaceBlock(final int typeID)
{
return setFaceBlock(Material.getMaterial(typeID));
}
/**
* Sets the type of the block attached to the face at the sight. Returns false if the block wasn't set.
*
* @param type
* @return boolean
*/
public boolean setFaceBlock(final Material type)
{
if (type == null)
{
return false;
}
if (getCurrentBlock() != null)
{
final Block blk = location.getWorld().getBlockAt(prevPositionX, prevPositionY, prevPositionZ);
blk.setType(type);
return true;
}
return false;
}
/**
* Sets the type of the block attached to the face at the sight. Returns false if the block wasn't set.
* Observe! At the moment this function is using the built-in enumerator function .valueOf(String) but would preferably be changed to smarter function, when implemented
*
* @param type
* @return boolean
*/
public boolean setFaceBlock(final String type)
{
return setFaceBlock(Material.valueOf(type));
}
/**
* Get next block
*
* @return Block
*/
public Block getNextBlock()
{
prevPositionX = itargetPositionX;
prevPositionY = itargetPositionY;
prevPositionZ = itargetPositionZ;
do
{
curDistance += checkDistance;
targetPositionX += offsetX;
targetPositionY += offsetY;
targetPositionZ += offsetZ;
itargetPositionX = (int)Math.floor(targetPositionX);
itargetPositionY = (int)Math.floor(targetPositionY);
itargetPositionZ = (int)Math.floor(targetPositionZ);
}
while (curDistance <= maxDistance && itargetPositionX == prevPositionX && itargetPositionY == prevPositionY && itargetPositionZ == prevPositionZ);
if (curDistance > maxDistance)
{
return null;
}
return this.location.getWorld().getBlockAt(itargetPositionX, itargetPositionY, itargetPositionZ);
}
/**
* Returns the current block along the line of vision
*
* @return Block
*/
public Block getCurrentBlock()
{
Block block;
if (curDistance <= maxDistance)
{
block = this.location.getWorld().getBlockAt(itargetPositionX, itargetPositionY, itargetPositionZ);
}
else
{
block = null;
}
return block;
}
/**
* Sets current block type. Returns false if the block wasn't set.
*
* @param typeID
*/
public boolean setCurrentBlock(final int typeID)
{
return setCurrentBlock(Material.getMaterial(typeID));
}
/**
* Sets current block type. Returns false if the block wasn't set.
*
* @param type
*/
public boolean setCurrentBlock(final Material type)
{
final Block blk = getCurrentBlock();
if (blk != null && type != null)
{
blk.setType(type);
return true;
}
return false;
}
/**
* Sets current block type. Returns false if the block wasn't set.
* Observe! At the moment this function is using the built-in enumerator function .valueOf(String) but would preferably be changed to smarter function, when implemented
*
* @param type
*/
public boolean setCurrentBlock(final String type)
{
return setCurrentBlock(Material.valueOf(type));
}
/**
* Returns the previous block in the aimed path
*
* @return Block
*/
public Block getPreviousBlock()
{
return this.location.getWorld().getBlockAt(prevPositionX, prevPositionY, prevPositionZ);
}
/**
* Sets previous block type id. Returns false if the block wasn't set.
*
* @param typeID
*/
public boolean setPreviousBlock(final int typeID)
{
return setPreviousBlock(Material.getMaterial(typeID));
}
/**
* Sets previous block type id. Returns false if the block wasn't set.
*
* @param type
*/
public boolean setPreviousBlock(final Material type)
{
final Block blk = getPreviousBlock();
if (blk != null && type != null)
{
blk.setType(type);
return true;
}
return false;
}
/**
* Sets previous block type id. Returns false if the block wasn't set.
* Observe! At the moment this function is using the built-in enumerator function .valueOf(String) but would preferably be changed to smarter function, when implemented
*
* @param type
*/
public boolean setPreviousBlock(final String type)
{
return setPreviousBlock(Material.valueOf(type));
}
private static int[] convertStringArraytoIntArray(final List<String> array)
{
final int intarray[] = new int[array == null ? 0 : array.size()];
for (int i = 0; i < intarray.length; i++)
{
try
{
intarray[i] = Integer.parseInt(array.get(i));
}
catch (NumberFormatException nfe)
{
}
}
return intarray;
}
private boolean blockIsIgnored(final int value)
{
for (int i : this.blockToIgnore)
{
if (i == value)
{
return true;
}
}
return false;
}
}

View File

@@ -1,15 +1,23 @@
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;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Teleport implements Runnable
public class Teleport implements Runnable, ITeleport
{
private static final double MOVE_CONSTANT = 0.3;
private static class Target
{
private final Location location;
@@ -51,19 +59,22 @@ public class Teleport implements Runnable
private Trade chargeFor;
private final IEssentials ess;
private static final Logger logger = Logger.getLogger("Minecraft");
private TeleportCause cause;
private void initTimer(long delay, Target target, Trade chargeFor)
private void initTimer(long delay, Target target, Trade chargeFor, TeleportCause cause)
{
this.started = System.currentTimeMillis();
this.delay = delay;
this.health = user.getHealth();
this.initX = Math.round(user.getLocation().getX()*MOVE_CONSTANT);
this.initY = Math.round(user.getLocation().getY()*MOVE_CONSTANT);
this.initZ = Math.round(user.getLocation().getZ()*MOVE_CONSTANT);
this.initX = Math.round(user.getLocation().getX() * MOVE_CONSTANT);
this.initY = Math.round(user.getLocation().getY() * MOVE_CONSTANT);
this.initZ = Math.round(user.getLocation().getZ() * MOVE_CONSTANT);
this.teleportTarget = target;
this.chargeFor = chargeFor;
this.cause = cause;
}
@Override
public void run()
{
@@ -72,9 +83,9 @@ public class Teleport implements Runnable
cancel();
return;
}
if (Math.round(user.getLocation().getX()*MOVE_CONSTANT) != initX
|| Math.round(user.getLocation().getY()*MOVE_CONSTANT) != initY
|| Math.round(user.getLocation().getZ()*MOVE_CONSTANT) != initZ
if (Math.round(user.getLocation().getX() * MOVE_CONSTANT) != initX
|| Math.round(user.getLocation().getY() * MOVE_CONSTANT) != initY
|| Math.round(user.getLocation().getZ() * MOVE_CONSTANT) != initZ
|| user.getHealth() < health)
{ // user moved, cancel teleport
cancel(true);
@@ -89,11 +100,11 @@ public class Teleport implements Runnable
try
{
cooldown(false);
user.sendMessage(Util.i18n("teleportationCommencing"));
user.sendMessage(_("teleportationCommencing"));
try
{
now(teleportTarget);
now(teleportTarget, cause);
if (chargeFor != null)
{
chargeFor.charge(user);
@@ -103,11 +114,10 @@ public class Teleport implements Runnable
{
ess.showError(user.getBase(), ex, "teleport");
}
return;
}
catch (Exception ex)
{
user.sendMessage(Util.format("cooldownWithMessage", ex.getMessage()));
user.sendMessage(_("cooldownWithMessage", ex.getMessage()));
}
}
}
@@ -118,16 +128,20 @@ public class Teleport implements Runnable
this.ess = ess;
}
public void respawn(Spawn spawn, Trade chargeFor) throws Exception
public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception
{
teleport(new Target(spawn.getSpawn(user.getGroup())), chargeFor);
final Player player = user.getBase();
final Location bed = player.getBedSpawnLocation();
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, bed == null ? player.getWorld().getSpawnLocation() : bed, bed != null);
ess.getServer().getPluginManager().callEvent(pre);
teleport(new Target(pre.getRespawnLocation()), chargeFor, cause);
}
public void warp(String warp, Trade chargeFor) throws Exception
public void warp(String warp, Trade chargeFor, TeleportCause cause) throws Exception
{
Location loc = ess.getWarps().getWarp(warp);
teleport(new Target(loc), chargeFor);
user.sendMessage(Util.format("warpingTo", warp));
teleport(new Target(loc), chargeFor, cause);
user.sendMessage(_("warpingTo", warp));
}
public void cooldown(boolean check) throws Exception
@@ -142,7 +156,7 @@ public class Teleport implements Runnable
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
if (cooldownTime.after(now) && !user.isAuthorized("essentials.teleport.cooldown.bypass"))
{
throw new Exception(Util.format("timeBeforeTeleport", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
throw new Exception(_("timeBeforeTeleport", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
}
}
// if justCheck is set, don't update lastTeleport; we're just checking
@@ -163,7 +177,7 @@ public class Teleport implements Runnable
ess.getServer().getScheduler().cancelTask(teleTimer);
if (notifyUser)
{
user.sendMessage(Util.i18n("pendingTeleportCancelled"));
user.sendMessage(_("pendingTeleportCancelled"));
}
}
finally
@@ -176,18 +190,23 @@ public class Teleport implements Runnable
{
cancel(false);
}
public void teleport(Location loc, Trade chargeFor) throws Exception
{
teleport(new Target(loc), chargeFor);
teleport(new Target(loc), chargeFor, TeleportCause.PLUGIN);
}
public void teleport(Entity entity, Trade chargeFor) throws Exception
public void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
{
teleport(new Target(entity), chargeFor);
teleport(new Target(loc), chargeFor, cause);
}
private void teleport(Target target, Trade chargeFor) throws Exception
public void teleport(Entity entity, Trade chargeFor, TeleportCause cause) throws Exception
{
teleport(new Target(entity), chargeFor, cause);
}
private void teleport(Target target, Trade chargeFor, TeleportCause cause) throws Exception
{
double delay = ess.getSettings().getTeleportDelay();
@@ -199,7 +218,7 @@ public class Teleport implements Runnable
if (delay <= 0 || user.isAuthorized("essentials.teleport.timer.bypass"))
{
cooldown(false);
now(target);
now(target, cause);
if (chargeFor != null)
{
chargeFor.charge(user);
@@ -211,70 +230,61 @@ public class Teleport implements Runnable
Calendar c = new GregorianCalendar();
c.add(Calendar.SECOND, (int)delay);
c.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
user.sendMessage(Util.format("dontMoveMessage", Util.formatDateDiff(c.getTimeInMillis())));
initTimer((long)(delay * 1000.0), target, chargeFor);
user.sendMessage(_("dontMoveMessage", Util.formatDateDiff(c.getTimeInMillis())));
initTimer((long)(delay * 1000.0), target, chargeFor, cause);
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
}
private void now(Target target) throws Exception
private void now(Target target, TeleportCause cause) throws Exception
{
cancel();
user.setLastLocation();
user.getBase().teleport(Util.getSafeDestination(target.getLocation()));
user.getBase().teleport(Util.getSafeDestination(target.getLocation()), cause);
}
public void now(Location loc) throws Exception
{
cooldown(false);
now(new Target(loc));
}
public void now(Location loc, Trade chargeFor) throws Exception
{
cooldown(false);
chargeFor.charge(user);
now(new Target(loc));
}
public void now(Entity entity, boolean cooldown) throws Exception
public void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception
{
if (cooldown)
{
cooldown(false);
}
now(new Target(entity));
now(new Target(loc), cause);
}
public void now(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
{
cooldown(false);
chargeFor.charge(user);
now(new Target(loc), cause);
}
public void now(Entity entity, boolean cooldown, TeleportCause cause) throws Exception
{
if (cooldown)
{
cooldown(false);
}
now(new Target(entity), cause);
}
public void back(Trade chargeFor) throws Exception
{
teleport(new Target(user.getLastLocation()), chargeFor);
teleport(new Target(user.getLastLocation()), chargeFor, TeleportCause.COMMAND);
}
public void back() throws Exception
{
back(null);
now(new Target(user.getLastLocation()), TeleportCause.COMMAND);
}
public void home(Trade chargeFor) throws Exception
public void home(IUser user, String home, Trade chargeFor) throws Exception
{
home(user, chargeFor);
}
public void home(IUser user, Trade chargeFor) throws Exception
{
Location loc = user.getHome(this.user.getLocation());
final Location loc = user.getHome(home);
if (loc == null)
{
if (ess.getSettings().spawnIfNoHome())
{
respawn(ess.getSpawn(), chargeFor);
}
else
{
throw new Exception(user == this.user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer"));
}
throw new NotEnoughArgumentsException();
}
teleport(new Target(loc), chargeFor);
teleport(new Target(loc), chargeFor, TeleportCause.COMMAND);
}
}

View File

@@ -1,10 +1,14 @@
package com.earth2me.essentials;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import com.earth2me.essentials.craftbukkit.SetExpFix;
import static com.earth2me.essentials.I18n._;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -17,28 +21,35 @@ public class Trade
private final transient String command;
private final transient Double money;
private final transient ItemStack itemStack;
private final transient Integer exp;
private final transient IEssentials ess;
public Trade(final String command, final IEssentials ess)
{
this(command, null, null, ess);
this(command, null, null, null, ess);
}
public Trade(final double money, final IEssentials ess)
{
this(null, money, null, ess);
this(null, money, null, null, ess);
}
public Trade(final ItemStack items, final IEssentials ess)
{
this(null, null, items, ess);
this(null, null, items, null, ess);
}
public Trade(final int exp, final IEssentials ess)
{
this(null, null, null, exp, ess);
}
private Trade(final String command, final Double money, final ItemStack item, final IEssentials ess)
private Trade(final String command, final Double money, final ItemStack item, final Integer exp, final IEssentials ess)
{
this.command = command;
this.money = money;
this.itemStack = item;
this.exp = exp;
this.ess = ess;
}
@@ -50,13 +61,13 @@ public class Trade
&& getMoney() > 0
&& !user.isAuthorized("essentials.eco.loan"))
{
throw new ChargeException(Util.i18n("notEnoughMoney"));
throw new ChargeException(_("notEnoughMoney"));
}
if (getItemStack() != null
&& !InventoryWorkaround.containsItem(user.getInventory(), true, itemStack))
&& !InventoryWorkaround.containsItem(user.getInventory(), true, true, itemStack))
{
throw new ChargeException(Util.format("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase().replace("_", " ")));
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
}
if (command != null && !command.isEmpty()
@@ -66,25 +77,48 @@ public class Trade
&& 0 < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
&& !user.isAuthorized("essentials.eco.loan"))
{
throw new ChargeException(Util.i18n("notEnoughMoney"));
throw new ChargeException(_("notEnoughMoney"));
}
if (exp != null && exp > 0
&& SetExpFix.getTotalExperience(user) < exp) {
throw new ChargeException(_("notEnoughExperience"));
}
}
public void pay(final IUser user)
{
pay(user, true);
}
public boolean pay(final IUser user, final boolean dropItems)
{
boolean success = true;
if (getMoney() != null && getMoney() > 0)
{
user.giveMoney(getMoney());
}
if (getItemStack() != null)
{
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
for (ItemStack itemStack : leftOver.values())
if (dropItems)
{
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
for (ItemStack itemStack : leftOver.values())
{
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
}
}
else
{
success = InventoryWorkaround.addAllItems(user.getInventory(), true, getItemStack());
}
user.updateInventory();
}
if (getExperience() != null)
{
SetExpFix.setTotalExperience(user, SetExpFix.getTotalExperience(user) + getExperience());
}
return success;
}
public void charge(final IUser user) throws ChargeException
@@ -94,17 +128,17 @@ public class Trade
final double mon = user.getMoney();
if (mon < getMoney() && getMoney() > 0 && !user.isAuthorized("essentials.eco.loan"))
{
throw new ChargeException(Util.i18n("notEnoughMoney"));
throw new ChargeException(_("notEnoughMoney"));
}
user.takeMoney(getMoney());
}
if (getItemStack() != null)
{
if (!InventoryWorkaround.containsItem(user.getInventory(), true, itemStack))
if (!InventoryWorkaround.containsItem(user.getInventory(), true, true, itemStack))
{
throw new ChargeException(Util.format("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase().replace("_", " ")));
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
}
InventoryWorkaround.removeItem(user.getInventory(), true, getItemStack());
InventoryWorkaround.removeItem(user.getInventory(), true, true, getItemStack());
user.updateInventory();
}
if (command != null && !command.isEmpty()
@@ -115,10 +149,19 @@ public class Trade
final double cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
if (mon < cost && cost > 0 && !user.isAuthorized("essentials.eco.loan"))
{
throw new ChargeException(Util.i18n("notEnoughMoney"));
throw new ChargeException(_("notEnoughMoney"));
}
user.takeMoney(cost);
}
if (getExperience() != null)
{
final int experience = SetExpFix.getTotalExperience(user);
if (experience < getExperience() && getExperience() > 0)
{
throw new ChargeException(_("notEnoughExperience"));
}
SetExpFix.setTotalExperience(user, experience - getExperience());
}
}
public Double getMoney()
@@ -130,6 +173,11 @@ public class Trade
{
return itemStack;
}
public Integer getExperience()
{
return exp;
}
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)
@@ -176,6 +224,12 @@ public class Trade
sb.append("money").append(",");
sb.append(ess.getSettings().getCurrencySymbol());
}
if (charge.getExperience() != null)
{
sb.append(charge.getExperience()).append(",");
sb.append("exp").append(",");
sb.append("\"\"");
}
}
sb.append(",\"");
if (receiver != null)
@@ -201,6 +255,12 @@ public class Trade
sb.append("money").append(",");
sb.append(ess.getSettings().getCurrencySymbol());
}
if (pay.getExperience() != null)
{
sb.append(pay.getExperience()).append(",");
sb.append("exp").append(",");
sb.append("\"\"");
}
}
if (loc == null)
{
@@ -228,7 +288,8 @@ public class Trade
public static void closeLog()
{
if (fw != null) {
if (fw != null)
{
try
{
fw.close();

View File

@@ -1,50 +1,67 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.register.payment.Method;
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;
public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
private static final Logger logger = Logger.getLogger("Minecraft");
private boolean justPortaled = false;
private CommandSender replyTo = null;
private User teleportRequester;
private boolean teleportRequestHere;
private final Teleport teleport;
private long lastActivity;
private transient User teleportRequester;
private transient boolean teleportRequestHere;
private transient final Teleport teleport;
private transient long teleportRequestTime;
private transient long lastOnlineActivity;
private transient long lastActivity = System.currentTimeMillis();
private boolean hidden = false;
private transient Location afkPosition = null;
private static final Logger logger = Logger.getLogger("Minecraft");
User(Player base, IEssentials ess)
User(final Player base, final IEssentials ess)
{
super(base, ess);
teleport = new Teleport(this, ess);
if (isAfk())
{
afkPosition = getLocation();
}
}
User update(Player base)
User update(final Player base)
{
setBase(base);
return this;
}
public boolean isAuthorized(IEssentialsCommand cmd)
@Override
public boolean isAuthorized(final IEssentialsCommand cmd)
{
return isAuthorized(cmd, "essentials.");
}
public boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix)
@Override
public boolean isAuthorized(final IEssentialsCommand cmd, final String permissionPrefix)
{
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
}
public boolean isAuthorized(String node)
@Override
public boolean isAuthorized(final String node)
{
if (base instanceof OfflinePlayer)
{
return false;
}
if (isOp())
{
return true;
@@ -55,87 +72,89 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return false;
}
return ess.getPermissionsHandler().hasPermission(this, node);
return ess.getPermissionsHandler().hasPermission(base, node);
}
public void healCooldown() throws Exception
{
Calendar now = new GregorianCalendar();
final Calendar now = new GregorianCalendar();
if (getLastHealTimestamp() > 0)
{
double cooldown = ess.getSettings().getHealCooldown();
Calendar cooldownTime = new GregorianCalendar();
final double cooldown = ess.getSettings().getHealCooldown();
final Calendar cooldownTime = new GregorianCalendar();
cooldownTime.setTimeInMillis(getLastHealTimestamp());
cooldownTime.add(Calendar.SECOND, (int)cooldown);
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
if (cooldownTime.after(now) && !isAuthorized("essentials.heal.cooldown.bypass"))
{
throw new Exception(Util.format("timeBeforeHeal", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
throw new Exception(_("timeBeforeHeal", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
}
}
setLastHealTimestamp(now.getTimeInMillis());
}
public void giveMoney(double value)
@Override
public void giveMoney(final double value)
{
giveMoney(value, null);
}
public void giveMoney(double value, CommandSender initiator)
public void giveMoney(final double value, final CommandSender initiator)
{
if (value == 0)
{
return;
}
setMoney(getMoney() + value);
sendMessage(Util.format("addedToAccount", Util.formatCurrency(value, ess)));
sendMessage(_("addedToAccount", Util.formatCurrency(value, ess)));
if (initiator != null)
{
initiator.sendMessage((Util.format("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())));
initiator.sendMessage(_("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
}
}
public void payUser(User reciever, double value) throws Exception
public void payUser(final User reciever, final double value) throws Exception
{
if (value == 0)
{
return;
}
if (!canAfford(value))
{
throw new Exception(Util.i18n("notEnoughMoney"));
}
else
if (canAfford(value))
{
setMoney(getMoney() - value);
reciever.setMoney(reciever.getMoney() + value);
sendMessage(Util.format("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
sendMessage(_("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
reciever.sendMessage(_("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
}
else
{
throw new Exception(_("notEnoughMoney"));
}
}
public void takeMoney(double value)
@Override
public void takeMoney(final double value)
{
takeMoney(value, null);
}
public void takeMoney(double value, CommandSender initiator)
public void takeMoney(final double value, final CommandSender initiator)
{
if (value == 0)
{
return;
}
setMoney(getMoney() - value);
sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value, ess)));
sendMessage(_("takenFromAccount", Util.formatCurrency(value, ess)));
if (initiator != null)
{
initiator.sendMessage((Util.format("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())));
initiator.sendMessage(_("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
}
}
public boolean canAfford(double cost)
public boolean canAfford(final double cost)
{
double mon = getMoney();
final double mon = getMoney();
return mon >= cost || isAuthorized("essentials.eco.loan");
}
@@ -144,70 +163,70 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
this.base = new OfflinePlayer(getName(), ess);
}
public boolean getJustPortaled()
{
return justPortaled;
}
public void setJustPortaled(boolean value)
{
justPortaled = value;
}
public void setReplyTo(CommandSender user)
@Override
public void setReplyTo(final CommandSender user)
{
replyTo = user;
}
@Override
public CommandSender getReplyTo()
{
return replyTo;
}
public int compareTo(User t)
@Override
public int compareTo(final User other)
{
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(t.getDisplayName()));
return Util.stripColor(this.getDisplayName()).compareToIgnoreCase(Util.stripColor(other.getDisplayName()));
}
@Override
public boolean equals(Object o)
public boolean equals(final Object object)
{
if (!(o instanceof User))
if (!(object instanceof User))
{
return false;
}
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)o).getDisplayName()));
return this.getName().equalsIgnoreCase(((User)object).getName());
}
@Override
public int hashCode()
{
return ChatColor.stripColor(this.getDisplayName()).hashCode();
return this.getName().hashCode();
}
public Boolean canSpawnItem(int itemId)
public Boolean canSpawnItem(final int itemId)
{
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
}
public Location getHome() throws Exception
{
return getHome(getHomes().get(0));
}
public void setHome()
{
setHome(getLocation(), true);
setHome("home", getLocation());
}
public void setHome(boolean defaultHome)
public void setHome(final String name)
{
setHome(getLocation(), defaultHome);
setHome(name, getLocation());
}
@Override
public void setLastLocation()
{
setLastLocation(getLocation());
}
public void requestTeleport(User player, boolean here)
public void requestTeleport(final User player, final boolean here)
{
teleportRequestTime = System.currentTimeMillis();
teleportRequester = player;
teleportRequestHere = here;
}
@@ -222,7 +241,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return teleportRequestHere;
}
public String getNick()
public String getNick(boolean addprefixsuffix)
{
final StringBuilder nickname = new StringBuilder();
final String nick = getNickname();
@@ -246,14 +265,23 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
}
if (ess.getSettings().addPrefixSuffix())
if (addprefixsuffix && ess.getSettings().addPrefixSuffix())
{
final String prefix = ess.getPermissionsHandler().getPrefix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
final String suffix = ess.getPermissionsHandler().getSuffix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
nickname.insert(0, prefix);
nickname.append(suffix);
if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
if (!ess.getSettings().disablePrefix())
{
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
nickname.insert(0, prefix);
}
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");
}
@@ -262,19 +290,51 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return nickname.toString();
}
public void setDisplayNick()
{
String name = getNick(true);
setDisplayName(name);
if (name.length() > 16)
{
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.");
}
}
@Override
public String getDisplayName()
{
if (!(base instanceof OfflinePlayer) && ess.getSettings().changeDisplayName())
{
setDisplayNick();
}
return super.getDisplayName() == null ? super.getName() : super.getDisplayName();
}
public Teleport getTeleport()
{
return teleport;
}
public long getLastActivity()
public long getLastOnlineActivity()
{
return lastActivity;
return lastOnlineActivity;
}
public void setLastActivity(long timestamp)
public void setLastOnlineActivity(final long timestamp)
{
lastActivity = timestamp;
lastOnlineActivity = timestamp;
}
@Override
@@ -284,12 +344,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
try
{
Method method = ess.getPaymentMethod().getMethod();
final Method method = ess.getPaymentMethod().getMethod();
if (!method.hasAccount(this.getName()))
{
throw new Exception();
}
Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
return account.balance();
}
catch (Throwable ex)
@@ -300,18 +360,18 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
@Override
public void setMoney(double value)
public void setMoney(final double value)
{
if (ess.getPaymentMethod().hasMethod())
{
try
{
Method method = ess.getPaymentMethod().getMethod();
final Method method = ess.getPaymentMethod().getMethod();
if (!method.hasAccount(this.getName()))
{
throw new Exception();
}
Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
account.set(value);
}
catch (Throwable ex)
@@ -322,27 +382,173 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
@Override
public void setAfk(boolean set)
public void setAfk(final boolean set)
{
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
if (set && !isAfk())
{
afkPosition = getLocation();
}
else if (!set && isAfk())
{
afkPosition = null;
}
super.setAfk(set);
}
@Override
public boolean toggleAfk()
{
boolean now = super.toggleAfk();
final boolean now = super.toggleAfk();
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now);
return now;
}
@Override
public boolean isHidden()
{
return hidden;
}
public void setHidden(boolean hidden)
public void setHidden(final boolean hidden)
{
this.hidden = hidden;
}
//Returns true if status expired during this check
public boolean checkJailTimeout(final long currentTime)
{
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
{
setJailTimeout(0);
setJailed(false);
sendMessage(_("haveBeenReleased"));
setJail(null);
try
{
getTeleport().back();
}
catch (Exception ex)
{
}
return true;
}
return false;
}
//Returns true if status expired during this check
public boolean checkMuteTimeout(final long currentTime)
{
if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
{
setMuteTimeout(0);
sendMessage(_("canTalkAgain"));
setMuted(false);
return true;
}
return false;
}
//Returns true if status expired during this check
public boolean checkBanTimeout(final long currentTime)
{
if (getBanTimeout() > 0 && getBanTimeout() < currentTime && isBanned())
{
setBanTimeout(0);
setBanned(false);
return true;
}
return false;
}
public void updateActivity(final boolean broadcast)
{
if (isAfk())
{
setAfk(false);
if (broadcast && !isHidden())
{
ess.broadcastMessage(this, _("userIsNotAway", getDisplayName()));
}
}
lastActivity = System.currentTimeMillis();
}
public void checkActivity()
{
final long autoafkkick = ess.getSettings().getAutoAfkKick();
if (autoafkkick > 0 && lastActivity > 0 && (lastActivity + (autoafkkick * 1000)) < System.currentTimeMillis()
&& !isHidden() && !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt"))
{
final String kickReason = _("autoAfkKickReason", autoafkkick / 60.0);
lastActivity = 0;
kickPlayer(kickReason);
for (Player player : ess.getServer().getOnlinePlayers())
{
final User user = ess.getUser(player);
if (user.isAuthorized("essentials.kick.notify"))
{
player.sendMessage(_("playerKicked", Console.NAME, getName(), kickReason));
}
}
}
final long autoafk = ess.getSettings().getAutoAfk();
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && isAuthorized("essentials.afk"))
{
setAfk(true);
if (!isHidden())
{
ess.broadcastMessage(this, _("userIsAway", getDisplayName()));
}
}
}
public Location getAfkPosition()
{
return afkPosition;
}
@Override
public boolean toggleGodModeEnabled()
{
if (!isGodModeEnabled())
{
setFoodLevel(20);
}
return super.toggleGodModeEnabled();
}
@Override
public boolean isGodModeEnabled()
{
return (super.isGodModeEnabled() && !ess.getSettings().getNoGodWorlds().contains(getLocation().getWorld().getName()))
|| (isAfk() && ess.getSettings().getFreezeAfkPlayers());
}
public boolean isGodModeEnabledRaw()
{
return super.isGodModeEnabled();
}
public String getGroup()
{
return ess.getPermissionsHandler().getGroup(base);
}
public boolean inGroup(final String group)
{
return ess.getPermissionsHandler().inGroup(base, group);
}
public boolean canBuild()
{
return ess.getPermissionsHandler().canBuild(base, getGroup());
}
public long getTeleportRequestTime()
{
return teleportRequestTime;
}
}

View File

@@ -1,27 +1,24 @@
package com.earth2me.essentials;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.*;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
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)
{
super(base, ess);
super(base);
this.ess = ess;
File folder = new File(ess.getDataFolder(), "userdata");
if (!folder.exists())
{
@@ -31,12 +28,14 @@ public abstract class UserData extends PlayerExtension implements IConf
reloadConfig();
}
@Override
public final void reloadConfig()
{
config.load();
money = _getMoney();
unlimited = _getUnlimited();
powertools = getPowertools();
powertools = _getPowertools();
homes = _getHomes();
lastLocation = _getLastLocation();
lastTeleportTimestamp = _getLastTeleportTimestamp();
lastHealTimestamp = _getLastHealTimestamp();
@@ -52,11 +51,13 @@ public abstract class UserData extends PlayerExtension implements IConf
jailTimeout = _getJailTimeout();
lastLogin = _getLastLogin();
lastLogout = _getLastLogout();
lastLoginAddress = _getLastLoginAddress();
afk = getAfk();
newplayer = getNew();
geolocation = _getGeoLocation();
isSocialSpyEnabled = _isSocialSpyEnabled();
isNPC = _isNPC();
arePowerToolsEnabled = _arePowerToolsEnabled();
kitTimestamps = _getKitTimestamps();
}
private double money;
@@ -89,6 +90,101 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("money", value);
config.save();
}
private Map<String, Object> homes;
private Map<String, Object> _getHomes()
{
Object o = config.getProperty("homes");
if (o instanceof Map)
{
return (Map<String, Object>)o;
}
else
{
return new HashMap<String, Object>();
}
}
public Location getHome(String name) throws Exception
{
Location loc = config.getLocation("homes." + name, getServer());
if (loc == null)
{
try
{
loc = config.getLocation("homes." + getHomes().get(Integer.parseInt(name) - 1), getServer());
}
catch (IndexOutOfBoundsException e)
{
return null;
}
catch (NumberFormatException e)
{
return null;
}
}
return loc;
}
public Location getHome(final Location world)
{
try
{
Location loc;
for (String home : getHomes())
{
loc = config.getLocation("homes." + home, getServer());
if (world.getWorld() == loc.getWorld())
{
return loc;
}
}
loc = config.getLocation("homes." + getHomes().get(0), getServer());
return loc;
}
catch (Exception ex)
{
return null;
}
}
public List<String> getHomes()
{
return new ArrayList(homes.keySet());
}
public void setHome(String name, Location loc)
{
//Invalid names will corrupt the yaml
name = Util.sanitizeFileName(name);
homes.put(name, loc);
config.setProperty("homes." + name, loc);
config.save();
}
public void delHome(String name) throws Exception
{
String search = name;
if (!homes.containsKey(search))
{
search = Util.sanitizeFileName(name);
}
if (homes.containsKey(search))
{
homes.remove(name);
config.removeProperty("homes." + name);
config.save();
}
else
{
//TODO: move this message to messages file
throw new Exception("Home " + name + " doesn't exist");
}
}
public boolean hasHome()
{
@@ -99,40 +195,6 @@ public abstract class UserData extends PlayerExtension implements IConf
return false;
}
public Location getHome(Location location)
{
if (!hasHome())
{
return null;
}
World world = location.getWorld();
String worldHome = "home.worlds." + world.getName().toLowerCase();
if (!config.hasProperty(worldHome))
{
String defaultWorld = config.getString("home.default");
worldHome = "home.worlds." + defaultWorld;
}
Location loc = config.getLocation(worldHome, getServer());
return loc;
}
public void setHome(Location loc, boolean b)
{
String worldName = loc.getWorld().getName().toLowerCase();
if (worldName == null || worldName.isEmpty())
{
logger.log(Level.WARNING, Util.i18n("emptyWorldName"));
return;
}
if (b || !config.hasProperty("home.default"))
{
config.setProperty("home.default", worldName);
}
config.setProperty("home.worlds." + worldName, loc);
config.save();
}
public String getNickname()
{
return config.getString("nickname");
@@ -173,46 +235,71 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("unlimited", unlimited);
config.save();
}
private Map<Integer, String> powertools;
private Map<Integer, Object> powertools;
@SuppressWarnings("unchecked")
private Map<Integer, String> getPowertools()
private Map<Integer, Object> _getPowertools()
{
Object o = config.getProperty("powertools");
if (o instanceof Map)
{
return (Map<Integer, String>)o;
return (Map<Integer, Object>)o;
}
else
{
return new HashMap<Integer, String>();
return new HashMap<Integer, Object>();
}
}
public String getPowertool(ItemStack stack)
public void clearAllPowertools()
{
return powertools.get(stack.getTypeId());
powertools.clear();
config.setProperty("powertools", powertools);
config.save();
}
public void setPowertool(ItemStack stack, String command)
public List<String> getPowertool(ItemStack stack)
{
if (command == null || command.isEmpty())
return (List<String>)powertools.get(stack.getTypeId());
}
public List<String> getPowertool(int id)
{
return (List<String>)powertools.get(id);
}
public void setPowertool(ItemStack stack, List<String> commandList)
{
if (commandList == null || commandList.isEmpty())
{
powertools.remove(stack.getTypeId());
}
else
{
powertools.put(stack.getTypeId(), command);
powertools.put(stack.getTypeId(), commandList);
}
config.setProperty("powertools", powertools);
config.save();
}
public boolean hasPowerTools()
{
return !powertools.isEmpty();
}
private Location lastLocation;
private Location _getLastLocation()
{
return config.getLocation("lastlocation", getServer());
try
{
return config.getLocation("lastlocation", getServer());
}
catch (Exception e)
{
return null;
}
}
public Location getLastLocation()
@@ -222,6 +309,10 @@ public abstract class UserData extends PlayerExtension implements IConf
public void setLastLocation(Location loc)
{
if (loc == null || loc.getWorld() == null)
{
return;
}
lastLocation = loc;
config.setProperty("lastlocation", loc);
config.save();
@@ -420,18 +511,18 @@ public abstract class UserData extends PlayerExtension implements IConf
public boolean isIgnoredPlayer(String name)
{
return ignoredPlayers.contains(name.toLowerCase());
return ignoredPlayers.contains(name.toLowerCase(Locale.ENGLISH));
}
public void setIgnoredPlayer(String name, boolean set)
{
if (set)
{
ignoredPlayers.add(name.toLowerCase());
ignoredPlayers.add(name.toLowerCase(Locale.ENGLISH));
}
else
{
ignoredPlayers.remove(name.toLowerCase());
ignoredPlayers.remove(name.toLowerCase(Locale.ENGLISH));
}
setIgnoredPlayers(ignoredPlayers);
}
@@ -604,6 +695,24 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("timestamps.logout", time);
config.save();
}
private String lastLoginAddress;
private String _getLastLoginAddress()
{
return config.getString("ipAddress", "");
}
public String getLastLoginAddress()
{
return lastLoginAddress;
}
public void setLastLoginAddress(String address)
{
lastLoginAddress = address;
config.setProperty("ipAddress", address);
config.save();
}
private boolean afk;
private boolean getAfk()
@@ -631,22 +740,6 @@ public abstract class UserData extends PlayerExtension implements IConf
}
private boolean newplayer;
private boolean getNew()
{
return config.getBoolean("newplayer", true);
}
public boolean isNew()
{
return newplayer;
}
public void setNew(boolean set)
{
newplayer = set;
config.setProperty("newplayer", set);
config.save();
}
private String geolocation;
private String _getGeoLocation()
@@ -709,4 +802,62 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("npc", set);
config.save();
}
private boolean arePowerToolsEnabled;
public boolean arePowerToolsEnabled()
{
return arePowerToolsEnabled;
}
public void setPowerToolsEnabled(boolean set)
{
arePowerToolsEnabled = set;
config.setProperty("powertoolsenabled", set);
config.save();
}
public boolean togglePowerToolsEnabled()
{
boolean ret = !arePowerToolsEnabled();
setPowerToolsEnabled(ret);
return ret;
}
private boolean _arePowerToolsEnabled()
{
return config.getBoolean("powertoolsenabled", true);
}
private Map<String, Object> kitTimestamps;
private Map<String, Object> _getKitTimestamps()
{
final Object map = config.getProperty("timestamps.kits");
if (map instanceof Map)
{
return (Map<String, Object>)map;
}
else
{
return new HashMap<String, Object>();
}
}
public Long getKitTimestamp(final String name)
{
final Number num = (Number)kitTimestamps.get(name.toLowerCase(Locale.ENGLISH));
return num == null ? null : num.longValue();
}
public void setKitTimestamp(final String name, final long time)
{
kitTimestamps.put(name.toLowerCase(Locale.ENGLISH), time);
config.setProperty("timestamps.kits", kitTimestamps);
config.save();
}
public void save()
{
config.save();
}
}

View File

@@ -0,0 +1,123 @@
package com.earth2me.essentials;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.util.concurrent.UncheckedExecutionException;
import java.io.File;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.ExecutionException;
import org.bukkit.entity.Player;
public class UserMap extends CacheLoader<String, User> implements IConf
{
private final transient IEssentials ess;
private final transient Cache<String, User> users = CacheBuilder.newBuilder().softValues().build(this);
private final transient ConcurrentSkipListSet<String> keys = new ConcurrentSkipListSet<String>();
public UserMap(final IEssentials ess)
{
super();
this.ess = ess;
loadAllUsersAsync(ess);
}
private void loadAllUsersAsync(final IEssentials ess)
{
ess.scheduleAsyncDelayedTask(new Runnable()
{
@Override
public void run()
{
final File userdir = new File(ess.getDataFolder(), "userdata");
if (!userdir.exists())
{
return;
}
keys.clear();
users.invalidateAll();
for (String string : userdir.list())
{
if (!string.endsWith(".yml"))
{
continue;
}
final String name = string.substring(0, string.length() - 4);
keys.add(Util.sanitizeFileName(name));
}
}
});
}
public boolean userExists(final String name)
{
return keys.contains(Util.sanitizeFileName(name));
}
public User getUser(final String name)
{
try
{
return users.get(Util.sanitizeFileName(name));
}
catch (ExecutionException ex)
{
return null;
}
catch (UncheckedExecutionException ex)
{
return null;
}
}
@Override
public User load(final String name) throws Exception
{
for (Player player : ess.getServer().getOnlinePlayers())
{
if (player.getName().equalsIgnoreCase(name))
{
keys.add(Util.sanitizeFileName(name));
return new User(player, ess);
}
}
final File userFile = getUserFile(name);
if (userFile.exists())
{
keys.add(Util.sanitizeFileName(name));
return new User(new OfflinePlayer(name, ess), ess);
}
throw new Exception("User not found!");
}
@Override
public void reloadConfig()
{
loadAllUsersAsync(ess);
}
public void removeUser(final String name)
{
keys.remove(Util.sanitizeFileName(name));
users.invalidate(Util.sanitizeFileName(name));
}
public Set<String> getAllUniqueUsers()
{
return Collections.unmodifiableSet(keys);
}
public int getUniqueUsers()
{
return keys.size();
}
public File getUserFile(final String name)
{
final File userFolder = new File(ess.getDataFolder(), "userdata");
return new File(userFolder, Util.sanitizeFileName(name) + ".yml");
}
}

View File

@@ -1,23 +1,9 @@
package com.earth2me.essentials;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import static com.earth2me.essentials.I18n._;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.MessageFormat;
import java.util.Calendar;
import java.util.Enumeration;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.*;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -25,6 +11,8 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
public class Util
@@ -33,10 +21,11 @@ public class Util
{
}
private final static Logger logger = Logger.getLogger("Minecraft");
private final static Pattern INVALIDCHARS = Pattern.compile("[^a-z0-9]");
public static String sanitizeFileName(String name)
public static String sanitizeFileName(final String name)
{
return name.toLowerCase().replaceAll("[^a-z0-9]", "_");
return INVALIDCHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
}
public static String formatDateDiff(long date)
@@ -52,7 +41,7 @@ public class Util
boolean future = false;
if (toDate.equals(fromDate))
{
return Util.i18n("now");
return _("now");
}
if (toDate.after(fromDate))
{
@@ -71,18 +60,18 @@ public class Util
};
String[] names = new String[]
{
Util.i18n("year"),
Util.i18n("years"),
Util.i18n("month"),
Util.i18n("months"),
Util.i18n("day"),
Util.i18n("days"),
Util.i18n("hour"),
Util.i18n("hours"),
Util.i18n("minute"),
Util.i18n("minutes"),
Util.i18n("second"),
Util.i18n("seconds")
_("year"),
_("years"),
_("month"),
_("months"),
_("day"),
_("days"),
_("hour"),
_("hours"),
_("minute"),
_("minutes"),
_("second"),
_("seconds")
};
for (int i = 0; i < types.length; i++)
{
@@ -182,7 +171,7 @@ public class Util
}
if (!found)
{
throw new Exception(Util.i18n("illegalDate"));
throw new Exception(_("illegalDate"));
}
Calendar c = new GregorianCalendar();
if (years > 0)
@@ -215,16 +204,74 @@ public class Util
}
return c.getTimeInMillis();
}
// The player can stand inside these materials
private static final Set<Integer> AIR_MATERIALS = new HashSet<Integer>();
private static final HashSet<Byte> AIR_MATERIALS_TARGET = new HashSet<Byte>();
static
{
AIR_MATERIALS.add(Material.AIR.getId());
AIR_MATERIALS.add(Material.SAPLING.getId());
AIR_MATERIALS.add(Material.POWERED_RAIL.getId());
AIR_MATERIALS.add(Material.DETECTOR_RAIL.getId());
AIR_MATERIALS.add(Material.LONG_GRASS.getId());
AIR_MATERIALS.add(Material.DEAD_BUSH.getId());
AIR_MATERIALS.add(Material.YELLOW_FLOWER.getId());
AIR_MATERIALS.add(Material.RED_ROSE.getId());
AIR_MATERIALS.add(Material.BROWN_MUSHROOM.getId());
AIR_MATERIALS.add(Material.RED_MUSHROOM.getId());
AIR_MATERIALS.add(Material.TORCH.getId());
AIR_MATERIALS.add(Material.REDSTONE_WIRE.getId());
AIR_MATERIALS.add(Material.SEEDS.getId());
AIR_MATERIALS.add(Material.SIGN_POST.getId());
AIR_MATERIALS.add(Material.WOODEN_DOOR.getId());
AIR_MATERIALS.add(Material.LADDER.getId());
AIR_MATERIALS.add(Material.RAILS.getId());
AIR_MATERIALS.add(Material.WALL_SIGN.getId());
AIR_MATERIALS.add(Material.LEVER.getId());
AIR_MATERIALS.add(Material.STONE_PLATE.getId());
AIR_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
AIR_MATERIALS.add(Material.WOOD_PLATE.getId());
AIR_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
AIR_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
AIR_MATERIALS.add(Material.STONE_BUTTON.getId());
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
AIR_MATERIALS.add(Material.TRAP_DOOR.getId());
AIR_MATERIALS.add(Material.PUMPKIN_STEM.getId());
AIR_MATERIALS.add(Material.MELON_STEM.getId());
AIR_MATERIALS.add(Material.VINE.getId());
AIR_MATERIALS.add(Material.NETHER_WARTS.getId());
AIR_MATERIALS.add(Material.WATER_LILY.getId());
for (Integer integer : AIR_MATERIALS)
{
AIR_MATERIALS_TARGET.add(integer.byteValue());
}
AIR_MATERIALS_TARGET.add((byte)Material.WATER.getId());
AIR_MATERIALS_TARGET.add((byte)Material.STATIONARY_WATER.getId());
}
public static Location getTarget(final LivingEntity entity) throws Exception
{
final Block block = entity.getTargetBlock(AIR_MATERIALS_TARGET, 300);
if (block == null)
{
throw new Exception("Not targeting a block");
}
return block.getLocation();
}
public static Location getSafeDestination(final Location loc) throws Exception
{
if (loc == null || loc.getWorld() == null)
{
throw new Exception(Util.i18n("destinationNotSet"));
throw new Exception(_("destinationNotSet"));
}
final World world = loc.getWorld();
int x = loc.getBlockX();
int y = loc.getBlockY();
int y = (int)Math.round(loc.getY());
int z = loc.getBlockZ();
while (isBlockAboveAir(world, x, y, z))
@@ -232,7 +279,7 @@ public class Util
y -= 1;
if (y < 0)
{
throw new Exception(Util.i18n("holeInFloor"));
break;
}
}
@@ -252,6 +299,10 @@ public class Util
{
y = 127;
x += 1;
if (x - 32 > loc.getBlockX())
{
throw new Exception(_("holeInFloor"));
}
}
}
return new Location(world, x + 0.5D, y, z + 0.5D, loc.getYaw(), loc.getPitch());
@@ -259,7 +310,7 @@ public class Util
private static boolean isBlockAboveAir(final World world, final int x, final int y, final int z)
{
return world.getBlockAt(x, y - 1, z).getType() == Material.AIR;
return AIR_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId());
}
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z)
@@ -275,13 +326,95 @@ public class Util
return true;
}
if ((world.getBlockAt(x, y, z).getType() != Material.AIR)
|| (world.getBlockAt(x, y + 1, z).getType() != Material.AIR))
if ((!AIR_MATERIALS.contains(world.getBlockAt(x, y, z).getType().getId()))
|| (!AIR_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType().getId())))
{
return true;
}
return isBlockAboveAir(world, x, y, z);
}
public static ItemStack convertBlockToItem(final Block block)
{
final ItemStack is = new ItemStack(block.getType(), 1, (short)0, block.getData());
switch (is.getType())
{
case WOODEN_DOOR:
is.setType(Material.WOOD_DOOR);
is.setDurability((short)0);
break;
case IRON_DOOR_BLOCK:
is.setType(Material.IRON_DOOR);
is.setDurability((short)0);
break;
case SIGN_POST:
case WALL_SIGN:
is.setType(Material.SIGN);
is.setDurability((short)0);
break;
case CROPS:
is.setType(Material.SEEDS);
is.setDurability((short)0);
break;
case CAKE_BLOCK:
is.setType(Material.CAKE);
is.setDurability((short)0);
break;
case BED_BLOCK:
is.setType(Material.BED);
is.setDurability((short)0);
break;
case REDSTONE_WIRE:
is.setType(Material.REDSTONE);
is.setDurability((short)0);
break;
case REDSTONE_TORCH_OFF:
case REDSTONE_TORCH_ON:
is.setType(Material.REDSTONE_TORCH_ON);
is.setDurability((short)0);
break;
case DIODE_BLOCK_OFF:
case DIODE_BLOCK_ON:
is.setType(Material.DIODE);
is.setDurability((short)0);
break;
case DOUBLE_STEP:
is.setType(Material.STEP);
break;
case TORCH:
case RAILS:
case LADDER:
case WOOD_STAIRS:
case COBBLESTONE_STAIRS:
case LEVER:
case STONE_BUTTON:
case FURNACE:
case DISPENSER:
case PUMPKIN:
case JACK_O_LANTERN:
case WOOD_PLATE:
case STONE_PLATE:
case PISTON_STICKY_BASE:
case PISTON_BASE:
case IRON_FENCE:
case THIN_GLASS:
case TRAP_DOOR:
case FENCE:
case FENCE_GATE:
case NETHER_FENCE:
is.setDurability((short)0);
break;
case FIRE:
return null;
case PUMPKIN_STEM:
is.setType(Material.PUMPKIN_SEEDS);
break;
case MELON_STEM:
is.setType(Material.MELON_SEEDS);
break;
}
return is;
}
private static DecimalFormat df = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
public static String formatCurrency(final double value, final IEssentials ess)
@@ -299,184 +432,72 @@ public class Util
return Math.round(d * 100.0) / 100.0;
}
public static Locale getCurrentLocale()
{
return currentLocale;
}
private static class ConfigClassLoader extends ClassLoader
{
private final transient File dataFolder;
private final transient ClassLoader cl;
private final transient IEssentials ess;
public ConfigClassLoader(final ClassLoader cl, final IEssentials ess)
{
this.ess = ess;
this.dataFolder = ess.getDataFolder();
this.cl = cl;
}
@Override
public URL getResource(final String string)
{
final File file = new File(dataFolder, string);
if (file.exists())
{
try
{
return file.toURI().toURL();
}
catch (MalformedURLException ex)
{
return cl.getResource(string);
}
}
return cl.getResource(string);
}
@Override
public synchronized void clearAssertionStatus()
{
cl.clearAssertionStatus();
}
@Override
public InputStream getResourceAsStream(final String string)
{
final File file = new File(dataFolder, string);
if (file.exists())
{
BufferedReader br = null;
try
{
br = new BufferedReader(new FileReader(file));
final String version = br.readLine();
if (version == null || !version.equals("#version: " + ess.getDescription().getVersion()))
{
logger.log(Level.WARNING, String.format("Translation file %s is not updated for Essentials version. Will use default.", file));
return cl.getResourceAsStream(string);
}
return new FileInputStream(file);
}
catch (IOException ex)
{
return cl.getResourceAsStream(string);
}
finally
{
if (br != null)
{
try
{
br.close();
}
catch (IOException ex)
{
}
}
}
}
return cl.getResourceAsStream(string);
}
@Override
public Enumeration<URL> getResources(final String string) throws IOException
{
return cl.getResources(string);
}
@Override
public Class<?> loadClass(final String string) throws ClassNotFoundException
{
return cl.loadClass(string);
}
@Override
public synchronized void setClassAssertionStatus(final String string, final boolean bln)
{
cl.setClassAssertionStatus(string, bln);
}
@Override
public synchronized void setDefaultAssertionStatus(final boolean bln)
{
cl.setDefaultAssertionStatus(bln);
}
@Override
public synchronized void setPackageAssertionStatus(final String string, final boolean bln)
{
cl.setPackageAssertionStatus(string, bln);
}
}
private static final Locale defaultLocale = Locale.getDefault();
private static Locale currentLocale = defaultLocale;
private static ResourceBundle bundle = ResourceBundle.getBundle("messages", defaultLocale);
private static ResourceBundle defaultBundle = ResourceBundle.getBundle("messages", Locale.US);
public static String i18n(String string)
public static boolean isInt(final String sInt)
{
try
{
return bundle.getString(string);
Integer.parseInt(sInt);
}
catch (MissingResourceException ex)
catch (NumberFormatException e)
{
logger.log(Level.WARNING, String.format("Missing translation key \"%s\" in translation file %s", ex.getKey(), bundle.getLocale().toString()), ex);
return defaultBundle.getString(string);
}
}
public static String format(String string, Object... objects)
{
MessageFormat mf = new MessageFormat(i18n(string));
return mf.format(objects);
}
public static void updateLocale(String loc, IEssentials ess)
{
if (loc == null || loc.isEmpty())
{
return;
}
String[] parts = loc.split("[_\\.]");
if (parts.length == 1)
{
currentLocale = new Locale(parts[0]);
}
if (parts.length == 2)
{
currentLocale = new Locale(parts[0], parts[1]);
}
if (parts.length == 3)
{
currentLocale = new Locale(parts[0], parts[1], parts[2]);
}
logger.log(Level.INFO, String.format("Using locale %s", currentLocale.toString()));
bundle = ResourceBundle.getBundle("messages", currentLocale, new ConfigClassLoader(Util.class.getClassLoader(), ess));
if (!bundle.keySet().containsAll(defaultBundle.keySet()))
{
logger.log(Level.WARNING, String.format("Translation file %s does not contain all translation keys.", currentLocale.toString()));
return false;
}
return true;
}
public static String joinList(Object... list)
{
final StringBuilder buf = new StringBuilder();
boolean first = true;
return joinList(", ", list);
}
public static String joinList(String seperator, Object... list)
{
StringBuilder buf = new StringBuilder();
for (Object each : list)
{
if (!first)
if (buf.length() > 0)
{
buf.append(", ");
buf.append(seperator);
}
if (each instanceof Collection)
{
buf.append(joinList(seperator, ((Collection)each).toArray()));
}
else
{
try
{
buf.append(each.toString());
}
catch (Exception e)
{
buf.append(each.toString());
}
}
first = false;
buf.append(each);
}
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 stripColor(final String input)
{
if (input == null)
{
return null;
}
return VANILLA_COLOR_PATTERN.matcher(input).replaceAll("");
}
public static String replaceColor(final String input)
{
if (input == null)
{
return null;
}
return EASY_COLOR_PATTERN.matcher(input).replaceAll("\u00a7$1");
}
}

View File

@@ -1,11 +1,8 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
@@ -35,9 +32,9 @@ public class Warps implements IConf
return warpPoints.isEmpty();
}
public Iterable<String> getWarpNames()
public Collection<String> getWarpNames()
{
List<String> keys = new ArrayList<String>();
final List<String> keys = new ArrayList<String>();
for (StringIgnoreCase stringIgnoreCase : warpPoints.keySet())
{
keys.add(stringIgnoreCase.getString());
@@ -51,7 +48,7 @@ public class Warps implements IConf
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp));
if (conf == null)
{
throw new Exception(Util.i18n("warpNotExist"));
throw new Exception(_("warpNotExist"));
}
return conf.getLocation(null, server);
}
@@ -65,7 +62,7 @@ public class Warps implements IConf
File confFile = new File(warpsFolder, filename + ".yml");
if (confFile.exists())
{
throw new Exception(Util.i18n("similarWarpExist"));
throw new Exception(_("similarWarpExist"));
}
conf = new EssentialsConf(confFile);
warpPoints.put(new StringIgnoreCase(name), conf);
@@ -80,15 +77,16 @@ public class Warps implements IConf
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(name));
if (conf == null)
{
throw new Exception(Util.i18n("warpNotExist"));
throw new Exception(_("warpNotExist"));
}
if (!conf.getFile().delete())
{
throw new Exception(Util.i18n("warpDeleteError"));
throw new Exception(_("warpDeleteError"));
}
warpPoints.remove(new StringIgnoreCase(name));
}
@Override
public final void reloadConfig()
{
warpPoints.clear();
@@ -112,7 +110,7 @@ public class Warps implements IConf
}
catch (Exception ex)
{
logger.log(Level.WARNING, Util.format("loadWarpError", filename), ex);
logger.log(Level.WARNING, _("loadWarpError", filename), ex);
}
}
}
@@ -132,7 +130,7 @@ public class Warps implements IConf
@Override
public int hashCode()
{
return getString().toLowerCase().hashCode();
return getString().toLowerCase(Locale.ENGLISH).hashCode();
}
@Override

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials;
import java.io.File;
import java.util.Locale;
import java.util.logging.Logger;
import org.bukkit.inventory.ItemStack;
@@ -19,36 +20,42 @@ public class Worth implements IConf
public double getPrice(ItemStack itemStack)
{
String itemname = itemStack.getType().toString().toLowerCase().replace("_", "");
String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");
double result;
result = config.getDouble("worth."+itemname+"."+itemStack.getDurability(), Double.NaN);
if (Double.isNaN(result)) {
result = config.getDouble("worth."+itemname+".0", Double.NaN);
result = config.getDouble("worth." + itemname + "." + itemStack.getDurability(), Double.NaN);
if (Double.isNaN(result))
{
result = config.getDouble("worth." + itemname + ".0", Double.NaN);
}
if (Double.isNaN(result)) {
result = config.getDouble("worth."+itemname, Double.NaN);
if (Double.isNaN(result))
{
result = config.getDouble("worth." + itemname, Double.NaN);
}
if (Double.isNaN(result)) {
result = config.getDouble("worth-"+itemStack.getTypeId(), Double.NaN);
if (Double.isNaN(result))
{
result = config.getDouble("worth-" + itemStack.getTypeId(), Double.NaN);
}
return result;
}
public void setPrice(ItemStack itemStack, double price)
{
if (itemStack.getType().getData() == null) {
config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", ""), price);
} else {
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", "")+"."+itemStack.getDurability(), price);
if (itemStack.getType().getData() == null)
{
config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""), price);
}
config.removeProperty("worth-"+itemStack.getTypeId());
else
{
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
config.setProperty("worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "") + "." + itemStack.getDurability(), price);
}
config.removeProperty("worth-" + itemStack.getTypeId());
config.save();
}
@Override
public void reloadConfig()
{
config.load();
}
}

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials.api;
import com.earth2me.essentials.EssentialsConf;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@@ -21,6 +22,7 @@ public final class Economy
}
private static final Logger logger = Logger.getLogger("Minecraft");
private static IEssentials ess;
private static final String noCallBeforeLoad = "Essentials API is called before Essentials is loaded.";
/**
* @param aEss the ess to set
@@ -58,14 +60,18 @@ public final class Economy
{
if (!config.delete())
{
logger.log(Level.WARNING, Util.format("deleteFileError", config));
logger.log(Level.WARNING, _("deleteFileError", config));
}
ess.getAllUsers().remove(name.toLowerCase());
ess.getUserMap().removeUser(name);
}
}
private static User getUserByName(String name)
{
if (ess == null)
{
throw new RuntimeException(noCallBeforeLoad);
}
User user;
Player player = ess.getServer().getPlayer(name);
if (player != null)
@@ -176,6 +182,10 @@ public final class Economy
*/
public static void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException
{
if (ess == null)
{
throw new RuntimeException(noCallBeforeLoad);
}
setMoney(name, ess.getSettings().getStartingBalance());
}
@@ -231,6 +241,10 @@ public final class Economy
*/
public static String format(double amount)
{
if (ess == null)
{
throw new RuntimeException(noCallBeforeLoad);
}
return Util.formatCurrency(amount, ess);
}

View File

@@ -0,0 +1,10 @@
package com.earth2me.essentials.api;
import java.util.Map;
import org.bukkit.command.PluginCommand;
public interface IAlternativeCommandsHandler
{
Map<String, String> disabledCommands();
}

View File

@@ -0,0 +1,51 @@
package com.earth2me.essentials.api;
import com.earth2me.essentials.perm.IPermissionsHandler;
import com.earth2me.essentials.register.payment.Methods;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
public interface IEssentials extends Plugin, IReload
{
void addReloadListener(IReload listener);
IUser getUser(Object base);
int broadcastMessage(IUser sender, String message);
II18n getI18n();
ISettings getSettings();
IJails getJail();
IWarps getWarps();
IWorth getWorth();
IItemDb getItemDb();
IUserMap getUserMap();
IEssentialsEconomy getEconomy();
World getWorld(String name);
Methods getPaymentMethod();
int scheduleAsyncDelayedTask(Runnable run);
int scheduleSyncDelayedTask(Runnable run);
int scheduleSyncDelayedTask(Runnable run, long delay);
int scheduleSyncRepeatingTask(Runnable run, long delay, long period);
IPermissionsHandler getPermissionsHandler();
IAlternativeCommandsHandler getAlternativeCommandsHandler();
void showCommandError(CommandSender sender, String commandLabel, Throwable exception);
}

View File

@@ -0,0 +1,37 @@
package com.earth2me.essentials.api;
public interface IEssentialsEconomy
{
double getMoney(String name) throws UserDoesNotExistException;
void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException;
void add(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException;
void subtract(String name, double amount) throws UserDoesNotExistException, NoLoanPermittedException;
void divide(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException;
void multiply(String name, double value) throws UserDoesNotExistException, NoLoanPermittedException;
void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException;
boolean hasEnough(String name, double amount) throws UserDoesNotExistException;
boolean hasMore(String name, double amount) throws UserDoesNotExistException;
boolean hasLess(String name, double amount) throws UserDoesNotExistException;
boolean isNegative(String name) throws UserDoesNotExistException;
String format(double amount);
boolean playerExists(String name);
boolean isNPC(String name) throws UserDoesNotExistException;
boolean createNPC(String name);
void removeNPC(String name) throws UserDoesNotExistException;
}

View File

@@ -0,0 +1,9 @@
package com.earth2me.essentials.api;
import java.util.Locale;
public interface II18n
{
Locale getCurrentLocale();
}

View File

@@ -0,0 +1,11 @@
package com.earth2me.essentials.api;
import org.bukkit.inventory.ItemStack;
public interface IItemDb
{
ItemStack get(final String name, final int quantity) throws Exception;
ItemStack get(final String name) throws Exception;
}

View File

@@ -0,0 +1,18 @@
package com.earth2me.essentials.api;
import java.util.Collection;
import org.bukkit.Location;
public interface IJails extends IReload
{
Location getJail(String jailName) throws Exception;
Collection<String> getList() throws Exception;
void removeJail(String jail) throws Exception;
void sendToJail(com.earth2me.essentials.IUser user, String jail) throws Exception;
void setJail(String jailName, Location loc) throws Exception;
}

View File

@@ -0,0 +1,7 @@
package com.earth2me.essentials.api;
public interface IReload
{
void onReload();
}

View File

@@ -0,0 +1,10 @@
package com.earth2me.essentials.api;
import com.earth2me.essentials.settings.Settings;
import com.earth2me.essentials.storage.IStorageObjectHolder;
public interface ISettings extends IStorageObjectHolder<Settings>
{
}

View File

@@ -0,0 +1,10 @@
package com.earth2me.essentials.api;
import org.bukkit.Location;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public interface ITeleport
{
void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception;
}

View File

@@ -0,0 +1,43 @@
package com.earth2me.essentials.api;
import com.earth2me.essentials.commands.IEssentialsCommand;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public interface IUser extends Player, IReload
{
long getLastTeleportTimestamp();
boolean isAuthorized(String node);
boolean isAuthorized(IEssentialsCommand cmd);
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
void setLastTeleportTimestamp(long time);
Location getLastLocation();
Player getBase();
double getMoney();
void takeMoney(double value);
void giveMoney(double value);
String getGroup();
void setLastLocation();
Location getHome(String name) throws Exception;
Location getHome(Location loc) throws Exception;
boolean isHidden();
ITeleport getTeleport();
void setJail(String jail);
}

View File

@@ -0,0 +1,20 @@
package com.earth2me.essentials.api;
import java.io.File;
import java.util.Set;
public interface IUserMap
{
boolean userExists(final String name);
IUser getUser(final String name);
void removeUser(final String name);
Set<String> getAllUniqueUsers();
int getUniqueUsers();
File getUserFile(final String name);
}

View File

@@ -0,0 +1,16 @@
package com.earth2me.essentials.api;
import java.util.Collection;
import org.bukkit.Location;
public interface IWarps extends IReload
{
Location getWarp(String warp) throws Exception;
Collection<String> getWarps();
void removeWarp(String name) throws Exception;
void setWarp(String name, Location loc) throws Exception;
}

View File

@@ -0,0 +1,11 @@
package com.earth2me.essentials.api;
import org.bukkit.inventory.ItemStack;
public interface IWorth extends IReload
{
double getPrice(ItemStack itemStack);
void setPrice(ItemStack itemStack, double price);
}

View File

@@ -1,13 +1,12 @@
package com.earth2me.essentials.api;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
public class NoLoanPermittedException extends Exception
{
public NoLoanPermittedException()
{
super(Util.i18n("negativeBalanceError"));
super(_("negativeBalanceError"));
}
}

View File

@@ -1,13 +1,12 @@
package com.earth2me.essentials.api;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
public class UserDoesNotExistException extends Exception
{
public UserDoesNotExistException(String name)
{
super(Util.format("userDoesNotExist", name));
super(_("userDoesNotExist", name));
}
}

View File

@@ -1,8 +1,8 @@
package com.earth2me.essentials.commands;
import org.bukkit.Server;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
public class Commandafk extends EssentialsCommand
@@ -15,8 +15,6 @@ public class Commandafk extends EssentialsCommand
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
charge(user);
if (args.length > 0 && user.isAuthorized("essentials.afk.others"))
{
User afkUser = ess.getUser(ess.getServer().matchPlayer(args[0]));
@@ -31,17 +29,24 @@ public class Commandafk extends EssentialsCommand
}
}
private final void toggleAfk(User user)
private void toggleAfk(User user)
{
if (!user.toggleAfk())
{
user.sendMessage(Util.i18n("markedAsNotAway"));
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
//user.sendMessage(_("markedAsNotAway"));
if (!user.isHidden())
{
ess.broadcastMessage(user, _("userIsNotAway", user.getDisplayName()));
}
user.updateActivity(false);
}
else
{
user.sendMessage(Util.i18n("markedAsAway"));
ess.broadcastMessage(user.getName(), Util.format("userIsAway", user.getDisplayName()));
//user.sendMessage(_("markedAsAway"));
if (!user.isHidden())
{
ess.broadcastMessage(user, _("userIsAway", user.getDisplayName()));
}
}
}
}

View File

@@ -1,9 +1,9 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Location;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.TargetBlock;
import org.bukkit.entity.TNTPrimed;
@@ -17,11 +17,10 @@ public class Commandantioch extends EssentialsCommand
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
charge(user);
ess.broadcastMessage(user.getName(), "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
ess.broadcastMessage(user.getName(), "who being naughty in My sight, shall snuff it.");
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 = new TargetBlock(user).getTargetBlock().getLocation();
final Location loc = Util.getTarget(user);
loc.getWorld().spawn(loc, TNTPrimed.class);
}
}

View File

@@ -1,8 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@@ -14,11 +14,11 @@ public class Commandback extends EssentialsCommand
}
@Override
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
Trade charge = new Trade(this.getName(), ess);
final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
user.sendMessage(Util.i18n("backUsageMsg"));
user.sendMessage(_("backUsageMsg"));
user.getTeleport().back(charge);
}
}

View File

@@ -1,7 +1,7 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Backup;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -14,15 +14,14 @@ public class Commandbackup extends EssentialsCommand
}
@Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
Backup backup = ess.getBackup();
final Backup backup = ess.getBackup();
if (backup == null)
{
return;
throw new Exception();
}
charge(sender);
backup.run();
sender.sendMessage(Util.i18n("backupStarted"));
sender.sendMessage(_("backupStarted"));
}
}

View File

@@ -1,8 +1,9 @@
package com.earth2me.essentials.commands;
import org.bukkit.Server;
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;
@@ -14,24 +15,23 @@ public class Commandbalance extends EssentialsCommand
}
@Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
sender.sendMessage(Util.format("balance", Util.formatCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
sender.sendMessage(_("balance", Util.formatCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
}
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
charge(user);
double bal = (args.length < 1
|| !(user.isAuthorized("essentials.balance.others")
|| user.isAuthorized("essentials.balance.other"))
? user
: getPlayer(server, args, 0, true)).getMoney();
user.sendMessage(Util.format("balance", Util.formatCurrency(bal, ess)));
final double bal = (args.length < 1
|| !(user.isAuthorized("essentials.balance.others")
|| user.isAuthorized("essentials.balance.other"))
? user
: getPlayer(server, args, 0, true)).getMoney();
user.sendMessage(_("balance", Util.formatCurrency(bal, ess)));
}
}

View File

@@ -1,15 +1,15 @@
package com.earth2me.essentials.commands;
import java.util.Map.Entry;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.earth2me.essentials.textreader.ArrayListInput;
import com.earth2me.essentials.textreader.TextPager;
import java.text.DateFormat;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -19,49 +19,160 @@ public class Commandbalancetop extends EssentialsCommand
{
super("balancetop");
}
private static final int CACHETIME = 2 * 60 * 1000;
public static final int MINUSERS = 50;
private static ArrayListInput cache = new ArrayListInput();
private static long cacheage = 0;
private static ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
@Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
int max = 10;
int page = 0;
boolean force = false;
if (args.length > 0)
{
try
{
if (Integer.parseInt(args[0]) < 10)
{
max = Integer.parseInt(args[0]);
}
page = Integer.parseInt(args[0]);
}
catch (NumberFormatException ex)
{
//catch it because they tried to enter a string not number.
if (args[0].equalsIgnoreCase("force") && sender.isOp())
{
force = true;
}
}
}
final Map<User, Double> balances = new HashMap<User, Double>();
for (User u : ess.getAllUsers().values())
{
balances.put(u, u.getMoney());
}
final List<Map.Entry<User, Double>> sortedEntries = new ArrayList<Map.Entry<User, Double>>(balances.entrySet());
Collections.sort(sortedEntries, new Comparator<Map.Entry<User, Double>>()
if (!force && lock.readLock().tryLock())
{
public int compare(final Entry<User, Double> entry1, final Entry<User, Double> entry2)
try
{
return -entry1.getValue().compareTo(entry2.getValue());
if (cacheage > System.currentTimeMillis() - CACHETIME)
{
outputCache(sender, page);
return;
}
if (ess.getUserMap().getUniqueUsers() > MINUSERS)
{
sender.sendMessage(_("orderBalances", ess.getUserMap().getUniqueUsers()));
}
}
});
int count = 0;
sender.sendMessage(Util.format("balanceTop", max));
for (Map.Entry<User, Double> entry : sortedEntries)
finally
{
lock.readLock().unlock();
}
ess.scheduleAsyncDelayedTask(new Viewer(sender, page, force));
}
else
{
if (count == max)
if (ess.getUserMap().getUniqueUsers() > MINUSERS)
{
break;
sender.sendMessage(_("orderBalances", ess.getUserMap().getUniqueUsers()));
}
sender.sendMessage(entry.getKey().getDisplayName() + ", " + Util.formatCurrency(entry.getValue(), ess));
count++;
ess.scheduleAsyncDelayedTask(new Viewer(sender, page, force));
}
}
private static void outputCache(final CommandSender sender, int page)
{
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(cacheage);
final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
sender.sendMessage(_("balanceTop", format.format(cal.getTime())));
new TextPager(cache).showPage(Integer.toString(page), "", "balancetop", sender);
}
private class Calculator implements Runnable
{
private final transient Viewer viewer;
private final boolean force;
public Calculator(final Viewer viewer, final boolean force)
{
this.viewer = viewer;
this.force = force;
}
@Override
public void run()
{
lock.writeLock().lock();
try
{
if (force || cacheage <= System.currentTimeMillis() - CACHETIME)
{
cache.getLines().clear();
final Map<String, Double> balances = new HashMap<String, Double>();
for (String u : ess.getUserMap().getAllUniqueUsers())
{
final User user = ess.getUserMap().getUser(u);
if (user != null)
{
balances.put(user.getDisplayName(), user.getMoney());
}
}
final List<Map.Entry<String, Double>> sortedEntries = new ArrayList<Map.Entry<String, Double>>(balances.entrySet());
Collections.sort(sortedEntries, new Comparator<Map.Entry<String, Double>>()
{
@Override
public int compare(final Entry<String, Double> entry1, final Entry<String, Double> entry2)
{
return -entry1.getValue().compareTo(entry2.getValue());
}
});
int pos = 1;
for (Map.Entry<String, Double> entry : sortedEntries)
{
cache.getLines().add(pos + ". " + entry.getKey() + ", " + Util.formatCurrency(entry.getValue(), ess));
pos++;
}
cacheage = System.currentTimeMillis();
}
}
finally
{
lock.writeLock().unlock();
}
ess.scheduleAsyncDelayedTask(viewer);
}
}
private class Viewer implements Runnable
{
private final transient CommandSender sender;
private final transient int page;
private final transient boolean force;
public Viewer(final CommandSender sender, final int page, final boolean force)
{
this.sender = sender;
this.page = page;
this.force = force;
}
@Override
public void run()
{
lock.readLock().lock();
try
{
if (!force && cacheage > System.currentTimeMillis() - CACHETIME)
{
outputCache(sender, page);
return;
}
}
finally
{
lock.readLock().unlock();
}
ess.scheduleAsyncDelayedTask(new Calculator(new Viewer(sender, page, force), force));
}
}
}

View File

@@ -1,10 +1,11 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.entity.Player;
@@ -22,21 +23,21 @@ public class Commandban extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
final User player = getPlayer(server, args, 0, true);
if (player.getBase() instanceof OfflinePlayer)
final User user = getPlayer(server, args, 0, true);
if (user.getBase() instanceof OfflinePlayer)
{
if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
{
sender.sendMessage(Util.i18n("banExempt"));
sender.sendMessage(_("banExempt"));
return;
}
}
else
{
if (player.isAuthorized("essentials.ban.exempt"))
if (user.isAuthorized("essentials.ban.exempt"))
{
sender.sendMessage(Util.i18n("banExempt"));
sender.sendMessage(_("banExempt"));
return;
}
}
@@ -45,20 +46,22 @@ public class Commandban extends EssentialsCommand
if (args.length > 1)
{
banReason = getFinalArg(args, 1);
player.setBanReason(commandLabel);
user.setBanReason(banReason);
}
else
{
banReason = Util.i18n("defaultBanReason");
banReason = _("defaultBanReason");
}
player.kickPlayer(banReason);
ess.getBans().banByName(player.getName());
for(Player p : server.getOnlinePlayers())
user.setBanned(true);
user.kickPlayer(banReason);
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
for (Player onlinePlayer : server.getOnlinePlayers())
{
User u = ess.getUser(p);
if(u.isAuthorized("essentials.ban.notify"))
final User player = ess.getUser(onlinePlayer);
if (player.isAuthorized("essentials.ban.notify"))
{
p.sendMessage(Util.format("playerBanned", player.getName(), banReason));
onlinePlayer.sendMessage(_("playerBanned", senderName, user.getName(), banReason));
}
}
}

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -13,14 +14,29 @@ public class Commandbanip extends EssentialsCommand
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
ess.getBans().banByIp(args[0]);
sender.sendMessage(Util.i18n("banIpAddress"));
final User player = ess.getUser(args[0]);
if (player == null)
{
ess.getServer().banIP(args[0]);
sender.sendMessage(_("banIpAddress"));
}
else
{
final String ipAddress = player.getLastLoginAddress();
if (ipAddress.length() == 0)
{
throw new Exception(_("playerNotFound"));
}
ess.getServer().banIP(player.getLastLoginAddress());
sender.sendMessage(_("banIpAddress"));
}
}
}

View File

@@ -1,10 +1,11 @@
package com.earth2me.essentials.commands;
import org.bukkit.Server;
import org.bukkit.TreeType;
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.TreeType;
public class Commandbigtree extends EssentialsCommand
@@ -15,7 +16,7 @@ public class Commandbigtree extends EssentialsCommand
}
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
TreeType tree;
if (args.length > 0 && args[0].equalsIgnoreCase("redwood"))
@@ -31,39 +32,16 @@ public class Commandbigtree extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
double x = user.getLocation().getX();
double y = user.getLocation().getY();
double z = user.getLocation().getZ();
// offset tree in direction player is facing
final int r = (int)user.getCorrectedYaw();
if (r < 68 || r > 292) // north
{
x -= 3.0D;
}
else if (r > 112 && r < 248) // south
{
x += 3.0D;
}
if (r > 22 && r < 158) // east
{
z -= 3.0D;
}
else if (r > 202 && r < 338) // west
{
z += 3.0D;
}
final Location safeLocation = Util.getSafeDestination(new Location(user.getWorld(), x, y, z));
final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
final Location loc = Util.getTarget(user);
final Location safeLocation = Util.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, tree);
if (success)
{
charge(user);
user.sendMessage(Util.i18n("bigTreeSuccess"));
user.sendMessage(_("bigTreeSuccess"));
}
else
{
user.sendMessage(Util.i18n("bigTreeFailure"));
throw new Exception(_("bigTreeFailure"));
}
}
}

View File

@@ -0,0 +1,45 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.event.block.BlockBreakEvent;
public class Commandbreak extends EssentialsCommand
{
public Commandbreak()
{
super("break");
}
//TODO: Switch to use util class
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
final Block block = user.getTargetBlock(null, 20);
if (block == null)
{
throw new NoChargeException();
}
if (block.getType() == Material.AIR)
{
throw new NoChargeException();
}
if (block.getType() == Material.BEDROCK && !user.isAuthorized("essentials.break.bedrock"))
{
throw new Exception("You are not allowed to destroy bedrock."); //TODO: Translation
}
final BlockBreakEvent event = new BlockBreakEvent(block, user.getBase());
server.getPluginManager().callEvent(event);
if (event.isCancelled())
{
throw new NoChargeException();
}
else
{
block.setType(Material.AIR);
}
}
}

View File

@@ -1,10 +1,8 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandbroadcast extends EssentialsCommand
@@ -15,15 +13,13 @@ public class Commandbroadcast extends EssentialsCommand
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
charge(sender);
ess.broadcastMessage(sender instanceof Player ? ((Player)sender).getName() : Console.NAME,
Util.format("broadcast", getFinalArg(args, 0)));
ess.broadcastMessage(null, _("broadcast", getFinalArg(args, 0)));
}
}

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -14,18 +14,17 @@ public class Commandburn extends EssentialsCommand
}
@Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
throw new NotEnoughArgumentsException();
}
charge(sender);
for (Player p : server.matchPlayer(args[0]))
{
p.setFireTicks(Integer.parseInt(args[1]) * 20);
sender.sendMessage(Util.format("burnMsg", p.getDisplayName(), Integer.parseInt(args[1])));
sender.sendMessage(_("burnMsg", p.getDisplayName(), Integer.parseInt(args[1])));
}
}
}

View File

@@ -1,11 +1,11 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.List;
public class Commandclearinventory extends EssentialsCommand
@@ -15,47 +15,46 @@ public class Commandclearinventory extends EssentialsCommand
super("clearinventory");
}
//TODO: Cleanup
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
if (args.length > 0 && user.isAuthorized("essentials.clearinventory.others"))
{
//TODO: Fix fringe user match case.
if (args[0].length() >= 3)
{
List<Player> online = server.matchPlayer(args[0]);
if (!online.isEmpty())
{
charge(user);
for (Player p : online)
{
p.getInventory().clear();
user.sendMessage(Util.format("inventoryClearedOthers", p.getDisplayName()));
user.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
}
return;
}
throw new Exception(Util.i18n("playerNotFound"));
throw new Exception(_("playerNotFound"));
}
else
{
Player p = server.getPlayer(args[0]);
if (p != null)
{
charge(user);
p.getInventory().clear();
user.sendMessage(Util.format("inventoryClearedOthers", p.getDisplayName()));
user.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
}
else
{
throw new Exception(Util.i18n("playerNotFound"));
throw new Exception(_("playerNotFound"));
}
}
}
else
{
charge(user);
user.getInventory().clear();
user.sendMessage(Util.i18n("inventoryCleared"));
user.sendMessage(_("inventoryCleared"));
}
}
@@ -76,11 +75,11 @@ public class Commandclearinventory extends EssentialsCommand
for (Player p : online)
{
p.getInventory().clear();
sender.sendMessage(Util.format("inventoryClearedOthers", p.getDisplayName()));
sender.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
}
return;
}
throw new Exception(Util.i18n("playerNotFound"));
throw new Exception(_("playerNotFound"));
}
else
{
@@ -88,11 +87,11 @@ public class Commandclearinventory extends EssentialsCommand
if (u != null)
{
u.getInventory().clear();
sender.sendMessage(Util.format("inventoryClearedOthers", u.getDisplayName()));
sender.sendMessage(_("inventoryClearedOthers", u.getDisplayName()));
}
else
{
throw new Exception(Util.i18n("playerNotFound"));
throw new Exception(_("playerNotFound"));
}
}
}

View File

@@ -1,8 +1,8 @@
package com.earth2me.essentials.commands;
import org.bukkit.Server;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
public class Commandcompass extends EssentialsCommand
@@ -13,20 +13,46 @@ public class Commandcompass extends EssentialsCommand
}
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
charge(user);
int r = (int)user.getCorrectedYaw();
final int bearing = (int)(user.getLocation().getYaw() + 180 + 360) % 360;
String dir;
if (r < 23) dir = "N";
else if (r < 68) dir = "NE";
else if (r < 113) dir = "E";
else if (r < 158) dir = "SE";
else if (r < 203) dir = "S";
else if (r < 248) dir = "SW";
else if (r < 293) dir = "W";
else if (r < 338) dir = "NW";
else dir = "N";
user.sendMessage(Util.format("compassBearing", dir, r));
if (bearing < 23)
{
dir = "N";
}
else if (bearing < 68)
{
dir = "NE";
}
else if (bearing < 113)
{
dir = "E";
}
else if (bearing < 158)
{
dir = "SE";
}
else if (bearing < 203)
{
dir = "S";
}
else if (bearing < 248)
{
dir = "SW";
}
else if (bearing < 293)
{
dir = "W";
}
else if (bearing < 338)
{
dir = "NW";
}
else
{
dir = "N";
}
user.sendMessage(_("compassBearing", dir, bearing));
}
}

View File

@@ -0,0 +1,60 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
public class Commanddelhome extends EssentialsCommand
{
public Commanddelhome()
{
super("delhome");
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
User user = ess.getUser(sender);
String name;
String[] expandedArg;
//Allowing both formats /sethome khobbits house | /sethome khobbits:house
final String[] nameParts = args[0].split(":");
if (nameParts[0].length() != args[0].length())
{
expandedArg = nameParts;
}
else
{
expandedArg = args;
}
if (expandedArg.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
{
user = getPlayer(server, expandedArg, 0, true);
name = expandedArg[1];
}
else if (user == null)
{
throw new NotEnoughArgumentsException();
}
else
{
name = expandedArg[0];
}
//TODO: Think up a nice error message
/*
* if (name.equalsIgnoreCase("bed")) { throw new Exception("You cannot remove the vanilla home point"); }
*/
user.delHome(name.toLowerCase(Locale.ENGLISH));
sender.sendMessage(_("deleteHome", name));
}
}

View File

@@ -1,23 +1,25 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import static com.earth2me.essentials.I18n._;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
public class Commanddeljail extends EssentialsCommand {
public Commanddeljail() {
public class Commanddeljail extends EssentialsCommand
{
public Commanddeljail()
{
super("deljail");
}
@Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception {
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
charge(sender);
ess.getJail().delJail(args[0]);
sender.sendMessage(Util.format("deleteJail", args[0]));
ess.getJails().removeJail(args[0]);
sender.sendMessage(_("deleteJail", args[0]));
}
}

View File

@@ -1,8 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.Util;
public class Commanddelwarp extends EssentialsCommand
@@ -13,14 +13,13 @@ public class Commanddelwarp extends EssentialsCommand
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
charge(sender);
ess.getWarps().delWarp(args[0]);
sender.sendMessage(Util.format("deleteWarp", args[0]));
sender.sendMessage(_("deleteWarp", args[0]));
}
}

View File

@@ -1,8 +1,8 @@
package com.earth2me.essentials.commands;
import org.bukkit.Server;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
public class Commanddepth extends EssentialsCommand
@@ -13,21 +13,20 @@ public class Commanddepth extends EssentialsCommand
}
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
charge(user);
int y = user.getLocation().getBlockY() - 63;
if (y > 0)
final int depth = user.getLocation().getBlockY() - 63;
if (depth > 0)
{
user.sendMessage(Util.format("depthAboveSea", y));
user.sendMessage(_("depthAboveSea", depth));
}
else if (y < 0)
else if (depth < 0)
{
user.sendMessage(Util.format("depthBelowSea", (-y)));
user.sendMessage(_("depthBelowSea", (-depth)));
}
else
{
user.sendMessage(Util.i18n("depth"));
user.sendMessage(_("depth"));
}
}
}

View File

@@ -1,9 +1,10 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.earth2me.essentials.User;
public class Commandeco extends EssentialsCommand
@@ -14,7 +15,7 @@ public class Commandeco extends EssentialsCommand
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
@@ -24,7 +25,7 @@ public class Commandeco extends EssentialsCommand
double amount;
try
{
cmd = EcoCommands.valueOf(args[0].toUpperCase());
cmd = EcoCommands.valueOf(args[0].toUpperCase(Locale.ENGLISH));
amount = Double.parseDouble(args[2].replaceAll("[^0-9\\.]", ""));
}
catch (Exception ex)
@@ -34,45 +35,46 @@ public class Commandeco extends EssentialsCommand
if (args[1].contentEquals("*"))
{
for (Player p : server.getOnlinePlayers())
for (Player onlinePlayer : server.getOnlinePlayers())
{
User u = ess.getUser(p);
final User player = ess.getUser(onlinePlayer);
switch (cmd)
{
case GIVE:
u.giveMoney(amount);
player.giveMoney(amount);
break;
case TAKE:
u.takeMoney(amount);
player.takeMoney(amount);
break;
case RESET:
u.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
break;
}
}
}
else
{
User u = getPlayer(server, args, 1, true);
final User player = getPlayer(server, args, 1, true);
switch (cmd)
{
case GIVE:
u.giveMoney(amount, sender);
player.giveMoney(amount, sender);
break;
case TAKE:
u.takeMoney(amount, sender);
player.takeMoney(amount, sender);
break;
case RESET:
u.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
break;
}
}
}
private enum EcoCommands
{
GIVE, TAKE, RESET

View File

@@ -0,0 +1,96 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Enchantments;
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.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
public class Commandenchant extends EssentialsCommand
{
public Commandenchant()
{
super("enchant");
}
//TODO: Implement charge costs: final Trade charge = new Trade("enchant-" + enchantmentName, ess);
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
final ItemStack stack = user.getItemInHand();
if (stack == null)
{
throw new Exception(_("nothingInHand"));
}
if (args.length == 0)
{
final Set<String> enchantmentslist = new TreeSet<String>();
for (Map.Entry<String, Enchantment> entry : Enchantments.entrySet())
{
final String enchantmentName = entry.getValue().getName().toLowerCase(Locale.ENGLISH);
if (enchantmentslist.contains(enchantmentName) || user.isAuthorized("essentials.enchant." + enchantmentName))
{
enchantmentslist.add(entry.getKey());
//enchantmentslist.add(enchantmentName);
}
}
throw new NotEnoughArgumentsException(_("enchantments", Util.joinList(enchantmentslist.toArray())));
}
int level = -1;
if (args.length > 1)
{
try
{
level = Integer.parseInt(args[1]);
}
catch (NumberFormatException ex)
{
level = -1;
}
}
final Enchantment enchantment = getEnchantment(args[0], user);
if (level < 0 || level > enchantment.getMaxLevel())
{
level = enchantment.getMaxLevel();
}
if (level == 0)
{
stack.removeEnchantment(enchantment);
}
else
{
stack.addEnchantment(enchantment, level);
}
user.getInventory().setItemInHand(stack);
user.updateInventory();
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
if (level == 0)
{
user.sendMessage(_("enchantmentRemoved", enchantmentName.replace('_', ' ')));
}
else
{
user.sendMessage(_("enchantmentApplied", enchantmentName.replace('_', ' ')));
}
}
public static Enchantment getEnchantment(final String name, final User user) throws Exception
{
final Enchantment enchantment = Enchantments.getByName(name);
if (enchantment == null)
{
throw new Exception(_("enchantmentNotFound"));
}
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
if (user != null && !user.isAuthorized("essentials.enchant." + enchantmentName))
{
throw new Exception(_("enchantmentPerm", enchantmentName));
}
return enchantment;
}
}

View File

@@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Util;
import java.util.HashMap;
import java.util.Map;
@@ -22,6 +23,52 @@ public class Commandessentials extends EssentialsCommand
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length == 0) {
run_disabled(server, sender, commandLabel, args);
}
else if (args[0].equalsIgnoreCase("debug"))
{
run_debug(server, sender, commandLabel, args);
}
else if (args[0].equalsIgnoreCase("nya"))
{
run_nya(server, sender, commandLabel, args);
}
else {
run_reload(server, sender, commandLabel, args);
}
}
private void run_disabled(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
sender.sendMessage("Essentials " + ess.getDescription().getVersion());
sender.sendMessage("/<command> <reload/debug>");
sender.sendMessage(_("blockList"));
final StringBuilder disabledCommands = new StringBuilder();
for (Map.Entry<String, String> entry : ess.getAlternativeCommandsHandler().disabledCommands().entrySet())
{
if (disabledCommands.length() > 0) {
disabledCommands.append(", ");
}
disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue());
}
sender.sendMessage(disabledCommands.toString());
}
private void run_debug(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
ess.getSettings().setDebug(!ess.getSettings().isDebug());
sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
}
private void run_reload(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
ess.reload();
sender.sendMessage(_("essentialsReload", ess.getDescription().getVersion()));
}
private void run_nya(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
noteMap.put("1F#", (byte)0x0);
@@ -48,15 +95,12 @@ public class Commandessentials extends EssentialsCommand
noteMap.put("2D#", (byte)(0x9 + 0xC));
noteMap.put("2E", (byte)(0xA + 0xC));
noteMap.put("2F", (byte)(0xB + 0xC));
if (args.length > 0 && args[0].equalsIgnoreCase("nya"))
{
if (!noteBlocks.isEmpty())
{
return;
}
final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1B,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,";
final String[] tune = tuneStr.split(",");
for (Player player : server.getOnlinePlayers())
{
final Location loc = player.getLocation();
@@ -75,6 +119,7 @@ public class Commandessentials extends EssentialsCommand
{
int i = 0;
@Override
public void run()
{
final String note = tune[i];
@@ -88,22 +133,18 @@ public class Commandessentials extends EssentialsCommand
return;
}
Map<Player, Block> noteBlocks = Commandessentials.this.noteBlocks;
for (Player player : server.getOnlinePlayers())
for (Player onlinePlayer : server.getOnlinePlayers())
{
Block block = noteBlocks.get(player);
if (block == null)
final Block block = noteBlocks.get(onlinePlayer);
if (block == null || block.getType() != Material.NOTE_BLOCK)
{
continue;
}
player.playNote(block.getLocation(), (byte)0, noteMap.get(note));
onlinePlayer.playNote(block.getLocation(), (byte)0, noteMap.get(note));
}
}
}, 20, 2);
return;
}
ess.reload();
charge(sender);
sender.sendMessage(Util.format("essentialsReload", ess.getDescription().getVersion()));
}
private void stopTune()
@@ -111,7 +152,10 @@ public class Commandessentials extends EssentialsCommand
ess.getScheduler().cancelTask(taskid);
for (Block block : noteBlocks.values())
{
block.setType(Material.AIR);
if (block.getType() == Material.NOTE_BLOCK)
{
block.setType(Material.AIR);
}
}
noteBlocks.clear();
}

View File

@@ -1,8 +1,8 @@
package com.earth2me.essentials.commands;
import org.bukkit.Server;
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.entity.Player;
@@ -15,7 +15,7 @@ public class Commandext extends EssentialsCommand
}
@Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
@@ -26,26 +26,24 @@ public class Commandext extends EssentialsCommand
}
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
charge(user);
user.setFireTicks(0);
user.sendMessage(Util.i18n("extinguish"));
user.sendMessage(_("extinguish"));
return;
}
extinguishPlayers(server, user, commandLabel);
}
private void extinguishPlayers(Server server, CommandSender sender, String name) throws Exception
private void extinguishPlayers(final Server server, final CommandSender sender, final String name) throws Exception
{
for (Player p : server.matchPlayer(name))
for (Player matchPlayer : server.matchPlayer(name))
{
charge(sender);
p.setFireTicks(0);
sender.sendMessage(Util.format("extinguishOthers", p.getDisplayName()));
matchPlayer.setFireTicks(0);
sender.sendMessage(_("extinguishOthers", matchPlayer.getDisplayName()));
}
}
}

View File

@@ -0,0 +1,52 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandfeed extends EssentialsCommand
{
public Commandfeed()
{
super("feed");
}
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length > 0 && user.isAuthorized("essentials.feed.others"))
{
feedOtherPlayers(server,user,args[0]);
}
else
{
user.setFoodLevel(20);
user.setSaturation(10);
user.sendMessage(_("feed"));
}
}
private void feedOtherPlayers(final Server server, final CommandSender sender, final String name)
{
final List<Player> players = server.matchPlayer(name);
if (players.isEmpty())
{
sender.sendMessage(_("playerNotFound"));
return;
}
for (Player player : players)
{
if (ess.getUser(player).isHidden())
{
continue;
}
player.setFoodLevel(20);
player.setSaturation(10);
sender.sendMessage(_("feedOther", player.getDisplayName()));
}
}
}

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