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

Compare commits

...

293 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
243 changed files with 21491 additions and 8316 deletions

7
.gitignore vendored
View File

@@ -32,4 +32,9 @@
/YamlAnnotations/
/EssentialsUpdate/nbproject/private/
/EssentialsRelease/
/EssentialsUpdate/
/EssentialsUpdate/dist/
/EssentialsUpdate/build/
/WebPush/apikey.php
/WebPush/apikey.php
/WebPush/apikey.php

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">
@@ -1038,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,8 +3,8 @@ 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=dbc81ee1
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

View File

@@ -1,6 +1,7 @@
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=
@@ -67,7 +68,8 @@ file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHO
file.reference.iCo4.jar=../lib/iCo4.jar
file.reference.iCo5.jar=../lib/iCo5.jar
file.reference.iCo6.jar=../lib/iCo6.jar
file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.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
@@ -78,7 +80,6 @@ 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}:\
@@ -86,7 +87,10 @@ javac.classpath=\
${file.reference.BOSEconomy7.jar}:\
${file.reference.PermissionsEx.jar}:\
${file.reference.bPermissions.jar}:\
${file.reference.PermissionsBukkit-1.2.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
@@ -107,6 +111,7 @@ 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
@@ -123,6 +128,8 @@ jnlp.signing.keystore=
meta.inf.dir=${src.dir}/META-INF
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

@@ -5,6 +5,7 @@ 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;
@@ -12,7 +13,7 @@ import org.bukkit.craftbukkit.CraftServer;
public class Backup implements Runnable
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient final CraftServer server;
private transient final Server server;
private transient final IEssentials ess;
private transient boolean running = false;
private transient int taskId = -1;
@@ -21,7 +22,7 @@ public class Backup implements Runnable
public Backup(final IEssentials ess)
{
this.ess = ess;
server = (CraftServer)ess.getServer();
server = ess.getServer();
if (server.getOnlinePlayers().length > 0)
{
startTask();
@@ -60,7 +61,7 @@ public class Backup implements Runnable
return;
}
LOGGER.log(Level.INFO, Util.i18n("backupStarted"));
final CommandSender cs = server.getServer().console;
final CommandSender cs = server.getConsoleSender();
server.dispatchCommand(cs, "save-all");
server.dispatchCommand(cs, "save-off");

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

View File

@@ -33,7 +33,6 @@ 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;
@@ -58,12 +57,10 @@ public class Essentials extends JavaPlugin implements IEssentials
private transient List<IConf> confList;
private transient Backup backup;
private transient ItemDb itemDb;
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 PermissionsHandler permissionsHandler;
private transient UserMap userMap;
private transient ExecuteTimer execTimer;
@Override
public ISettings getSettings()
@@ -94,32 +91,36 @@ public class Essentials extends JavaPlugin implements IEssentials
@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);
}
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);
itemDb = new ItemDb(this);
confList.add(itemDb);
execTimer.mark("Init(Worth/ItemDB)");
reload();
backup = new Backup(this);
@@ -188,8 +189,10 @@ public class Essentials extends JavaPlugin implements IEssentials
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);
@@ -201,29 +204,25 @@ 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, 100);
Economy.setEss(this);
if (getSettings().isUpdateEnabled())
{
updateTimer = new EssentialsUpdateTimer(this);
getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 20 * 60 * 10, 20 * 3600 * 6);
}
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
@@ -234,6 +233,7 @@ public class Essentials extends JavaPlugin implements IEssentials
for (IConf iConf : confList)
{
iConf.reloadConfig();
execTimer.mark("Reload(" + iConf.getClass().getSimpleName() + ")");
}
Util.updateLocale(settings.getLocale(), this);
@@ -483,14 +483,6 @@ public class Essentials extends JavaPlugin implements IEssentials
{
LOGGER.log(logRecord);
}
else
{
if (enableErrorLogging)
{
errorHandler.publish(logRecord);
errorHandler.flush();
}
}
}
@Override
@@ -613,10 +605,12 @@ public class Essentials extends JavaPlugin implements IEssentials
@Override
public int broadcastMessage(final IUser sender, final String message)
{
if (sender == null) {
if (sender == null)
{
return getServer().broadcastMessage(message);
}
if (sender.isHidden()) {
if (sender.isHidden())
{
return 0;
}
final Player[] players = getServer().getOnlinePlayers();
@@ -633,11 +627,6 @@ 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)
{

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.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;
@@ -8,12 +10,16 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
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)
@@ -33,6 +39,7 @@ public class EssentialsEntityListener extends EntityListener
{
User defender = ess.getUser(eDefend);
User attacker = ess.getUser(eAttack);
attacker.updateActivity(true);
ItemStack is = attacker.getItemInHand();
List<String> commandList = attacker.getPowertool(is);
if (commandList != null && !commandList.isEmpty())
@@ -69,16 +76,21 @@ 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("");
}
}
}
@@ -87,7 +99,17 @@ public class EssentialsEntityListener extends EntityListener
{
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{
event.setFoodLevel(20);
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

@@ -14,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;
@@ -46,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());
}
}
@@ -76,7 +76,7 @@ public class EssentialsPlayerListener extends PlayerListener
user.updateActivity(true);
if (ess.getSettings().changeDisplayName())
{
user.setDisplayName(user.getNick());
user.setDisplayNick(user.getNick());
}
}
@@ -107,113 +107,11 @@ public class EssentialsPlayerListener extends PlayerListener
return;
}
Location afk = user.getAfkPosition();
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9) {
final Location afk = user.getAfkPosition();
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
{
user.updateActivity(true);
}
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);
try
{
user.getTeleport().now(loc, new Trade("portal", ess));
}
catch (Exception ex)
{
user.sendMessage(ex.getMessage());
}
user.setJustPortaled(true);
user.sendMessage(Util.i18n("teleportingPortal"));
event.setCancelled(true);
return;
}
user.setJustPortaled(false);
}
@Override
@@ -268,8 +166,9 @@ public class EssentialsPlayerListener extends PlayerListener
if (ess.getSettings().changeDisplayName())
{
user.setDisplayName(user.getNick());
user.setDisplayNick(user.getNick());
}
user.setLastLoginAddress(user.getAddress().getAddress().getHostAddress());
user.updateActivity(false);
if (user.isAuthorized("essentials.sleepingignored"))
{
@@ -307,20 +206,21 @@ public class EssentialsPlayerListener extends PlayerListener
{
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;
}
User user = ess.getUser(event.getPlayer());
user.setNPC(false);
final long currentTime = System.currentTimeMillis();
user.checkBanTimeout(currentTime);
final boolean banExpired = user.checkBanTimeout(currentTime);
user.checkMuteTimeout(currentTime);
user.checkJailTimeout(currentTime);
if (user.isBanned())
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;
}
@@ -356,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);
}
@@ -419,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);
}

View File

@@ -21,10 +21,9 @@ public class EssentialsPluginListener extends ServerListener implements IConf
public void onPluginEnable(final PluginEnableEvent event)
{
ess.getPermissionsHandler().checkPermissions();
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(event.getPlugin()))
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager()))
{
LOGGER.log(Level.INFO, "[Essentials] Payment method found (" + ess.getPaymentMethod().getMethod().getName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
}
}
@@ -35,6 +34,7 @@ public class EssentialsPluginListener extends ServerListener implements IConf
// 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.");
}
}

View File

@@ -1,84 +0,0 @@
package com.earth2me.essentials;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
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;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.entity.Player;
class EssentialsUpdateTimer implements Runnable
{
private transient URL url;
private final transient IEssentials ess;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private final transient Pattern pattern = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*");
public EssentialsUpdateTimer(final IEssentials ess)
{
this.ess = ess;
try
{
url = new URL("http://essentialsupdate.appspot.com/check");
}
catch (MalformedURLException ex)
{
LOGGER.log(Level.SEVERE, "Invalid url!", ex);
}
}
@Override
public void run()
{
try
{
final StringBuilder builder = new StringBuilder();
String bukkitVersion = ess.getServer().getVersion();
final Matcher versionMatch = pattern.matcher(bukkitVersion);
if (versionMatch.matches())
{
bukkitVersion = versionMatch.group(4);
}
builder.append("v=").append(URLEncoder.encode(ess.getDescription().getVersion(), "UTF-8"));
builder.append("&b=").append(URLEncoder.encode(bukkitVersion, "UTF-8"));
final URLConnection conn = url.openConnection();
conn.setConnectTimeout(10000);
conn.setDoOutput(true);
conn.connect();
final OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
writer.write(builder.toString());
writer.flush();
final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
final String ret = reader.readLine();
writer.close();
reader.close();
if (!ret.isEmpty() && !ret.equalsIgnoreCase("OK"))
{
LOGGER.log(Level.INFO, "Essentials Update-Check: " + ret);
if (ret.startsWith("New Version"))
{
for (Player player : ess.getServer().getOnlinePlayers())
{
final User user = ess.getUser(player);
if (user.isAuthorized("essentials.admin.notices.update"))
{
user.sendMessage(ret);
}
}
}
}
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, "Failed to open connection", ex);
}
}
}

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;
@@ -437,4 +438,21 @@ public class FakeWorld implements World
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

@@ -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();
@@ -73,7 +65,11 @@ public interface ISettings extends IConf
boolean getRespawnAtHome();
int getMultipleHomes();
List getMultipleHomes();
int getHomeLimit(String set);
int getHomeLimit(User user);
boolean getSortListByGroups();
@@ -101,8 +97,6 @@ public interface ISettings extends IConf
boolean isEcoDisabled();
boolean isNetherEnabled();
boolean isTradeInStacks(int id);
List<Integer> itemSpawnBlacklist();
@@ -113,8 +107,6 @@ public interface ISettings extends IConf
boolean spawnIfNoHome();
boolean use1to1RatioInNether();
boolean warnOnBuildDisallow();
boolean warnOnSmite();
@@ -132,12 +124,18 @@ public interface ISettings extends IConf
boolean useBukkitPermissions();
boolean addPrefixSuffix();
boolean isUpdateEnabled();
boolean disablePrefix();
boolean disableSuffix();
long getAutoAfk();
long getAutoAfkKick();
boolean getFreezeAfkPlayers();
boolean areDeathMessagesEnabled();
public void setDebug(boolean debug);
}

View File

@@ -64,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>();
@@ -106,7 +120,7 @@ public final class InventoryWorkaround
{
continue;
}
while (true)
{
// Do we already have a stack of it?

View File

@@ -26,11 +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),
CAVESPIDER("CaveSpider", Enemies.ENEMY, CreatureType.CAVE_SPIDER),
ENDERMAN("Enderman", Enemies.ENEMY, CreatureType.ENDERMAN),
SILVERFISH("Silverfish", Enemies.ENEMY, CreatureType.SILVERFISH);
ENDERMAN("Enderman", Enemies.ENEMY, "", CreatureType.ENDERMAN),
SILVERFISH("Silverfish", Enemies.ENEMY, "", CreatureType.SILVERFISH);
public static final Logger logger = Logger.getLogger("Minecraft");

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,6 +5,7 @@ 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;
@@ -35,40 +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();
private org.bukkit.OfflinePlayer base;
@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 base.isOnline();
}
public boolean isOp()
{
return base.isOp();
}
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)
{
}
@@ -86,11 +79,6 @@ public class OfflinePlayer implements Player
{
}
public String getName()
{
return name;
}
public PlayerInventory getInventory()
{
return null;
@@ -576,42 +564,13 @@ public class OfflinePlayer implements Player
{
throw new UnsupportedOperationException("Not supported yet.");
}
public void setOp(boolean bln)
{
base.setOp(bln);
}
@Override
public void sendMap(MapView mv)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isBanned()
{
return base.isBanned();
}
@Override
public void setBanned(boolean bln)
{
base.setBanned(bln);
}
@Override
public boolean isWhitelisted()
{
return base.isWhitelisted();
}
@Override
public void setWhitelisted(boolean bln)
{
base.setWhitelisted(bln);
}
@Override
public GameMode getGameMode()
{
@@ -695,7 +654,7 @@ public class OfflinePlayer implements Player
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Location getBedSpawnLocation()
{
@@ -713,5 +672,28 @@ public class OfflinePlayer implements Player
{
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,37 +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 float getCorrectedYaw()
public final Player getBase()
{
float angle = (getLocation().getYaw() - 90.0f) % 360.0f;
if (angle < 0) {
angle += 360.0f;
}
return angle;
return base;
}
public final Player setBase(final Player base)
{
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());
}
@@ -46,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,747 +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.map.MapView;
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();
}
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);
}
@Override
public void sendMap(MapView mv)
{
base.sendMap(mv);
}
@Override
public boolean isBanned()
{
return base.isBanned();
}
@Override
public void setBanned(boolean bln)
{
base.setBanned(bln);
}
@Override
public boolean isWhitelisted()
{
return base.isWhitelisted();
}
@Override
public void setWhitelisted(boolean bln)
{
base.setWhitelisted(bln);
}
@Override
public GameMode getGameMode()
{
return base.getGameMode();
}
@Override
public void setGameMode(GameMode gm)
{
base.setGameMode(gm);
}
@Override
public int getExperience()
{
return base.getExperience();
}
@Override
public void setExperience(int i)
{
base.setExperience(i);
}
@Override
public int getLevel()
{
return base.getLevel();
}
@Override
public void setLevel(int i)
{
base.setLevel(i);
}
@Override
public int getTotalExperience()
{
return base.getTotalExperience();
}
@Override
public void setTotalExperience(int i)
{
base.setTotalExperience(i);
}
@Override
public float getExhaustion()
{
return base.getExhaustion();
}
@Override
public void setExhaustion(float f)
{
base.setExhaustion(f);
}
@Override
public float getSaturation()
{
return base.getSaturation();
}
@Override
public void setSaturation(float f)
{
base.setSaturation(f);
}
@Override
public int getFoodLevel()
{
return base.getFoodLevel();
}
@Override
public void setFoodLevel(int i)
{
base.setFoodLevel(i);
}
@Override
public Location getBedSpawnLocation()
{
return base.getBedSpawnLocation();
}
@Override
public boolean isSprinting()
{
return base.isSprinting();
}
@Override
public void setSprinting(boolean bln)
{
base.setSprinting(bln);
}
}

