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

Compare commits

...

579 Commits

Author SHA1 Message Date
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
snowleo
832910d480 Merge branch 'master' into release 2011-07-23 22:34:43 +02:00
snowleo
164541794e SuperpermsBridge fail 2011-07-23 13:17:22 -07:00
snowleo
13da2b2924 Merge branch 'master' into release 2011-07-23 20:06:00 +02:00
snowleo
84ac520353 Master and Release branch are now identical again.
Removed warning for an older bukkit version.
2011-07-23 20:05:44 +02:00
snowleo
7aea9e71e8 NPE check in PlayerInteract 2011-07-23 19:13:05 +02:00
406 changed files with 32522 additions and 13543 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>

14
.gitignore vendored
View File

@@ -25,4 +25,16 @@
/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/apikey.php
/WebPush/apikey.php

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

@@ -636,13 +636,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"/>
@@ -931,11 +924,12 @@ is divided into following sections:
<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>
</javadoc>
<copy todir="${dist.javadoc.dir}">
@@ -1135,13 +1129,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=66b89647
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45

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,24 +62,23 @@ 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}:\
@@ -71,7 +105,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 +113,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

@@ -601,6 +601,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">
@@ -868,11 +875,12 @@ is divided into following sections:
<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>
</javadoc>
<copy todir="${dist.javadoc.dir}">
@@ -1037,6 +1045,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=64a00ba6
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45
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,2 @@
DoNotUseThreads
SignatureDeclareThrowsException

View File

@@ -1,9 +1,45 @@
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.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,28 +63,41 @@ dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
file.reference.bPermissions.jar=../lib/bPermissions.jar
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.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.junit-4.5.jar=../lib/junit_4/junit-4.5.jar
file.reference.lombok-0.10.1.jar=../lib/lombok-0.10.1.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
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-0.10.1.jar}:\
${reference.EssentialsGroupManager.jar}:\
${file.reference.craftbukkit-0.0.1-SNAPSHOT.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}:\
@@ -62,13 +111,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