View File

@@ -30,12 +30,6 @@ public class Settings implements ISettings
{
return config.getBoolean("respawn-at-home", false);
}
@Override
public int getMultipleHomes()
{
return config.getInt("multiple-homes", 5);
}
@Override
public boolean getBedSetsHome()
@@ -43,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()
{
@@ -60,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)
{
@@ -84,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);
@@ -101,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;
@@ -126,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);
@@ -143,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;
}
@@ -171,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()
{
@@ -190,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
{
@@ -211,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()
@@ -272,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()
{
@@ -301,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()
{
@@ -314,7 +336,8 @@ public class Settings implements ISettings
}
@Override
public void reloadConfig() {
public void reloadConfig()
{
config.load();
}
@@ -322,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"));
}
}
@@ -350,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()
{
@@ -410,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));
}
}
@@ -444,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;
@@ -459,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);
@@ -479,11 +500,15 @@ public class Settings implements ISettings
{
return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat"));
}
@Override
public boolean isUpdateEnabled()
public boolean disablePrefix()
{
return config.getBoolean("update-check", false);
return config.getBoolean("disablePrefix", false);
}
public boolean disableSuffix()
{
return config.getBoolean("disableSuffix", false);
}
@Override
@@ -503,4 +528,16 @@ public class Settings implements ISettings
{
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

@@ -37,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);
}
@@ -54,28 +55,31 @@ public class TNTExplodeListener extends EntityListener implements Runnable
{
return;
}
try {
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);
}
}
((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));
} catch (Throwable ex) {
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
}
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

@@ -256,7 +256,7 @@ public class Teleport implements Runnable
public void back() throws Exception
{
back(null);
now(new Target(user.getLastLocation()));
}
public void home(IUser user, String home, Trade chargeFor) throws Exception

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

@@ -12,7 +12,6 @@ import org.bukkit.entity.Player;
public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
private boolean justPortaled = false;
private CommandSender replyTo = null;
private transient User teleportRequester;
private transient boolean teleportRequestHere;
@@ -20,14 +19,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
private transient long lastOnlineActivity;
private transient long lastActivity = System.currentTimeMillis();
private boolean hidden = false;
private transient boolean godStateBeforeAfk;
private transient Location afkPosition;
User(final Player base, final IEssentials ess)
{
super(base, ess);
teleport = new Teleport(this, ess);
godStateBeforeAfk = isGodModeEnabled();
afkPosition = getLocation();
}
@@ -158,16 +155,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
this.base = new OfflinePlayer(getName(), ess);
}
public boolean getJustPortaled()
{
return justPortaled;
}
public void setJustPortaled(final boolean value)
{
justPortaled = value;
}
@Override
public void setReplyTo(final CommandSender user)
{
@@ -271,12 +258,21 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
if (ess.getSettings().addPrefixSuffix())
{
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
final String suffix = ess.getPermissionsHandler().getSuffix(base).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");
}
@@ -285,6 +281,22 @@ 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;
@@ -348,16 +360,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
public void setAfk(final boolean set)
{
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
if (set && !isAfk() && ess.getSettings().getFreezeAfkPlayers())
if (set && !isAfk())
{
godStateBeforeAfk = isGodModeEnabled();
setGodModeEnabled(true);
}
if (!set && isAfk() && ess.getSettings().getFreezeAfkPlayers())
{
setGodModeEnabled(godStateBeforeAfk);
}
if (set && !isAfk()) {
afkPosition = getLocation();
}
super.setAfk(set);
@@ -381,7 +385,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
this.hidden = hidden;
}
public void checkJailTimeout(final long currentTime)
//Returns true if status expired during this check
public boolean checkJailTimeout(final long currentTime)
{
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
{
@@ -396,26 +401,34 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
catch (Exception ex)
{
}
return true;
}
return false;
}
public void checkMuteTimeout(final long currentTime)
//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;
}
public void checkBanTimeout(final long currentTime)
//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)
@@ -451,10 +464,11 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
}
final long autoafk = ess.getSettings().getAutoAfk();
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis())
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && isAuthorized("essentials.afk"))
{
setAfk(true);
if (!isHidden()) {
if (!isHidden())
{
ess.broadcastMessage(this, Util.format("userIsAway", getDisplayName()));
}
}
@@ -468,9 +482,16 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
@Override
public boolean toggleGodModeEnabled()
{
if (!isGodModeEnabled()) {
if (!isGodModeEnabled())
{
setFoodLevel(20);
}
return super.toggleGodModeEnabled();
}
}
@Override
public boolean isGodModeEnabled()
{
return super.isGodModeEnabled() || (isAfk() && ess.getSettings().getFreezeAfkPlayers());
}
}

View File

@@ -52,12 +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;
@@ -154,6 +156,8 @@ public abstract class UserData extends PlayerExtension implements IConf
public void setHome(String name, Location loc)
{
//Invalid names will corrupt the yaml
name = Util.sanitizeFileName(name);
homes.put(name, loc);
config.setProperty("homes." + name, loc);
config.save();
@@ -161,7 +165,12 @@ public abstract class UserData extends PlayerExtension implements IConf
public void delHome(String name) throws Exception
{
if (getHome(name) != null)
String search = name;
if (!homes.containsKey(search))
{
search = Util.sanitizeFileName(name);
}
if (homes.containsKey(search))
{
homes.remove(name);
config.removeProperty("homes." + name);
@@ -241,12 +250,13 @@ public abstract class UserData extends PlayerExtension implements IConf
}
public void clearAllPowertools() {
public void clearAllPowertools()
{
powertools.clear();
config.setProperty("powertools", powertools);
config.save();
}
public List<String> getPowertool(ItemStack stack)
{
return (List<String>)powertools.get(stack.getTypeId());
@@ -265,12 +275,11 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("powertools", powertools);
config.save();
}
public boolean hasPowerTools()
{
return powertools.size() > 0;
}
private Location lastLocation;
private Location _getLastLocation()
@@ -292,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();
@@ -656,6 +669,7 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("timestamps.login", time);
config.save();
}
private long lastLogout;
private long _getLastLogout()
@@ -674,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()
@@ -779,31 +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

@@ -52,7 +52,7 @@ public class UserMap implements Function<String, User>, IConf
}
catch (ComputationException ex)
{
Bukkit.getLogger().log(Level.INFO, "Failed to preload user "+name, ex);
Bukkit.getLogger().log(Level.INFO, "Failed to preload user " + name, ex);
}
}
}

View File

@@ -28,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
@@ -221,36 +223,57 @@ public class Util
// 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.RAILS.getId());
AIR_MATERIALS.add(Material.YELLOW_FLOWER.getId());
AIR_MATERIALS.add(Material.RED_ROSE.getId());
AIR_MATERIALS.add(Material.RED_MUSHROOM.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.WALL_SIGN.getId());
AIR_MATERIALS.add(Material.WOODEN_DOOR.getId());
AIR_MATERIALS.add(Material.LADDER.getId());
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
AIR_MATERIALS.add(Material.REDSTONE_WIRE.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.TORCH.getId());
AIR_MATERIALS.add(Material.SOIL.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.STONE_BUTTON.getId());
AIR_MATERIALS.add(Material.STONE_PLATE.getId());
AIR_MATERIALS.add(Material.WOOD_PLATE.getId());
AIR_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
AIR_MATERIALS.add(Material.WOODEN_DOOR.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
@@ -260,9 +283,9 @@ public class Util
throw new Exception(Util.i18n("destinationNotSet"));
}
final World world = loc.getWorld();
int x = (int)Math.round(loc.getX());
int x = loc.getBlockX();
int y = (int)Math.round(loc.getY());
int z = (int)Math.round(loc.getZ());
int z = loc.getBlockZ();
while (isBlockAboveAir(world, x, y, z))
{

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
@@ -66,6 +67,10 @@ public final class Economy
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

@@ -46,7 +46,7 @@ public class Commandban extends EssentialsCommand
if (args.length > 1)
{
banReason = getFinalArg(args, 1);
player.setBanReason(commandLabel);
player.setBanReason(banReason);
}
else
{

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.getServer().banIP(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

@@ -1,6 +1,5 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.TargetBlock;
import org.bukkit.Server;
import org.bukkit.TreeType;
import com.earth2me.essentials.User;
@@ -31,14 +30,10 @@ public class Commandbigtree extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
final int[] ignore =
{
8, 9
};
final Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation();
final Location loc = Util.getTarget(user);
final Location safeLocation = Util.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
final boolean success = user.getWorld().generateTree(safeLocation, tree);
if (success)
{
user.sendMessage(Util.i18n("bigTreeSuccess"));

View File

@@ -15,17 +15,44 @@ public class Commandcompass extends EssentialsCommand
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
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

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

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;
}
@@ -110,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

@@ -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,10 +16,10 @@ public class Commandgetpos extends EssentialsCommand
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
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

@@ -34,6 +34,7 @@ public class Commandheal extends EssentialsCommand
user.healCooldown();
}
user.setHealth(20);
user.setFoodLevel(20);
user.sendMessage(Util.i18n("heal"));
}

View File

@@ -45,18 +45,18 @@ public class Commandhome extends EssentialsCommand
catch (NotEnoughArgumentsException e)
{
List<String> homes = u.getHomes();
if (homes.isEmpty())
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 == user)
else if (homes.size() == 1 && u.equals(user))
{
user.getTeleport().home(u, homes.get(0), charge);
}
else if (ess.getSettings().spawnIfNoHome())
{
user.getTeleport().respawn(ess.getSpawn(), charge);
}
else
{
user.sendMessage(Util.format("homes", Util.joinList(homes)));

View File

@@ -31,7 +31,8 @@ public class Commandinvsee extends EssentialsCommand
{
invUser.getInventory().setContents(user.getSavedInventory());
user.setSavedInventory(null);
throw new Exception(Util.i18n("invRestored"));
user.sendMessage(Util.i18n("invRestored"));
throw new NoChargeException();
}
if (user.getSavedInventory() == null)
@@ -49,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

@@ -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
@@ -23,6 +24,13 @@ public class Commandkill extends EssentialsCommand
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

@@ -15,22 +15,20 @@ 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()))
@@ -56,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))
@@ -70,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)
@@ -110,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);
@@ -124,11 +109,11 @@ public class Commandkit extends EssentialsCommand
boolean spew = false;
for (String d : items)
{
String[] parts = d.split("[^0-9]+", 3);
int id = Material.getMaterial(Integer.parseInt(parts[0])).getId();
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);

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;
@@ -23,13 +24,15 @@ public class Commandmail extends EssentialsCommand
List<String> mail = user.getMails();
if (mail.isEmpty())
{
throw new Exception(Util.i18n("noMail"));
user.sendMessage(Util.i18n("noMail"));
throw new NoChargeException();
}
for (String s : mail)
{
user.sendMessage(s);
}
throw new Exception(Util.i18n("mailClear"));
user.sendMessage(Util.i18n("mailClear"));
return;
}
if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
{
@@ -62,7 +65,63 @@ public class Commandmail extends EssentialsCommand
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
{
user.setMails(null);
throw new Exception(Util.i18n("mailCleared"));
user.sendMessage(Util.i18n("mailCleared"));
return;
}
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

@@ -24,15 +24,13 @@ public class Commandme extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
final StringBuilder message = new StringBuilder();
message.append("* ");
message.append(user.getDisplayName());
message.append(' ');
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");
}
ess.broadcastMessage(user, message.toString());
ess.broadcastMessage(user, Util.format("action", user.getDisplayName(), message));
}
}

View File