@@ -1,35 +1,46 @@
package com.earth2me.essentials;
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,84 @@ public class Backup implements Runnable {
}
}
public void run() {
if (active) return;
active = true;
final String command = ess.getSettings().getBackupCommand();
if (command == null || "".equals(command)) {
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, Util.i18n("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()
{
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()
{
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, Util.i18n("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,35 @@ 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();
}
public void setReplyTo(CommandSender user)
{
replyTo = user;
}
public CommandSender getReplyTo() {
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 com.earth2me.essentials.commands.Commandtime;
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().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().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().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 Util.format("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

@@ -26,27 +26,27 @@ 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.util.regex.Matcher;
import java.util.regex.Pattern;
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.scheduler.BukkitScheduler;
public class Essentials extends JavaPlugin implements IEssentials
{
public static final int BUKKIT_VERSION = 1000;
public static final int BUKKIT_VERSION = 1060;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
@@ -56,15 +56,13 @@ public class Essentials extends JavaPlugin implements IEssentials
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 UserMap userMap;
private transient ExecuteTimer execTimer;
@Override
public ISettings getSettings()
{
return settings;
@@ -85,38 +83,44 @@ public class Essentials extends JavaPlugin implements IEssentials
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);
userMap = new UserMap(this);
permissionsHandler = new PermissionsHandler(this, false);
Economy.setEss(this);
}
@Override
public void onEnable()
{
execTimer = new ExecuteTimer();
execTimer.start();
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);
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");
Util.updateLocale(settings.getLocale(), this);
userMap = new UserMap(this);
confList.add(userMap);
execTimer.mark("Init(Usermap)");
spawn = new Spawn(getServer(), this.getDataFolder());
confList.add(spawn);
warps = new Warps(getServer(), this.getDataFolder());
confList.add(warps);
execTimer.mark("Init(Spawn/Warp)");
worth = new Worth(this.getDataFolder());
confList.add(worth);
bans = new BanWorkaround(this);
confList.add(bans);
itemDb = new ItemDb(this);
confList.add(itemDb);
execTimer.mark("Init(Worth/ItemDB)");
reload();
backup = new Backup(this);
@@ -143,9 +147,11 @@ public class Essentials extends JavaPlugin implements IEssentials
LOGGER.log(Level.INFO, Util.i18n("bukkitFormatChanged"));
}
final ServerListener serverListener = new EssentialsPluginListener(this);
permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions());
final EssentialsPluginListener serverListener = new EssentialsPluginListener(this);
pm.registerEvent(Type.PLUGIN_ENABLE, serverListener, Priority.Low, this);
pm.registerEvent(Type.PLUGIN_DISABLE, serverListener, Priority.Low, this);
confList.add(serverListener);
final EssentialsPlayerListener playerListener = new EssentialsPlayerListener(this);
pm.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Monitor, this);
@@ -177,12 +183,16 @@ public class Essentials extends JavaPlugin implements IEssentials
final SignEntityListener signEntityListener = new SignEntityListener(this);
pm.registerEvent(Type.ENTITY_EXPLODE, signEntityListener, Priority.Low, this);
pm.registerEvent(Type.ENDERMAN_PICKUP, signEntityListener, Priority.Low, 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.registerEvent(Type.ENTITY_REGAIN_HEALTH, entityListener, Priority.Lowest, this);
pm.registerEvent(Type.FOOD_LEVEL_CHANGE, entityListener, Priority.Lowest, this);
//TODO: Check if this should be here, and not above before reload()
jail = new Jail(this);
final JailPlayerListener jailPlayerListener = new JailPlayerListener(this);
confList.add(jail);
@@ -194,30 +204,28 @@ public class Essentials extends JavaPlugin implements IEssentials
pm.registerEvent(Type.PLAYER_TELEPORT, jailPlayerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_JOIN, jailPlayerListener, Priority.High, this);
if (settings.isNetherEnabled() && getServer().getWorlds().size() < 2)
{
getServer().createWorld(settings.getNetherName(), World.Environment.NETHER);
}
pm.registerEvent(Type.ENTITY_EXPLODE, tntListener, Priority.High, this);
final EssentialsTimer timer = new EssentialsTimer(this);
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 50);
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
Economy.setEss(this);
if (enableErrorLogging)
{
updateTimer = new EssentialsUpdateTimer(this);
getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 50, 50 * 60 * (this.getDescription().getVersion().startsWith("Dev") ? 60 : 360));
}
execTimer.mark("RegListeners");
LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors())));
final String timeroutput = execTimer.end();
if (getSettings().isDebug())
{
LOGGER.log(Level.INFO, "Essentials load " + timeroutput);
}
}
@Override
public void onDisable()
{
Economy.setEss(null);
Trade.closeLog();
LOGGER.removeHandler(errorHandler);
}
@Override
public void reload()
{
Trade.closeLog();
@@ -225,25 +233,23 @@ 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)
@Override
public String[] getMotd(final CommandSender sender, final String def)
{
return getLines(sender, "motd", def);
}
public String[] getLines(CommandSender sender, String node, String def)
@Override
public String[] getLines(final CommandSender sender, final String node, final String def)
{
List<String> lines = (List<String>)getConfiguration().getProperty(node);
if (lines == null)
@@ -304,7 +310,7 @@ public class Essentials extends JavaPlugin implements IEssentials
}
}
m = m.replace("{ONLINE}", Integer.toString(getServer().getOnlinePlayers().length - playerHidden));
m = m.replace("{UNIQUE}", Integer.toString(users.size()));
m = m.replace("{UNIQUE}", Integer.toString(userMap.getUniqueUsers()));
if (m.matches(".*\\{PLAYERLIST\\}.*"))
{
@@ -348,12 +354,13 @@ public class Essentials extends JavaPlugin implements IEssentials
}
@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.");
}
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)
{
// Allow plugins to override the command via onCommand
if (!getSettings().isCommandOverridden(command.getName()) && !commandLabel.startsWith("e"))
@@ -365,7 +372,7 @@ public class Essentials extends JavaPlugin implements IEssentials
continue;
}
PluginDescriptionFile desc = p.getDescription();
final PluginDescriptionFile desc = p.getDescription();
if (desc == null)
{
continue;
@@ -376,7 +383,7 @@ public class Essentials extends JavaPlugin implements IEssentials
continue;
}
PluginCommand pc = getServer().getPluginCommand(desc.getName() + ":" + commandLabel);
final PluginCommand pc = getServer().getPluginCommand(desc.getName() + ":" + commandLabel);
if (pc != null)
{
return pc.execute(sender, commandLabel, args);
@@ -443,6 +450,10 @@ public class Essentials extends JavaPlugin implements IEssentials
}
return true;
}
catch (NoChargeException ex)
{
return true;
}
catch (NotEnoughArgumentsException ex)
{
sender.sendMessage(command.getDescription());
@@ -462,6 +473,7 @@ public class Essentials extends JavaPlugin implements IEssentials
}
}
@Override
public void showError(final CommandSender sender, final Throwable exception, final String commandLabel)
{
sender.sendMessage(Util.format("errorWithMessage", exception.getMessage()));
@@ -471,56 +483,66 @@ public class Essentials extends JavaPlugin implements IEssentials
{
LOGGER.log(logRecord);
}
else
{
if (enableErrorLogging)
{
errorHandler.publish(logRecord);
errorHandler.flush();
}
}
}
public CraftScheduler getScheduler()
@Override
public BukkitScheduler getScheduler()
{
return (CraftScheduler)this.getServer().getScheduler();
return this.getServer().getScheduler();
}
@Override
public Jail getJail()
{
return jail;
}
@Override
public Warps getWarps()
{
return warps;
}
@Override
public Worth getWorth()
{
return worth;
}
@Override
public Backup getBackup()
{
return backup;
}
@Override
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)
{
try
{
return userMap.getUser((String)base);
}
catch (NullPointerException ex)
{
return null;
}
}
return null;
}
private <T extends Player> User getUser(T base)
private <T extends Player> User getUser(final T base)
{
if (base == null)
{
@@ -531,71 +553,72 @@ public class Essentials extends JavaPlugin implements IEssentials
{
return (User)base;
}
if (users.containsKey(base.getName().toLowerCase()))
try
{
return users.get(base.getName().toLowerCase()).update(base);
return userMap.getUser(base.getName()).update(base);
}
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)
catch (NullPointerException ex)
{
return u;
return new User(base, this);
}
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;
}
@Override
public User getOfflineUser(final String name)
{
try
{
return userMap.getUser(name);
}
catch (NullPointerException ex)
{
return null;
}
}
@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 +627,51 @@ 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)
{
this.permissionsHandler = handler;
}
public BanWorkaround getBans()
{
return bans;
}
@Override
public ItemDb getItemDb()
{
return itemDb;
}
@Override
public UserMap getUserMap()
{
return userMap;
}
}

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials;
import java.util.logging.Logger;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent;
@@ -93,7 +94,7 @@ public class EssentialsBlockListener extends BlockListener
return;
}
boolean unlimitedForUser = user.hasUnlimited(is);
if (unlimitedForUser)
if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL)
{
ess.scheduleSyncDelayedTask(
new Runnable()

View File

@@ -1,6 +1,8 @@
package com.earth2me.essentials;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -19,12 +21,12 @@ 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 +44,79 @@ public class EssentialsConf extends Configuration
{
if (!configFile.getParentFile().mkdirs())
{
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
LOGGER.log(Level.SEVERE, Util.format("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, Util.format("creatingConfigFromTemplate", configFile.toString()));
createFromTemplate();
}
else
{
try
{
logger.log(Level.INFO, Util.format("creatingEmptyConfig", configFile.toString()));
LOGGER.log(Level.INFO, Util.format("creatingEmptyConfig", configFile.toString()));
if (!configFile.createNewFile())
{
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
}
}
catch (IOException ex)
{
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()), ex);
LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()), ex);
}
}
}
super.load();
try
{
super.load();
}
catch (RuntimeException e)
{
LOGGER.log(Level.INFO, "File: " + configFile.toString());
throw e;
}
if (this.root == null)
{
this.root = new HashMap<String, Object>();
@@ -84,7 +132,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, Util.format("couldNotFindTemplate", templateName));
return;
}
ostr = new FileOutputStream(configFile);
@@ -99,7 +147,7 @@ public class EssentialsConf extends Configuration
}
catch (IOException ex)
{
logger.log(Level.SEVERE, Util.format("failedToWriteConfig", configFile.toString()), ex);
LOGGER.log(Level.SEVERE, Util.format("failedToWriteConfig", configFile.toString()), ex);
return;
}
finally
@@ -124,12 +172,12 @@ public class EssentialsConf extends Configuration
}
catch (IOException ex)
{
logger.log(Level.SEVERE, Util.format("failedToCloseConfig", configFile.toString()), ex);
LOGGER.log(Level.SEVERE, Util.format("failedToCloseConfig", configFile.toString()), ex);
}
}
}
public void setTemplateName(String templateName)
public void setTemplateName(final String templateName)
{
this.templateName = templateName;
}
@@ -139,48 +187,48 @@ 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(Util.i18n("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(
Material.valueOf(getString(path + ".type", "AIR")),
@@ -189,9 +237,9 @@ public class EssentialsConf extends Configuration
(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());
@@ -200,40 +248,30 @@ public class EssentialsConf extends Configuration
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,20 +1,25 @@
package com.earth2me.essentials;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
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.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
public class EssentialsEntityListener extends EntityListener
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private final IEssentials ess;
public EssentialsEntityListener(IEssentials ess)
@@ -34,26 +39,30 @@ 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()));
event.setCancelled(true);
return;
for (String command : commandList)
{
if (command != null && !command.isEmpty())
{
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
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);
}
}
@@ -67,16 +76,40 @@ public class EssentialsEntityListener extends EntityListener
}
@Override
public void onEntityDeath(EntityDeathEvent event)
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"));
}
if (!ess.getSettings().areDeathMessagesEnabled())
{
pdevent.setDeathMessage("");
}
}
}
@Override
public void onFoodLevelChange(FoodLevelChangeEvent event)
{
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{
event.setCancelled(true);
}
}
@Override
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,8 +1,6 @@
package com.earth2me.essentials;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
@@ -16,6 +14,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.event.player.PlayerAnimationType;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@@ -48,11 +47,10 @@ public class EssentialsPlayerListener extends PlayerListener
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(user.getNick());
}
}
@@ -75,14 +73,10 @@ 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(user.getNick());
}
}
@@ -95,114 +89,29 @@ 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
@@ -218,6 +127,7 @@ public class EssentialsPlayerListener extends PlayerListener
user.getInventory().setContents(user.getSavedInventory());
user.setSavedInventory(null);
}
user.updateActivity(false);
user.dispose();
if (!ess.getSettings().getReclaimSetting())
{
@@ -254,19 +164,12 @@ public class EssentialsPlayerListener extends PlayerListener
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.getNick());
}
user.setAfk(false);
user.setLastLoginAddress(user.getAddress().getAddress().getHostAddress());
user.updateActivity(false);
if (user.isAuthorized("essentials.sleepingignored"))
{
user.setSleepingIgnored(true);
@@ -301,17 +204,23 @@ public class EssentialsPlayerListener extends PlayerListener
@Override
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)
{
LOGGER.log(Level.INFO, "Disconnecting user " + event.getPlayer().toString() + " due to " + event.getResult().toString());
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 : Util.i18n("defaultBanReason"));
return;
}
@@ -320,6 +229,7 @@ public class EssentialsPlayerListener extends PlayerListener
event.disallow(Result.KICK_FULL, Util.i18n("serverFull"));
return;
}
event.allow();
user.setLastLogin(System.currentTimeMillis());
updateCompass(user);
@@ -346,7 +256,7 @@ public class EssentialsPlayerListener extends PlayerListener
final User user = ess.getUser(event.getPlayer());
if (ess.getSettings().changeDisplayName())
{
user.setDisplayName(user.getNick());
user.setDisplayNick(user.getNick());
}
updateCompass(user);
}
@@ -409,6 +319,8 @@ public class EssentialsPlayerListener extends PlayerListener
@Override
public void onPlayerAnimation(final PlayerAnimationEvent event)
{
final User user = ess.getUser(event.getPlayer());
user.updateActivity(true);
usePowertools(event);
}
@@ -420,30 +332,35 @@ public class EssentialsPlayerListener extends PlayerListener
}
final User user = ess.getUser(event.getPlayer());
final ItemStack is = user.getItemInHand();
if (is == null || is.getType() == Material.AIR)
if (is == null || is.getType() == Material.AIR || !user.arePowerToolsEnabled())
{
return;
}
final String command = user.getPowertool(is);
if (command == null || command.isEmpty())
final List<String> commandList = user.getPowertool(is);
if (commandList == null || commandList.isEmpty())
{
return;
}
if (command.matches(".*\\{player\\}.*"))
// We need to loop through each command and execute
for (String command : commandList)
{
//user.sendMessage("Click a player to use this command");
return;
}
if (command.startsWith("c:"))
{
for (Player p : server.getOnlinePlayers())
if (command.matches(".*\\{player\\}.*"))
{
p.sendMessage(user.getDisplayName() + ":" + command.substring(2));
//user.sendMessage("Click a player to use this command");
continue;
}
else if (command.startsWith("c:"))
{
for (Player p : server.getOnlinePlayers())
{
p.sendMessage(user.getDisplayName() + ":" + command.substring(2));
}
}
else
{
user.getServer().dispatchCommand(event.getPlayer(), command);
}
}
else
{
user.getServer().dispatchCommand(user, command);
}
}
@@ -461,16 +378,16 @@ public class EssentialsPlayerListener extends PlayerListener
{
for (Player player : ess.getServer().getOnlinePlayers())
{
if (ess.getUser(player).isSocialSpyEnabled())
User spyer = ess.getUser(player);
if (spyer.isSocialSpyEnabled() && !user.equals(spyer))
{
player.sendMessage(user.getDisplayName() + " : " + event.getMessage());
}
}
}
if (user.isAfk())
if (!cmd.equalsIgnoreCase("afk"))
{
user.setAfk(false);
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
user.updateActivity(true);
}
}
}

View File

@@ -1,16 +1,13 @@
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.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 extends ServerListener implements IConf
{
private final transient IEssentials ess;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
@@ -23,59 +20,29 @@ public class EssentialsPluginListener extends ServerListener
@Override
public void onPluginEnable(final PluginEnableEvent event)
{
checkPermissions();
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(event.getPlugin()))
ess.getPermissionsHandler().checkPermissions();
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() + ")");
}
}
@Override
public void onPluginDisable(PluginDisableEvent event)
public void onPluginDisable(final PluginDisableEvent event)
{
checkPermissions();
ess.getPermissionsHandler().checkPermissions();
// 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()))
{
ess.getPaymentMethod().reset();
LOGGER.log(Level.INFO, "[Essentials] 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,24 @@
package com.earth2me.essentials;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigInteger;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
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 +27,70 @@ 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, Util.i18n("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 +99,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,22 +108,22 @@ 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"))))
@@ -116,19 +134,25 @@ public class EssentialsUpgrade
{
throw new Exception(Util.i18n("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 +160,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 +179,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 +187,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();
if (worldName != null && !worldName.isEmpty())
{
config.removeProperty("home");
@@ -175,30 +200,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();
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 +360,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 +370,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 +385,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,7 +456,7 @@ 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")))
{
@@ -294,52 +465,52 @@ public class EssentialsUpgrade
}
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(Util.format("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 +519,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, Util.format("userdataMoveError", filename, sanitizedFilename));
continue;
}
if (newFile.exists())
{
logger.log(Level.WARNING, Util.format("duplicatedUserdata", filename, sanitizedFilename));
LOGGER.log(Level.WARNING, Util.format("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, Util.format("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 +580,73 @@ 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);
}
}
}
public void beforeSettings()
{
if (!ess.getDataFolder().exists())
@@ -416,5 +662,8 @@ public class EssentialsUpgrade
updateUsersToNewDefaultHome();
moveUsersDataToUserdataFolder();
convertWarps();
updateUsersPowerToolsFormat();
updateUsersHomesFormat();
deleteOldItemsCsv();
}
}

View File

@@ -0,0 +1,84 @@
package com.earth2me.essentials;
import java.util.ArrayList;
import java.util.List;
public class ExecuteTimer
{
private final List<ExecuteRecord> times;
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.currentTimeMillis()));
}
}
public String end()
{
final StringBuilder output = new StringBuilder();
output.append("execution time: ");
String mark;
long time0 = 0;
long time1 = 0;
long time2 = 0;
long duration;
for (ExecuteRecord pair : times)
{
mark = (String)pair.getMark();
time2 = (Long)pair.getTime();
if (time1 > 0)
{
duration = time2 - time1;
output.append(mark).append(": ").append(duration).append("ms - ");
}
else
{
time0 = time2;
}
time1 = time2;
}
duration = time1 - time0;
output.append("Total: ").append(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,190 @@
package com.earth2me.essentials;
import java.util.HashMap;
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
public class FakeInventory implements Inventory
{
ItemStack[] items;
public FakeInventory(ItemStack[] items)
{
this.items = new ItemStack[items.length];
for (int i = 0; i < items.length; i++)
{
if (items[i] == null)
{
continue;
}
this.items[i] = new ItemStack(items[i].getTypeId(), items[i].getAmount(), items[i].getDurability());
}
}
@Override
public int getSize()
{
return items.length;
}
@Override
public String getName()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ItemStack getItem(int i)
{
return items[i];
}
@Override
public void setItem(int i, ItemStack is)
{
items[i] = is;
}
@Override
public HashMap<Integer, ItemStack> addItem(ItemStack... iss)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public HashMap<Integer, ItemStack> removeItem(ItemStack... iss)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ItemStack[] getContents()
{
return items;
}
@Override
public void setContents(ItemStack[] iss)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(Material mtrl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(ItemStack is)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(int i, int i1)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(Material mtrl, int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(ItemStack is, int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public HashMap<Integer, ? extends ItemStack> all(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public HashMap<Integer, ? extends ItemStack> all(Material mtrl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public HashMap<Integer, ? extends ItemStack> all(ItemStack is)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int first(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int first(Material mtrl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int first(ItemStack is)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int firstEmpty()
{
for (int i = 0; i < items.length; i++)
{
if (items[i] == null || items[i].getTypeId() == 0) {
return i;
}
}
return -1;
}
@Override
public void remove(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void remove(Material mtrl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void remove(ItemStack is)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void clear(int i)
{
items[i] = null;
}
@Override
public void clear()
{
for (int i = 0; i < items.length; i++)
{
items[i] = null;
}
}
}

View File

@@ -5,6 +5,7 @@ import java.util.UUID;
import org.bukkit.BlockChangeDelegate;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
import org.bukkit.Difficulty;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.TreeType;
@@ -12,16 +13,12 @@ import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Boat;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.entity.PoweredMinecart;
import org.bukkit.entity.StorageMinecart;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemStack;
@@ -404,5 +401,58 @@ public class FakeWorld implements World
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean unloadChunk(Chunk chunk)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getMaxHeight()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean getKeepSpawnInMemory()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setKeepSpawnInMemory(boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isAutoSave()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setAutoSave(boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Difficulty getDifficulty()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setDifficulty(Difficulty difficulty)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getSeaLevel()
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -1,12 +1,12 @@
package com.earth2me.essentials;
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;
public interface IEssentials extends Plugin
@@ -23,11 +23,11 @@ public interface IEssentials extends Plugin
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);
@@ -53,17 +53,13 @@ public interface IEssentials extends Plugin
int scheduleSyncRepeatingTask(final Runnable run, long delay, long period);
BanWorkaround getBans();
TNTExplodeListener getTNTListener();
IPermissionsHandler getPermissionsHandler();
void setPermissionsHandler(IPermissionsHandler handler);
PermissionsHandler getPermissionsHandler();
void showError(final CommandSender sender, final Throwable exception, final String commandLabel);
Map<String, User> getAllUsers();
ItemDb getItemDb();
UserMap getUserMap();
}

View File

@@ -35,8 +35,6 @@ public interface ISettings extends IConf
int getDefaultStackSize();
boolean getGenerateExitPortals();
double getHealCooldown();
Object getKit(String name);
@@ -45,12 +43,6 @@ public interface ISettings extends IConf
String getLocale();
String getNetherName();
boolean getNetherPortalsEnabled();
double getNetherRatio();
String getNewbieSpawn();
String getNicknamePrefix();
@@ -72,6 +64,12 @@ public interface ISettings extends IConf
boolean getReclaimSetting();
boolean getRespawnAtHome();
List getMultipleHomes();
int getHomeLimit(String set);
int getHomeLimit(User user);
boolean getSortListByGroups();
@@ -99,22 +97,16 @@ public interface ISettings extends IConf
boolean isEcoDisabled();
boolean isNetherEnabled();
boolean isTradeInStacks(int id);
List<Integer> itemSpawnBlacklist();
boolean permissionBasedItemSpawn();
void reloadConfig();
boolean showNonEssCommandsInHelp();
boolean spawnIfNoHome();
boolean use1to1RatioInNether();
boolean warnOnBuildDisallow();
boolean warnOnSmite();
@@ -129,7 +121,21 @@ public interface ISettings extends IConf
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);
}

View File

@@ -22,7 +22,7 @@ public interface IUser
boolean isAuthorized(String node);
boolean isAuthorized(IEssentialsCommand cmd);
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
void setLastTeleportTimestamp(long time);
@@ -45,11 +45,15 @@ public interface IUser
void setLastLocation();
Location getHome(Location location);
Location getHome(String name) throws Exception;
Location getHome(Location loc) throws Exception;
String getName();
InetSocketAddress getAddress();
String getDisplayName();
boolean isHidden();
}

View File

@@ -3,7 +3,6 @@ package com.earth2me.essentials;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.Item;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@@ -65,6 +64,20 @@ public final class InventoryWorkaround
return -1;
}
public static boolean addAllItems(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
{
final Inventory fake = new FakeInventory(cinventory.getContents());
if (addItem(fake, forceDurability, items).isEmpty())
{
addItem(cinventory, forceDurability, items);
return true;
}
else
{
return false;
}
}
public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
{
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
@@ -107,7 +120,7 @@ public final class InventoryWorkaround
{
continue;
}
while (true)
{
// Do we already have a stack of it?
@@ -130,7 +143,7 @@ public final class InventoryWorkaround
// More than a single stack!
if (item.getAmount() > item.getType().getMaxStackSize())
{
cinventory.setItem(firstFree, new CraftItemStack(item.getTypeId(), item.getType().getMaxStackSize(), item.getDurability()));
cinventory.setItem(firstFree, new ItemStack(item.getTypeId(), item.getType().getMaxStackSize(), item.getDurability()));
item.setAmount(item.getAmount() - item.getType().getMaxStackSize());
}
else

View File

@@ -1,14 +1,8 @@
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 java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@@ -17,108 +11,45 @@ public class ItemDb implements IConf
{
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");
if (!file.exists())
{
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)
{
}
}
final List<String> lines = file.getLines();
if (lines.isEmpty()) {
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();
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(), parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0);
items.put(parts[0].toLowerCase(), numeric);
}
}
@@ -163,6 +94,11 @@ 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));

View File

@@ -31,7 +31,7 @@ public class Jail extends BlockListener implements IConf
public Location getJail(String jailName) throws Exception
{
if (config.getProperty(jailName.toLowerCase()) == null)
if (jailName == null || config.getProperty(jailName.toLowerCase()) == null)
{
throw new Exception(Util.i18n("jailNotExist"));
}

View File

@@ -0,0 +1,235 @@
package com.earth2me.essentials;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
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, Util.i18n("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.matches("#[a-f0-9]{32}"))
{
hash = hash.substring(1);
bais.reset();
final String versionline = reader.readLine();
if (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

@@ -26,8 +26,10 @@ 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);
public static final Logger logger = Logger.getLogger("Minecraft");
@@ -86,6 +88,9 @@ public enum Mob
final protected String type;
}
public CreatureType getType () {
return bukkitType;
}
public static class MobException extends Exception
{

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

@@ -5,8 +5,10 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import lombok.Delegate;
import org.bukkit.Achievement;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Instrument;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -24,6 +26,7 @@ import org.bukkit.entity.Vehicle;
import org.bukkit.event.entity.EntityDamageEvent;
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,38 +36,32 @@ import org.bukkit.util.Vector;
public class OfflinePlayer implements Player
{
private final String name;
final transient IEssentials ess;
private final transient IEssentials ess;
private Location location = new Location(null, 0, 0, 0, 0, 0);
private World world;
private UUID uniqueId = UUID.randomUUID();
@Delegate(types=org.bukkit.OfflinePlayer.class)
private final 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)
{
}
@@ -82,11 +79,6 @@ public class OfflinePlayer implements Player
{
}
public String getName()
{
return name;
}
public PlayerInventory getInventory()
{
return null;
@@ -572,8 +564,136 @@ public class OfflinePlayer implements Player
{
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 Location getBedSpawnLocation()
{
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.");
}
}

View File

@@ -1,47 +1,53 @@
package com.earth2me.essentials;
import lombok.Delegate;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.IInventory;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
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)
protected final transient IEssentials ess;
@Delegate(types =
{
super(base);
Player.class, Entity.class, CommandSender.class, ServerOperator.class,
HumanEntity.class, ConfigurationSerializable.class, LivingEntity.class,
Permissible.class
})
protected Player base;
public PlayerExtension(final Player base, final IEssentials ess)
{
this.base = base;
this.ess = ess;
}
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;
return this.base = base;
}
public void showInventory(IInventory inventory)
public void showInventory(final IInventory inventory)
{
getHandle().a(inventory);
}
public void showInventory(CraftInventoryPlayer inventory)
public void showInventory(final CraftInventoryPlayer inventory)
{
showInventory((IInventory)inventory.getInventory());
}
@@ -56,7 +62,7 @@ public class PlayerExtension extends PlayerWrapper
return ess.getPermissionsHandler().getGroup(base);
}
public boolean inGroup(String group)
public boolean inGroup(final String group)
{
return ess.getPermissionsHandler().inGroup(base, group);
}

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

@@ -37,6 +37,39 @@ public class Settings implements ISettings
return config.getBoolean("bed-sethome", false);
}
@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
public int getChatRadius()
{
@@ -54,19 +87,13 @@ public class Settings implements ISettings
{
return config.getInt("default-stack-size", 64);
}
@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,7 +105,10 @@ 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);
@@ -95,18 +125,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);
}
@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,7 +156,9 @@ 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);
@@ -137,7 +175,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;
}
@@ -165,13 +205,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,9 +225,13 @@ 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
{
@@ -205,35 +250,23 @@ public class Settings implements ISettings
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()
@@ -266,12 +299,6 @@ public class Settings implements ISettings
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
}
@Override
public boolean getGenerateExitPortals()
{
return config.getBoolean("nether.generate-exit-portals", true);
}
@Override
public boolean getAnnounceNewPlayers()
{
@@ -295,12 +322,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,7 +336,8 @@ public class Settings implements ISettings
}
@Override
public void reloadConfig() {
public void reloadConfig()
{
config.load();
}
@@ -316,16 +345,21 @@ public class Settings implements ISettings
public List<Integer> itemSpawnBlacklist()
{
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;
}
ItemStack is;
try {
try
{
is = ess.getItemDb().get(itemName);
epItemSpwn.add(is.getTypeId());
} catch (Exception ex) {
}
catch (Exception ex)
{
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "item-spawn-blacklist"));
}
}
@@ -344,33 +378,20 @@ public class Settings implements ISettings
return config.getBoolean("protect.disable.warn-on-build-disallow", 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);
}
private boolean debug = false;
@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,23 +425,28 @@ 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) {
}
catch (Exception ex)
{
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, configName));
}
}
@@ -438,12 +464,13 @@ public class Settings implements ISettings
{
return config.getBoolean(configName, def);
}
private final static double MAXMONEY = 10000000000000.0;
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;
@@ -453,7 +480,7 @@ public class Settings implements ISettings
{
return config.getBoolean("economy-log-enabled", false);
}
public boolean removeGodOnDisconnect()
{
return config.getBoolean("remove-god-on-disconnect", false);
@@ -471,6 +498,46 @@ public class Settings implements ISettings
public boolean addPrefixSuffix()
{
return config.getBoolean("add-prefix-suffix", false);
return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat"));
}
public boolean disablePrefix()
{
return config.getBoolean("disablePrefix", false);
}
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);
}
@Override
public void setDebug(final boolean debug)
{
this.debug = debug;
}
}