@@ -15,96 +15,77 @@ public class Commandnick extends EssentialsCommand
}
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
if (!ess.getSettings().changeDisplayName()) {
if (!ess.getSettings().changeDisplayName())
{
throw new Exception(Util.i18n("nickDisplayName"));
}
if (args.length > 1)
{
if (!user.isAuthorized("essentials.nick.others"))
{
throw new Exception(Util.i18n("nickOthersPermission"));
}
setOthersNickname(server, user, args);
setNickname(server, getPlayer(server, args, 0), args[1]);
user.sendMessage(Util.i18n("nickChanged"));
return;
}
String nick = args[0];
if ("off".equalsIgnoreCase(nick) || user.getName().equalsIgnoreCase(nick))
{
user.setDisplayName(user.getName());
user.setNickname(null);
user.sendMessage(Util.i18n("nickNoMore"));
return;
}
if (nick.matches("[^a-zA-Z_0-9]"))
{
throw new Exception(Util.i18n("nickNamesAlpha"));
}
for (Player p : server.getOnlinePlayers())
{
if (user == p)
{
continue;
}
String dn = p.getDisplayName().toLowerCase();
String n = p.getName().toLowerCase();
String nk = nick.toLowerCase();
if (nk.equals(dn) || nk.equals(n))
{
throw new Exception(Util.i18n("nickInUse"));
}
}
user.setDisplayName(ess.getSettings().getNicknamePrefix() + nick);
user.setNickname(nick);
user.sendMessage(Util.format("nickSet", user.getDisplayName() + "§7."));
setNickname(server, user, args[0]);
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
throw new NotEnoughArgumentsException();
}
if (!ess.getSettings().changeDisplayName()) {
sender.sendMessage(Util.i18n("nickDisplayName"));
return;
if (!ess.getSettings().changeDisplayName())
{
throw new Exception(Util.i18n("nickDisplayName"));
}
setOthersNickname(server, sender, args);
setNickname(server, getPlayer(server, args, 0), args[1]);
sender.sendMessage(Util.i18n("nickChanged"));
}
private void setOthersNickname(Server server, CommandSender sender, String[] args) throws Exception
private void setNickname(final Server server, final User target, final String nick) throws Exception
{
User target = getPlayer(server, args, 0);
String nick = args[1];
if ("off".equalsIgnoreCase(nick) || target.getName().equalsIgnoreCase(nick))
if (nick.matches("[^a-zA-Z_0-9]"))
{
target.setDisplayName(target.getName());
throw new Exception(Util.i18n("nickNamesAlpha"));
}
else if ("off".equalsIgnoreCase(nick) || target.getName().equalsIgnoreCase(nick))
{
target.setDisplayNick(target.getName());
target.setNickname(null);
target.sendMessage(Util.i18n("nickNoMore"));
}
else
{
target.setDisplayName(ess.getSettings().getNicknamePrefix() + nick);
target.setNickname(nick);
final String formattedNick = nick.replace('&', '\u00a7').replace("\u00a7\u00a7", "&");
for (Player p : server.getOnlinePlayers())
{
if (target.getBase() == p)
{
continue;
}
String dn = p.getDisplayName().toLowerCase();
String n = p.getName().toLowerCase();
String nk = formattedNick.toLowerCase();
if (nk.equals(dn) || nk.equals(n))
{
throw new Exception(Util.i18n("nickInUse"));
}
}
target.setDisplayNick(ess.getSettings().getNicknamePrefix() + formattedNick);
target.setNickname(formattedNick);
target.sendMessage(Util.format("nickSet", target.getDisplayName() + "§7."));
}
sender.sendMessage(Util.i18n("nickChanged"));
}
}

View File

@@ -22,13 +22,13 @@ public class Commandpowertool extends EssentialsCommand
String command = getFinalArg(args, 0);
// check to see if this is a clear all command
if(command != null && command.equalsIgnoreCase("clearall"))
if(command != null && command.equalsIgnoreCase("c:"))
{
user.clearAllPowertools();
user.sendMessage(Util.i18n("powerToolClearAll"));
return;
}
final ItemStack itemStack = user.getItemInHand();
if (itemStack == null || itemStack.getType() == Material.AIR)
{

View File

@@ -11,7 +11,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.entity.Player;
@@ -97,29 +96,31 @@ public class Commandptime extends EssentialsCommand
*/
private void getUsersTime(final CommandSender sender, final Collection<User> users)
{
if (users.size() > 1)
if (users.size() > 1)
{
sender.sendMessage(Util.format("pTimePlayers"));
}
for (User user : users)
for (User user : users)
{
if(user.getPlayerTimeOffset() == 0)
if (user.getPlayerTimeOffset() == 0)
{
sender.sendMessage(Util.format("pTimeNormal", user.getName()));
}
else {
else
{
String time = DescParseTickFormat.format(user.getPlayerTime());
if(!user.isPlayerTimeRelative())
if (!user.isPlayerTimeRelative())
{
sender.sendMessage(Util.format("pTimeCurrentFixed", user.getName(), time));
}
else {
else
{
sender.sendMessage(Util.format("pTimeCurrent", user.getName(), time));
}
}
}
return;
}
@@ -177,7 +178,8 @@ public class Commandptime extends EssentialsCommand
{
sender.sendMessage(Util.format("pTimeSetFixed", time, msg.toString()));
}
else {
else
{
sender.sendMessage(Util.format("pTimeSet", time, msg.toString()));
}
}

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials.commands;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@@ -15,7 +16,7 @@ public class Commandrealname extends EssentialsCommand
}
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length < 1)
{
@@ -36,7 +37,7 @@ public class Commandrealname extends EssentialsCommand
{
continue;
}
user.sendMessage(u.getDisplayName() + " " + Util.i18n("is") + " " + u.getName());
sender.sendMessage(u.getDisplayName() + " " + Util.i18n("is") + " " + u.getName());
}
}
}

View File

@@ -1,21 +0,0 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
public class Commandreloadall extends EssentialsCommand
{
public Commandreloadall()
{
super("reloadall");
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
server.reload();
sender.sendMessage(Util.i18n("reloadAllPlugins"));
}
}

View File

@@ -30,6 +30,10 @@ public class Commandrepair extends EssentialsCommand
if (args[0].equalsIgnoreCase("hand"))
{
final ItemStack item = user.getItemInHand();
if (item == null)
{
throw new Exception(Util.i18n("repairInvalidType"));
}
final String itemName = item.getType().toString().toLowerCase();
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
@@ -46,7 +50,9 @@ public class Commandrepair extends EssentialsCommand
final List<String> repaired = new ArrayList<String>();
repairItems(user.getInventory().getContents(), user, repaired);
repairItems(user.getInventory().getArmorContents(), user, repaired);
if (user.isAuthorized("essentials.repair.armor")) {
repairItems(user.getInventory().getArmorContents(), user, repaired);
}
if (repaired.isEmpty())
{
@@ -84,6 +90,10 @@ public class Commandrepair extends EssentialsCommand
{
for (ItemStack item : items)
{
if (item == null)
{
continue;
}
final String itemName = item.getType().toString().toLowerCase();
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
try

View File

@@ -29,7 +29,7 @@ public class Commandsell extends EssentialsCommand
{
is = user.getItemInHand();
}
else if (args[0].equalsIgnoreCase("inventory"))
else if (args[0].equalsIgnoreCase("inventory") || args[0].equalsIgnoreCase("invent") || args[0].equalsIgnoreCase("all"))
{
for (ItemStack stack : user.getInventory().getContents())
{
@@ -103,28 +103,21 @@ public class Commandsell extends EssentialsCommand
int max = 0;
if (!isBulkSell)
for (ItemStack s : user.getInventory().getContents())
{
for (ItemStack s : user.getInventory().getContents())
if (s == null)
{
if (s == null)
{
continue;
}
if (s.getTypeId() != is.getTypeId())
{
continue;
}
if (s.getDurability() != is.getDurability())
{
continue;
}
max += s.getAmount();
continue;
}
}
else
{
max += is.getAmount();
if (s.getTypeId() != is.getTypeId())
{
continue;
}
if (s.getDurability() != is.getDurability())
{
continue;
}
max += s.getAmount();
}
if (stack)
@@ -140,20 +133,26 @@ public class Commandsell extends EssentialsCommand
{
amount -= amount % 64;
}
if (amount > max || amount < 1)
{
user.sendMessage(Util.i18n("itemNotEnough1"));
user.sendMessage(Util.i18n("itemNotEnough2"));
throw new Exception(Util.i18n("itemNotEnough3"));
if (!isBulkSell)
{
user.sendMessage(Util.i18n("itemNotEnough1"));
user.sendMessage(Util.i18n("itemNotEnough2"));
throw new Exception(Util.i18n("itemNotEnough3"));
}
else
{
return;
}
}
final ItemStack ris = new ItemStack(is.getType(), amount, is.getDurability());
InventoryWorkaround.removeItem(user.getInventory(), true, ris);
user.updateInventory();
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth*amount, ess), user.getLocation(), ess);
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess);
user.giveMoney(worth * amount);
user.sendMessage(Util.format("itemSold", Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess)));
user.sendMessage(Util.format("itemSold", Util.formatCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(), Util.formatCurrency(worth, ess)));
logger.log(Level.INFO, Util.format("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(), Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess)));
}

View File

@@ -28,14 +28,14 @@ public class Commandsethome extends EssentialsCommand
{
if (user.isAuthorized("essentials.sethome.multiple"))
{
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getMultipleHomes())
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getHomeLimit(user))
|| (user.getHomes().contains(args[0].toLowerCase())))
{
user.setHome(args[0].toLowerCase());
}
else
{
throw new Exception(Util.format("maxHomes", ess.getSettings().getMultipleHomes()));
throw new Exception(Util.format("maxHomes", ess.getSettings().getHomeLimit(user)));
}
}

View File

@@ -56,11 +56,6 @@ public class Commandspawnmob extends EssentialsCommand
}
}
if (ess.getSettings().getProtectPreventSpawn(mobType.toLowerCase())
|| (mountType != null && ess.getSettings().getProtectPreventSpawn(mountType.toLowerCase())))
{
throw new Exception(Util.i18n("unableToSpawnMob"));
}
Entity spawnedMob = null;
Mob mob = null;
@@ -72,6 +67,12 @@ public class Commandspawnmob extends EssentialsCommand
{
throw new Exception(Util.i18n("invalidMob"));
}
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase()))
{
throw new Exception(Util.i18n("unableToSpawnMob"));
}
int[] ignore =
{
8, 9
@@ -79,8 +80,7 @@ public class Commandspawnmob extends EssentialsCommand
Block block = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock();
if (block == null)
{
user.sendMessage(Util.i18n("unableToSpawnMob"));
return;
throw new Exception(Util.i18n("unableToSpawnMob"));
}
Location loc = block.getLocation();
Location sloc = Util.getSafeDestination(loc);
@@ -90,8 +90,7 @@ public class Commandspawnmob extends EssentialsCommand
}
catch (MobException e)
{
user.sendMessage(Util.i18n("unableToSpawnMob"));
return;
throw new Exception(Util.i18n("unableToSpawnMob"));
}
if (mountType != null)
@@ -102,14 +101,18 @@ public class Commandspawnmob extends EssentialsCommand
user.sendMessage(Util.i18n("invalidMob"));
return;
}
if (ess.getSettings().getProtectPreventSpawn(mobMount.getType().toString().toLowerCase()))
{
throw new Exception(Util.i18n("unableToSpawnMob"));
}
try
{
spawnedMount = mobMount.spawn(user, server, loc);
}
catch (MobException e)
{
user.sendMessage(Util.i18n("unableToSpawnMob"));
return;
throw new Exception(Util.i18n("unableToSpawnMob"));
}
spawnedMob.setPassenger(spawnedMount);
}
@@ -144,8 +147,7 @@ public class Commandspawnmob extends EssentialsCommand
}
catch (MobException e)
{
user.sendMessage(Util.i18n("unableToSpawnMob"));
return;
throw new Exception(Util.i18n("unableToSpawnMob"));
}
spawnedMob.setPassenger(spawnedMount);
}

View File

@@ -0,0 +1,41 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
public class Commandsudo extends EssentialsCommand
{
public Commandsudo()
{
super("sudo");
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
throw new NotEnoughArgumentsException();
}
final User user = getPlayer(server, args, 0, false);
final String command = args[1];
final String[] arguments = new String[args.length - 2];
if (arguments.length > 0) {
System.arraycopy(args, 2, arguments, 0, args.length - 2);
}
//TODO: Translate this.
sender.sendMessage("Running the command as " + user.getDisplayName());
final PluginCommand pc = ess.getServer().getPluginCommand(command);
if (pc != null)
{
pc.execute(user.getBase(), command, arguments);
}
}
}

View File

@@ -18,6 +18,6 @@ public class Commandsuicide extends EssentialsCommand
user.setHealth(0);
user.sendMessage(Util.i18n("suicideMessage"));
ess.broadcastMessage(user,
Util.format("suicideSuccess",user.getDisplayName()));
Util.format("suicideSuccess", user.getDisplayName()));
}
}

View File

@@ -25,7 +25,7 @@ public class Commandtime extends EssentialsCommand
{
worldSelector = args[1];
}
Set<World> worlds = getWorlds(server, sender, worldSelector);
final Set<World> worlds = getWorlds(server, sender, worldSelector);
// If no arguments we are reading the time
if (args.length == 0)
@@ -34,7 +34,7 @@ public class Commandtime extends EssentialsCommand
return;
}
User user = ess.getUser(sender);
final User user = ess.getUser(sender);
if (user != null && !user.isAuthorized("essentials.time.set"))
{
user.sendMessage(Util.i18n("timeSetPermission"));

View File

@@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.Trade;
import org.bukkit.Server;
import com.earth2me.essentials.User;
@@ -14,34 +15,36 @@ public class Commandtpaccept extends EssentialsCommand
}
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
User p = user.getTeleportRequest();
if (p == null)
final User target = user.getTeleportRequest();
if (target == null
|| target.getBase() instanceof OfflinePlayer
|| (user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpahere")))
{
throw new Exception(Util.i18n("noPendingRequest"));
}
Trade charge = new Trade(this.getName(), ess);
final Trade charge = new Trade(this.getName(), ess);
if (user.isTeleportRequestHere())
{
charge.isAffordableFor(user);
}
else
{
charge.isAffordableFor(p);
charge.isAffordableFor(target);
}
user.sendMessage(Util.i18n("requestAccepted"));
p.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName()));
target.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName()));
if (user.isTeleportRequestHere())
{
user.getTeleport().teleport(p, charge);
user.getTeleport().teleport(target, charge);
}
else
{
p.getTeleport().teleport(user, charge);
target.getTeleport().teleport(user, charge);
}
user.requestTeleport(null, false);
}