View File

@@ -9,20 +9,23 @@ import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.World.Environment;
public class Spawn implements IConf {
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) {
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) {
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());
@@ -33,18 +36,24 @@ public class Spawn implements IConf {
config.setProperty(group, map);
config.save();
if ("default".equals(group)) {
if ("default".equals(group))
{
loc.getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
}
}
public Location getSpawn(String group) {
if (config.getProperty(group) == null) {
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) {
if (config.getProperty(group) == null)
{
for (World w : server.getWorlds())
{
if (w.getEnvironment() != Environment.NORMAL)
{
continue;
}
return w.getSpawnLocation();
@@ -52,15 +61,19 @@ public class Spawn implements IConf {
}
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) {
for (World w : server.getWorlds())
{
if (w.getEnvironment() != Environment.NORMAL)
{
continue;
}
world = w;
break;
}
for (World w : server.getWorlds()) {
if (!w.getName().equals(worldId)) {
for (World w : server.getWorlds())
{
if (!w.getName().equals(worldId))
{
continue;
}
world = w;
@@ -70,18 +83,20 @@ public class Spawn implements IConf {
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));
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) {
if (y < 1)
{
retval.setY(world.getHighestBlockYAt(retval));
}
return retval;
}
public void reloadConfig() {
public void reloadConfig()
{
config.load();
}
}

View File

@@ -4,6 +4,8 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.server.ChunkPosition;
import net.minecraft.server.Packet60Explosion;
import org.bukkit.Location;
@@ -35,7 +37,8 @@ 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);
}
@@ -52,26 +55,33 @@ 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)
try
{
if (player.getWorld().equals(loc.getWorld()))
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)
{
blocksUnderPlayers.add(new ChunkPosition(player.getLocation().getBlockX(), player.getLocation().getBlockY() - 1, player.getLocation().getBlockZ()));
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));
}
for (Block block : event.blockList())
catch (Throwable ex)
{
final ChunkPosition cp = new ChunkPosition(block.getX(), block.getY(), block.getZ());
if (!blocksUnderPlayers.contains(cp))
{
set.add(cp);
}
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
}
((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));
event.setCancelled(true);
}

View File

@@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
/**
* Original authors: toi & Raphfrk
*/
@Deprecated
public class TargetBlock
{
private transient final Location location;

View File

@@ -1,5 +1,6 @@
package com.earth2me.essentials;
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.logging.Logger;
@@ -10,6 +11,8 @@ import org.bukkit.entity.Entity;
public class Teleport implements Runnable
{
private static final double MOVE_CONSTANT = 0.3;
private static class Target
{
private final Location location;
@@ -57,9 +60,9 @@ public class Teleport implements Runnable
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;
}
@@ -72,9 +75,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);
@@ -92,7 +95,7 @@ public class Teleport implements Runnable
user.sendMessage(Util.i18n("teleportationCommencing"));
try
{
now(teleportTarget);
if (chargeFor != null)
{
@@ -229,7 +232,7 @@ public class Teleport implements Runnable
cooldown(false);
now(new Target(loc));
}
public void now(Location loc, Trade chargeFor) throws Exception
{
cooldown(false);
@@ -253,27 +256,15 @@ public class Teleport implements Runnable
public void back() throws Exception
{
back(null);
now(new Target(user.getLastLocation()));
}
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);
}

View File

@@ -72,19 +72,33 @@ public class Trade
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();
}
return success;
}
public void charge(final IUser user) throws ChargeException
@@ -228,7 +242,8 @@ public class Trade
public static void closeLog()
{
if (fw != null) {
if (fw != null)
{
try
{
fw.close();

View File

@@ -4,47 +4,56 @@ 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.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 lastOnlineActivity;
private transient long lastActivity = System.currentTimeMillis();
private boolean hidden = false;
private transient Location afkPosition;
User(Player base, IEssentials ess)
User(final Player base, final IEssentials ess)
{
super(base, ess);
teleport = new Teleport(this, ess);
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,16 +64,16 @@ 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));
@@ -76,12 +85,13 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
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)
{
@@ -91,35 +101,36 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
sendMessage(Util.format("addedToAccount", Util.formatCurrency(value, ess)));
if (initiator != null)
{
initiator.sendMessage((Util.format("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())));
initiator.sendMessage(Util.format("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()));
}
else
{
throw new Exception(Util.i18n("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)
{
@@ -129,13 +140,13 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value, ess)));
if (initiator != null)
{
initiator.sendMessage((Util.format("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())));
initiator.sendMessage(Util.format("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,39 +155,32 @@ 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 ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.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 ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)object).getDisplayName()));
}
@@ -186,27 +190,33 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return ChatColor.stripColor(this.getDisplayName()).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)
{
teleportRequester = player;
teleportRequestHere = here;
@@ -248,12 +258,21 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
if (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 +281,35 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return nickname.toString();
}
public void setDisplayNick(String name)
{
setDisplayName(name);
setPlayerListName(name.length() > 16 ? name.substring(0, 16) : name);
}
@Override
public String getDisplayName()
{
if (!(base instanceof OfflinePlayer) && ess.getSettings().changeDisplayName())
{
setDisplayNick(getNick());
}
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 +319,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 +335,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,16 +357,20 @@ 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();
}
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;
}
@@ -341,8 +380,118 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
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(Util.i18n("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(Util.i18n("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, Util.format("userIsNotAway", getDisplayName()));
}
}
lastActivity = System.currentTimeMillis();
}
public void checkActivity()
{
final long autoafkkick = ess.getSettings().getAutoAfkKick();
if (autoafkkick > 0 && lastActivity + autoafkkick * 1000 < System.currentTimeMillis()
&& !isHidden() && !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt"))
{
final String kickReason = Util.format("autoAfkKickReason", autoafkkick / 60.0);
kickPlayer(kickReason);
for (Player player : ess.getServer().getOnlinePlayers())
{
final User user = ess.getUser(player);
if (user.isAuthorized("essentials.kick.notify"))
{
player.sendMessage(Util.format("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, Util.format("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() || (isAfk() && ess.getSettings().getFreezeAfkPlayers());
}
}

View File

@@ -1,15 +1,14 @@
package com.earth2me.essentials;
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
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.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -36,7 +35,8 @@ public abstract class UserData extends PlayerExtension implements IConf
config.load();
money = _getMoney();
unlimited = _getUnlimited();
powertools = getPowertools();
powertools = _getPowertools();
homes = _getHomes();
lastLocation = _getLastLocation();
lastTeleportTimestamp = _getLastTeleportTimestamp();
lastHealTimestamp = _getLastHealTimestamp();
@@ -52,11 +52,14 @@ 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 +92,96 @@ 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(Location world) throws Exception
{
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;
}
public List<String> getHomes()
{
List<String> list = new ArrayList(homes.keySet());
return list;
}
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 +192,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 +232,66 @@ 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 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.size() > 0;
}
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 +301,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();
@@ -586,6 +669,7 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("timestamps.login", time);
config.save();
}
private long lastLogout;
private long _getLastLogout()
@@ -604,6 +688,26 @@ 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()
@@ -709,4 +813,57 @@ 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());
return num == null ? null : num.longValue();
}
public void setKitTimestamp(final String name, final long time)
{
kitTimestamps.put(name.toLowerCase(), time);
config.setProperty("timestamps.kits", kitTimestamps);
config.save();
}
}

View File

@@ -0,0 +1,119 @@
package com.earth2me.essentials;
import com.google.common.base.Function;
import com.google.common.collect.ComputationException;
import com.google.common.collect.MapMaker;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class UserMap implements Function<String, User>, IConf
{
private final transient IEssentials ess;
private final transient ConcurrentMap<String, User> users = new MapMaker().softValues().makeComputingMap(this);
public UserMap(final IEssentials ess)
{
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;
}
for (String string : userdir.list())
{
if (!string.endsWith(".yml"))
{
continue;
}
final String name = string.substring(0, string.length() - 4);
try
{
users.get(name.toLowerCase());
}
catch (NullPointerException ex)
{
// Ignore these
}
catch (ComputationException ex)
{
Bukkit.getLogger().log(Level.INFO, "Failed to preload user " + name, ex);
}
}
}
});
}
public boolean userExists(final String name)
{
return users.containsKey(name.toLowerCase());
}
public User getUser(final String name) throws NullPointerException
{
return users.get(name.toLowerCase());
}
@Override
public User apply(final String name)
{
for (Player player : ess.getServer().getOnlinePlayers())
{
if (player.getName().equalsIgnoreCase(name))
{
return new User(player, ess);
}
}
final File userFolder = new File(ess.getDataFolder(), "userdata");
final File userFile = new File(userFolder, Util.sanitizeFileName(name) + ".yml");
if (userFile.exists())
{
return new User(new OfflinePlayer(name, ess), ess);
}
return null;
}
@Override
public void reloadConfig()
{
for (User user : users.values())
{
user.reloadConfig();
}
}
public void removeUser(final String name)
{
users.remove(name.toLowerCase());
}
public Set<User> getAllUsers()
{
final Set<User> userSet = new HashSet<User>();
for (String name : users.keySet())
{
userSet.add(users.get(name));
}
return userSet;
}
public int getUniqueUsers()
{
return users.size();
}
}

View File

@@ -14,9 +14,12 @@ import java.text.MessageFormat;
import java.util.Calendar;
import java.util.Enumeration;
import java.util.GregorianCalendar;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
@@ -25,6 +28,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.entity.Player;
public class Util
@@ -216,6 +221,61 @@ 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());
//TODO: Add 1.9 materials
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)
@@ -224,15 +284,15 @@ public class Util
}
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))
{
y -= 1;
if (y < 0)
{
throw new Exception(Util.i18n("holeInFloor"));
break;
}
}
@@ -252,6 +312,10 @@ public class Util
{
y = 127;
x += 1;
if (x - 32 > loc.getBlockX())
{
throw new Exception(Util.i18n("holeInFloor"));
}
}
}
return new Location(world, x + 0.5D, y, z + 0.5D, loc.getYaw(), loc.getPitch());
@@ -259,7 +323,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,8 +339,8 @@ 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;
}
@@ -465,18 +529,40 @@ public class Util
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 List)
{
buf.append(joinList(seperator, ((List)each).toArray()));
}
else
{
try
{
buf.append(each.toString());
}
catch (Exception e)
{
buf.append(each.toString());
}
}
first = false;
buf.append(each);
}
return buf.toString();
}
public static String capitalCase(String s)
{
return s.toUpperCase().charAt(0) + s.toLowerCase().substring(1);
}
}