View File

@@ -1,13 +1,10 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.TargetBlock;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.TreeType;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Material;
import org.bukkit.block.Block;
public class Commandtree extends EssentialsCommand
@@ -20,7 +17,7 @@ public class Commandtree extends EssentialsCommand
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
Object tree = new Object();
TreeType tree;
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
@@ -46,9 +43,9 @@ public class Commandtree extends EssentialsCommand
{
8, 9
};
final Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation();
final Location loc = Util.getTarget(user);
final Location safeLocation = Util.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
final boolean success = user.getWorld().generateTree(safeLocation, tree);
if (success)
{
user.sendMessage(Util.i18n("treeSpawned"));

View File

@@ -20,18 +20,16 @@ public class Commandunban extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
String name;
try
{
User u = getPlayer(server, args, 0, true);
name = u.getName();
final User u = getPlayer(server, args, 0, true);
u.setBanned(false);
sender.sendMessage(Util.i18n("unbannedPlayer"));
}
catch (NoSuchFieldException e)
{
sender.sendMessage(Util.i18n("playerNotFound"));
throw new Exception(Util.i18n("playerNotFound"));
}
}
}

View File

@@ -8,6 +8,7 @@ import com.earth2me.essentials.Warps;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bukkit.command.CommandSender;
public class Commandwarp extends EssentialsCommand
@@ -28,33 +29,7 @@ public class Commandwarp extends EssentialsCommand
{
throw new Exception(Util.i18n("warpListPermission"));
}
Warps warps = ess.getWarps();
if (warps.isEmpty())
{
throw new Exception(Util.i18n("noWarpsDefined"));
}
final List<String> warpNameList = new ArrayList<String>(warps.getWarpNames());
final Iterator<String> iterator = warpNameList.iterator();
while (iterator.hasNext())
{
final String warpName = iterator.next();
if (ess.getSettings().getPerWarpPermission() && !user.isAuthorized("essentials.warp." + warpName))
{
iterator.remove();
}
}
int page = 1;
if (args.length > 0)
{
page = Integer.parseInt(args[0]);
}
if (warpNameList.size() > WARPS_PER_PAGE)
{
user.sendMessage(Util.format("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE)));
}
final int warpPage = (page - 1) * WARPS_PER_PAGE;
user.sendMessage(Util.joinList(warpNameList.subList(warpPage, warpPage+Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE))));
warpList(user, args);
throw new NoChargeException();
}
if (args.length > 0)
@@ -75,6 +50,63 @@ public class Commandwarp extends EssentialsCommand
}
}
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length < 2 || args[0].matches("[0-9]+"))
{
warpList(null, args);
throw new NoChargeException();
}
User otherUser = ess.getUser(server.getPlayer(args[1]));
if (otherUser == null)
{
throw new Exception(Util.i18n("playerNotFound"));
}
warpUser(otherUser, args[0]);
throw new NoChargeException();
}
private void warpList(User user, String[] args) throws Exception
{
Warps warps = ess.getWarps();
if (warps.isEmpty())
{
throw new Exception(Util.i18n("noWarpsDefined"));
}
final List<String> warpNameList = new ArrayList<String>(warps.getWarpNames());
if (user != null)
{
final Iterator<String> iterator = warpNameList.iterator();
while (iterator.hasNext())
{
final String warpName = iterator.next();
if (ess.getSettings().getPerWarpPermission() && !user.isAuthorized("essentials.warp." + warpName))
{
iterator.remove();
}
}
}
int page = 1;
if (args.length > 0)
{
page = Integer.parseInt(args[0]);
}
final int warpPage = (page - 1) * WARPS_PER_PAGE;
final String warpList = Util.joinList(warpNameList.subList(warpPage, warpPage + Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE)));
if (warpNameList.size() > WARPS_PER_PAGE)
{
user.sendMessage(Util.format("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE)));
user.sendMessage(warpList);
}
else {
user.sendMessage(Util.format("warps", warpList));
}
}
private void warpUser(User user, String name) throws Exception
{
Trade charge = new Trade(this.getName(), ess);

View File

@@ -4,6 +4,7 @@ import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
public class Commandweather extends EssentialsCommand
@@ -29,16 +30,50 @@ public class Commandweather extends EssentialsCommand
world.setStorm(isStorm ? true : false);
world.setWeatherDuration(Integer.parseInt(args[1]) * 20);
user.sendMessage(isStorm
? Util.format("weatherStormFor", args[1])
: Util.format("weatherSunFor", args[1]));
? Util.format("weatherStormFor", world.getName(), args[1])
: Util.format("weatherSunFor", world.getName(), args[1]));
return;
}
else
{
world.setStorm(isStorm ? true : false);
user.sendMessage(isStorm
? Util.i18n("weatherStorm")
: Util.i18n("weatherSun"));
? Util.format("weatherStorm", world.getName())
: Util.format("weatherSun", world.getName()));
return;
}
}
@Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length < 2) //running from console means inserting a world arg before other args
{
throw new Exception("When running from console, usage is: /" + commandLabel + " <world> <storm/sun> [duration]");
}
boolean isStorm = args[1].equalsIgnoreCase("storm");
World world = server.getWorld(args[0]);
if (world == null)
{
throw new Exception("World named " + args[0] + " not found!");
}
if (args.length > 2)
{
world.setStorm(isStorm ? true : false);
world.setWeatherDuration(Integer.parseInt(args[2]) * 20);
sender.sendMessage(isStorm
? Util.format("weatherStormFor", world.getName(), args[2])
: Util.format("weatherSunFor", world.getName(), args[2]));
return;
}
else
{
world.setStorm(isStorm ? true : false);
sender.sendMessage(isStorm
? Util.format("weatherStorm", world.getName())
: Util.format("weatherSun", world.getName()));
return;
}
}

View File

@@ -53,17 +53,20 @@ public class Commandwhois extends EssentialsCommand
sender.sendMessage("");
sender.sendMessage(Util.format("whoisIs", u.getDisplayName(), u.getName()));
sender.sendMessage(Util.format("whoisHealth", u.getHealth()));
sender.sendMessage(Util.format("whoisOP", (u.isOp() ? Util.i18n("true") : Util.i18n("false"))));
sender.sendMessage(Util.format("whoisGod", (u.isGodModeEnabled() ? Util.i18n("true") : Util.i18n("false"))));
sender.sendMessage(Util.format("whoisGamemode", Util.i18n(u.getGameMode().toString().toLowerCase())));
sender.sendMessage(Util.format("whoisLocation", u.getLocation().getWorld().getName(), u.getLocation().getBlockX(), u.getLocation().getBlockY(), u.getLocation().getBlockZ()));
if (!ess.getSettings().isEcoDisabled())
{
sender.sendMessage(Util.format("whoisMoney", Util.formatCurrency(u.getMoney(), ess)));
}
sender.sendMessage(u.isAfk()
? Util.i18n("whoisStatusAway")
sender.sendMessage(u.isAfk()
? Util.i18n("whoisStatusAway")
: Util.i18n("whoisStatusAvailable"));
sender.sendMessage(Util.format("whoisIPAddress", u.getAddress().getAddress().toString()));
final String location = u.getGeoLocation();
if (location != null
if (location != null
&& (sender instanceof Player ? ess.getUser(sender).isAuthorized("essentials.geoip.show") : true))
{
sender.sendMessage(Util.format("whoisGeoLocation", location));

View File

@@ -17,26 +17,28 @@ public class Commandworld 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
{
World world;
List<World> worlds = server.getWorlds();
if (args.length < 1)
{
World nether = server.getWorld(ess.getSettings().getNetherName());
if (nether == null) {
for (World world2 : worlds)
World nether = null;
final List<World> worlds = server.getWorlds();
for (World world2 : worlds)
{
if (world2.getEnvironment() == World.Environment.NETHER)
{
if (world2.getEnvironment() == World.Environment.NETHER) {
nether = world2;
break;
}
}
if (nether == null) {
return;
nether = world2;
break;
}
}
if (nether == null)
{
return;
}
world = user.getWorld() == nether ? worlds.get(0) : nether;
}
else
@@ -54,23 +56,22 @@ public class Commandworld extends EssentialsCommand
double factor;
if (user.getWorld().getEnvironment() == World.Environment.NETHER && world.getEnvironment() == World.Environment.NORMAL)
{
factor = ess.getSettings().getNetherRatio();
factor = 8.0;
}
else if (user.getWorld().getEnvironment() != world.getEnvironment())
else if (user.getWorld().getEnvironment() == World.Environment.NORMAL && world.getEnvironment() == World.Environment.NETHER)
{
factor = 1.0 / ess.getSettings().getNetherRatio();
factor = 1.0 / 8.0;
}
else
{
else {
factor = 1.0;
}
Location loc = user.getLocation();
loc = new Location(world, loc.getBlockX() * factor + .5, loc.getBlockY(), loc.getBlockZ() * factor + .5);
final Location loc = user.getLocation();
final Location target = new Location(world, loc.getBlockX() * factor + .5, loc.getBlockY(), loc.getBlockZ() * factor + .5);
Trade charge = new Trade(this.getName(), ess);
final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
user.getTeleport().teleport(loc, charge);
user.getTeleport().teleport(target, charge);
throw new NoChargeException();
}
}

View File

@@ -3,6 +3,8 @@ package com.earth2me.essentials.commands;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.command.CommandSender;
import org.bukkit.inventory.ItemStack;
@@ -33,7 +35,7 @@ public class Commandworth extends EssentialsCommand
}
catch (NumberFormatException ex)
{
amount = 64;
amount = is.getType().getMaxStackSize();
}
is.setAmount(amount);
@@ -56,4 +58,49 @@ public class Commandworth extends EssentialsCommand
amount,
Util.formatCurrency(worth, ess)));
}
@Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
ItemStack is = ess.getItemDb().get(args[0]);
int amount = is.getAmount();
try
{
if (args.length > 1)
{
amount = Integer.parseInt(args[1]);
}
}
catch (NumberFormatException ex)
{
amount = is.getType().getMaxStackSize();
}
is.setAmount(amount);
double worth = ess.getWorth().getPrice(is);
if (Double.isNaN(worth))
{
throw new Exception(Util.i18n("itemCannotBeSold"));
}
sender.sendMessage(is.getDurability() != 0
? Util.format("worthMeta",
is.getType().toString().toLowerCase().replace("_", ""),
is.getDurability(),
Util.formatCurrency(worth * amount, ess),
amount,
Util.formatCurrency(worth, ess))
: Util.format("worth",
is.getType().toString().toLowerCase().replace("_", ""),
Util.formatCurrency(worth * amount, ess),
amount,
Util.formatCurrency(worth, ess)));
}
}

View File

@@ -55,7 +55,7 @@ public class BPermissionsHandler implements IPermissionsHandler
@Override
public boolean canBuild(final Player base, final String group)
{
return hasPermission(base, "bPermissions.build");
return hasPermission(base, "essentials.build") || hasPermission(base, "bPermissions.build");
}
@Override

View File

@@ -0,0 +1,69 @@
package com.earth2me.essentials.perm;
import java.util.Arrays;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
public class GroupManagerHandler implements IPermissionsHandler
{
private final transient GroupManager groupManager;
public GroupManagerHandler(final Plugin permissionsPlugin)
{
groupManager = ((GroupManager)permissionsPlugin);
}
@Override
public String getGroup(final Player base)
{
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
return handler.getGroup(base.getName());
}
@Override
public List<String> getGroups(final Player base)
{
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
return Arrays.asList(handler.getGroups(base.getName()));
}
@Override
public boolean canBuild(final Player base, final String group)
{
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
return handler.canUserBuild(base.getName());
}
@Override
public boolean inGroup(final Player base, final String group)
{
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
return handler.inGroup(base.getName(), group);
}
@Override
public boolean hasPermission(final Player base, final String node)
{
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
return handler.has(base, node);
}
@Override
public String getPrefix(final Player base)
{
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
return handler.getUserPrefix(base.getName());
}
@Override
public String getSuffix(final Player base)
{
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
return handler.getUserSuffix(base.getName());
}
}

View File

@@ -74,4 +74,10 @@ public class PermissionsBukkitHandler extends SuperpermsHandler
}
return false;
}
@Override
public boolean canBuild(Player base, String group)
{
return base.hasPermission("essentials.build") || base.hasPermission("permissions.build");
}
}

View File

@@ -77,7 +77,7 @@ public class PermissionsExHandler implements IPermissionsHandler
{
return null;
}
return user.getPrefix();
return user.getPrefix(base.getWorld().getName());
}
@Override
@@ -88,6 +88,7 @@ public class PermissionsExHandler implements IPermissionsHandler
{
return null;
}
return user.getSuffix();
return user.getSuffix(base.getWorld().getName());
}
}

View File