View File

@@ -2,6 +2,7 @@ package com.earth2me.essentials;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -35,9 +36,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());

View File

@@ -21,28 +21,34 @@ public class Worth implements IConf
{
String itemname = itemStack.getType().toString().toLowerCase().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) {
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);
}
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().replace("_", "") + "." + itemStack.getDurability(), price);
}
config.removeProperty("worth-" + itemStack.getTypeId());
config.save();
}
@@ -50,5 +56,4 @@ public class Worth implements IConf
{
config.load();
}
}

View File

@@ -21,6 +21,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
@@ -60,12 +61,16 @@ public final class Economy
{
logger.log(Level.WARNING, Util.format("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 +181,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 +240,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

@@ -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]));
@@ -35,13 +33,20 @@ public class Commandafk extends EssentialsCommand
{
if (!user.toggleAfk())
{
user.sendMessage(Util.i18n("markedAsNotAway"));
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
//user.sendMessage(Util.i18n("markedAsNotAway"));
if (!user.isHidden())
{
ess.broadcastMessage(user, Util.format("userIsNotAway", user.getDisplayName()));
}
user.updateActivity(false);
}
else
{
user.sendMessage(Util.i18n("markedAsAway"));
ess.broadcastMessage(user.getName(), Util.format("userIsAway", user.getDisplayName()));
//user.sendMessage(Util.i18n("markedAsAway"));
if (!user.isHidden())
{
ess.broadcastMessage(user, Util.format("userIsAway", user.getDisplayName()));
}
}
}
}

View File

@@ -17,9 +17,8 @@ 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();
loc.getWorld().spawn(loc, TNTPrimed.class);

View File

@@ -19,9 +19,8 @@ public class Commandbackup extends EssentialsCommand
Backup backup = ess.getBackup();
if (backup == null)
{
return;
throw new Exception();
}
charge(sender);
backup.run();
sender.sendMessage(Util.i18n("backupStarted"));
}

View File

@@ -26,7 +26,6 @@ public class Commandbalance extends EssentialsCommand
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
charge(user);
double bal = (args.length < 1
|| !(user.isAuthorized("essentials.balance.others")
|| user.isAuthorized("essentials.balance.other"))

View File

@@ -39,7 +39,7 @@ public class Commandbalancetop extends EssentialsCommand
}
}
final Map<User, Double> balances = new HashMap<User, Double>();
for (User u : ess.getAllUsers().values())
for (User u : ess.getUserMap().getAllUsers())
{
balances.put(u, u.getMoney());
}

View File

@@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import com.earth2me.essentials.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -45,20 +46,22 @@ public class Commandban extends EssentialsCommand
if (args.length > 1)
{
banReason = getFinalArg(args, 1);
player.setBanReason(commandLabel);
player.setBanReason(banReason);
}
else
{
banReason = Util.i18n("defaultBanReason");
}
player.setBanned(true);
player.kickPlayer(banReason);
ess.getBans().banByName(player.getName());
String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
for(Player p : server.getOnlinePlayers())
{
User u = ess.getUser(p);
if(u.isAuthorized("essentials.ban.notify"))
{
p.sendMessage(Util.format("playerBanned", player.getName(), banReason));
p.sendMessage(Util.format("playerBanned", senderName, player.getName(), banReason));
}
}
}

View File

@@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
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 u = ess.getUser(args[0]);
if (u == null)
{
ess.getServer().banIP(args[0]);
sender.sendMessage(Util.i18n("banIpAddress"));
}
else
{
final String ipAddress = u.getLastLoginAddress();
if (ipAddress.length() == 0)
{
throw new Exception(Util.i18n("playerNotFound"));
}
ess.getServer().banIP(u.getLastLoginAddress());
sender.sendMessage(Util.i18n("banIpAddress"));
}
}
}

View File

@@ -30,40 +30,17 @@ 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"));
}
else
{
user.sendMessage(Util.i18n("bigTreeFailure"));
throw new Exception(Util.i18n("bigTreeFailure"));
}
}
}

View File

@@ -1,6 +1,5 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -15,15 +14,14 @@ 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,
ess.broadcastMessage(null,
Util.format("broadcast", getFinalArg(args, 0)));
}
}

View File