@@ -111,17 +111,6 @@ public class PermissionsHandler implements IPermissionsHandler
return;
}
final Plugin permBukkitPlugin = pluginManager.getPlugin("PermissionsBukkit");
if (permBukkitPlugin != null && permBukkitPlugin.isEnabled())
{
if (!(handler instanceof PermissionsBukkitHandler))
{
LOGGER.log(Level.INFO, "Essentials: Using PermissionsBukkit based permissions.");
handler = new PermissionsBukkitHandler(permBukkitPlugin);
}
return;
}
final Plugin bPermPlugin = pluginManager.getPlugin("bPermissions");
if (bPermPlugin != null && bPermPlugin.isEnabled())
{
@@ -132,6 +121,28 @@ public class PermissionsHandler implements IPermissionsHandler
}
return;
}
final Plugin GMplugin = pluginManager.getPlugin("GroupManager");
if (GMplugin != null && GMplugin.isEnabled())
{
if (!(handler instanceof GroupManagerHandler))
{
LOGGER.log(Level.INFO, "Essentials: Using GroupManager based permissions.");
handler = new GroupManagerHandler(GMplugin);
}
return;
}
final Plugin permBukkitPlugin = pluginManager.getPlugin("PermissionsBukkit");
if (permBukkitPlugin != null && permBukkitPlugin.isEnabled())
{
if (!(handler instanceof PermissionsBukkitHandler))
{
LOGGER.log(Level.INFO, "Essentials: Using PermissionsBukkit based permissions.");
handler = new PermissionsBukkitHandler(permBukkitPlugin);
}
return;
}
final Plugin permPlugin = pluginManager.getPlugin("Permissions");
if (permPlugin != null && permPlugin.isEnabled())

View File