@@ -21,7 +21,6 @@ public class Commandburn extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
charge(sender);
for (Player p : server.matchPlayer(args[0]))
{
p.setFireTicks(Integer.parseInt(args[1]) * 20);

View File

@@ -20,13 +20,13 @@ public class Commandclearinventory extends EssentialsCommand
{
if (args.length > 0 && user.isAuthorized("essentials.clearinventory.others"))
{
//TODO: Fix fringe user match case.
if (args[0].length() >= 3)
{
List<Player> online = server.matchPlayer(args[0]);
if (!online.isEmpty())
{
charge(user);
for (Player p : online)
{
p.getInventory().clear();
@@ -41,7 +41,6 @@ public class Commandclearinventory extends EssentialsCommand
Player p = server.getPlayer(args[0]);
if (p != null)
{
charge(user);
p.getInventory().clear();
user.sendMessage(Util.format("inventoryClearedOthers", p.getDisplayName()));
}
@@ -53,7 +52,6 @@ public class Commandclearinventory extends EssentialsCommand
}
else
{
charge(user);
user.getInventory().clear();
user.sendMessage(Util.i18n("inventoryCleared"));
}

View File

@@ -15,18 +15,44 @@ public class Commandcompass extends EssentialsCommand
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
charge(user);
int r = (int)user.getCorrectedYaw();
int r = (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";
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));
}
}

View File

@@ -0,0 +1,48 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.Util;
public class Commanddelhome extends EssentialsCommand
{
public Commanddelhome()
{
super("delhome");
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
//Allowing both formats /delhome khobbits house | /delhome khobbits:house
final String[] nameParts = args[0].split(":");
if (nameParts[0].length() != args[0].length())
{
args = nameParts;
}
User user = ess.getUser(sender);
String name;
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
else if (args.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
{
user = getPlayer(server, args, 0, true);
name = args[1];
}
else
{
if (user == null)
{
throw new NotEnoughArgumentsException();
}
name = args[0];
}
user.delHome(name.toLowerCase());
sender.sendMessage(Util.format("deleteHome", name));
}
}

View File

@@ -16,7 +16,6 @@ public class Commanddeljail extends EssentialsCommand {
{
throw new NotEnoughArgumentsException();
}
charge(sender);
ess.getJail().delJail(args[0]);
sender.sendMessage(Util.format("deleteJail", args[0]));
}

View File

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

View File

@@ -15,7 +15,6 @@ public class Commanddepth extends EssentialsCommand
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
charge(user);
int y = user.getLocation().getBlockY() - 63;
if (y > 0)
{

View File

@@ -23,6 +23,12 @@ 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 && args[0].equalsIgnoreCase("debug"))
{
ess.getSettings().setDebug(!ess.getSettings().isDebug());
sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
return;
}
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
noteMap.put("1F#", (byte)0x0);
noteMap.put("1G", (byte)0x1);
@@ -56,7 +62,6 @@ public class Commandessentials extends EssentialsCommand
}
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();
@@ -91,7 +96,7 @@ public class Commandessentials extends EssentialsCommand
for (Player player : server.getOnlinePlayers())
{
Block block = noteBlocks.get(player);
if (block == null)
if (block == null || block.getType() != Material.NOTE_BLOCK)
{
continue;
}
@@ -102,7 +107,6 @@ public class Commandessentials extends EssentialsCommand
return;
}
ess.reload();
charge(sender);
sender.sendMessage(Util.format("essentialsReload", ess.getDescription().getVersion()));
}
@@ -111,7 +115,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

@@ -30,7 +30,6 @@ public class Commandext extends EssentialsCommand
{
if (args.length < 1)
{
charge(user);
user.setFireTicks(0);
user.sendMessage(Util.i18n("extinguish"));
return;
@@ -43,7 +42,6 @@ public class Commandext extends EssentialsCommand
{
for (Player p : server.matchPlayer(name))
{
charge(sender);
p.setFireTicks(0);
sender.sendMessage(Util.format("extinguishOthers", p.getDisplayName()));
}

View File

@@ -17,7 +17,6 @@ public class Commandfireball extends EssentialsCommand
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
charge(user);
final Vector direction = user.getEyeLocation().getDirection().multiply(2);
user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), Fireball.class);
}

View File

@@ -0,0 +1,43 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.GameMode;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandgamemode extends EssentialsCommand
{
public Commandgamemode()
{
super("gamemode");
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
Player player;
if (args.length == 0)
{
if (sender instanceof Player)
{
player = ess.getUser(sender); }
else
{
throw new NotEnoughArgumentsException();
}
}
else
{
player = server.getPlayer(args[0]);
if (player == null)
{
throw new Exception(Util.i18n("playerNotFound"));
}
}
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
sender.sendMessage(Util.format("gameMode", Util.i18n(player.getGameMode().toString().toLowerCase()), player.getDisplayName()));
}
}

View File

@@ -16,7 +16,6 @@ public class Commandgc extends EssentialsCommand
@Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
charge(sender);
sender.sendMessage(Util.format("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
sender.sendMessage(Util.format("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
sender.sendMessage(Util.format("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));

View File

@@ -15,12 +15,11 @@ public class Commandgetpos extends EssentialsCommand
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
charge(user);
Location coords = user.getLocation();
user.sendMessage("§7X: " + coords.getBlockX() + " (-North <-> +South)");
user.sendMessage("§7X: " + coords.getBlockX() + " (+East <-> -West)");
user.sendMessage("§7Y: " + coords.getBlockY() + " (+Up <-> -Down)");
user.sendMessage("§7Z: " + coords.getBlockZ() + " (+East <-> -West)");
user.sendMessage("§7Yaw: " + user.getCorrectedYaw() + " (Rotation)");
user.sendMessage("§7Z: " + coords.getBlockZ() + " (+South <-> -North)");
user.sendMessage("§7Yaw: " + (coords.getYaw() + 180 + 360) % 360 + " (Rotation)");
user.sendMessage("§7Pitch: " + coords.getPitch() + " (Head angle)");
}
}

View File

@@ -16,6 +16,7 @@ public class Commandgive extends EssentialsCommand
super("give");
}
//TODO: move these messages to message file
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
@@ -35,8 +36,7 @@ public class Commandgive extends EssentialsCommand
: (!ess.getUser(sender).isAuthorized("essentials.itemspawn.exempt")
&& !ess.getUser(sender).canSpawnItem(stack.getTypeId()))))
{
sender.sendMessage(ChatColor.RED + "You are not allowed to spawn the item " + itemname);
return;
throw new Exception(ChatColor.RED + "You are not allowed to spawn the item " + itemname);
}
if (args.length > 2 && Integer.parseInt(args[2]) > 0)
{
@@ -45,13 +45,11 @@ public class Commandgive extends EssentialsCommand
if (stack.getType() == Material.AIR)
{
sender.sendMessage(ChatColor.RED + "You can't give air.");
return;
throw new Exception(ChatColor.RED + "You can't give air.");
}
User giveTo = getPlayer(server, args, 0);
String itemName = stack.getType().name().toLowerCase().replace('_', ' ');
charge(sender);
String itemName = stack.getType().toString().toLowerCase().replace('_', ' ');
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
giveTo.getInventory().addItem(stack);
giveTo.updateInventory();

View File

@@ -28,7 +28,6 @@ public class Commandgod extends EssentialsCommand
@Override
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
charge(user);
if (args.length > 0 && user.isAuthorized("essentials.god.others"))
{
godOtherPlayers(server, user, args[0]);

View File

@@ -25,7 +25,6 @@ public class Commandheal extends EssentialsCommand
{
user.healCooldown();
}
charge(user);
healOtherPlayers(server, user, args[0]);
return;
}
@@ -34,8 +33,8 @@ public class Commandheal extends EssentialsCommand
{
user.healCooldown();
}
charge(user);
user.setHealth(20);
user.setFoodLevel(20);
user.sendMessage(Util.i18n("heal"));
}

View File

@@ -20,6 +20,9 @@ import java.util.logging.Level;
public class Commandhelp extends EssentialsCommand
{
private static final String DESCRIPTION = "description";
private static final String PERMISSION = "permission";
private static final String PERMISSIONS = "permissions";
public final Yaml yaml = new Yaml(new SafeConstructor());
public Commandhelp()
@@ -28,7 +31,7 @@ public class Commandhelp 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
{
int page = 1;
String match = "";
@@ -53,34 +56,32 @@ public class Commandhelp extends EssentialsCommand
}
}
List<String> lines = getHelpLines(user, match);
if (lines.size() > 0)
final List<String> lines = getHelpLines(user, match);
if (lines.isEmpty())
{
int start = (page - 1) * 9;
int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
user.sendMessage(Util.format("helpPages", page, pages));
for (int i = start; i < lines.size() && i < start + 9; i++)
{
user.sendMessage(lines.get(i));
}
throw new Exception(Util.i18n("noHelpFound"));
}
else
final int start = (page - 1) * 9;
final int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
user.sendMessage(Util.format("helpPages", page, pages));
for (int i = start; i < lines.size() && i < start + 9; i++)
{
user.sendMessage(Util.i18n("noHelpFound"));
user.sendMessage(lines.get(i));
}
}
@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
{
sender.sendMessage(Util.i18n("helpConsole"));
}
@SuppressWarnings("CallToThreadDumpStack")
private List<String> getHelpLines(User user, String match) throws Exception
private List<String> getHelpLines(final User user, final String match) throws Exception
{
List<String> retval = new ArrayList<String>();
final List<String> retval = new ArrayList<String>();
File helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getName()) + ".txt");
if (!helpFile.exists())
{
@@ -116,53 +117,98 @@ public class Commandhelp extends EssentialsCommand
try
{
final PluginDescriptionFile desc = p.getDescription();
final HashMap<String, HashMap<String, String>> cmds = (HashMap<String, HashMap<String, String>>)desc.getCommands();
for (Entry<String, HashMap<String, String>> k : cmds.entrySet())
final HashMap<String, HashMap<String, Object>> cmds = (HashMap<String, HashMap<String, Object>>)desc.getCommands();
pluginName = p.getDescription().getName().toLowerCase();
for (Entry<String, HashMap<String, Object>> k : cmds.entrySet())
{
if ((!match.equalsIgnoreCase("")) && (!k.getKey().toLowerCase().contains(match))
&& (!k.getValue().get("description").toLowerCase().contains(match)))
try
{
if ((!match.equalsIgnoreCase(""))
&& (!k.getKey().toLowerCase().contains(match))
&& (!(k.getValue().get(DESCRIPTION) instanceof String
&& ((String)k.getValue().get(DESCRIPTION)).toLowerCase().contains(match)))
&& (!pluginName.contains(match)))
{
continue;
}
if (pluginName.contains("essentials"))
{
final String node = "essentials." + k.getKey();
if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node))
{
retval.add("§c" + k.getKey() + "§7: " + k.getValue().get(DESCRIPTION));
}
}
else
{
if (ess.getSettings().showNonEssCommandsInHelp())
{
final HashMap<String, Object> value = k.getValue();
if (value.containsKey(PERMISSION) && value.get(PERMISSION) instanceof String && !(value.get(PERMISSION).equals("")))
{
if (user.isAuthorized((String)value.get(PERMISSION)))
{
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
}
}
else if (value.containsKey(PERMISSION) && value.get(PERMISSION) instanceof List && !((List<Object>)value.get(PERMISSION)).isEmpty())
{
boolean enabled = false;
for (Object o : (List<Object>)value.get(PERMISSION))
{
if (o instanceof String && user.isAuthorized((String)o))
{
enabled = true;
break;
}
}
if (enabled)
{
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
}
}
else if (value.containsKey(PERMISSIONS) && value.get(PERMISSIONS) instanceof String && !(value.get(PERMISSIONS).equals("")))
{
if (user.isAuthorized((String)value.get(PERMISSIONS)))
{
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
}
}
else if (value.containsKey(PERMISSIONS) && value.get(PERMISSIONS) instanceof List && !((List<Object>)value.get(PERMISSIONS)).isEmpty())
{
boolean enabled = false;
for (Object o : (List<Object>)value.get(PERMISSIONS))
{
if (o instanceof String && user.isAuthorized((String)o))
{
enabled = true;
break;
}
}
if (enabled)
{
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
}
}
else if (user.isAuthorized("essentials.help." + pluginName))
{
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
}
else
{
if (!ess.getSettings().hidePermissionlessHelp())
{
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
}
}
}
}
}
catch (NullPointerException ex)
{
continue;
}
if (p.getDescription().getName().toLowerCase().contains("essentials"))
{
final String node = "essentials." + k.getKey();
if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node))
{
retval.add("§c" + k.getKey() + "§7: " + k.getValue().get("description"));
}
}
else
{
if (ess.getSettings().showNonEssCommandsInHelp())
{
pluginName = p.getDescription().getName();
final HashMap<String, String> value = k.getValue();
if (value.containsKey("permission") && value.get("permission") != null && !(value.get("permission").equals("")))
{
if (user.isAuthorized(value.get("permission")))
{
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
}
}
else if (value.containsKey("permissions") && value.get("permissions") != null && !(value.get("permissions").equals("")))
{
if (user.isAuthorized(value.get("permissions")))
{
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
}
}
else
{
if (!ess.getSettings().hidePermissionlessHelp())
{
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
}
}
}
}
}
}
catch (NullPointerException ex)