@@ -4,7 +4,7 @@ import org.bukkit.plugin.Plugin;
/**
* Method.java
* Interface to be implemented by a payment method.
*
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright Copyright (C) 2011
@@ -41,6 +41,14 @@ public interface Method
*/
public String getVersion();
/**
* Returns the amount of decimal places that get stored
* NOTE: it will return -1 if there is no rounding
*
* @return <code>int</code> for each decimal place
*/
public int fractionalDigits();
/**
* Formats amounts into this payment methods style of currency display.
*
@@ -82,6 +90,23 @@ public interface Method
*/
public boolean hasBankAccount(String bank, String name);
/**
* Forces an account creation
*
* @param name Account name
* @return <code>boolean</code>
*/
public boolean createAccount(String name);
/**
* Forces an account creation
*
* @param name Account name
* @param balance Initial account balance
* @return <code>boolean</code>
*/
public boolean createAccount(String name, Double balance);
/**
* Returns a <code>MethodAccount</code> class for an account <code>name</code>.
*

View File

@@ -2,12 +2,10 @@ package com.earth2me.essentials.register.payment;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import java.util.HashSet;
import java.util.Set;
/**
* The <code>Methods</code> initializes Methods that utilize the Method interface
@@ -15,15 +13,13 @@ import java.util.Set;
*
* Allowing you to check whether a payment method exists or not.
*
* <blockquote><pre>
* Methods methods = new Methods();
* </pre></blockquote>
*
* Methods also allows you to set a preferred method of payment before it captures
* payment plugins in the initialization process.
*
* in <code>bukkit.yml</code>:
* <blockquote><pre>
* Methods methods = new Methods("iConomy");
* economy:
* preferred: "iConomy"
* </pre></blockquote>
*
* @author: Nijikokun <nijikokun@shortmail.com> (@nijikokun)
@@ -32,51 +28,62 @@ import java.util.Set;
*/
public class Methods
{
private boolean self = false;
private Method Method = null;
private String preferred = "";
private Set<Method> Methods = new HashSet<Method>();
private Set<String> Dependencies = new HashSet<String>();
private Set<Method> Attachables = new HashSet<Method>();
private static String version = null;
private static boolean self = false;
private static Method Method = null;
private static String preferred = "";
private static Set<Method> Methods = new HashSet<Method>();
private static Set<String> Dependencies = new HashSet<String>();
private static Set<Method> Attachables = new HashSet<Method>();
/**
* Initialize Method class
*/
public Methods()
static
{
this._init();
}
/**
* Initializes <code>Methods</code> class utilizing a "preferred" payment method check before
* returning the first method that was initialized.
*
* @param preferred Payment method that is most preferred for this setup.
*/
public Methods(String preferred)
{
this._init();
if (this.Dependencies.contains(preferred))
{
this.preferred = preferred;
}
_init();
}
/**
* Implement all methods along with their respective name & class.
*
* @see #Methods()
* @see #Methods(java.lang.String)
*/
private void _init()
private static void _init()
{
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo4());
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo5());
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo6());
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE6());
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE7());
this.addMethod("MultiCurrency", new com.earth2me.essentials.register.payment.methods.MCUR());
addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo6());
addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo5());
addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo4());
addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE6());
addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE7());
addMethod("Currency", new com.earth2me.essentials.register.payment.methods.MCUR());
Dependencies.add("MultiCurrency");
}
/**
* Used by the plugin to setup version
*
* @param v version
*/
public static void setVersion(String v)
{
version = v;
}
/**
* Use to reset methods during disable
*/
public static void reset()
{
version = null;
self = false;
Method = null;
preferred = "";
Attachables.clear();
}
/**
* Use to get version of Register plugin
* @return version
*/
public static String getVersion()
{
return version;
}
/**
@@ -86,7 +93,7 @@ public class Methods
* @return <code>Set<String></code> - Array of payment methods that are loaded.
* @see #setMethod(org.bukkit.plugin.Plugin)
*/
public Set<String> getDependencies()
public static Set<String> getDependencies()
{
return Dependencies;
}
@@ -98,7 +105,7 @@ public class Methods
* @param plugin Plugin data from bukkit, Internal Class file.
* @return Method <em>or</em> Null
*/
public Method createMethod(Plugin plugin)
public static Method createMethod(Plugin plugin)
{
for (Method method : Methods)
{
@@ -112,7 +119,7 @@ public class Methods
return null;
}
private void addMethod(String name, Method method)
private static void addMethod(String name, Method method)
{
Dependencies.add(name);
Methods.add(method);
@@ -125,7 +132,7 @@ public class Methods
* @see #setMethod(org.bukkit.plugin.Plugin)
* @see #checkDisabled(org.bukkit.plugin.Plugin)
*/
public boolean hasMethod()
public static boolean hasMethod()
{
return (Method != null);
}
@@ -134,15 +141,16 @@ public class Methods
* Checks Plugin Class against a multitude of checks to verify it's usability
* as a payment method.
*
* @param method Plugin data from bukkit, Internal Class file.
* @param <code>PluginManager</code> the plugin manager for the server
* @return <code>boolean</code> True on success, False on failure.
*/
public boolean setMethod(Plugin method)
public static boolean setMethod(PluginManager manager)
{
if (hasMethod())
{
return true;
}
if (self)
{
self = false;
@@ -152,44 +160,37 @@ public class Methods
int count = 0;
boolean match = false;
Plugin plugin = null;
PluginManager manager = method.getServer().getPluginManager();
for (String name : this.getDependencies())
for (String name : getDependencies())
{
if (hasMethod())
{
break;
}
if (method.getDescription().getName().equals(name))
{
plugin = method;
}
else
{
plugin = manager.getPlugin(name);
}
if (plugin == null)
plugin = manager.getPlugin(name);
if (plugin == null || !plugin.isEnabled())
{
continue;
}
Method current = this.createMethod(plugin);
Method current = createMethod(plugin);
if (current == null)
{
continue;
}
if (this.preferred.isEmpty())
if (preferred.isEmpty())
{
this.Method = current;
Method = current;
}
else
{
this.Attachables.add(current);
Attachables.add(current);
}
}
if (!this.preferred.isEmpty())
if (!preferred.isEmpty())
{
do
{
@@ -199,7 +200,7 @@ public class Methods
}
else
{
for (Method attached : this.Attachables)
for (Method attached : Attachables)
{
if (attached == null)
{
@@ -212,21 +213,21 @@ public class Methods
break;
}
if (this.preferred.isEmpty())
if (preferred.isEmpty())
{
this.Method = attached;
Method = attached;
}
if (count == 0)
{
if (this.preferred.equalsIgnoreCase(attached.getName()))
if (preferred.equalsIgnoreCase(attached.getName()))
{
this.Method = attached;
Method = attached;
}
else
{
Method = attached;
}
}
else
{
this.Method = attached;
}
}
@@ -239,12 +240,28 @@ public class Methods
return hasMethod();
}
/**
* Sets the preferred economy
*
* @return <code>boolean</code>
*/
public static boolean setPreferred(String check)
{
if (getDependencies().contains(check))
{
preferred = check;
return true;
}
return false;
}
/**
* Grab the existing and initialized (hopefully) Method Class.
*
* @return <code>Method</code> <em>or</em> <code>Null</code>
*/
public Method getMethod()
public static Method getMethod()
{
return Method;
}
@@ -256,16 +273,18 @@ public class Methods
* @param method Plugin data from bukkit, Internal Class file.
* @return <code>boolean</code>
*/
public boolean checkDisabled(Plugin method)
public static boolean checkDisabled(Plugin method)
{
if (!hasMethod())
{
return true;
}
if (Method.isCompatible(method))
{
Method = null;
}
return (Method == null);
}
}

View File

@@ -1,9 +1,11 @@
package com.earth2me.essentials.register.payment.methods;
import com.earth2me.essentials.register.payment.Method;
import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin;
/**
* BOSEconomy 6 Implementation of Method
*
@@ -11,191 +13,279 @@ import org.bukkit.plugin.Plugin;
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class BOSE6 implements Method {
private BOSEconomy BOSEconomy;
@SuppressWarnings("deprecation")
public class BOSE6 implements Method
{
private BOSEconomy BOSEconomy;
public BOSEconomy getPlugin() {
return this.BOSEconomy;
}
public BOSEconomy getPlugin()
{
return this.BOSEconomy;
}
public String getName() {
return "BOSEconomy";
}
public String getName()
{
return "BOSEconomy";
}
public String getVersion() {
return "0.6.2";
}
public String getVersion()
{
return "0.6.2";
}
public String format(double amount) {
String currency = this.BOSEconomy.getMoneyNamePlural();
if(amount == 1) currency = this.BOSEconomy.getMoneyName();
return amount + " " + currency;
}
public int fractionalDigits()
{
return 0;
}
public boolean hasBanks() {
return true;
}
public String format(double amount)
{
String currency = this.BOSEconomy.getMoneyNamePlural();
public boolean hasBank(String bank) {
return this.BOSEconomy.bankExists(bank);
}
if (amount == 1)
{
currency = this.BOSEconomy.getMoneyName();
}
public boolean hasAccount(String name) {
return this.BOSEconomy.playerRegistered(name, false);
}
return amount + " " + currency;
}
public boolean hasBankAccount(String bank, String name) {
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
}
public boolean hasBanks()
{
return true;
}
public MethodAccount getAccount(String name) {
if(!hasAccount(name)) return null;
return new BOSEAccount(name, this.BOSEconomy);
}
public boolean hasBank(String bank)
{
return this.BOSEconomy.bankExists(bank);
}
public MethodBankAccount getBankAccount(String bank, String name) {
if(!hasBankAccount(bank, name)) return null;
return new BOSEBankAccount(bank, BOSEconomy);
}
public boolean hasAccount(String name)
{
return this.BOSEconomy.playerRegistered(name, false);
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && plugin.getDescription().getVersion().equals("0.6.2");
}
public boolean hasBankAccount(String bank, String name)
{
return this.BOSEconomy.isBankOwner(bank, name)
|| this.BOSEconomy.isBankMember(bank, name);
}
public void setPlugin(Plugin plugin) {
BOSEconomy = (BOSEconomy)plugin;
}
public boolean createAccount(String name)
{
if (hasAccount(name))
{
return false;
}
public class BOSEAccount implements MethodAccount {
private String name;
private BOSEconomy BOSEconomy;
this.BOSEconomy.registerPlayer(name);
return true;
}
public BOSEAccount(String name, BOSEconomy bOSEconomy) {
this.name = name;
this.BOSEconomy = bOSEconomy;
}
public boolean createAccount(String name, Double balance)
{
if (hasAccount(name))
{
return false;
}
public double balance() {
return (double) this.BOSEconomy.getPlayerMoney(this.name);
}
this.BOSEconomy.registerPlayer(name);
this.BOSEconomy.setPlayerMoney(name, balance, false);
return true;
}
public boolean set(double amount) {
int IntAmount = (int)Math.ceil(amount);
return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false);
}
public MethodAccount getAccount(String name)
{
if (!hasAccount(name))
{
return null;
}
public boolean add(double amount) {
int IntAmount = (int)Math.ceil(amount);
return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false);
}
return new BOSEAccount(name, this.BOSEconomy);
}
public boolean subtract(double amount) {
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance - IntAmount), false);
}
public MethodBankAccount getBankAccount(String bank, String name)
{
if (!hasBankAccount(bank, name))
{
return null;
}
public boolean multiply(double amount) {
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance * IntAmount), false);
}
return new BOSEBankAccount(bank, BOSEconomy);
}
public boolean divide(double amount) {
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance / IntAmount), false);
}
public boolean isCompatible(Plugin plugin)
{
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
&& plugin instanceof BOSEconomy
&& plugin.getDescription().getVersion().equals("0.6.2");
}
public boolean hasEnough(double amount) {
return (this.balance() >= amount);
}
public void setPlugin(Plugin plugin)
{
BOSEconomy = (BOSEconomy)plugin;
}
public boolean hasOver(double amount) {
return (this.balance() > amount);
}
public boolean hasUnder(double amount) {
return (this.balance() < amount);
}
public class BOSEAccount implements MethodAccount
{
private final String name;
private final BOSEconomy BOSEconomy;
public boolean isNegative() {
return (this.balance() < 0);
}
public BOSEAccount(String name, BOSEconomy bOSEconomy)
{
this.name = name;
this.BOSEconomy = bOSEconomy;
}
public boolean remove() {
return false;
}
}
public double balance()
{
return (double)this.BOSEconomy.getPlayerMoney(this.name);
}
public class BOSEBankAccount implements MethodBankAccount {
private final String bank;
private final BOSEconomy BOSEconomy;
public boolean set(double amount)
{
int IntAmount = (int)Math.ceil(amount);
return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false);
}
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
this.bank = bank;
this.BOSEconomy = bOSEconomy;
}
public boolean add(double amount)
{
int IntAmount = (int)Math.ceil(amount);
return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false);
}
public String getBankName() {
return this.bank;
}
public boolean subtract(double amount)
{
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance - IntAmount), false);
}
public int getBankId() {
return -1;
}
public boolean multiply(double amount)
{
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance * IntAmount), false);
}
public double balance() {
return (double) this.BOSEconomy.getBankMoney(bank);
}
public boolean divide(double amount)
{
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance / IntAmount), false);
}
public boolean set(double amount) {
int IntAmount = (int)Math.ceil(amount);
return this.BOSEconomy.setBankMoney(bank, IntAmount, true);
}
public boolean hasEnough(double amount)
{
return (this.balance() >= amount);
}
public boolean add(double amount) {
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance + IntAmount), false);
}
public boolean hasOver(double amount)
{
return (this.balance() > amount);
}
public boolean subtract(double amount) {
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance - IntAmount), false);
}
public boolean hasUnder(double amount)
{
return (this.balance() < amount);
}
public boolean multiply(double amount) {
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance * IntAmount), false);
}
public boolean isNegative()
{
return (this.balance() < 0);
}
public boolean divide(double amount) {
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance / IntAmount), false);
}
public boolean remove()
{
return false;
}
}
public boolean hasEnough(double amount) {
return (this.balance() >= amount);
}
public boolean hasOver(double amount) {
return (this.balance() > amount);
}
public class BOSEBankAccount implements MethodBankAccount
{
private final String bank;
private final BOSEconomy BOSEconomy;
public boolean hasUnder(double amount) {
return (this.balance() < amount);
}
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy)
{
this.bank = bank;
this.BOSEconomy = bOSEconomy;
}
public boolean isNegative() {
return (this.balance() < 0);
}
public String getBankName()
{
return this.bank;
}
public boolean remove() {
return this.BOSEconomy.removeBank(bank);
}
}
public int getBankId()
{
return -1;
}
public double balance()
{
return (double)this.BOSEconomy.getBankMoney(bank);
}
public boolean set(double amount)
{
int IntAmount = (int)Math.ceil(amount);
return this.BOSEconomy.setBankMoney(bank, IntAmount, true);
}
public boolean add(double amount)
{
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance + IntAmount), false);
}
public boolean subtract(double amount)
{
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance - IntAmount), false);
}
public boolean multiply(double amount)
{
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance * IntAmount), false);
}
public boolean divide(double amount)
{
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance / IntAmount), false);
}
public boolean hasEnough(double amount)
{
return (this.balance() >= amount);
}
public boolean hasOver(double amount)
{
return (this.balance() > amount);
}
public boolean hasUnder(double amount)
{
return (this.balance() < amount);
}
public boolean isNegative()
{
return (this.balance() < 0);
}
public boolean remove()
{
return this.BOSEconomy.removeBank(bank);
}
}
}

View File

@@ -1,9 +1,11 @@
package com.earth2me.essentials.register.payment.methods;
import com.earth2me.essentials.register.payment.Method;
import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin;
/**
* BOSEconomy 7 Implementation of Method
*
@@ -12,182 +14,267 @@ import org.bukkit.plugin.Plugin;
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class BOSE7 implements Method
{
private BOSEconomy BOSEconomy;
public class BOSE7 implements Method {
private BOSEconomy BOSEconomy;
public BOSEconomy getPlugin()
{
return this.BOSEconomy;
}
public BOSEconomy getPlugin() {
return this.BOSEconomy;
}
public String getName()
{
return "BOSEconomy";
}
public String getName() {
return "BOSEconomy";
}
public String getVersion()
{
return "0.7.0";
}
public String getVersion() {
return "0.7.0";
}
public int fractionalDigits()
{
return this.BOSEconomy.getFractionalDigits();
}
public String format(double amount) {
String currency = this.BOSEconomy.getMoneyNamePlural();
if(amount == 1) currency = this.BOSEconomy.getMoneyName();
return amount + " " + currency;
}
public String format(double amount)
{
String currency = this.BOSEconomy.getMoneyNamePlural();
public boolean hasBanks() {
return true;
}
if (amount == 1)
{
currency = this.BOSEconomy.getMoneyName();
}
public boolean hasBank(String bank) {
return this.BOSEconomy.bankExists(bank);
}
return amount + " " + currency;
}
public boolean hasAccount(String name) {
return this.BOSEconomy.playerRegistered(name, false);
}
public boolean hasBanks()
{
return true;
}
public boolean hasBankAccount(String bank, String name) {
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
}
public boolean hasBank(String bank)
{
return this.BOSEconomy.bankExists(bank);
}
public MethodAccount getAccount(String name) {
if(!hasAccount(name)) return null;
return new BOSEAccount(name, this.BOSEconomy);
}
public boolean hasAccount(String name)
{
return this.BOSEconomy.playerRegistered(name, false);
}
public MethodBankAccount getBankAccount(String bank, String name) {
if(!hasBankAccount(bank, name)) return null;
return new BOSEBankAccount(bank, BOSEconomy);
}
public boolean hasBankAccount(String bank, String name)
{
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && !plugin.getDescription().getVersion().equals("0.6.2");
}
public boolean createAccount(String name)
{
if (hasAccount(name))
{
return false;
}
public void setPlugin(Plugin plugin) {
BOSEconomy = (BOSEconomy)plugin;
}
this.BOSEconomy.registerPlayer(name);
return true;
}
public class BOSEAccount implements MethodAccount {
private String name;
private BOSEconomy BOSEconomy;
public boolean createAccount(String name, Double balance)
{
if (hasAccount(name))
{
return false;
}
public BOSEAccount(String name, BOSEconomy bOSEconomy) {
this.name = name;
this.BOSEconomy = bOSEconomy;
}
this.BOSEconomy.registerPlayer(name);
this.BOSEconomy.setPlayerMoney(name, balance, false);
return true;
}
public double balance() {
return this.BOSEconomy.getPlayerMoneyDouble(this.name);
}
public MethodAccount getAccount(String name)
{
if (!hasAccount(name))
{
return null;
}
public boolean set(double amount) {
return this.BOSEconomy.setPlayerMoney(this.name, amount, false);
}
return new BOSEAccount(name, this.BOSEconomy);
}
public boolean add(double amount) {
return this.BOSEconomy.addPlayerMoney(this.name, amount, false);
}
public MethodBankAccount getBankAccount(String bank, String name)
{
if (!hasBankAccount(bank, name))
{
return null;
}
public boolean subtract(double amount) {
double balance = this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance - amount), false);
}
return new BOSEBankAccount(bank, BOSEconomy);
}
public boolean multiply(double amount) {
double balance = this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance * amount), false);
}
public boolean isCompatible(Plugin plugin)
{
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
&& plugin instanceof BOSEconomy
&& !plugin.getDescription().getVersion().equals("0.6.2");
}
public boolean divide(double amount) {
double balance = this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance / amount), false);
}
public void setPlugin(Plugin plugin)
{
BOSEconomy = (BOSEconomy)plugin;
}
public boolean hasEnough(double amount) {
return (this.balance() >= amount);
}
public boolean hasOver(double amount) {
return (this.balance() > amount);
}
public class BOSEAccount implements MethodAccount
{
private String name;
private BOSEconomy BOSEconomy;
public boolean hasUnder(double amount) {
return (this.balance() < amount);
}
public BOSEAccount(String name, BOSEconomy bOSEconomy)
{
this.name = name;
this.BOSEconomy = bOSEconomy;
}
public boolean isNegative() {
return (this.balance() < 0);
}
public double balance()
{
return this.BOSEconomy.getPlayerMoneyDouble(this.name);
}
public boolean remove() {
return false;
}
}
public boolean set(double amount)
{
return this.BOSEconomy.setPlayerMoney(this.name, amount, false);
}
public class BOSEBankAccount implements MethodBankAccount {
private String bank;
private BOSEconomy BOSEconomy;
public boolean add(double amount)
{
return this.BOSEconomy.addPlayerMoney(this.name, amount, false);
}
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
this.bank = bank;
this.BOSEconomy = bOSEconomy;
}
public boolean subtract(double amount)
{
double balance = this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance - amount), false);
}
public String getBankName() {
return this.bank;
}
public boolean multiply(double amount)
{
double balance = this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance * amount), false);
}
public int getBankId() {
return -1;
}
public boolean divide(double amount)
{
double balance = this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance / amount), false);
}
public double balance() {
return this.BOSEconomy.getBankMoneyDouble(bank);
}
public boolean hasEnough(double amount)
{
return (this.balance() >= amount);
}
public boolean set(double amount) {
return this.BOSEconomy.setBankMoney(bank, amount, true);
}
public boolean hasOver(double amount)
{
return (this.balance() > amount);
}
public boolean add(double amount) {
double balance = this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance + amount), false);
}
public boolean hasUnder(double amount)
{
return (this.balance() < amount);
}
public boolean subtract(double amount) {
double balance = this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance - amount), false);
}
public boolean isNegative()
{
return (this.balance() < 0);
}
public boolean multiply(double amount) {
double balance = this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance * amount), false);
}
public boolean remove()
{
return false;
}
}
public boolean divide(double amount) {
double balance = this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance / amount), false);
}
public boolean hasEnough(double amount) {
return (this.balance() >= amount);
}
public class BOSEBankAccount implements MethodBankAccount
{
private String bank;
private BOSEconomy BOSEconomy;
public boolean hasOver(double amount) {
return (this.balance() > amount);
}
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy)
{
this.bank = bank;
this.BOSEconomy = bOSEconomy;
}
public boolean hasUnder(double amount) {
return (this.balance() < amount);
}
public String getBankName()
{
return this.bank;
}
public boolean isNegative() {
return (this.balance() < 0);
}
public int getBankId()
{
return -1;
}
public boolean remove() {
return this.BOSEconomy.removeBank(bank);
}
}
public double balance()
{
return this.BOSEconomy.getBankMoneyDouble(bank);
}
public boolean set(double amount)
{
return this.BOSEconomy.setBankMoney(bank, amount, true);
}
public boolean add(double amount)
{
double balance = this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance + amount), false);
}
public boolean subtract(double amount)
{
double balance = this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance - amount), false);
}
public boolean multiply(double amount)
{
double balance = this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance * amount), false);
}
public boolean divide(double amount)
{
double balance = this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance / amount), false);
}
public boolean hasEnough(double amount)
{
return (this.balance() >= amount);
}
public boolean hasOver(double amount)
{
return (this.balance() > amount);
}
public boolean hasUnder(double amount)
{
return (this.balance() < amount);
}
public boolean isNegative()
{
return (this.balance() < 0);
}
public boolean remove()
{
return this.BOSEconomy.removeBank(bank);
}
}
}

View File

@@ -7,6 +7,7 @@ import me.ashtheking.currency.CurrencyList;
import org.bukkit.plugin.Plugin;
/**
* MultiCurrency Method implementation.
*
@@ -14,107 +15,153 @@ import org.bukkit.plugin.Plugin;
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class MCUR implements Method {
private Currency currencyList;
public class MCUR implements Method
{
private Currency currencyList;
public Object getPlugin() {
return this.currencyList;
}
public Object getPlugin()
{
return this.currencyList;
}
public String getName() {
return "MultiCurrency";
}
public String getName()
{
return "MultiCurrency";
}
public String getVersion() {
return "0.09";
}
public String getVersion()
{
return "0.09";
}
public String format(double amount) {
return amount + " Currency";
}
public int fractionalDigits()
{
return -1;
}
public boolean hasBanks() {
return false;
}
public String format(double amount)
{
return amount + " Currency";
}
public boolean hasBank(String bank) {
return false;
}
public boolean hasBanks()
{
return false;
}
public boolean hasAccount(String name) {
return true;
}
public boolean hasBank(String bank)
{
return false;
}
public boolean hasBankAccount(String bank, String name) {
return false;
}
public boolean hasAccount(String name)
{
return true;
}
public MethodAccount getAccount(String name) {
return new MCurrencyAccount(name);
}
public boolean hasBankAccount(String bank, String name)
{
return false;
}
public MethodBankAccount getBankAccount(String bank, String name) {
return null;
}
public boolean createAccount(String name)
{
CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, 0);
return true;
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase(getName()) && plugin instanceof Currency;
}
public boolean createAccount(String name, Double balance)
{
CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, balance);
return true;
}
public void setPlugin(Plugin plugin) {
currencyList = (Currency) plugin;
}
public MethodAccount getAccount(String name)
{
return new MCurrencyAccount(name);
}
public class MCurrencyAccount implements MethodAccount{
private String name;
public MethodBankAccount getBankAccount(String bank, String name)
{
return null;
}
public MCurrencyAccount(String name) {
this.name = name;
}
public boolean isCompatible(Plugin plugin)
{
return (plugin.getDescription().getName().equalsIgnoreCase("Currency")
|| plugin.getDescription().getName().equalsIgnoreCase("MultiCurrency"))
&& plugin instanceof Currency;
}
public double balance() {
return CurrencyList.getValue((String) CurrencyList.maxCurrency(name)[0], name);
}
public void setPlugin(Plugin plugin)
{
currencyList = (Currency)plugin;
}
public boolean set(double amount) {
CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, amount);
return true;
}
public boolean add(double amount) {
return CurrencyList.add(name, amount);
}
public class MCurrencyAccount implements MethodAccount
{
private String name;
public boolean subtract(double amount) {
return CurrencyList.subtract(name, amount);
}
public MCurrencyAccount(String name)
{
this.name = name;
}
public boolean multiply(double amount) {
return CurrencyList.multiply(name, amount);
}
public double balance()
{
return CurrencyList.getValue((String)CurrencyList.maxCurrency(name)[0], name);
}
public boolean divide(double amount) {
return CurrencyList.divide(name, amount);
}
public boolean set(double amount)
{
CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, amount);
return true;
}
public boolean hasEnough(double amount) {
return CurrencyList.hasEnough(name, amount);
}
public boolean add(double amount)
{
return CurrencyList.add(name, amount);
}
public boolean hasOver(double amount) {
return CurrencyList.hasOver(name, amount);
}
public boolean subtract(double amount)
{
return CurrencyList.subtract(name, amount);
}
public boolean hasUnder(double amount) {
return CurrencyList.hasUnder(name, amount);
}
public boolean multiply(double amount)
{
return CurrencyList.multiply(name, amount);
}
public boolean isNegative() {
return CurrencyList.isNegative(name);
}
public boolean divide(double amount)
{
return CurrencyList.divide(name, amount);
}
public boolean remove() {
return CurrencyList.remove(name);
}
}
public boolean hasEnough(double amount)
{
return CurrencyList.hasEnough(name, amount);
}
public boolean hasOver(double amount)
{
return CurrencyList.hasOver(name, amount);
}
public boolean hasUnder(double amount)
{
return CurrencyList.hasUnder(name, amount);
}
public boolean isNegative()
{
return CurrencyList.isNegative(name);
}
public boolean remove()
{
return CurrencyList.remove(name);
}
}
}

View File

@@ -1,12 +1,13 @@
package com.earth2me.essentials.register.payment.methods;
import com.earth2me.essentials.register.payment.Method;
import com.nijiko.coelho.iConomy.iConomy;
import com.nijiko.coelho.iConomy.system.Account;
import com.earth2me.essentials.register.payment.Method;
import org.bukkit.plugin.Plugin;
/**
* iConomy 4 Implementation of Method
*
@@ -14,122 +15,213 @@ import org.bukkit.plugin.Plugin;
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class iCo4 implements Method {
private iConomy iConomy;
public class iCo4 implements Method
{
private iConomy iConomy;
public iConomy getPlugin() {
return this.iConomy;
}
public iConomy getPlugin()
{
return this.iConomy;
}
public String getName() {
return "iConomy";
}
public String getName()
{
return "iConomy";
}
public String getVersion() {
return "4";
}
public String getVersion()
{
return "4";
}
public String format(double amount) {
return this.iConomy.getBank().format(amount);
}
public int fractionalDigits()
{
return 2;
}
public boolean hasBanks() {
return false;
}
public String format(double amount)
{
return com.nijiko.coelho.iConomy.iConomy.getBank().format(amount);
}
public boolean hasBank(String bank) {
return false;
}
public boolean hasBanks()
{
return false;
}
public boolean hasAccount(String name) {
return this.iConomy.getBank().hasAccount(name);
}
public boolean hasBank(String bank)
{
return false;
}
public boolean hasBankAccount(String bank, String name) {
return false;
}
public boolean hasAccount(String name)
{
return com.nijiko.coelho.iConomy.iConomy.getBank().hasAccount(name);
}
public MethodAccount getAccount(String name) {
return new iCoAccount(this.iConomy.getBank().getAccount(name));
}
public boolean hasBankAccount(String bank, String name)
{
return false;
}
public MethodBankAccount getBankAccount(String bank, String name) {
return null;
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy") && plugin instanceof iConomy;
}
public boolean createAccount(String name)
{
if (hasAccount(name))
{
return false;
}
public void setPlugin(Plugin plugin) {
iConomy = (iConomy)plugin;
}
public class iCoAccount implements MethodAccount {
private Account account;
try
{
com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name);
}
catch (Exception E)
{
return false;
}
public iCoAccount(Account account) {
this.account = account;
}
return true;
}
public Account getiCoAccount() {
return account;
}
public boolean createAccount(String name, Double balance)
{
if (hasAccount(name))
{
return false;
}
public double balance() {
return this.account.getBalance();
}
try
{
com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name, balance);
}
catch (Exception E)
{
return false;
}
public boolean set(double amount) {
if(this.account == null) return false;
this.account.setBalance(amount);
return true;
}
return true;
}
public boolean add(double amount) {
if(this.account == null) return false;
this.account.add(amount);
return true;
}
public MethodAccount getAccount(String name)
{
return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name));
}
public boolean subtract(double amount) {
if(this.account == null) return false;
this.account.subtract(amount);
return true;
}
public MethodBankAccount getBankAccount(String bank, String name)
{
return null;
}
public boolean multiply(double amount) {
if(this.account == null) return false;
this.account.multiply(amount);
return true;
}
public boolean isCompatible(Plugin plugin)
{
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
&& plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy")
&& plugin instanceof iConomy;
}
public boolean divide(double amount) {
if(this.account == null) return false;
this.account.divide(amount);
return true;
}
public void setPlugin(Plugin plugin)
{
iConomy = (iConomy)plugin;
}
public boolean hasEnough(double amount) {
return this.account.hasEnough(amount);
}
public boolean hasOver(double amount) {
return this.account.hasOver(amount);
}
public class iCoAccount implements MethodAccount
{
private Account account;
public boolean hasUnder(double amount) {
return (this.balance() < amount);
}
public iCoAccount(Account account)
{
this.account = account;
}
public boolean isNegative() {
return this.account.isNegative();
}
public Account getiCoAccount()
{
return account;
}
public boolean remove() {
if(this.account == null) return false;
this.account.remove();
return true;
}
}
public double balance()
{
return this.account.getBalance();
}
public boolean set(double amount)
{
if (this.account == null)
{
return false;
}
this.account.setBalance(amount);
return true;
}
public boolean add(double amount)
{
if (this.account == null)
{
return false;
}
this.account.add(amount);
return true;
}
public boolean subtract(double amount)
{
if (this.account == null)
{
return false;
}
this.account.subtract(amount);
return true;
}
public boolean multiply(double amount)
{
if (this.account == null)
{
return false;
}
this.account.multiply(amount);
return true;
}
public boolean divide(double amount)
{
if (this.account == null)
{
return false;
}
this.account.divide(amount);
return true;
}
public boolean hasEnough(double amount)
{
return this.account.hasEnough(amount);
}
public boolean hasOver(double amount)
{
return this.account.hasOver(amount);
}
public boolean hasUnder(double amount)
{
return (this.balance() < amount);
}
public boolean isNegative()
{
return this.account.isNegative();
}
public boolean remove()
{
if (this.account == null)
{
return false;
}
this.account.remove();
return true;
}
}
}

View File

@@ -1,12 +1,12 @@
package com.earth2me.essentials.register.payment.methods;
import com.earth2me.essentials.register.payment.Method;
import com.iConomy.iConomy;
import com.iConomy.system.Account;
import com.iConomy.system.BankAccount;
import com.iConomy.system.Holdings;
import com.iConomy.util.Constants;
import com.earth2me.essentials.register.payment.Method;
import org.bukkit.plugin.Plugin;
@@ -37,9 +37,14 @@ public class iCo5 implements Method
return "5";
}
public int fractionalDigits()
{
return 2;
}
public String format(double amount)
{
return this.iConomy.format(amount);
return com.iConomy.iConomy.format(amount);
}
public boolean hasBanks()
@@ -49,32 +54,61 @@ public class iCo5 implements Method
public boolean hasBank(String bank)
{
return (hasBanks()) && this.iConomy.Banks.exists(bank);
return (hasBanks()) && com.iConomy.iConomy.Banks.exists(bank);
}
public boolean hasAccount(String name)
{
return this.iConomy.hasAccount(name);
return com.iConomy.iConomy.hasAccount(name);
}
public boolean hasBankAccount(String bank, String name)
{
return (hasBank(bank)) && this.iConomy.getBank(bank).hasAccount(name);
return (hasBank(bank)) && com.iConomy.iConomy.getBank(bank).hasAccount(name);
}
public boolean createAccount(String name)
{
if (hasAccount(name))
{
return false;
}
return com.iConomy.iConomy.Accounts.create(name);
}
public boolean createAccount(String name, Double balance)
{
if (hasAccount(name))
{
return false;
}
if (!com.iConomy.iConomy.Accounts.create(name))
{
return false;
}
getAccount(name).set(balance);
return true;
}
public MethodAccount getAccount(String name)
{
return new iCoAccount(this.iConomy.getAccount(name));
return new iCoAccount(com.iConomy.iConomy.getAccount(name));
}
public MethodBankAccount getBankAccount(String bank, String name)
{
return new iCoBankAccount(this.iConomy.getBank(bank).getAccount(name));
return new iCoBankAccount(com.iConomy.iConomy.getBank(bank).getAccount(name));
}
public boolean isCompatible(Plugin plugin)
{
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iConomy.iConomy") && plugin instanceof iConomy;
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
&& plugin.getClass().getName().equals("com.iConomy.iConomy")
&& plugin instanceof iConomy;
}
public void setPlugin(Plugin plugin)

View File

@@ -1,14 +1,15 @@
package com.earth2me.essentials.register.payment.methods;
import com.earth2me.essentials.register.payment.Method;
import com.iCo6.iConomy;
import com.iCo6.system.Account;
import com.iCo6.system.Accounts;
import com.iCo6.system.Holdings;
import com.earth2me.essentials.register.payment.Method;
import org.bukkit.plugin.Plugin;
/**
* iConomy 6 Implementation of Method
*
@@ -16,127 +17,197 @@ import org.bukkit.plugin.Plugin;
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class iCo6 implements Method {
private iConomy iConomy;
public class iCo6 implements Method
{
private iConomy iConomy;
public iConomy getPlugin() {
return this.iConomy;
}
public iConomy getPlugin()
{
return this.iConomy;
}
public String getName() {
return "iConomy";
}
public String getName()
{
return "iConomy";
}
public String getVersion() {
return "6";
}
public String getVersion()
{
return "6";
}
public String format(double amount) {
return this.iConomy.format(amount);
}
public int fractionalDigits()
{
return 2;
}
public boolean hasBanks() {
return false;
}
public String format(double amount)
{
return com.iCo6.iConomy.format(amount);
}
public boolean hasBank(String bank) {
return false;
}
public boolean hasBanks()
{
return false;
}
public boolean hasAccount(String name) {
return (new Accounts()).exists(name);
}
public boolean hasBank(String bank)
{
return false;
}
public boolean hasBankAccount(String bank, String name) {
return false;
}
public boolean hasAccount(String name)
{
return (new Accounts()).exists(name);
}
public MethodAccount getAccount(String name) {
return new iCoAccount((new Accounts()).get(name));
}
public boolean hasBankAccount(String bank, String name)
{
return false;
}
public MethodBankAccount getBankAccount(String bank, String name) {
return null;
}
public boolean createAccount(String name)
{
if (hasAccount(name))
{
return false;
}
public boolean isCompatible(Plugin plugin) {
try { Class.forName("com.iCo6.IO"); }
catch(Exception e) { return false; }
return (new Accounts()).create(name);
}
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iCo6.iConomy") && plugin instanceof iConomy;
}
public boolean createAccount(String name, Double balance)
{
if (hasAccount(name))
{
return false;
}
public void setPlugin(Plugin plugin) {
iConomy = (iConomy)plugin;
}
return (new Accounts()).create(name, balance);
}
public class iCoAccount implements MethodAccount {
private Account account;
private Holdings holdings;
public MethodAccount getAccount(String name)
{
return new iCoAccount((new Accounts()).get(name));
}
public iCoAccount(Account account) {
this.account = account;
this.holdings = account.getHoldings();
}
public MethodBankAccount getBankAccount(String bank, String name)
{
return null;
}
public Account getiCoAccount() {
return account;
}
public boolean isCompatible(Plugin plugin)
{
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
&& plugin.getClass().getName().equals("com.iCo6.iConomy")
&& plugin instanceof iConomy;
}
public double balance() {
return this.holdings.getBalance();
}
public void setPlugin(Plugin plugin)
{
iConomy = (iConomy)plugin;
}
public boolean set(double amount) {
if(this.holdings == null) return false;
this.holdings.setBalance(amount);
return true;
}
public boolean add(double amount) {
if(this.holdings == null) return false;
this.holdings.add(amount);
return true;
}
public class iCoAccount implements MethodAccount
{
private Account account;
private Holdings holdings;
public boolean subtract(double amount) {
if(this.holdings == null) return false;
this.holdings.subtract(amount);
return true;
}
public iCoAccount(Account account)
{
this.account = account;
this.holdings = account.getHoldings();
}
public boolean multiply(double amount) {
if(this.holdings == null) return false;
this.holdings.multiply(amount);
return true;
}
public Account getiCoAccount()
{
return account;
}
public boolean divide(double amount) {
if(this.holdings == null) return false;
this.holdings.divide(amount);
return true;
}
public double balance()
{
return this.holdings.getBalance();
}
public boolean hasEnough(double amount) {
return this.holdings.hasEnough(amount);
}
public boolean set(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.setBalance(amount);
return true;
}
public boolean hasOver(double amount) {
return this.holdings.hasOver(amount);
}
public boolean add(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.add(amount);
return true;
}
public boolean hasUnder(double amount) {
return this.holdings.hasUnder(amount);
}
public boolean subtract(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.subtract(amount);
return true;
}
public boolean isNegative() {
return this.holdings.isNegative();
}
public boolean multiply(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.multiply(amount);
return true;
}
public boolean remove() {
if(this.account == null) return false;
this.account.remove();
return true;
}
}
public boolean divide(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.divide(amount);
return true;
}
public boolean hasEnough(double amount)
{
return this.holdings.hasEnough(amount);
}
public boolean hasOver(double amount)
{
return this.holdings.hasOver(amount);
}
public boolean hasUnder(double amount)
{
return this.holdings.hasUnder(amount);
}
public boolean isNegative()
{
return this.holdings.isNegative();
}
public boolean remove()
{
if (this.account == null)
{
return false;
}
this.account.remove();
return true;
}
}
}

View File

@@ -0,0 +1,17 @@
package com.earth2me.essentials.settings;
import com.earth2me.essentials.storage.Comment;
import com.earth2me.essentials.storage.StorageObject;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public class Backup extends StorageObject
{
@Comment("Interval in minutes")
private long interval = 60;
@Comment("Add a command that backups your data, e.g. 'rdiff-backup World1 backups/World1'")
private String command;
}

View File

@@ -0,0 +1,32 @@
package com.earth2me.essentials.settings;
import com.earth2me.essentials.storage.Comment;
import com.earth2me.essentials.storage.StorageObject;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public class Chat extends StorageObject
{
@Comment("The character(s) to prefix all nicknames, so that you know they are not true usernames.")
private String nicknamePrefix = "~";
@Comment("Disable this if you have any other plugin, that modifies the displayname of a user.")
private boolean changeDisplayname = true;
private String displaynameFormat = "{PREFIX}{NICKNAMEPREFIX}{NAME}{SUFFIX}";
@Comment({
"If EssentialsChat is installed, this will define how far a player's voice travels, in blocks. Set to 0 to make all chat global.",
"Note that users with the \"essentials.chat.spy\" permission will hear everything, regardless of this setting.",
"Users with essentials.chat.shout can override this by prefixing text with an exclamation mark (!)",
"Or with essentials.chat.question can override this by prefixing text with a question mark (?)",
"You can add command costs for shout/question by adding chat-shout and chat-question to the command costs section."
})
private int localRadius = 0;
@Comment("Set the default chat format here, it will be overwritten by group specific chat formats.")
private String defaultFormat = "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}";
}

View File

@@ -0,0 +1,47 @@
package com.earth2me.essentials.settings;
import com.earth2me.essentials.settings.commands.Afk;
import com.earth2me.essentials.settings.commands.God;
import com.earth2me.essentials.settings.commands.Help;
import com.earth2me.essentials.settings.commands.Home;
import com.earth2me.essentials.settings.commands.Kit;
import com.earth2me.essentials.settings.commands.Lightning;
import com.earth2me.essentials.settings.commands.Spawnmob;
import com.earth2me.essentials.storage.Comment;
import com.earth2me.essentials.storage.ListType;
import com.earth2me.essentials.storage.StorageObject;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public class Commands extends StorageObject
{
private Afk afk = new Afk();
private God god = new God();
private Help help = new Help();
private Home home = new Home();
private Kit kit = new Kit();
private Lightning lightning = new Lightning();
private Spawnmob spawnmob = new Spawnmob();
@ListType
@Comment(
{
"When a command conflicts with another plugin, by default, Essentials will try to force the OTHER plugin to take",
"priority. If a command is in this list, Essentials will try to give ITSELF priority. This does not always work:",
"usually whichever plugin was updated most recently wins out. However, the full name of the command will always work.",
"For example, if WorldGuard and Essentials are both enabled, and WorldGuard takes control over /god, /essentials:god",
"will still map to Essentials, whereas it might normally get forced upon WorldGuard. Commands prefixed with an \"e\",",
"such as /egod, will always grant Essentials priority.",
"We should try to take priority over /god. If this doesn't work, use /essentials:god or /egod.",
"If god is set using WorldGuard, use /ungod to remove then use whichever you see fit."
})
private List<String> overwritten = new ArrayList<String>();
@ListType
@Comment("Disabled commands will be completelly unavailable on the server.")
private List<String> disabled = new ArrayList<String>();
}

View File

@@ -0,0 +1,42 @@
package com.earth2me.essentials.settings;
import com.earth2me.essentials.storage.Comment;
import com.earth2me.essentials.storage.MapType;
import com.earth2me.essentials.storage.StorageObject;
import java.util.HashMap;
import java.util.Map;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public class Economy extends StorageObject
{
@Comment("Defines the balance with which new players begin. Defaults to 0.")
private double startingBalance = 0.0;
@MapType(Double.class)
@Comment("Defines the cost to use the given commands PER USE")
private Map<String, Double> commandCosts = new HashMap<String, Double>();
@Comment("Set this to a currency symbol you want to use.")
private String currencySymbol = "$";
public String getCurrencySymbol()
{
return currencySymbol == null || currencySymbol.isEmpty() ? "$" : currencySymbol.substring(0, 1);
}
private final transient static double MAXMONEY = 10000000000000.0;
@Comment(
{
"Set the maximum amount of money a player can have",
"The amount is always limited to 10 trillions because of the limitations of a java double"
})
private double maxMoney = MAXMONEY;
public double getMaxMoney()
{
return Math.abs(maxMoney) > MAXMONEY ? MAXMONEY : Math.abs(maxMoney);
}
@Comment("Enable this to log all interactions with trade/buy/sell signs and sell command")
private boolean logEnabled = false;
}

View File

@@ -0,0 +1,33 @@
package com.earth2me.essentials.settings;
import com.earth2me.essentials.storage.Comment;
import com.earth2me.essentials.storage.StorageObject;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public class General extends StorageObject
{
@Comment("Backup runs a command while saving is disabled")
private Backup backup = new Backup();
@Comment("You can disable the death messages of minecraft.")
private boolean deathMessages = true;
@Comment("Turn this on, if you want to see more error messages, if something goes wrong.")
private boolean debug = false;
@Comment(
{
"Set the locale here, if you want to change the language of Essentials.",
"If this is not set, Essentials will use the language of your computer.",
"Available locales: da, de, en, fr, nl"
})
private String locale;
@Comment(
{
"Should we announce to the server when someone logs in for the first time?",
"If so, use this format, replacing {DISPLAYNAME} with the player name.",
"If not, set to ''"
})
private String newPlayerAnnouncement = "&dWelcome {DISPLAYNAME} to the server!";
}

View File

@@ -0,0 +1,27 @@
package com.earth2me.essentials.settings;
import com.earth2me.essentials.storage.Comment;
import com.earth2me.essentials.storage.StorageObject;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public class GroupOptions extends StorageObject
{
@Comment("Message format of chat messages")
private String messageFormat;
@Comment("Prefix for name")
private String prefix;
@Comment("Suffix for name")
private String suffix;
@Comment("Amount of homes a player can have")
private Integer homes;
@Comment("Cooldown between teleports")
private Integer teleportCooldown;
@Comment("Delay before teleport")
private Integer teleportDelay;
@Comment("Cooldown between heals")
private Integer healCooldown;
}

View File

@@ -0,0 +1,27 @@
package com.earth2me.essentials.settings;
import com.earth2me.essentials.storage.Comment;
import com.earth2me.essentials.storage.MapType;
import com.earth2me.essentials.storage.StorageObject;
import java.util.LinkedHashMap;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public class Groups extends StorageObject
{
public Groups() {
GroupOptions defaultOptions = new GroupOptions();
groups.put("default", defaultOptions);
}
@Comment(
{
"The order of the groups matters, the groups are checked from top to bottom.",
"All group names have to be lower case.",
"The groups can be connected to users using the permission essentials.groups.groupname"
})
@MapType(GroupOptions.class)
private LinkedHashMap<String, GroupOptions> groups = new LinkedHashMap<String, GroupOptions>();
}

View File

@@ -0,0 +1,28 @@
package com.earth2me.essentials.settings;
import com.earth2me.essentials.storage.StorageObject;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.bukkit.Server;
@Data
@EqualsAndHashCode(callSuper = false)
public class Location extends StorageObject
{
private String worldName = "Test";
private double x;
private double y;
private double z;
private Float yaw;
private Float pitch;
public org.bukkit.Location getBukkit(Server server)
{
if (yaw == null || pitch == null)
{
return new org.bukkit.Location(server.getWorld(worldName), x, y, z);
}
return new org.bukkit.Location(server.getWorld(worldName), x, y, z, yaw, pitch);
}
}

View File

@@ -0,0 +1,58 @@
package com.earth2me.essentials.settings;
import com.earth2me.essentials.storage.Comment;
import com.earth2me.essentials.storage.StorageObject;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public class Settings extends StorageObject
{
@Comment(
{
"##########################################################",
"+------------------------------------------------------+ #",
"| General Settings | #",
"+------------------------------------------------------+ #",
"##########################################################"
})
private General general = new General();
@Comment(
{
"##########################################################",
"+------------------------------------------------------+ #",
"| Chat Settings | #",
"+------------------------------------------------------+ #",
"##########################################################"
})
private Chat chat = new Chat();
@Comment(
{
"##########################################################",
"+------------------------------------------------------+ #",
"| Economy Settings | #",
"+------------------------------------------------------+ #",
"##########################################################"
})
private Economy economy = new Economy();
@Comment(
{
"##########################################################",
"+------------------------------------------------------+ #",
"| Commands Settings | #",
"+------------------------------------------------------+ #",
"##########################################################"
})
private Commands commands = new Commands();
@Comment(
{
"##########################################################",
"+------------------------------------------------------+ #",
"| Group Settings | #",
"+------------------------------------------------------+ #",
"##########################################################"
})
private Groups groups = new Groups();
}

View File

@@ -0,0 +1,36 @@
package com.earth2me.essentials.settings.commands;
import com.earth2me.essentials.storage.Comment;
import com.earth2me.essentials.storage.StorageObject;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public class Afk extends StorageObject
{
@Comment(
{
"After this timeout in seconds, the user will be set as afk.",
"Set to -1 for no timeout."
})
private int autoAFK = 300;
@Comment(
{
"Auto-AFK Kick",
"After this timeout in seconds, the user will be kicked from the server.",
"Set to -1 for no timeout."
})
private int autoAFKKick = -1;
@Comment(
{
"Set this to true, if you want to freeze the player, if he is afk.",
"Other players or monsters can't push him out of afk mode then.",
"This will also enable temporary god mode for the afk player.",
"The player has to use the command /afk to leave the afk mode.",
"You have to add a message to your welcome message or help page,",
"since the player will not get a message, if he tries to move."
})
private boolean freezeAFKPlayers = false;
}

View File

@@ -0,0 +1,14 @@
package com.earth2me.essentials.settings.commands;
import com.earth2me.essentials.storage.Comment;
import com.earth2me.essentials.storage.StorageObject;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper=false)
public class God extends StorageObject
{
@Comment("Turn off god mode when people exit")
private boolean removeOnDisconnect = false;
}

View File

@@ -0,0 +1,23 @@
package com.earth2me.essentials.settings.commands;
import com.earth2me.essentials.storage.Comment;
import com.earth2me.essentials.storage.StorageObject;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public class Help extends StorageObject
{
@Comment("Show other plugins commands in help")
private boolean showNonEssCommandsInHelp = true;
@Comment(
{
"Hide plugins which don't give a permission in their plugin.yml for each command.",
"You can override a true value here for a single plugin by adding a permission to a user/group.",
"The individual permission is: essentials.help.<plugin>, anyone with essentials.* or '*' will see all help this setting reguardless.",
"You can use negative permissions to remove access to just a single plugins help if the following is enabled."
})
private boolean hidePermissionlessCommands = true;
}

View File

@@ -0,0 +1,24 @@
package com.earth2me.essentials.settings.commands;
import com.earth2me.essentials.storage.Comment;
import com.earth2me.essentials.storage.StorageObject;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public class Home extends StorageObject
{
@Comment("When players die, should they respawn at their homes, instead of the spawnpoint?")
private boolean respawnAtHome = false;
@Comment(
{
"When a player interacts with a bed, should their home be set to that location?",
"If you enable this and remove default player access to the /sethome command, ",
"you can make beds the only way for players to set their home location."
})
private boolean bedSetsHome = false;
@Comment("If no home is set, should the player be send to spawn, when /home is used.")
private boolean spawnIfNoHome = false;
}

View File

@@ -0,0 +1,28 @@
package com.earth2me.essentials.settings.commands;
import com.earth2me.essentials.storage.MapType;
import com.earth2me.essentials.storage.StorageObject;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public class Kit extends StorageObject
{
public Kit()
{
final KitObject kit = new KitObject();
kit.setDelay(10.0);
kit.setItems(Arrays.asList("277 1,278 1,279 1".split(",")));
kits.put("tools", kit);
}
@MapType(KitObject.class)
private Map<String,KitObject> kits = new HashMap<String, KitObject>();
}

View File

@@ -0,0 +1,18 @@
package com.earth2me.essentials.settings.commands;
import com.earth2me.essentials.storage.ListType;
import com.earth2me.essentials.storage.StorageObject;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public class KitObject extends StorageObject
{
@ListType
private List<String> items = new ArrayList<String>();
private Double delay;
}

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