View File

@@ -22,7 +22,6 @@ public class Commandhelpop extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
charge(user);
final String message = Util.format("helpOp", user.getDisplayName(), getFinalArg(args, 0));
logger.log(Level.INFO, message);
for (Player p : server.getOnlinePlayers())

View File

@@ -4,6 +4,7 @@ import com.earth2me.essentials.Trade;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.List;
public class Commandhome extends EssentialsCommand
@@ -18,24 +19,49 @@ public class Commandhome extends EssentialsCommand
{
Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
if(args.length > 0 && user.isAuthorized("essentials.home.others"))
User u = user;
String homeName = "";
String[] nameParts;
if (args.length > 0)
{
User u;
try
nameParts = args[0].split(":");
if (nameParts[0].length() == args[0].length() || !user.isAuthorized("essentials.home.others"))
{
u = getPlayer(server, args, 0);
homeName = nameParts[0];
}
catch(NoSuchFieldException ex)
else
{
u = ess.getOfflineUser(args[0]);
u = getPlayer(server, nameParts[0].split(" "), 0, true);
if (nameParts.length > 1)
{
homeName = nameParts[1];
}
}
if (u == null)
{
throw new Exception(Util.i18n("playerNotFound"));
}
user.getTeleport().home(u, charge);
return;
}
user.getTeleport().home(charge);
try
{
user.getTeleport().home(u, homeName.toLowerCase(), charge);
}
catch (NotEnoughArgumentsException e)
{
List<String> homes = u.getHomes();
if (homes.isEmpty() && u.equals(user) && ess.getSettings().spawnIfNoHome())
{
user.getTeleport().respawn(ess.getSpawn(), charge);
}
else if (homes.isEmpty())
{
throw new Exception(u == user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer"));
}
else if (homes.size() == 1 && u.equals(user))
{
user.getTeleport().home(u, homes.get(0), charge);
}
else
{
user.sendMessage(Util.format("homes", Util.joinList(homes)));
}
}
throw new NoChargeException();
}
}

View File

@@ -68,9 +68,8 @@ public class Commandinfo extends EssentialsCommand
}
else
{
sender.sendMessage(Util.i18n("infoFileDoesNotExist"));
file.createNewFile();
return;
throw new Exception(Util.i18n("infoFileDoesNotExist"));
}
if (bookmarks.isEmpty())
@@ -88,7 +87,6 @@ public class Commandinfo extends EssentialsCommand
int start = (page - 1) * 9;
int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
charge(sender);
sender.sendMessage(Util.format("infoPages", page, pages ));
for (int i = start; i < lines.size() && i < start + 9; i++)
{
@@ -140,7 +138,6 @@ public class Commandinfo extends EssentialsCommand
}
int pages = end / 9 + (end % 9 > 0 ? 1 : 0);
charge(sender);
sender.sendMessage(Util.format("infoPages", page, pages ));
for (int i = start; i < end && i < start + 9; i++)
{
@@ -182,7 +179,6 @@ public class Commandinfo extends EssentialsCommand
int page = chapterpage + 1;
int pages = (chapterend - chapterstart) / 9 + ((chapterend - chapterstart) % 9 > 0 ? 1 : 0);
charge(sender);
sender.sendMessage(Util.format("infoChapterPages", pageStr, page , pages));
for (int i = start; i < chapterend && i < start + 9; i++)
{

View File

@@ -32,10 +32,9 @@ public class Commandinvsee extends EssentialsCommand
invUser.getInventory().setContents(user.getSavedInventory());
user.setSavedInventory(null);
user.sendMessage(Util.i18n("invRestored"));
return;
throw new NoChargeException();
}
charge(user);
if (user.getSavedInventory() == null)
{
user.setSavedInventory(user.getInventory().getContents());
@@ -51,5 +50,6 @@ public class Commandinvsee extends EssentialsCommand
user.getInventory().setContents(invUserStack);
user.sendMessage(Util.format("invSee", invUser.getDisplayName()));
user.sendMessage(Util.i18n("invSeeHelp"));
throw new NoChargeException();
}
}

View File

@@ -31,8 +31,7 @@ public class Commanditem extends EssentialsCommand
: (!user.isAuthorized("essentials.itemspawn.exempt")
&& !user.canSpawnItem(stack.getTypeId())))
{
user.sendMessage(Util.format("cantSpawnItem", itemname));
return;
throw new Exception(Util.format("cantSpawnItem", itemname));
}
if (args.length > 1 && Integer.parseInt(args[1]) > 0)
@@ -42,12 +41,10 @@ public class Commanditem extends EssentialsCommand
if (stack.getType() == Material.AIR)
{
user.sendMessage(Util.format("cantSpawnItem", "Air"));
return;
throw new Exception(Util.format("cantSpawnItem", "Air"));
}
String itemName = stack.getType().name().toLowerCase().replace('_', ' ');
charge(user);
String itemName = stack.getType().toString().toLowerCase().replace('_', ' ');
user.sendMessage(Util.format("itemSpawn", stack.getAmount(), itemName));
user.getInventory().addItem(stack);
user.updateInventory();

View File

@@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -14,12 +15,6 @@ public class Commandjails extends EssentialsCommand
@Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
StringBuilder jailList = new StringBuilder();
for (String j : ess.getJail().getJails())
{
jailList.append(j);
jailList.append(' ');
}
sender.sendMessage("§7" + jailList);
sender.sendMessage("§7" + Util.joinList(" ", ess.getJail().getJails()));
}
}

View File

@@ -1,9 +1,11 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.entity.Player;
public class Commandkick extends EssentialsCommand
@@ -21,15 +23,22 @@ public class Commandkick extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
User u = getPlayer(server, args, 0);
if (u.isAuthorized("essentials.kick.exempt"))
User player = getPlayer(server, args, 0);
if (player.isAuthorized("essentials.kick.exempt"))
{
sender.sendMessage(Util.i18n("kickExempt"));
return;
throw new Exception(Util.i18n("kickExempt"));
}
charge(sender);
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault");
u.kickPlayer(kickReason);
server.broadcastMessage(Util.format("playerKicked", u.getName(), kickReason));
player.kickPlayer(kickReason);
String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
for(Player p : server.getOnlinePlayers())
{
User u = ess.getUser(p);
if(u.isAuthorized("essentials.kick.notify"))
{
p.sendMessage(Util.format("playerKicked", senderName, player.getName(), kickReason));
}
}
}
}

View File

@@ -16,8 +16,6 @@ public class Commandkickall extends EssentialsCommand
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
charge(sender);
for (Player p : server.getOnlinePlayers())
{
if (sender instanceof Player && p.getName().equalsIgnoreCase(((Player)sender).getName()))

View File

@@ -4,6 +4,7 @@ import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
public class Commandkill extends EssentialsCommand
@@ -21,9 +22,15 @@ public class Commandkill extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
charge(sender);
for (Player p : server.matchPlayer(args[0]))
{
final EntityDamageEvent ede = new EntityDamageEvent(p, sender instanceof Player && ((Player)sender).getName().equals(p.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, 1000);
server.getPluginManager().callEvent(ede);
if (ede.isCancelled() && !sender.hasPermission("essentials.kill.force"))
{
continue;
}
p.setHealth(0);
sender.sendMessage(Util.format("kill", p.getDisplayName()));
}

View File

@@ -9,27 +9,26 @@ import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.GregorianCalendar;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public class Commandkit extends EssentialsCommand
{
static private final Map<User, Map<String, Long>> kitPlayers = new HashMap<User, Map<String, Long>>();
public Commandkit()
{
super("kit");
}
@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)
{
try
{
Map<String, Object> kits = ess.getSettings().getKits();
StringBuilder list = new StringBuilder();
final Map<String, Object> kits = ess.getSettings().getKits();
final StringBuilder list = new StringBuilder();
for (String k : kits.keySet())
{
if (user.isAuthorized("essentials.kit." + k.toLowerCase()))
@@ -55,8 +54,8 @@ public class Commandkit extends EssentialsCommand
{
try
{
String kitName = args[0].toLowerCase();
Object kit = ess.getSettings().getKit(kitName);
final String kitName = args[0].toLowerCase();
final Object kit = ess.getSettings().getKit(kitName);
List<String> items;
if (!user.isAuthorized("essentials.kit." + kitName))
@@ -69,39 +68,26 @@ public class Commandkit extends EssentialsCommand
{
//System.out.println("Kit is timed");
Map<String, Object> els = (Map<String, Object>)kit;
final Map<String, Object> els = (Map<String, Object>)kit;
items = (List<String>)els.get("items");
double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L;
Calendar c = new GregorianCalendar();
c.add(Calendar.SECOND, (int)delay);
c.add(Calendar.MILLISECOND, (int)((delay*1000.0)%1000.0));
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));
long time = c.getTimeInMillis();
Calendar now = new GregorianCalendar();
Map<String, Long> kitTimes;
if (!kitPlayers.containsKey(user))
{
kitTimes = new HashMap<String, Long>();
kitTimes.put(kitName, time);
kitPlayers.put(user, kitTimes);
}
else
{
kitTimes = kitPlayers.get(user);
if (!kitTimes.containsKey(kitName))
{
kitTimes.put(kitName, time);
}
else if (kitTimes.get(kitName) < now.getTimeInMillis())
{
kitTimes.put(kitName, time);
}
else
{
user.sendMessage(Util.format("kitTimed", Util.formatDateDiff(kitTimes.get(kitName))));
return;
}
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(Util.format("kitTimed", Util.formatDateDiff(future.getTimeInMillis())));
return;
}
}
catch (Exception ex)
@@ -109,7 +95,7 @@ public class Commandkit extends EssentialsCommand
items = (List<String>)kit;
}
Trade charge = new Trade("kit-" + kitName, ess);
final Trade charge = new Trade("kit-" + kitName, ess);
try
{
charge.isAffordableFor(user);
@@ -123,11 +109,11 @@ public class Commandkit extends EssentialsCommand
boolean spew = false;
for (String d : items)
{
String[] parts = d.split("[^0-9]+", 3);
int id = Integer.parseInt(parts[0]);
int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1;
short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0;
HashMap<Integer,ItemStack> overfilled = user.getInventory().addItem(new ItemStack(id, amount, data));
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 HashMap<Integer,ItemStack> overfilled = user.getInventory().addItem(new ItemStack(id, amount, data));
for (ItemStack itemStack : overfilled.values())
{
user.getWorld().dropItemNaturally(user.getLocation(), itemStack);
@@ -140,7 +126,6 @@ public class Commandkit extends EssentialsCommand
}
try
{
charge(user);
charge.charge(user);
}
catch (Exception ex)

View File

@@ -26,20 +26,14 @@ public class Commandlightning extends EssentialsCommand
if (args.length < 1 & user != null)
{
user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation());
charge(user);
return;
}
if (server.matchPlayer(args[0]).isEmpty())
{
sender.sendMessage(Util.i18n("playerNotFound"));
return;
throw new Exception(Util.i18n("playerNotFound"));
}
if (user != null)
{
charge(user);
}
for (Player p : server.matchPlayer(args[0]))
{
sender.sendMessage(Util.format("lightningUse", p.getDisplayName()));

View File

@@ -44,7 +44,7 @@ public class Commandlist extends EssentialsCommand
playerHidden++;
}
}
charge(sender);
//TODO: move these to messages file
StringBuilder online = new StringBuilder();
online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length - playerHidden);
if (showhidden && playerHidden > 0)

View File

@@ -5,6 +5,7 @@ import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -24,7 +25,7 @@ public class Commandmail extends EssentialsCommand
if (mail.isEmpty())
{
user.sendMessage(Util.i18n("noMail"));
return;
throw new NoChargeException();
}
for (String s : mail)
{
@@ -37,8 +38,7 @@ public class Commandmail extends EssentialsCommand
{
if (!user.isAuthorized("essentials.mail.send"))
{
user.sendMessage(Util.i18n("noMailSendPerm"));
return;
throw new Exception(Util.i18n("noMailSendPerm"));
}
Player player = server.getPlayer(args[1]);
@@ -53,10 +53,8 @@ public class Commandmail extends EssentialsCommand
}
if (u == null)
{
user.sendMessage(Util.format("playerNeverOnServer", args[1]));
return;
throw new Exception(Util.format("playerNeverOnServer", args[1]));
}
charge(user);
if (!u.isIgnoredPlayer(user.getName()))
{
u.addMail(ChatColor.stripColor(user.getDisplayName()) + ": " + getFinalArg(args, 2));
@@ -72,4 +70,59 @@ public class Commandmail extends EssentialsCommand
}
throw new NotEnoughArgumentsException();
}
@Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length >= 1 && "read".equalsIgnoreCase(args[0]))
{
throw new Exception(Util.format("onlyPlayers", commandLabel + " read"));
}
else if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
{
throw new Exception(Util.format("onlyPlayers", commandLabel + " clear"));
}
else if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
{
Player player = server.getPlayer(args[1]);
User u;
if (player != null)
{
u = ess.getUser(player);
}
else
{
u = ess.getOfflineUser(args[1]);
}
if (u == null)
{
throw new Exception(Util.format("playerNeverOnServer", args[1]));
}
u.addMail("Server: " + getFinalArg(args, 2));
sender.sendMessage(Util.i18n("mailSent"));
return;
}
else if (args.length >= 2)
{
//allow sending from console without "send" argument, since it's the only thing the console can do
Player player = server.getPlayer(args[0]);
User u;
if (player != null)
{
u = ess.getUser(player);
}
else
{
u = ess.getOfflineUser(args[0]);
}
if (u == null)
{
throw new Exception(Util.format("playerNeverOnServer", args[0]));
}
u.addMail("Server: " + getFinalArg(args, 1));
sender.sendMessage(Util.i18n("mailSent"));
return;
}
throw new NotEnoughArgumentsException();
}
}

View File

@@ -17,21 +17,20 @@ public class Commandme extends EssentialsCommand
{
if (user.isMuted())
{
user.sendMessage(Util.i18n("voiceSilenced"));
return;
throw new Exception(Util.i18n("voiceSilenced"));
}
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
StringBuilder message = new StringBuilder();
for (int i = 0; i < args.length; i++)
String message = getFinalArg(args, 0);
if (user.isAuthorized("essentials.chat.color"))
{
message.append(args[i]);
message.append(' ');
message = message.replaceAll("&([0-9a-f])", "§$1");
}
charge(user);
ess.broadcastMessage(user.getName(), "* " + user.getDisplayName() + " " + message);
ess.broadcastMessage(user, Util.format("action", user.getDisplayName(), message));
}
}

View File

@@ -15,7 +15,6 @@ public class Commandmotd extends EssentialsCommand
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
charge(sender);
for (String m : ess.getMotd(sender, Util.i18n("noMotd")))
{
sender.sendMessage(m);

View File

@@ -25,6 +25,15 @@ public class Commandmsg extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
if (sender instanceof Player)
{
User user = ess.getUser(sender);
if (user.isMuted())
{
throw new Exception(Util.i18n("voiceSilenced"));
}
}
String message = getFinalArg(args, 1);
String translatedMe = Util.i18n("me");
@@ -45,10 +54,9 @@ public class Commandmsg extends EssentialsCommand
if (matches.isEmpty())
{
sender.sendMessage(Util.i18n("playerNotFound"));
return;
throw new Exception(Util.i18n("playerNotFound"));
}
int i = 0;
for (Player p : matches)
{
@@ -60,11 +68,9 @@ public class Commandmsg extends EssentialsCommand
}
if (i == matches.size())
{
sender.sendMessage(Util.i18n("playerNotFound"));
return;
throw new Exception(Util.i18n("playerNotFound"));
}
charge(sender);
for (Player p : matches)
{
sender.sendMessage(Util.format("msgFormat", translatedMe, p.getDisplayName(), message));

View File

@@ -1,52 +1,50 @@
package com.earth2me.essentials.commands;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
public class Commandmute extends EssentialsCommand
{
public Commandmute()
{
super("mute");
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
User p = getPlayer(server, args, 0, true);
if (!p.isMuted() && p.isAuthorized("essentials.mute.exempt"))
{
sender.sendMessage(Util.i18n("muteExempt"));
return;
}
long muteTimestamp = 0;
if (args.length > 1)
{
String time = getFinalArg(args, 1);
muteTimestamp = Util.parseDateDiff(time, true);
}
p.setMuteTimeout(muteTimestamp);
charge(sender);
boolean muted = p.toggleMuted();
sender.sendMessage(
muted
? (muteTimestamp > 0
? Util.format("mutedPlayerFor", p.getDisplayName(), Util.formatDateDiff(muteTimestamp))
: Util.format("mutedPlayer", p.getDisplayName()))
: Util.format("unmutedPlayer", p.getDisplayName()));
p.sendMessage(
muted
? (muteTimestamp > 0
? Util.format("playerMutedFor", Util.formatDateDiff(muteTimestamp))
: Util.i18n("playerMuted"))
: Util.i18n("playerUnmuted"));
}
}
package com.earth2me.essentials.commands;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
public class Commandmute extends EssentialsCommand
{
public Commandmute()
{
super("mute");
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
User p = getPlayer(server, args, 0, true);
if (!p.isMuted() && p.isAuthorized("essentials.mute.exempt"))
{
throw new Exception(Util.i18n("muteExempt"));
}
long muteTimestamp = 0;
if (args.length > 1)
{
String time = getFinalArg(args, 1);
muteTimestamp = Util.parseDateDiff(time, true);
}
p.setMuteTimeout(muteTimestamp);
boolean muted = p.toggleMuted();
sender.sendMessage(
muted
? (muteTimestamp > 0
? Util.format("mutedPlayerFor", p.getDisplayName(), Util.formatDateDiff(muteTimestamp))
: Util.format("mutedPlayer", p.getDisplayName()))
: Util.format("unmutedPlayer", p.getDisplayName()));
p.sendMessage(
muted
? (muteTimestamp > 0
? Util.format("playerMutedFor", Util.formatDateDiff(muteTimestamp))
: Util.i18n("playerMuted"))
: Util.i18n("playerUnmuted"));
}
}

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