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

Compare commits

...

382 Commits

Author SHA1 Message Date
snowleo
9bb2ef9cbe Merge branch 'master' into release 2011-07-27 01:04:37 +02:00
snowleo
beb34a7651 Allow fractions of 1 2011-07-27 01:04:21 +02:00
snowleo
0ac26265e2 Fix for money exploit on trade signs 2011-07-27 01:00:55 +02:00
ementalo
8bb4067f06 double quoting ' 2011-07-26 10:35:55 +02:00
ementalo
fe1820134b Merge pull request #19 from khobbits/master
Xesxen's Dutch translation.
2011-07-26 01:34:32 -07:00
KHobbits
7d7c686e6a Edited Essentials/src/plugin.yml via GitHub 2011-07-25 23:25:07 -07:00
KHobbits
0b681c3654 Edited Essentials/src/messages_nl.properties via GitHub 2011-07-25 19:24:14 -07:00
KHobbits
23eeb82ac4 Edited Essentials/src/messages_nl.properties via GitHub 2011-07-25 19:20:42 -07:00
snowleo
edd6adc78f Another obsolete file 2011-07-24 23:33:48 +02:00
snowleo
c9028623ac Removed useless files 2011-07-24 23:30:11 +02:00
snowleo
dd5bcb8762 Edited README.markdown via GitHub 2011-07-24 14:25:12 -07:00
snowleo
bc1c252dca Correcting all line endings to LF 2011-07-24 23:19:12 +02:00
KHobbits
19ba6e5195 Added plural alias for kit & warp 2011-07-24 12:47:59 -07:00
snowleo
864e608582 Added code guidelines to all projects, so we don't need them globally.
Compress jar files
Don't copy lib files into dist folders
Removed vendor names
Changed all java versions to 1.6 to make it consistent.
2011-07-24 04:07:28 +02:00
snowleo
b84785cc82 If add-prefix-suffix is not set in config and EssentialsChat is installed, it will default to true now for backwards compatibility. 2011-07-24 00:41:54 +02:00
snowleo
832910d480 Merge branch 'master' into release 2011-07-23 22:34:43 +02:00
snowleo
164541794e SuperpermsBridge fail 2011-07-23 13:17:22 -07:00
snowleo
13da2b2924 Merge branch 'master' into release 2011-07-23 20:06:00 +02:00
snowleo
84ac520353 Master and Release branch are now identical again.
Removed warning for an older bukkit version.
2011-07-23 20:05:44 +02:00
snowleo
7aea9e71e8 NPE check in PlayerInteract 2011-07-23 19:13:05 +02:00
snowleo
5613975314 Merge branch 'master' into release 2011-07-23 03:11:14 +02:00
snowleo
dc0ca35017 More german translations 2011-07-23 03:10:53 +02:00
snowleo
662d30ae45 Merge branch 'master' into release 2011-07-23 03:07:38 +02:00
snowleo
4099755b9b German translation for muted 2011-07-23 03:07:21 +02:00
snowleo
57bee443b1 Merge branch 'master' into release 2011-07-23 02:39:37 +02:00
snowleo
0f3c0e82f2 Readded some code, so that the user is not checked, if he is next to himself. 2011-07-23 02:07:25 +02:00
snowleo
0e21d3287e Fix Util.getSafeDestination() to use int instead of double. 2011-07-23 02:06:13 +02:00
snowleo
3cedfeef2c Separate config setting for prefix/suffix 2011-07-23 01:43:02 +02:00
snowleo
a20f2b71da Added more default permissions for players to config.yml 2011-07-23 01:29:31 +02:00
snowleo
b2e3290038 Removed quotes from translation files 2011-07-23 01:13:55 +02:00
snowleo
979592c8ba Missing space in Spawnmob message 2011-07-23 01:10:22 +02:00
snowleo
7001798874 Don't give out a full stack on /unlimited, instead either 2 or 1, if the max stack size is 1 2011-07-23 01:03:45 +02:00
snowleo
40a2bccf2d Now the cleanup 2011-07-23 00:53:55 +02:00
snowleo
ee13d33b66 Revert "minor cleanup"
This reverts commit 5027198010.

Don't mess with the line endings!
2011-07-23 00:50:52 +02:00
snowleo
fdb46f60fd Add white color after each name to prevent coloration of the next name. 2011-07-23 00:47:02 +02:00
ementalo
5027198010 minor cleanup 2011-07-22 23:33:33 +01:00
ementalo
90a5a4a470 Merge pull request #17 from Macel/master
Added translations to plugin help command failure log messages
2011-07-22 15:13:47 -07:00
Robert Meany
85cab9533e *First Commit - Please verify I did everything right* - Added translations
to plugin help command failure log messagets.
2011-07-22 13:53:06 -04:00
ementalo
304b13ca5e SignProtection code fix number 92324 2011-07-22 17:16:08 +01:00
ementalo
6a1c53dd01 SignProtection another fix 2011-07-22 17:03:55 +01:00
ementalo
d7b2ac97aa fix of my fix 2011-07-22 16:56:41 +01:00
ementalo
7b7289db4c Test #725 fix for Protection signs created before 2.5 2011-07-22 14:07:04 +01:00
ementalo
ba2b827d7c Test #723 essentials.ban.notify - only people with this permission get notified on ban 2011-07-22 12:36:49 +01:00
snowleo
621618e41f Merge branch 'master' into release 2011-07-21 02:58:39 +02:00
snowleo
54559172c6 /unlimited: Instead of 2, give the player a full stack 2011-07-21 02:58:20 +02:00
snowleo
6ccb60813a Merge branch 'master' into release 2011-07-21 02:52:25 +02:00
snowleo
2067bb8f0d EssentialsChat: The user should see his own message
Corrected radius
2011-07-21 02:42:54 +02:00
snowleo
b34119901e Merge branch 'master' into release 2011-07-21 02:29:45 +02:00
snowleo
4f31d2779d Null pointer check for Perm 2.7.4 prefix/suffix 2011-07-21 02:09:54 +02:00
snowleo
ed29f29622 Merge pull request #15 from khobbits/patch-3
Not sure how well this would work, but its probably worth giving the user at least two of the item to combat client lag, if you try and build something with unlimited, but you only have 1 item, client lag prevents you from doing so quickly, because you need to wait for the server to give you back the item.
2011-07-20 16:44:51 -07:00
snowleo
b8e41df0f6 Merge pull request #16 from Brettflan/master
Fix for local chat, leftover Factions cleanup
2011-07-20 16:43:41 -07:00
Brettflan
602517473d Fix for local chat not working (instead acting just like global chat) 2011-07-20 18:08:02 -05:00
Brettflan
cee0823db4 Removed leftovers from initial Factions integration 2011-07-20 18:06:58 -05:00
snowleo
b317aef8c9 Merge branch 'master' into release 2011-07-21 00:31:39 +02:00
snowleo
8b41219fcc Updated VanishNoPickup:
vanish player if they are set as hidden on join
2011-07-20 23:58:41 +02:00
snowleo
61fa43a769 Updated VanishNoPickup
Correctly save hidden users
Allow /vanish hide playername from console
2011-07-20 23:48:21 +02:00
snowleo
fdbc6fa94f Merge branch 'master' into release 2011-07-20 23:18:34 +02:00
snowleo
28dd14d38c Fix /time for players without essentials.time.world 2011-07-20 23:18:09 +02:00
snowleo
0ffe24903a Merge branch 'master' into release 2011-07-20 23:09:40 +02:00
snowleo
f6e6e0042a Updated VanishNoPickup
Moved /noaggro command to /vanish aggro
2011-07-20 23:08:47 +02:00
snowleo
e550a7cc44 Merge branch 'master' into release 2011-07-20 22:37:43 +02:00
snowleo
9efc0840e3 VanishNoPickup 1.9.12+essentials2 2011-07-20 22:35:59 +02:00
snowleo
82165a2af6 Merge branch 'master' into release 2011-07-20 22:22:02 +02:00
snowleo
815b700eac Don't return offline players with getPlayer() 2011-07-20 22:14:56 +02:00
snowleo
fcda9f9d3b Prevent players to create correct signs with essentials.signs.color permission. 2011-07-20 22:04:02 +02:00
snowleo
aa663c0c98 Don't teleport to offline users. 2011-07-20 22:03:15 +02:00
snowleo
bda2f5e615 Show player not found message, if no unhidden player is found in /msg 2011-07-20 21:36:23 +02:00
snowleo
377f967dab Native support for PermissionsEx 2011-07-20 20:42:19 +02:00
snowleo
63a4fe32c1 Merge branch 'master' into release 2011-07-20 18:40:04 +02:00
snowleo
06dc9c25af Revert "I don't think we need this anymore."
This reverts commit 83b71eef5e.

Also inverted it, so it works now again.
2011-07-20 18:36:29 +02:00
snowleo
feb1c53004 Spawnmob sign 2011-07-20 18:20:12 +02:00
snowleo
2530a5018f Cleanup 2011-07-20 18:19:26 +02:00
snowleo
4bb1185bd5 Added VanishNoPickup 1.9.12+essentials1 2011-07-20 17:25:32 +02:00
KHobbits
d5c8d0c1bf Not sure how well this would work, but its probably worth giving the user at least two of the item to combat client lag, if you try and build something with unlimited, but you only have 1 item, client lag prevents you from doing so quickly, because you need to wait for the server to give you back the item. 2011-07-20 08:15:40 -07:00
snowleo
8828fb0868 Socialspy for aliases of commands
Adding tell as alias of msg
2011-07-20 17:11:59 +02:00
snowleo
cc29ebbbc9 Fix: Unmute players, even if they have essentials.mute.exempt permission 2011-07-20 17:10:55 +02:00
snowleo
1c44a25a4a Merge branch 'master' into release 2011-07-20 12:13:24 +02:00
snowleo
0483635a5c More changes to the EssentialsChat API for Factions 2011-07-20 12:12:49 +02:00
snowleo
cf21ecee2e Merge branch 'master' into release 2011-07-19 12:09:48 +02:00
snowleo
3b59dd0b02 Fix duplicated logger messages in GM after reload 2011-07-19 12:04:06 +02:00
snowleo
5467e502a5 Merge branch 'master' into release 2011-07-19 11:42:18 +02:00
snowleo
e805d1047f The event.getPlayer() is needed for the hook. 2011-07-19 11:29:16 +02:00
snowleo
dc99efb0a7 Rewritten Factions hook, so we don't need Factions in our code. 2011-07-19 11:26:23 +02:00
snowleo
6a156ede68 Removing the annoying c3p0 start message. 2011-07-19 11:11:59 +02:00
snowleo
4a963b22f1 Close database connections on plugin deactivation 2011-07-19 10:34:02 +02:00
snowleo
6af9ec266b Merge branch 'master' into release 2011-07-19 01:52:44 +02:00
snowleo
150a0e0ddd /tempban and /ban have the same problem as /tjail
new permissions:
essentials.ban.offline
essentials.tempban.offline
2011-07-19 01:32:48 +02:00
snowleo
d388290427 user.dispose() should be called on every quit. 2011-07-19 01:27:56 +02:00
snowleo
c8ba06f0ee We can't test for essentials.jail.exempt, if the player is offline, so added a new permission essentials.togglejail.offline 2011-07-19 01:27:16 +02:00
snowleo
a65390ed98 More fixes to /tjail
Don't prevent unjailing an admin
Fix time change
2011-07-19 01:12:19 +02:00
snowleo
6b85b306ef Another fix for /tjail offline players 2011-07-19 00:59:43 +02:00
snowleo
faa7e0e7a9 Merge branch 'master' into release 2011-07-19 00:47:14 +02:00
snowleo
fdbb6510ef Send helpop messages to console 2011-07-19 00:46:41 +02:00
snowleo
aa3606007a Merge branch 'master' into release 2011-07-19 00:42:10 +02:00
snowleo
d0bf1905a9 {UNIQUE} player count for motd 2011-07-19 00:10:33 +02:00
snowleo
548666b79b show hidden for /whois 2011-07-19 00:09:30 +02:00
snowleo
6dbb5bc605 Always use lowercase if accessing users map. 2011-07-19 00:02:35 +02:00
ementalo
15687c20d0 only check hidden if !offline, compare user with offlineplayer class 2011-07-18 22:49:27 +01:00
ementalo
81cc5b1f28 Add yet another way to get a user from our users list, Don't teleport an offline player when jailed
Added playerjoin to jaillistener to teleport a player on login
2011-07-18 22:16:58 +01:00
snowleo
7aea8a3fce NPE fix in InventoryWorkaround 2011-07-18 22:39:01 +02:00
snowleo
db5974970d Merge branch 'master' into release 2011-07-18 20:55:31 +02:00
snowleo
d2bc7e01a2 Workaround for the crippled bukkit permissions.
Splits the node at . and checks for * permissions on all levels.
2011-07-18 13:18:28 +02:00
snowleo
3d232e13d9 New config settings for Protect:
protect.prevent.tnt-playerdamage
protect.prevent.fireball-fire
protect.prevent.fireball-playerdamage
2011-07-18 07:22:28 +02:00
snowleo
83b71eef5e I don't think we need this anymore. 2011-07-18 06:19:40 +02:00
snowleo
13e5f22c25 Removed " from language files 2011-07-18 06:14:00 +02:00
snowleo
b88d0f88a1 Fix: Player staying afk if moving 2011-07-18 06:08:13 +02:00
snowleo
d727cad2db Merge branch 'master' of https://github.com/essentials/Essentials 2011-07-18 05:45:24 +02:00
snowleo
fd1256b449 Only show hidden player count, if it's more than 0 2011-07-18 05:45:05 +02:00
snowleo
c3235b3694 Merge pull request #14 from khobbits/patch-2
Missing commands in config.yml
2011-07-17 20:37:31 -07:00
snowleo
c1c3005454 Fix InventoryWorkaround.addItem() not using the combined list. 2011-07-18 04:59:47 +02:00
snowleo
a3c71e4617 Append the event and not the word event to trade log 2011-07-18 04:58:55 +02:00
snowleo
5aa2bc1706 Log location of /sell and signs 2011-07-18 04:49:38 +02:00
snowleo
277c623a77 Missing return in /time reset command 2011-07-18 04:42:10 +02:00
snowleo
e37db99c56 Fix player still being in user list after he was deleted. 2011-07-18 03:54:33 +02:00
snowleo
be83383fd5 Added option to hide player from /list /who ... login message.
This is for other plugins, that want to hide a player.
Use IEssentials.getUser(Player p).setHidden(boolean)
2011-07-18 03:42:21 +02:00
KHobbits
033151a170 Edited Essentials/src/config.yml via GitHub 2011-07-17 18:09:34 -07:00
snowleo
ba2539db67 Merge branch 'master' into release 2011-07-18 02:30:16 +02:00
snowleo
e3a470e264 Split build and use protection 2011-07-18 02:30:05 +02:00
snowleo
21d0661d79 Merge branch 'master' into release 2011-07-18 01:49:45 +02:00
snowleo
1556801834 Protect Rails and other signs from pistons 2011-07-18 01:39:41 +02:00
snowleo
e0dc003464 Cleaned deprecated functions 2011-07-18 01:17:24 +02:00
snowleo
81f0ad4d92 Piston push blacklist 2011-07-18 01:05:42 +02:00
snowleo
1ce6be5944 Protection of signs against pistons 2011-07-18 00:50:03 +02:00
snowleo
cc31fbed8e Bukkit Permission system
New config setting: use-bukkit-permissions
2011-07-18 00:30:39 +02:00
ementalo
29a15dfe18 CB #1000 Bukkit #700 2011-07-17 22:31:12 +01:00
ementalo
2f00865847 Test #706. essentials.mute.exempt - messages for mute players 2011-07-17 00:13:57 +01:00
ementalo
462fe18b15 Merge branch 'master' of github.com:essentials/Essentials 2011-07-17 00:08:30 +01:00
ementalo
31326d530f essentials.mute.exempt prevents muting, send messages when a player is muted to the muted 2011-07-16 23:53:53 +01:00
snowleo
9f3eb461a9 Merge branch 'master' into release 2011-07-16 17:04:46 +02:00
snowleo
48230f615d Fixes to EssentialsProtect that will remove conflicts with WorldGuard and other protection plugins. 2011-07-16 17:04:25 +02:00
snowleo
34b0deba29 Merge branch 'master' into release 2011-07-16 16:53:13 +02:00
snowleo
088f50ce8a mute for offline users 2011-07-16 16:52:50 +02:00
snowleo
d9a93d8dff Merge branch 'master' into release 2011-07-16 14:04:49 +02:00
snowleo
5ad12b52f8 Register API #8f66f7dcae80945250301a9d9e644a74ab28d0b6
Supports BOSE7
2011-07-16 14:04:30 +02:00
snowleo
747776344b Fixing merge error 2011-07-16 13:32:10 +02:00
snowleo
f979a79081 Merge branch 'master' into release
Conflicts:
	Essentials/src/com/earth2me/essentials/Essentials.java
	Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java
	Essentials/src/com/earth2me/essentials/commands/Commandspawner.java
	Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
	Essentials/src/com/earth2me/essentials/register/payment/Methods.java
	Essentials/src/items.csv
	EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java
	lib/bukkit-0.0.1-SNAPSHOT.jar
	lib/craftbukkit-0.0.1-SNAPSHOT.jar
2011-07-16 13:25:12 +02:00
snowleo
e6685abe4d Disable old message about iconomy not being enabled before essentials 2011-07-16 05:56:35 +02:00
snowleo
f867f675b9 fix kickexempt 2011-07-16 05:55:52 +02:00
snowleo
d9bfabd652 Revert to correct class loader 2011-07-16 05:06:08 +02:00
snowleo
d9b88a83d1 restricted-commands have been removed from config.yml
Now we have a whitelist: player-commands
2011-07-16 04:05:43 +02:00
snowleo
a8fdce257b Log free signs.
We don't how much the user takes out of the free sign, so we log the maximum value.
Also corrected the stack sizes.
2011-07-16 03:51:12 +02:00
snowleo
c3a8958046 Colored signs with &0-f
Permissions: essentials.signs.color
2011-07-16 03:23:58 +02:00
snowleo
d0345e45b6 Revert broken ban reason for /tempban 2011-07-16 03:11:52 +02:00
snowleo
5ab3422b29 German language file corrections 2011-07-16 02:54:35 +02:00
snowleo
66c4a24852 Fixing the UnitTests 2011-07-16 02:45:12 +02:00
snowleo
db27a8c627 Merge branch 'master' of https://github.com/essentials/Essentials 2011-07-16 02:38:46 +02:00
snowleo
78c376af79 Created an interface for settings. 2011-07-16 02:38:22 +02:00
ementalo
b749cd4e42 Merge pull request #12 from khobbits/master
Tidy plugins.yml, tidy help.
2011-07-15 17:12:29 -07:00
ementalo
a0554f566d This change did not commit 2011-07-16 01:09:28 +01:00
ementalo
1696d7ae71 Test #393 adding optional ban reason with tempban /tempban player time reason, also adding essentials.tempban.exempt 2011-07-16 01:05:11 +01:00
snowleo
ad8ad8b574 Fix merge error 2011-07-16 01:35:30 +02:00
snowleo
3c28dabfad Merge branch 'master' of https://github.com/essentials/Essentials 2011-07-16 01:33:33 +02:00
snowleo
a38fe6acd4 Heavy cleanup of all classes
ItemDb is not static anymore
Essentials.getStatic() removed
2011-07-16 01:33:22 +02:00
ementalo
f104c2e8f6 offline player validation for banning 2011-07-15 22:58:03 +01:00
ementalo
4dc92a144e Merge branch 'master' of github.com:essentials/Essentials 2011-07-15 22:51:43 +01:00
ementalo
1a7b198353 fixing offline player permissions check-ups.
Ban for offline players.
2 new permissions nodes. essentials.ban.exempt and essentials.kick.exempt. People with this permission cannot be banned / kicked
2011-07-15 22:48:42 +01:00
snowleo
25c9557c59 Cleanup of Essentials class
Moved all ban stuff to BanWorkaround
2011-07-15 23:39:56 +02:00
snowleo
963fd7cf01 Fix #682 line numbers of trade signs corrected 2011-07-15 22:02:43 +02:00
KHobbits
d7080950b0 Format. 2011-07-15 20:59:40 +01:00
snowleo
9c51f6e177 Test #683
fix for unbreakable sign
2011-07-15 21:58:24 +02:00
KHobbits
39352da929 Adding a failure message for help search 2011-07-15 20:56:58 +01:00
snowleo
ad65e66a7c Cleanup of Essentials Block and Player Listeners
Removed old sign code
Moved some jail stuff to the JailPlayerListener
Jail Events now have low priority, so that events are cancelled early.
2011-07-15 21:49:52 +02:00
KHobbits
132ddc323f Adjust the help for more alias' 2011-07-15 20:44:37 +01:00
snowleo
411e96bb18 Fix /time command:
Removed essentials.time.player permission (this is now default)
Added essentials.time.others permission
Admins can now set the time of players
Added reset option, that sets the time of the player to the world time
2011-07-15 21:16:06 +02:00
snowleo
705f9c267c Broadcast message on kick/ban 2011-07-15 20:49:47 +02:00
snowleo
d2db6348d9 Moved user.setDisplayName() from EssentialsChat to Essentials
Added new config: change-displayname (default to true)
It allows users to disable the setDisplayName, if they have other plugins that modify the display name
Updated user.getNick() to use StringBuilder
2011-07-15 20:35:09 +02:00
snowleo
ae7275c7ad New permission: essentials.sleepingignored 2011-07-15 20:13:52 +02:00
snowleo
cecb9867d9 /balance in console for offline users 2011-07-15 20:06:34 +02:00
snowleo
7e65038ae7 Log Protection alerts to the console
Also added the world name, which was missing.
2011-07-15 19:52:29 +02:00
snowleo
37d77f3e89 Disable /unlimited for fire block 2011-07-15 19:38:27 +02:00
snowleo
f4ef5a2094 Correct sorting 2011-07-15 19:29:06 +02:00
ementalo
af364b4bb4 actually remove sorting methods 2011-07-15 17:50:48 +01:00
ementalo
cd4c58cfcb balancetop only braodcasts to the issuer now, fix messages, remove util sortingmethods 2011-07-15 17:47:36 +01:00
ementalo
3898970bba balance top output to chat 2011-07-15 16:15:29 +01:00
ementalo
fb8f89e6dc Test #383 added balance top. Hardlimit max of 10 users at the moment. /balancetop retrieves all 10 /balancetop <1-10> retrieves the top number you specify 2011-07-15 15:43:39 +01:00
ementalo
1b0b0b1b57 fix messages when /eco'ing others 2011-07-14 23:27:04 +01:00
ementalo
4c89ef5638 Test #614 fix for socialspy 2011-07-14 22:58:36 +01:00
snowleo
5478a47e25 Signcolors also has High, so we have to use Highest 2011-07-10 14:14:40 -07:00
snowleo
48affa91b0 Fix signcolors bug 2011-07-10 14:11:50 -07:00
ementalo
fa2f97760b add thy shears forsooth 2011-07-09 23:48:26 +01:00
ementalo
557ca86ab2 add missing items 2011-07-09 22:52:43 +01:00
ementalo
b32d28be37 updated items.csv by necrodoom 2011-07-09 20:26:23 +01:00
ementalo
b9b5db8ccd merge went odd 2011-07-09 12:52:46 +01:00
ementalo
7ec1ca651f CB# 974 2011-07-09 12:45:41 +01:00
ementalo
8245adfd08 Merge pull request #11 from khobbits/patch-1
Add support for permissions: in plugin.yml files
2011-07-09 03:36:34 -07:00
KHobbits
beea6879b1 Edited Essentials/src/com/earth2me/essentials/commands/Commandhelp.java via GitHub 2011-07-08 19:51:48 -07:00
ementalo
e4ba0245be fix take message for ec 2011-07-08 12:49:57 +01:00
ementalo
aefbf921fe fixing eco command player argument. must be careful with c&p :/ 2011-07-08 12:38:54 +01:00
ementalo
8a1fb88ecd missed this from checkin oops 2011-07-08 12:29:06 +01:00
ementalo
962b6848c4 /balance offline players. Send message to initiator of eco commands 2011-07-08 12:24:32 +01:00
ementalo
2086b8c978 update signs after trades 2011-07-08 12:00:18 +01:00
ementalo
343291b210 copy and paste argument fix 2011-07-08 10:39:49 +01:00
ementalo
7ed57bc291 /eco offline players 2011-07-08 10:37:40 +01:00
snowleo
367e9840cc Fix save inventory after logout for new players. 2011-07-08 02:19:59 +02:00
snowleo
ea590c2ed1 NPE fix for offline users in UserData
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1583 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-07-08 02:16:23 +02:00
snowleo
cb5ab32be6 Set priority to Highest to prevent item dupe with trade signs. 2011-07-08 02:10:42 +02:00
ementalo
244674124b missing translation 2011-07-08 00:06:14 +01:00
ementalo
39770cd46d Test #304 set the location using the setters location, not the players location.
Support for offlline players
2011-07-07 22:24:50 +01:00
ementalo
f58fa10686 use full english for disconnect to spare eyeballs 2011-07-07 21:43:44 +01:00
ementalo
da8d5454d4 #539 new config . remove-god-on-discon if people discon with godmode on it will be turned off on quit. 2011-07-07 21:37:55 +01:00
ementalo
71c11d05fd remove null check for user in toggle jail. this is handled when we get user 2011-07-07 21:08:42 +01:00
ementalo
dab37c7b5b Merge branch 'master' of github.com:essentials/Essentials 2011-07-07 21:05:46 +01:00
ementalo
ce14779d2b #571 test jailing offline players. Person needs to have visited the server at least once and have a players.yml file 2011-07-07 21:05:08 +01:00
snowleo
a447bc7e66 Return boolean on sendMessage (XMPP) 2011-07-07 21:25:15 +02:00
snowleo
4d3e8332a8 Missing signs in sign list: balance and weather 2011-07-07 19:35:55 +02:00
snowleo
367fcdd029 /spawnmob command: Show error message if EssentialsProtect will prevent spawning of creature. 2011-07-07 19:22:57 +02:00
snowleo
3b838cc23d Fix a bug with temp banning offline users 2011-07-07 19:11:57 +02:00
snowleo
f2d9b10e87 New permission: essentials.signs.trade.override
Allows admins to break trade sign of other players.
2011-07-07 19:00:31 +02:00
snowleo
fc2c67ceda Merge branch 'master' of https://github.com/essentials/Essentials 2011-07-07 18:54:52 +02:00
snowleo
d02380edba Prevent loops generated by logging directly to xmpp 2011-07-07 18:54:25 +02:00
snowleo
3a1d0032c6 Merge pull request #10 from khobbits/master
Fixing help
2011-07-07 07:03:33 -07:00
KHobbits
ef37306701 Fixing help 2011-07-07 05:19:11 +01:00
KHobbits
34568ea8fc Merge branch 'master' of github.com:khobbits/Essentials
Conflicts:
	Essentials/src/com/earth2me/essentials/commands/Commandhelp.java
2011-07-07 04:14:50 +01:00
snowleo
56a2398d9b Added a comment to config that the item-spawn-blacklist will be ignored, if permission-based-item-spawn is set to true. 2011-07-06 02:59:16 -07:00
snowleo
db03b3c09e Missing config for last commit 2011-07-06 03:13:03 +02:00
snowleo
b272374072 Basic logging of trade/buy/sell signs and sell command 2011-07-06 02:58:59 +02:00
snowleo
8afde1ccc0 Fix /realname 2011-07-06 01:55:15 +02:00
snowleo
674128b3f7 Prevent oversized lines on trade signs 2011-07-06 01:39:24 +02:00
snowleo
c2936186f8 Now fireball explosion prevention has it's own config settings (was catched by tnt explosion prevention before) 2011-07-06 01:24:54 +02:00
snowleo
5006c68af2 Bounce projectiles, if they are cancelled. 2011-07-06 01:13:03 +02:00
snowleo
526df76ca9 Weather sign 2011-07-06 00:55:05 +02:00
snowleo
e92aeee91b Run the sign break event with the lowest priority, so it won't restore if other plugins cancel the event. 2011-07-06 00:14:06 +02:00
snowleo
f2107047da Set sleeping ignored for afk players & disable afk mode on login 2011-07-06 00:05:44 +02:00
snowleo
f280985dd6 Merge branch 'master' of https://github.com/essentials/Essentials 2011-07-05 23:50:50 +02:00
snowleo
f610dd9c72 Limiting the amount of money a player can have.
The maximum limit is 10 trillions.
2011-07-05 23:50:31 +02:00
snowleo
7e4cbd7b26 Merge pull request #9 from khobbits/patch-2
essentials.back.ondeath would be useless without essentials.back
2011-07-05 08:06:03 -07:00
KHobbits
ffd1154ca3 essentials.back.ondeath would be useless without essentials.back 2011-07-03 06:58:20 -07:00
ementalo
7f4ba16388 fixes #654 - user is no longer afk on chat or command use 2011-07-03 00:05:46 +01:00
ementalo
66dafdca0d Merge branch 'master' of github.com:essentials/Essentials 2011-07-02 23:54:43 +01:00
ementalo
3a8b888e7c fixes #475. User is no longer afk if they move. others can set afk /afk playername. needs essentials.afk.others 2011-07-02 23:53:54 +01:00
snowleo
ed1aa2f9dc Added softdepend: Factions to EssentialsChat 2011-07-02 15:42:28 -07:00
snowleo
4eb94e7fac Merge pull request #8 from Brettflan/master
Implemented Factions plugin hooks to EssentialsChat for proper chat integration between them (master/dev branch)
2011-07-02 15:41:17 -07:00
Brettflan
16b101b958 Implemented Factions hooks for proper chat integration with it (master/dev branch) 2011-07-02 17:34:49 -05:00
snowleo
ff8564787a Edited README.markdown via GitHub 2011-07-02 15:12:43 -07:00
snowleo
6616d9a62f Merge pull request #6 from khobbits/patch-1
Updated groups.yml
2011-07-02 14:57:45 -07:00
snowleo
ae053dea58 Prevent signs created by plugins like SignColours 2011-07-02 13:16:44 +02:00
snowleo
335c9f37ab Fix: No cooldown for all /tpo commands
TP-Delay: Player can move around roughly in the 9 blocks surrounding them.
2011-07-02 13:12:10 +02:00
snowleo
914a44007d Update of bukkit version number in essentials class 2011-07-02 01:13:44 +02:00
snowleo
bbd10b90c0 CB# 953
B# 754
2011-07-02 01:12:59 +02:00
snowleo
d93120257b Update of bukkit version number in essentials class 2011-07-02 01:10:48 +02:00
snowleo
e763b362d9 CB# 953
B# 754
2011-07-02 01:09:19 +02:00
snowleo
5ae0ab745f More names for pistons (items.csv)
Fix for /unlimited and pistons
2011-07-01 10:58:50 +02:00
snowleo
e5eb1ca0cb More names for pistons (items.csv)
Fix for /unlimited and pistons
2011-07-01 10:52:59 +02:00
snowleo
ecaecc5e62 Fix Protection signs 2011-07-01 01:33:35 +02:00
snowleo
e596f85953 Fix Trade signs 2011-07-01 01:33:09 +02:00
snowleo
aef2ca3e5d Fix Groups for warp signs 2011-07-01 01:32:49 +02:00
snowleo
bd7a50ad07 Always cancel interact with sign. 2011-07-01 01:32:13 +02:00
snowleo
5346b112a4 Don't add items with an amount of 0 or lower to the inventory. 2011-07-01 01:31:20 +02:00
snowleo
d95d7745ad Fix for a bug in getTrade() of Signs that would return the quantity of items as money. 2011-06-30 23:27:00 +02:00
snowleo
6c9a57d4b3 Don't place a block, if interacting with a sign. 2011-06-30 22:57:39 +02:00
snowleo
60235d0da4 Only act on right click, otherwise signs can't be destroyed. 2011-06-30 22:55:00 +02:00
snowleo
995f18bb0f Fix: Blocks can't be broken. 2011-06-30 22:50:22 +02:00
snowleo
a720bf33ce Updated items.csv 2011-06-30 19:17:58 +02:00
snowleo
ea2649db5e Updated items.csv 2011-06-30 19:16:50 +02:00
snowleo
0f87670991 CB #946
B #750
2011-06-30 18:57:36 +02:00
snowleo
b53fc9cadc Renamed functions 2011-06-30 18:54:05 +02:00
snowleo
4b35e1b729 CB #946
B #750
2011-06-30 18:43:23 +02:00
KHobbits
016defd043 Query:
- does essentials.back.ondeath work without essentials.back, and vice versa?
- should we swap signs.protection.override? to signs.override.protection?
2011-06-29 02:33:11 -07:00
ementalo
2aa88d05cf Updating for huge renames in #939 2011-06-28 23:32:30 +01:00
ementalo
c530030e5d sethome for others, missed from commit 2011-06-28 10:13:18 +01:00
ementalo
48e0073b31 admin can set others homes. needs "essentials.sethome.others" permission 2011-06-28 10:10:29 +01:00
ementalo
ce6d5596aa move socialspy handler to commandpreprocess 2011-06-28 09:29:40 +01:00
snowleo
40e106db13 Fix /spawner command
The name had to be first letter uppercase, the rest lowercase
2011-06-27 11:57:03 +02:00
snowleo
3dc0659f66 Another fix to /spawnmob
Merged for release
2011-06-27 11:53:57 +02:00
snowleo
8f32d66e03 Another fix to /spawnmob 2011-06-27 11:46:57 +02:00
snowleo
1c11ab0957 Fix Mop spawning 2011-06-26 18:15:20 +02:00
snowleo
fafd9b20a9 Renamed getInteger method name to getIntegerPositive. 2011-06-26 18:14:59 +02:00
snowleo
a6d60dbc94 Deprecating the old sign code and adding the new code.
Please test everything without EssentialsProtect. The signs should protect themselves.
2011-06-26 16:17:45 +02:00
snowleo
fa5d6fbfae Missing onBlockPlace event for Protection sign 2011-06-26 16:06:19 +02:00
snowleo
88ded926f4 Corrected all commands of PermCommands
onCommand now supports the change of the permissions prefix
2011-06-26 15:47:28 +02:00
snowleo
3b9a07e560 Protection signs and
new Listeners for the signs
2011-06-26 15:31:13 +02:00
snowleo
512a1b9183 Corrected the output of /gc
It's now max, total and free
2011-06-26 12:16:50 +02:00
snowleo
fb834bf104 Fix: Player was unable to use any commands, if his money was negative. 2011-06-25 22:23:11 +02:00
snowleo
953ce38d63 Updated bukkit version number in Essentials class 2011-06-25 16:46:41 +02:00
snowleo
ca29f18850 Cleanup of KHobbits commit 2011-06-25 16:46:02 +02:00
KHobbits
503b4fee55 Searchable help.
Toggle commands with no permissions.
2011-06-25 22:39:46 +08:00
snowleo
b7cb11cd95 Remove the restriction of EssEcoApi to not use iConomy or BOSE 2011-06-25 15:34:33 +02:00
snowleo
cfa8b8e2f4 Same in messages.properties 2011-06-25 15:19:45 +02:00
snowleo
70621e3eff Merge pull request #3 from khobbits/patch-1
Fixing Typo in messages_en.properties
2011-06-25 06:18:13 -07:00
snowleo
0731580cc9 Don't connect to example.com, the default value 2011-06-25 15:17:10 +02:00
snowleo
8bb3a76366 Merge branch 'bukkitupdate' 2011-06-25 15:00:08 +02:00
KHobbits
209a9a2f95 Searchable help.
Toggle commands with no permissions.
2011-06-24 15:29:49 +01:00
KHobbits
d50d8bfee0 Fixing Typo 2011-06-24 15:25:08 +01:00
KHobbits
b0e606568f Fixing Typo 2011-06-24 05:13:37 -07:00
snowleo
22ea5b0f8b More permissions that should be restricted to ops 2011-06-23 20:44:18 +02:00
snowleo
6676efe029 Fix /spawner command
The name had to be first letter uppercase, the rest lowercase
2011-06-23 20:14:59 +02:00
snowleo
6b360da8d8 Cleanup 2011-06-23 19:34:51 +02:00
snowleo
198b205d83 Fix unbreakable blocks 2011-06-23 15:57:52 +02:00
snowleo
b9e56d100c /antioch now uses bukkit code 2011-06-23 15:02:05 +02:00
snowleo
0a924bf226 Cleanup 2011-06-23 14:58:37 +02:00
snowleo
2ea5e6c03b Better /nuke command, now accepts playernames as argument 2011-06-23 14:58:26 +02:00
snowleo
efaed85188 New command /fireball 2011-06-23 14:14:24 +02:00
snowleo
c378d98b0f Updated /spawnmob to use bukkit code
Less code that breaks with future minecraft updates.
2011-06-23 14:10:27 +02:00
snowleo
9d6727daf2 Merge branch 'bukkitupdate'
Conflicts:
	EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java
2011-06-23 13:49:37 +02:00
snowleo
c6aa5f1e68 Check java version to be at least 1.6 2011-06-23 12:38:21 +02:00
snowleo
a16ced78a5 Merge branch 'master' of https://github.com/essentials/Essentials 2011-06-23 12:23:42 +02:00
snowleo
cdea68443a Only get data from valid rows
Fixes #641
2011-06-23 12:22:52 +02:00
jessenic
e24c053b95 Adding a command deprecated notice for players 2011-06-22 07:44:01 +08:00
jessenic
798d4458d4 Deleting my name xD 2011-06-22 07:44:01 +08:00
jessenic
a228708138 Fixing typo in EssentialsPermissionsCommands plugin.yml. And adding my name there :P 2011-06-22 07:44:00 +08:00
snowleo
5d8f5cecee Translation error (german) 2011-06-19 13:09:29 +02:00
snowleo
34f650e270 Moved some code from EssentialsSign to SignTrade, because it's only needed there. 2011-06-13 15:15:19 +02:00
snowleo
49bdf5719e Trade sign 2011-06-13 15:05:31 +02:00
snowleo
fd2d2456b9 Renamed the Charge class to Trade 2011-06-13 15:05:11 +02:00
snowleo
adc7502115 Use the new Workaround in buy signs. 2011-06-12 22:58:37 +02:00
snowleo
631c7f30b6 Workaround methods are static 2011-06-12 22:57:43 +02:00
snowleo
46cba7a9a7 Use the correct maxStackSize, when adding things to the inventory. 2011-06-12 22:55:08 +02:00
snowleo
246383804a Limit buy signs amount to a full inventory of a player. 2011-06-12 22:40:25 +02:00
snowleo
32bbe877aa Sell & Buy Sign 2011-06-12 22:33:47 +02:00
snowleo
0eee5acac7 To make things consistent:
permissions: essentials.signs.break.signname and essentials.signs.signname.break
2011-06-12 21:58:09 +02:00
snowleo
7d112a957c Updated french translation by Nelo 2011-06-12 18:41:50 +02:00
snowleo
76c06ce17a Correct header 2011-06-12 18:31:33 +02:00
snowleo
350a951e8b Sort all messages, so diffs are easier. 2011-06-12 18:30:24 +02:00
snowleo
6cc742b139 Fix for calling command for plugins that are loaded after Essentials. 2011-06-12 17:52:46 +02:00
snowleo
ebc56c0e15 Prevent lava bucket placed in air (far away from user)
event.isCancelled() does not return the expected value
2011-06-12 16:15:50 +02:00
snowleo
f0c503dd13 Another missing part 2011-06-12 14:54:56 +02:00
snowleo
bfa8b26661 The permission is essentials.protect.ownerinfo 2011-06-12 14:32:28 +02:00
snowleo
772bf4c7d0 Merge branch 'master' of https://github.com/essentials/Essentials 2011-06-12 02:48:50 +02:00
snowleo
edefb21142 Fix for Craftbukkit Bug 912 2011-06-12 02:47:50 +02:00
ementalo
01f69b3f2b Protect: Remove protection when attached block is destroyed 2011-06-11 16:05:14 +01:00
snowleo
26c9b34744 Merge branch 'master' of https://github.com/essentials/Essentials 2011-06-11 13:03:10 +02:00
snowleo
dfad01d558 Merge branch 'release'
Conflicts:
	.gitignore
	lib/bukkit-0.0.1-SNAPSHOT.jar
2011-06-11 13:02:34 +02:00
ementalo
b974410dd9 Protect: Get block owners on right click block only 2011-06-11 08:37:05 +01:00
snowleo
d01e2e0a3b Merge pull request #2 from khobbits/master
gm aliases
2011-06-08 17:28:01 -07:00
KHobbits
5a544fd251 Adding group permission alias 2011-06-08 17:41:48 +01:00
KHobbits
f5fac6f9f5 Adding user permission alias 2011-06-08 17:36:43 +01:00
KHobbits
5d925aa338 Adding manload 2011-06-08 17:32:37 +01:00
KHobbits
8136179e55 Adding some GM aliases 2011-06-08 17:20:51 +01:00
snowleo
dea44d7cbc Catch NumberFormatException 2011-06-08 03:44:16 +02:00
snowleo
e0597f2df1 Cleanup 2011-06-08 03:40:00 +02:00
snowleo
99268b9d9e The sign permissions will be:
essentials.signs.create.*
essentials.signs.use.*
essentials.signs.break.*
2011-06-08 03:30:32 +02:00
snowleo
bcf81d9f0a Refactoring of the signs
Todo: Eco signs, Protection signs

New permission: essentials.signs.[signname].break
2011-06-08 03:18:33 +02:00
snowleo
775c8d34dd Added developer readme and settings. 2011-06-07 23:01:28 +02:00
snowleo
75973f69a5 Fix save inventory after logout for new players. 2011-06-07 22:18:57 +02:00
snowleo
f04b7133eb Remove unused imports 2011-06-07 22:17:55 +02:00
snowleo
b1446154bf Fix dependency
Loading from lib won't work, so back to the old method.
2011-06-07 21:55:31 +02:00
snowleo
640f51564a The rest of Wundarks commit, cleaned 2011-06-07 01:55:39 +02:00
Wundark
5c258c03dc Added [Time] Sign 2011-06-07 07:46:42 +08:00
Wundark
bc8aa0c77a Changed MOTD 2011-06-07 07:33:13 +08:00
snowleo
cc18f95bc9 Merge branch 'permissions3' 2011-06-07 01:23:37 +02:00
snowleo
9e5c64ae9c ignore build directories 2011-06-07 01:23:07 +02:00
snowleo
7bbb62ce50 Fix the tests. 2011-06-07 01:11:00 +02:00
snowleo
d8a81923b1 Only import what we really need. 2011-06-07 01:08:31 +02:00
snowleo
1321f8de5d Bukkit #704 2011-06-07 01:07:16 +02:00
snowleo
4bfc8e1459 Cleanup
/manuadd command
2011-06-07 00:54:36 +02:00
snowleo
4f16c8b5a7 Permissions 3.1.4
Added Code for Perm2, Perm3 and Config Permissions
Cleaned EssentialsChat
2011-06-07 00:24:39 +02:00
snowleo
a45e620946 Major cleanup of the Protect code 2011-06-06 22:29:08 +02:00
snowleo
d877880171 Ignore all build files 2011-06-06 14:16:56 +02:00
snowleo
a91aeb1a76 gitignore for .DS_Store files 2011-06-06 12:08:54 +00:00
snowleo
b7791caa75 cleanup
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1593 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-06 12:06:41 +00:00
snowleo
6c862e72b5 cleanup
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1592 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-06 12:04:37 +00:00
snowleo
710088fb13 cleanup
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1591 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-06 12:02:33 +00:00
snowleo
198607d425 Cleaned InventoryWorkaround
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1590 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-06 12:01:56 +00:00
snowleo
4bbc2aa8d5 Rewrote TargetBlock
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1589 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-06 12:01:23 +00:00
snowleo
c038751c0b Pull-Request #1 by mrapple
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1588 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-05 23:56:52 +00:00
ementalo
f1b544a96f [trunk] Protect, add missing listener
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1587 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-05 21:36:47 +00:00
ementalo
9a4ef7cd20 [trunk] Protect, more merges
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1586 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-05 19:09:29 +00:00
snowleo
bc3d8d5ece NPE fix for offline users in UserData
That one was correct, otherwise the inventory will be deleted by offline changes.

git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1585 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-05 00:03:44 +00:00
snowleo
1751baeed6 NPE fix for offline users in UserData
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1584 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-05 00:01:15 +00:00
snowleo
7b825cc8d5 NPE fix for offline users in UserData
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1583 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-05 00:00:41 +00:00
ementalo
a005436510 [trunk] Protect, move some bits about
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1582 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-03 21:03:08 +00:00
ementalo
541fc51780 [trunk] Protect, merging changes in
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1581 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-03 20:56:29 +00:00
snowleo
aef2dd35d6 Fix Spawner
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1580 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-03 20:11:20 +00:00
ementalo
e94a01b149 [trunk] Adding dependancy checker, need to fix timings as Protect tries to use it before the file system finishes
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1579 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-03 14:23:55 +00:00
ementalo
1a572bca2e [trunk] Fix the build, bundling the c3p0 jar inside protect for the moment
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1578 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-03 07:57:35 +00:00
snowleo
5a47d18a9b Fixes for XMPP: Prevent loops on errors
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1577 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-03 03:57:41 +00:00
snowleo
991a5cb24c Fixes for XMPP: display minecraft username for players that have set their address using /setxmpp, others will have the jabber address next to the message
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1576 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-03 02:22:32 +00:00
snowleo
e8e97e86a0 Fixes for XMPP: display message on /setxmpp, ignore resource on xmpp addresses, reconnect on reload
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1575 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-03 01:50:40 +00:00
ementalo
f6cedda1e2 [trunk] Protect refactors (formally known as 3.0) needs ***EXTENSIVE*** testing
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1574 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-02 23:09:59 +00:00
ementalo
3dab3d8df8 [trunk] fix class not found
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1573 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-02 22:01:57 +00:00
snowleo
3e359b5b48 Code cleanup
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1572 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-02 14:23:50 +00:00
snowleo
09e17a4d6c timePattern for dutch translation
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1571 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-02 14:04:24 +00:00
snowleo
651b89d97b More cleanup
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1570 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-02 13:59:02 +00:00
snowleo
0ff89abeee Code cleanup
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1569 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-02 13:49:58 +00:00
snowleo
8ba3e3c2f9 Stupid Netbeans is stupid.
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1568 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-02 13:31:52 +00:00
snowleo
e53ce03d36 Missing file for EssentialsXMPP
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1566 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-02 13:25:57 +00:00
snowleo
aeb3b0f37c Smack 3.2.0
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1565 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-02 13:24:51 +00:00
snowleo
2d038579ba Added EssentialsXMPP from newplugins branch.
Updated to work with trunk.

git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1564 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-02 13:24:26 +00:00
snowleo
ba86a338c2 Cleanup
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1563 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-02 13:22:24 +00:00
snowleo
1bcc2e6e50 items.csv by necrodoom
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1562 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-02 11:50:17 +00:00
snowleo
797dde94e1 May death rain upon them
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1561 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-02 11:43:25 +00:00
ementalo
b83bb1faa3 Dutch translations by Geertje123
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1560 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-06-02 11:26:58 +00:00
248 changed files with 17552 additions and 9202 deletions

8
.gitignore vendored
View File

@@ -22,4 +22,10 @@
/EssentialsXMPP/dist/
/EssentialsXMPP/build/
/EssentialsProtect/dist/
/EssentialsProtect/build/
/EssentialsProtect/build/
/EssentialsPermissionsCommands/nbproject/private/
/EssentialsPermissionsCommands/build/
/EssentialsPermissionsCommands/dist/
/Essentials/nbproject/private/
/Essentials/dist/
/Essentials/build/

View File

@@ -636,6 +636,13 @@ is divided into following sections:
<param name="call.target" value="jar"/>
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
</antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-jar.properties}"/>
<param location="${project.EssentialsPermissionsCommands}" name="call.subproject"/>
<param location="${project.EssentialsPermissionsCommands}/build.xml" name="call.script"/>
<param name="call.target" value="jar"/>
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
</antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-jar.properties}"/>
<param location="${project.EssentialsProtect}" name="call.subproject"/>
@@ -650,6 +657,13 @@ is divided into following sections:
<param name="call.target" value="jar"/>
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
</antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-jar.properties}"/>
<param location="${project.EssentialsXMPP}" name="call.subproject"/>
<param location="${project.EssentialsXMPP}/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">
@@ -1121,6 +1135,13 @@ is divided into following sections:
<param name="call.target" value="clean"/>
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
</antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-clean.properties}"/>
<param location="${project.EssentialsPermissionsCommands}" name="call.subproject"/>
<param location="${project.EssentialsPermissionsCommands}/build.xml" name="call.script"/>
<param name="call.target" value="clean"/>
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
</antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-clean.properties}"/>
<param location="${project.EssentialsProtect}" name="call.subproject"/>
@@ -1135,6 +1156,13 @@ is divided into following sections:
<param name="call.target" value="clean"/>
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
</antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-clean.properties}"/>
<param location="${project.EssentialsXMPP}" name="call.subproject"/>
<param location="${project.EssentialsXMPP}/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

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,7 +3,42 @@ annotation.processing.enabled.in.editor=false
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=Essentials
application.vendor=Paul
application.vendor=
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineArrayInit=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAssignment=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineBinaryOp=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineDisjunctiveCatchTypes=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineParenthesized=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTernaryOp=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTryResources=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterClassHeader=0
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesBeforeClass=2
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indentCasesFromSwitch=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
@@ -26,27 +61,31 @@ dist.jar=${dist.dir}/Essentials.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.BOSEconomy.jar=../lib/BOSEconomy.jar
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
file.reference.iCo4.jar=../lib/iCo4.jar
file.reference.iCo5.jar=../lib/iCo5.jar
file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar
file.reference.Permissions.jar=..\\lib\\Permissions.jar
file.reference.Permissions3.jar=../lib/Permissions3.jar
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
includes=**
jar.compress=false
jar.archive.disabled=${jnlp.enabled}
jar.compress=true
jar.index=${jnlp.enabled}
javac.classpath=\
${file.reference.Permissions.jar}:\
${file.reference.Permissions3.jar}:\
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
${file.reference.BOSEconomy.jar}:\
${file.reference.iCo4.jar}:\
${file.reference.iCo5.jar}
${file.reference.iCo5.jar}:\
${file.reference.BOSEconomy7.jar}:\
${file.reference.PermissionsEx.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
javac.source=1.5
javac.target=1.5
javac.source=1.6
javac.target=1.6
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}:\
@@ -64,8 +103,17 @@ javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
jnlp.codebase.type=no.codebase
jnlp.descriptor=application
jnlp.enabled=false
jnlp.mixed.code=default
jnlp.offline-allowed=false
jnlp.signed=false
jnlp.signing=
jnlp.signing.alias=
jnlp.signing.keystore=
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
mkdist.disabled=true
platform.active=default_platform
run.classpath=\
${javac.classpath}:\

View File

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

View File

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

View File

@@ -1,104 +0,0 @@
package com.earth2me.essentials;
import org.bukkit.inventory.ItemStack;
public class Charge
{
private final String command;
private final Double costs;
private final ItemStack items;
private final IEssentials ess;
public Charge(String command, IEssentials ess)
{
this(command, null, null, ess);
}
public Charge(double money, IEssentials ess)
{
this(null, money, null, ess);
}
public Charge(ItemStack items, IEssentials ess)
{
this(null, null, items, ess);
}
private Charge(String command, Double money, ItemStack item, IEssentials ess)
{
this.command = command;
this.costs = money;
this.items = item;
this.ess = ess;
}
public void isAffordableFor(IUser user) throws Exception
{
double mon = user.getMoney();
if (costs != null)
{
if (mon < costs && !user.isAuthorized("essentials.eco.loan"))
{
throw new Exception(Util.i18n("notEnoughMoney"));
}
}
if (items != null)
{
if (!InventoryWorkaround.containsItem(user.getInventory(), true, items))
{
throw new Exception(Util.format("missingItems", items.getAmount(), items.getType().toString().toLowerCase().replace("_", " ")));
}
}
if (command != null && !command.isEmpty())
{
if (user.isAuthorized("essentials.nocommandcost.all")
|| user.isAuthorized("essentials.nocommandcost." + command))
{
return;
}
double cost = ess.getSettings().getCommandCost(command.startsWith("/") ? command.substring(1) : command);
if (mon < cost && !user.isAuthorized("essentials.eco.loan"))
{
throw new Exception(Util.i18n("notEnoughMoney"));
}
}
}
public void charge(IUser user) throws Exception
{
double mon = user.getMoney();
if (costs != null)
{
if (mon < costs && !user.isAuthorized("essentials.eco.loan"))
{
throw new Exception(Util.i18n("notEnoughMoney"));
}
user.takeMoney(costs);
}
if (items != null)
{
if (!InventoryWorkaround.containsItem(user.getInventory(), true, items))
{
throw new Exception(Util.format("missingItems", items.getAmount(), items.getType().toString().toLowerCase().replace("_", " ")));
}
InventoryWorkaround.removeItem(user.getInventory(), true, items);
user.updateInventory();
}
if (command != null && !command.isEmpty())
{
if (user.isAuthorized("essentials.nocommandcost.all")
|| user.isAuthorized("essentials.nocommandcost." + command))
{
return;
}
double cost = ess.getSettings().getCommandCost(command.startsWith("/") ? command.substring(1) : command);
if (mon < cost && !user.isAuthorized("essentials.eco.loan"))
{
throw new Exception(Util.i18n("notEnoughMoney"));
}
user.takeMoney(cost);
}
}
}

View File

@@ -0,0 +1,15 @@
package com.earth2me.essentials;
public class ChargeException extends Exception
{
public ChargeException(final String message)
{
super(message);
}
public ChargeException(final String message, final Throwable throwable)
{
super(message, throwable);
}
}

View File

@@ -0,0 +1,46 @@
package com.earth2me.essentials;
import org.bukkit.entity.Player;
public class ConfigPermissionsHandler implements IPermissionsHandler
{
private final transient IEssentials ess;
public ConfigPermissionsHandler(final IEssentials ess)
{
this.ess = ess;
}
public String getGroup(final Player base)
{
return "default";
}
public boolean canBuild(final Player base, final String group)
{
return true;
}
public boolean inGroup(final Player base, final String group)
{
return false;
}
public boolean hasPermission(final Player base, final String node)
{
final String[] cmds = node.split("\\.", 2);
return !ess.getSettings().isCommandRestricted(cmds[cmds.length - 1])
&& ess.getSettings().isPlayerCommand(cmds[cmds.length - 1]);
}
public String getPrefix(final Player base)
{
return "";
}
public String getSuffix(final Player base)
{
return "";
}
}

View File

@@ -17,6 +17,7 @@
*/
package com.earth2me.essentials;
import com.earth2me.essentials.api.Economy;
import com.earth2me.essentials.commands.EssentialsCommand;
import java.io.*;
import java.util.*;
@@ -27,10 +28,13 @@ import org.bukkit.command.CommandSender;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
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.craftbukkit.entity.CraftPlayer;
import org.bukkit.command.PluginCommand;
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Priority;
@@ -42,123 +46,113 @@ import org.bukkit.plugin.java.*;
public class Essentials extends JavaPlugin implements IEssentials
{
public static final String AUTHORS = "Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans and Xeology";
public static final int minBukkitBuildVersion = 860;
private static final Logger logger = Logger.getLogger("Minecraft");
private Settings settings;
private EssentialsPlayerListener playerListener;
private EssentialsBlockListener blockListener;
private EssentialsEntityListener entityListener;
private JailPlayerListener jailPlayerListener;
private static Essentials instance = null;
private Spawn spawn;
private Jail jail;
private Warps warps;
private Worth worth;
private List<IConf> confList;
public ArrayList bans = new ArrayList();
public ArrayList bannedIps = new ArrayList();
private Backup backup;
private final Map<String, User> users = new HashMap<String, User>();
private EssentialsTimer timer;
private EssentialsUpdateTimer updateTimer;
private boolean registerFallback = true;
private final Methods paymentMethod = new Methods();
private final static boolean enableErrorLogging = false;
private final EssentialsErrorHandler errorHandler = new EssentialsErrorHandler();
public static final int BUKKIT_VERSION = 1000;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
private transient Spawn spawn;
private transient Jail jail;
private transient Warps warps;
private transient Worth worth;
private transient List<IConf> confList;
private transient Backup backup;
private transient BanWorkaround bans;
private transient ItemDb itemDb;
private transient final Map<String, User> users = new HashMap<String, User>();
private transient EssentialsUpdateTimer updateTimer;
private transient final Methods paymentMethod = new Methods();
private transient final static boolean enableErrorLogging = false;
private transient final EssentialsErrorHandler errorHandler = new EssentialsErrorHandler();
private transient IPermissionsHandler permissionsHandler;
public static IEssentials getStatic()
{
return instance;
}
public Settings getSettings()
public ISettings getSettings()
{
return settings;
}
public void setupForTesting(Server server) throws IOException, InvalidDescriptionException
public void setupForTesting(final Server server) throws IOException, InvalidDescriptionException
{
File dataFolder = File.createTempFile("essentialstest", "");
dataFolder.delete();
dataFolder.mkdir();
logger.log(Level.INFO, Util.i18n("usingTempFolderForTesting"));
logger.log(Level.INFO, dataFolder.toString());
final File dataFolder = File.createTempFile("essentialstest", "");
if (!dataFolder.delete())
{
throw new IOException();
}
if (!dataFolder.mkdir())
{
throw new IOException();
}
LOGGER.log(Level.INFO, Util.i18n("usingTempFolderForTesting"));
LOGGER.log(Level.INFO, dataFolder.toString());
this.initialize(null, server, new PluginDescriptionFile(new FileReader(new File("src" + File.separator + "plugin.yml"))), dataFolder, null, null);
settings = new Settings(dataFolder);
setStatic();
}
public void setStatic()
{
instance = this;
settings = new Settings(this);
permissionsHandler = new ConfigPermissionsHandler(this);
Economy.setEss(this);
}
public void onEnable()
{
if (!Thread.currentThread().getStackTrace()[5].getMethodName().equals("loadPlugin")) {
logger.log(Level.SEVERE, "Another plugin is trying to enable Essentials manually. Don't do this! It's probably "
+ Thread.currentThread().getStackTrace()[5].getClassName());
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);
LOGGER.addHandler(errorHandler);
}
setStatic();
EssentialsUpgrade upgrade = new EssentialsUpgrade(this.getDescription().getVersion(), this);
upgrade.beforeSettings();
confList = new ArrayList<IConf>();
settings = new Settings(this.getDataFolder());
settings = new Settings(this);
confList.add(settings);
upgrade.afterSettings();
Util.updateLocale(settings.getLocale(), this.getDataFolder());
Util.updateLocale(settings.getLocale(), this);
spawn = new Spawn(getServer(), this.getDataFolder());
confList.add(spawn);
warps = new Warps(getServer(), this.getDataFolder());
confList.add(warps);
worth = new Worth(this.getDataFolder());
confList.add(worth);
bans = new BanWorkaround(this);
confList.add(bans);
itemDb = new ItemDb(this);
confList.add(itemDb);
reload();
backup = new Backup(this);
PluginManager pm = getServer().getPluginManager();
final PluginManager pm = getServer().getPluginManager();
for (Plugin plugin : pm.getPlugins())
{
if (plugin.getDescription().getName().startsWith("Essentials"))
if (plugin.getDescription().getName().startsWith("Essentials")
&& !plugin.getDescription().getVersion().equals(this.getDescription().getVersion()))
{
if (!plugin.getDescription().getVersion().equals(this.getDescription().getVersion()))
{
logger.log(Level.WARNING, Util.format("versionMismatch", plugin.getDescription().getName()));
}
LOGGER.log(Level.WARNING, Util.format("versionMismatch", plugin.getDescription().getName()));
}
}
Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*").matcher(getServer().getVersion());
final Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*").matcher(getServer().getVersion());
if (versionMatch.matches())
{
int versionNumber = Integer.parseInt(versionMatch.group(4));
if (versionNumber < minBukkitBuildVersion)
final int versionNumber = Integer.parseInt(versionMatch.group(4));
if (versionNumber < BUKKIT_VERSION)
{
logger.log(Level.WARNING, Util.i18n("notRecommendedBukkit"));
LOGGER.log(Level.WARNING, Util.i18n("notRecommendedBukkit"));
}
}
else
{
logger.log(Level.INFO, Util.i18n("bukkitFormatChanged"));
LOGGER.log(Level.INFO, Util.i18n("bukkitFormatChanged"));
}
ServerListener serverListener = new EssentialsPluginListener(paymentMethod);
final ServerListener serverListener = new EssentialsPluginListener(this);
pm.registerEvent(Type.PLUGIN_ENABLE, serverListener, Priority.Low, this);
pm.registerEvent(Type.PLUGIN_DISABLE, serverListener, Priority.Low, this);
playerListener = new EssentialsPlayerListener(this);
final EssentialsPlayerListener playerListener = new EssentialsPlayerListener(this);
pm.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Monitor, this);
pm.registerEvent(Type.PLAYER_QUIT, playerListener, Priority.Monitor, this);
pm.registerEvent(Type.PLAYER_CHAT, playerListener, Priority.Lowest, this);
if (getSettings().getNetherPortalsEnabled())
{
pm.registerEvent(Type.PLAYER_MOVE, playerListener, Priority.High, this);
}
pm.registerEvent(Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Lowest, this);
pm.registerEvent(Type.PLAYER_MOVE, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_LOGIN, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_TELEPORT, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.High, this);
@@ -166,57 +160,74 @@ public class Essentials extends JavaPlugin implements IEssentials
pm.registerEvent(Type.PLAYER_BUCKET_EMPTY, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_ANIMATION, playerListener, Priority.High, this);
blockListener = new EssentialsBlockListener(this);
pm.registerEvent(Type.SIGN_CHANGE, blockListener, Priority.Low, this);
pm.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Lowest, this);
final EssentialsBlockListener blockListener = new EssentialsBlockListener(this);
pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Lowest, this);
entityListener = new EssentialsEntityListener(this);
final SignBlockListener signBlockListener = new SignBlockListener(this);
pm.registerEvent(Type.SIGN_CHANGE, signBlockListener, Priority.Highest, this);
pm.registerEvent(Type.BLOCK_PLACE, signBlockListener, Priority.Low, this);
pm.registerEvent(Type.BLOCK_BREAK, signBlockListener, Priority.Highest, this);
pm.registerEvent(Type.BLOCK_IGNITE, signBlockListener, Priority.Low, this);
pm.registerEvent(Type.BLOCK_BURN, signBlockListener, Priority.Low, this);
pm.registerEvent(Type.BLOCK_PISTON_EXTEND, signBlockListener, Priority.Low, this);
pm.registerEvent(Type.BLOCK_PISTON_RETRACT, signBlockListener, Priority.Low, this);
final SignPlayerListener signPlayerListener = new SignPlayerListener(this);
pm.registerEvent(Type.PLAYER_INTERACT, signPlayerListener, Priority.Low, this);
final SignEntityListener signEntityListener = new SignEntityListener(this);
pm.registerEvent(Type.ENTITY_EXPLODE, signEntityListener, Priority.Low, this);
final EssentialsEntityListener entityListener = new EssentialsEntityListener(this);
pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Lowest, this);
pm.registerEvent(Type.ENTITY_COMBUST, entityListener, Priority.Lowest, this);
pm.registerEvent(Type.ENTITY_DEATH, entityListener, Priority.Lowest, this);
jail = new Jail(this);
jailPlayerListener = new JailPlayerListener(this);
final JailPlayerListener jailPlayerListener = new JailPlayerListener(this);
confList.add(jail);
pm.registerEvent(Type.BLOCK_BREAK, jail, Priority.High, this);
pm.registerEvent(Type.BLOCK_DAMAGE, jail, Priority.High, this);
pm.registerEvent(Type.BLOCK_PLACE, jail, Priority.High, this);
pm.registerEvent(Type.PLAYER_INTERACT, jailPlayerListener, Priority.High, this);
attachEcoListeners();
pm.registerEvent(Type.BLOCK_BREAK, jail, Priority.Low, this);
pm.registerEvent(Type.BLOCK_DAMAGE, jail, Priority.Low, this);
pm.registerEvent(Type.BLOCK_PLACE, jail, Priority.Low, this);
pm.registerEvent(Type.PLAYER_INTERACT, jailPlayerListener, Priority.Low, this);
pm.registerEvent(Type.PLAYER_RESPAWN, jailPlayerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_TELEPORT, jailPlayerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_JOIN, jailPlayerListener, Priority.High, this);
if (settings.isNetherEnabled() && getServer().getWorlds().size() < 2)
{
logger.log(Level.WARNING, "Old nether is disabled until multiworld support in bukkit is fixed.");
getServer().createWorld(settings.getNetherName(), World.Environment.NETHER);
}
timer = new EssentialsTimer(this);
pm.registerEvent(Type.ENTITY_EXPLODE, tntListener, Priority.High, this);
final EssentialsTimer timer = new EssentialsTimer(this);
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 50);
Economy.setEss(this);
if (enableErrorLogging)
{
updateTimer = new EssentialsUpdateTimer(this);
getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 50, 50 * 60 * (this.getDescription().getVersion().startsWith("Dev") ? 60 : 360));
}
logger.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), AUTHORS));
LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors())));
}
public void onDisable()
{
instance = null;
logger.removeHandler(errorHandler);
Trade.closeLog();
LOGGER.removeHandler(errorHandler);
}
public void reload()
{
loadBanList();
Trade.closeLog();
for (IConf iConf : confList)
{
iConf.reloadConfig();
}
Util.updateLocale(settings.getLocale(), this.getDataFolder());
Util.updateLocale(settings.getLocale(), this);
for (User user : users.values())
{
@@ -225,15 +236,6 @@ public class Essentials extends JavaPlugin implements IEssentials
// for motd
getConfiguration().load();
try
{
ItemDb.load(getDataFolder(), "items.csv");
}
catch (Exception ex)
{
logger.log(Level.WARNING, Util.i18n("itemsCsvNotLoaded"), ex);
}
}
public String[] getMotd(CommandSender sender, String def)
@@ -250,7 +252,7 @@ public class Essentials extends JavaPlugin implements IEssentials
}
String[] retval = new String[lines.size()];
if (lines == null || lines.isEmpty() || lines.get(0) == null)
if (lines.isEmpty() || lines.get(0) == null)
{
try
{
@@ -264,7 +266,7 @@ public class Essentials extends JavaPlugin implements IEssentials
}
catch (Throwable ex2)
{
logger.log(Level.WARNING, Util.format("corruptNodeInConfig", node));
LOGGER.log(Level.WARNING, Util.format("corruptNodeInConfig", node));
return new String[0];
}
}
@@ -291,15 +293,28 @@ public class Essentials extends JavaPlugin implements IEssentials
m = m.replace("{IP}", user.getAddress().toString());
m = m.replace("{BALANCE}", Double.toString(user.getMoney()));
m = m.replace("{MAILS}", Integer.toString(user.getMails().size()));
m = m.replace("{WORLD}", user.getLocation().getWorld().getName());
}
m = m.replace("{ONLINE}", Integer.toString(getServer().getOnlinePlayers().length));
int playerHidden = 0;
for (Player p : getServer().getOnlinePlayers())
{
if (getUser(p).isHidden())
{
playerHidden++;
}
}
m = m.replace("{ONLINE}", Integer.toString(getServer().getOnlinePlayers().length - playerHidden));
m = m.replace("{UNIQUE}", Integer.toString(users.size()));
if (m.matches(".*\\{PLAYERLIST\\}.*"))
{
StringBuilder online = new StringBuilder();
for (Player p : getServer().getOnlinePlayers())
{
if (getUser(p).isHidden())
{
continue;
}
if (online.length() > 0)
{
online.append(", ");
@@ -332,39 +347,14 @@ public class Essentials extends JavaPlugin implements IEssentials
return retval;
}
@SuppressWarnings("LoggerStringConcat")
public static void previewCommand(CommandSender sender, Command command, String commandLabel, String[] args)
{
if (sender instanceof Player)
{
logger.info(ChatColor.BLUE + "[PLAYER_COMMAND] " + ((Player)sender).getName() + ": /" + commandLabel + " " + EssentialsCommand.getFinalArg(args, 0));
}
}
@Override
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
{
return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command");
return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.");
}
public boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath)
public boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix)
{
if (("msg".equals(commandLabel.toLowerCase()) || "r".equals(commandLabel.toLowerCase()) || "mail".equals(commandLabel.toLowerCase())) && sender instanceof Player)
{
StringBuilder str = new StringBuilder();
str.append(commandLabel).append(" ");
for (String a : args)
{
str.append(a).append(" ");
}
for (Player player : getServer().getOnlinePlayers())
{
if (getUser(player).isSocialSpyEnabled())
{
player.sendMessage(getUser(sender).getDisplayName() + " : " + str);
}
}
}
// Allow plugins to override the command via onCommand
if (!getSettings().isCommandOverridden(command.getName()) && !commandLabel.startsWith("e"))
{
@@ -386,24 +376,22 @@ public class Essentials extends JavaPlugin implements IEssentials
continue;
}
if (!(desc.getCommands() instanceof Map))
PluginCommand pc = getServer().getPluginCommand(desc.getName() + ":" + commandLabel);
if (pc != null)
{
continue;
return pc.execute(sender, commandLabel, args);
}
Map<String, Object> cmds = (Map<String, Object>)desc.getCommands();
if (!cmds.containsKey(command.getName()))
{
continue;
}
return p.onCommand(sender, command, commandLabel, args);
}
}
try
{
previewCommand(sender, command, commandLabel, args);
User user = sender instanceof Player ? getUser(sender) : null;
User user = null;
if (sender instanceof Player)
{
user = getUser(sender);
LOGGER.log(Level.INFO, String.format("[PLAYER_COMMAND] %s: /%s %s ", ((Player)sender).getName(), commandLabel, EssentialsCommand.getFinalArg(args, 0)));
}
// New mail notification
if (user != null && !getSettings().isCommandDisabled("mail") && !commandLabel.equals("mail") && user.isAuthorized("essentials.mail"))
@@ -430,14 +418,14 @@ public class Essentials extends JavaPlugin implements IEssentials
catch (Exception ex)
{
sender.sendMessage(Util.format("commandNotLoaded", commandLabel));
logger.log(Level.SEVERE, Util.format("commandNotLoaded", commandLabel), ex);
LOGGER.log(Level.SEVERE, Util.format("commandNotLoaded", commandLabel), ex);
return true;
}
// Check authorization
if (user != null && !user.isAuthorized(cmd))
if (user != null && !user.isAuthorized(cmd, permissionPrefix))
{
logger.log(Level.WARNING, Util.format("deniedAccessCommand", user.getName()));
LOGGER.log(Level.WARNING, Util.format("deniedAccessCommand", user.getName()));
user.sendMessage(Util.i18n("noAccessCommand"));
return true;
}
@@ -463,133 +451,34 @@ public class Essentials extends JavaPlugin implements IEssentials
}
catch (Throwable ex)
{
sender.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
LogRecord lr = new LogRecord(Level.WARNING, Util.format("errorCallingCommand", commandLabel));
lr.setThrown(ex);
if (getSettings().isDebug())
{
logger.log(lr);
}
else
{
if (enableErrorLogging)
{
errorHandler.publish(lr);
errorHandler.flush();
}
}
showError(sender, ex, commandLabel);
return true;
}
}
catch (Throwable ex)
{
logger.log(Level.SEVERE, Util.format("commandFailed", commandLabel), ex);
LOGGER.log(Level.SEVERE, Util.format("commandFailed", commandLabel), ex);
return true;
}
}
public void loadBanList()
public void showError(final CommandSender sender, final Throwable exception, final String commandLabel)
{
//I don't like this but it needs to be done until CB fixors
File file = new File("banned-players.txt");
File ipFile = new File("banned-ips.txt");
try
sender.sendMessage(Util.format("errorWithMessage", exception.getMessage()));
final LogRecord logRecord = new LogRecord(Level.WARNING, Util.format("errorCallingCommand", commandLabel));
logRecord.setThrown(exception);
if (getSettings().isDebug())
{
if (!file.exists())
LOGGER.log(logRecord);
}
else
{
if (enableErrorLogging)
{
throw new FileNotFoundException(Util.i18n("bannedPlayersFileNotFound"));
}
final BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
try
{
bans.clear();
while (bufferedReader.ready())
{
final String line = bufferedReader.readLine().trim().toLowerCase();
if (line.length() > 0 && line.charAt(0) == '#')
{
continue;
}
bans.add(line);
}
}
catch (IOException io)
{
logger.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), io);
}
finally
{
try
{
bufferedReader.close();
}
catch (IOException ex)
{
logger.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), ex);
}
errorHandler.publish(logRecord);
errorHandler.flush();
}
}
catch (FileNotFoundException ex)
{
logger.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), ex);
}
try
{
if (!ipFile.exists())
{
throw new FileNotFoundException(Util.i18n("bannedIpsFileNotFound"));
}
final BufferedReader bufferedReader = new BufferedReader(new FileReader(ipFile));
try
{
bannedIps.clear();
while (bufferedReader.ready())
{
final String line = bufferedReader.readLine().trim().toLowerCase();
if (line.length() > 0 && line.charAt(0) == '#')
{
continue;
}
bannedIps.add(line);
}
}
catch (IOException io)
{
logger.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), io);
}
finally
{
try
{
bufferedReader.close();
}
catch (IOException ex)
{
logger.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), ex);
}
}
}
catch (FileNotFoundException ex)
{
logger.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), ex);
}
}
private void attachEcoListeners()
{
PluginManager pm = getServer().getPluginManager();
EssentialsEcoBlockListener ecoBlockListener = new EssentialsEcoBlockListener(this);
EssentialsEcoPlayerListener ecoPlayerListener = new EssentialsEcoPlayerListener(this);
pm.registerEvent(Type.PLAYER_INTERACT, ecoPlayerListener, Priority.High, this);
pm.registerEvent(Type.BLOCK_BREAK, ecoBlockListener, Priority.High, this);
pm.registerEvent(Type.SIGN_CHANGE, ecoBlockListener, Priority.Monitor, this);
}
public CraftScheduler getScheduler()
@@ -653,47 +542,43 @@ public class Essentials extends JavaPlugin implements IEssentials
return u;
}
public Map<String, User> getAllUsers()
{
return users;
}
public User getOfflineUser(String name)
{
// Don't create a new offline user, if we already have that user loaded.
User u = users.get(name.toLowerCase());
if (u != null)
{
return u;
}
File userFolder = new File(getDataFolder(), "userdata");
File userFile = new File(userFolder, Util.sanitizeFileName(name) + ".yml");
if (userFile.exists())
{ //Users do not get offline changes saved without being reproccessed as Users! ~ Xeology :)
return getUser((Player)new OfflinePlayer(name));
return getUser((Player)new OfflinePlayer(name, this));
}
return null;
}
public World getWorld(String name)
public World getWorld(final String name)
{
if (name.matches("[0-9]+"))
{
int id = Integer.parseInt(name);
final int id = Integer.parseInt(name);
if (id < getServer().getWorlds().size())
{
return getServer().getWorlds().get(id);
}
}
World w = getServer().getWorld(name);
if (w != null)
{
return w;
}
return null;
return getServer().getWorld(name);
}
public void setRegisterFallback(boolean registerFallback)
{
this.registerFallback = registerFallback;
}
public boolean isRegisterFallbackEnabled()
{
return registerFallback;
}
public void addReloadListener(IConf listener)
public void addReloadListener(final IConf listener)
{
confList.add(listener);
}
@@ -703,7 +588,7 @@ public class Essentials extends JavaPlugin implements IEssentials
return paymentMethod;
}
public int broadcastMessage(String name, String message)
public int broadcastMessage(final String name, final String message)
{
Player[] players = getServer().getOnlinePlayers();
@@ -734,18 +619,38 @@ public class Essentials extends JavaPlugin implements IEssentials
return this.getScheduler().scheduleSyncDelayedTask(this, run);
}
public int scheduleSyncRepeatingTask(final Runnable run, long delay, long period)
public int scheduleSyncDelayedTask(final Runnable run, final long delay)
{
return this.getScheduler().scheduleSyncDelayedTask(this, run, delay);
}
public int scheduleSyncRepeatingTask(final Runnable run, final long delay, final long period)
{
return this.getScheduler().scheduleSyncRepeatingTask(this, run, delay, period);
}
public List<String> getBans()
public TNTExplodeListener getTNTListener()
{
return tntListener;
}
public IPermissionsHandler getPermissionsHandler()
{
return permissionsHandler;
}
public void setPermissionsHandler(IPermissionsHandler handler)
{
this.permissionsHandler = handler;
}
public BanWorkaround getBans()
{
return bans;
}
public List<String> getBannedIps()
public ItemDb getItemDb()
{
return bannedIps;
return itemDb;
}
}

View File

@@ -1,15 +1,9 @@
package com.earth2me.essentials;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.craftbukkit.block.CraftSign;
import org.bukkit.event.block.*;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
@@ -17,372 +11,99 @@ public class EssentialsBlockListener extends BlockListener
{
private final IEssentials ess;
private static final Logger logger = Logger.getLogger("Minecraft");
public final static List<Material> protectedBlocks = new ArrayList<Material>(4);
static
{
protectedBlocks.add(Material.CHEST);
protectedBlocks.add(Material.BURNING_FURNACE);
protectedBlocks.add(Material.FURNACE);
protectedBlocks.add(Material.DISPENSER);
}
public EssentialsBlockListener(IEssentials ess)
{
this.ess = ess;
}
@Override
public void onBlockBreak(BlockBreakEvent event)
{
if (event.isCancelled()) return;
if (ess.getSettings().areSignsDisabled()) return;
User user = ess.getUser(event.getPlayer());
if (protectedBlocks.contains(event.getBlock().getType()) && !user.isAuthorized("essentials.signs.protection.override"))
{
if (isBlockProtected(event.getBlock(), user))
{
event.setCancelled(true);
user.sendMessage(Util.format("noDestroyPermission", event.getBlock().getType().toString().toLowerCase()));
return;
}
}
if (checkProtectionSign(event.getBlock(), user) != NOSIGN &&
checkProtectionSign(event.getBlock(), user) != OWNER)
{
event.setCancelled(true);
user.sendMessage(Util.format("noDestroyPermission", event.getBlock().getType().toString().toLowerCase()));
}
}
@Override
public void onSignChange(SignChangeEvent event)
{
if (event.isCancelled()) return;
if (ess.getSettings().areSignsDisabled()) return;
User user = ess.getUser(event.getPlayer());
String username = user.getName().substring(0, user.getName().length() > 14 ? 14 : user.getName().length());
try
{
if (event.getLine(0).equalsIgnoreCase("[Protection]"))
{
Block block = event.getBlock();
if (user.isAuthorized("essentials.signs.protection.create") && hasAdjacentChest(block) && !isBlockProtected(block, user))
event.setLine(0, "§1[Protection]");
else
event.setLine(0, "§4[Protection]");
event.setLine(3, username);
return;
}
if (event.getLine(0).equalsIgnoreCase("[Disposal]"))
{
if (user.isAuthorized("essentials.signs.disposal.create"))
event.setLine(0, "§1[Disposal]");
else
event.setLine(0, "§4[Disposal]");
return;
}
if (event.getLine(0).equalsIgnoreCase("[Heal]"))
{
event.setLine(0, "§4[Heal]");
if (user.isAuthorized("essentials.signs.heal.create"))
{
if (!event.getLine(1).isEmpty())
{
String[] l1 = event.getLine(1).split("[ :-]+", 2);
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
if (q1 < 1 || (!m1 && (int)q1 < 1)) throw new Exception(Util.i18n("moreThanZero"));
if (!m1) ItemDb.get(l1[1]);
event.setLine(1, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]));
}
event.setLine(0, "§1[Heal]");
}
return;
}
if (event.getLine(0).equalsIgnoreCase("[Free]"))
{
event.setLine(0, "§4[Free]");
ItemDb.get(event.getLine(1));
if (user.isAuthorized("essentials.signs.free.create"))
event.setLine(0, "§1[Free]");
return;
}
if (event.getLine(0).equalsIgnoreCase("[Mail]"))
{
if (user.isAuthorized("essentials.signs.mail.create"))
event.setLine(0, "§1[Mail]");
else
event.setLine(0, "§4[Mail]");
return;
}
if (event.getLine(0).equalsIgnoreCase("[Balance]"))
{
if (user.isAuthorized("essentials.signs.balance.create"))
event.setLine(0, "§1[Balance]");
else
event.setLine(0, "§4[Balance]");
return;
}
if (event.getLine(0).equalsIgnoreCase("[Warp]"))
{
event.setLine(0, "§4[Warp]");
if (user.isAuthorized("essentials.signs.warp.create")) {
if (!event.getLine(3).isEmpty())
{
String[] l1 = event.getLine(3).split("[ :-]+", 2);
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
if (!m1 && l1.length != 2)
{
throw new Exception(Util.format("invalidSignLine", 4));
}
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
if ((int)q1 < 1) throw new Exception(Util.i18n("moreThanZero"));
if (!m1) ItemDb.get(l1[1]);
event.setLine(3, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]));
}
if (event.getLine(1).isEmpty()) {
event.setLine(1, "§dWarp name!");
return;
} else {
ess.getWarps().getWarp(event.getLine(1));
if (event.getLine(2).equalsIgnoreCase("Everyone")) {
event.setLine(2, "§2Everyone");
}
event.setLine(0, "§1[Warp]");
}
}
return;
}
}
catch (Throwable ex)
{
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
if (ess.getSettings().isDebug())
{
logger.log(Level.WARNING, ex.getMessage(), ex);
}
}
}
@Override
public void onBlockPlace(BlockPlaceEvent event)
{
if (event.isCancelled()) return;
Block signBlock = event.getBlockAgainst();
if (signBlock.getType() == Material.WALL_SIGN || signBlock.getType() == Material.SIGN_POST)
if (event.isCancelled())
{
Sign sign = new CraftSign(signBlock);
if (sign.getLine(0).matches("§1\\[[a-zA-Z]+\\]"))
{
event.setCancelled(true);
return;
}
return;
}
final User user = ess.getUser(event.getPlayer());
// Do not rely on getItemInHand();
// http://leaky.bukkit.org/issues/663
final ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short)0, event.getBlockPlaced().getData());
switch(is.getType()) {
case WOODEN_DOOR:
is.setType(Material.WOOD_DOOR);
is.setDurability((short)0);
break;
case IRON_DOOR_BLOCK:
is.setType(Material.IRON_DOOR);
is.setDurability((short)0);
break;
case SIGN_POST:
case WALL_SIGN:
is.setType(Material.SIGN);
is.setDurability((short)0);
break;
case CROPS:
is.setType(Material.SEEDS);
is.setDurability((short)0);
break;
case CAKE_BLOCK:
is.setType(Material.CAKE);
is.setDurability((short)0);
break;
case BED_BLOCK:
is.setType(Material.BED);
is.setDurability((short)0);
break;
case REDSTONE_WIRE:
is.setType(Material.REDSTONE);
is.setDurability((short)0);
break;
case REDSTONE_TORCH_OFF:
case REDSTONE_TORCH_ON:
is.setType(Material.REDSTONE_TORCH_ON);
is.setDurability((short)0);
break;
case DIODE_BLOCK_OFF:
case DIODE_BLOCK_ON:
is.setType(Material.DIODE);
is.setDurability((short)0);
break;
case DOUBLE_STEP:
is.setType(Material.STEP);
break;
case TORCH:
case RAILS:
case LADDER:
case WOOD_STAIRS:
case COBBLESTONE_STAIRS:
case LEVER:
case STONE_BUTTON:
case FURNACE:
case DISPENSER:
case PUMPKIN:
case JACK_O_LANTERN:
case WOOD_PLATE:
case STONE_PLATE:
is.setDurability((short)0);
break;
switch (is.getType())
{
case WOODEN_DOOR:
is.setType(Material.WOOD_DOOR);
is.setDurability((short)0);
break;
case IRON_DOOR_BLOCK:
is.setType(Material.IRON_DOOR);
is.setDurability((short)0);
break;
case SIGN_POST:
case WALL_SIGN:
is.setType(Material.SIGN);
is.setDurability((short)0);
break;
case CROPS:
is.setType(Material.SEEDS);
is.setDurability((short)0);
break;
case CAKE_BLOCK:
is.setType(Material.CAKE);
is.setDurability((short)0);
break;
case BED_BLOCK:
is.setType(Material.BED);
is.setDurability((short)0);
break;
case REDSTONE_WIRE:
is.setType(Material.REDSTONE);
is.setDurability((short)0);
break;
case REDSTONE_TORCH_OFF:
case REDSTONE_TORCH_ON:
is.setType(Material.REDSTONE_TORCH_ON);
is.setDurability((short)0);
break;
case DIODE_BLOCK_OFF:
case DIODE_BLOCK_ON:
is.setType(Material.DIODE);
is.setDurability((short)0);
break;
case DOUBLE_STEP:
is.setType(Material.STEP);
break;
case TORCH:
case RAILS:
case LADDER:
case WOOD_STAIRS:
case COBBLESTONE_STAIRS:
case LEVER:
case STONE_BUTTON:
case FURNACE:
case DISPENSER:
case PUMPKIN:
case JACK_O_LANTERN:
case WOOD_PLATE:
case STONE_PLATE:
case PISTON_STICKY_BASE:
case PISTON_BASE:
is.setDurability((short)0);
break;
case FIRE:
return;
}
boolean unlimitedForUser = user.hasUnlimited(is);
if (unlimitedForUser) {
if (unlimitedForUser)
{
ess.scheduleSyncDelayedTask(
new Runnable() {
public void run() {
user.getInventory().addItem(is);
user.updateInventory();
}
});
}
}
public boolean hasAdjacentChest(Block block)
{
Block[] faces = getAdjacentBlocks(block);
for (Block b : faces)
{
if (protectedBlocks.contains(b.getType()))
{
return true;
}
}
return false;
}
private static final int NOT_ALLOWED = 0;
private static final int ALLOWED = 1;
private static final int NOSIGN = 2;
private static final int OWNER = 3;
private int checkProtectionSign(Block block, User user)
{
String username = user.getName().substring(0, user.getName().length() > 14 ? 14 : user.getName().length());
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
{
Sign sign = new CraftSign(block);
if (sign.getLine(0).equalsIgnoreCase("§1[Protection]") && !user.isAuthorized("essentials.signs.protection.override"))
{
for (int i = 1; i <= 2; i++) {
String line = sign.getLine(i);
if (line.startsWith("(") && line.endsWith(")")) {
line = line.substring(1, line.length() - 1);
if (user.inGroup(line)) {
return ALLOWED;
}
} else if (line.equalsIgnoreCase(username)) {
return ALLOWED;
}
}
if (sign.getLine(3).equalsIgnoreCase(username))
{
return OWNER;
}
return NOT_ALLOWED;
}
}
return NOSIGN;
}
private static Block[] getAdjacentBlocks(Block block)
{
return new Block[]
{
block.getFace(BlockFace.NORTH),
block.getFace(BlockFace.SOUTH),
block.getFace(BlockFace.EAST),
block.getFace(BlockFace.WEST),
block.getFace(BlockFace.DOWN),
block.getFace(BlockFace.UP)
};
}
public boolean isBlockProtected(Block block, User user)
{
Block[] faces = getAdjacentBlocks(block);
boolean protect = false;
for (Block b : faces)
{
int check = checkProtectionSign(b, user);
if (check == NOT_ALLOWED)
{
protect = true;
}
if (check == ALLOWED || check == OWNER)
{
return false;
}
if (protectedBlocks.contains(b.getType()))
{
Block[] faceChest = getAdjacentBlocks(b);
for (Block a : faceChest)
{
check = checkProtectionSign(a, user);
if (check == NOT_ALLOWED)
new Runnable()
{
protect = true;
}
if (check == ALLOWED || check == OWNER)
{
return false;
}
}
}
}
return protect;
}
public static boolean isBlockProtected(Block block)
{
Block[] faces = getAdjacentBlocks(block);
for (Block b : faces)
{
if (b.getType() == Material.SIGN_POST || b.getType() == Material.WALL_SIGN)
{
Sign sign = new CraftSign(b);
if (sign.getLine(0).equalsIgnoreCase("§1[Protection]"))
{
return true;
}
}
if (protectedBlocks.contains(b.getType()))
{
Block[] faceChest = getAdjacentBlocks(b);
for (Block a : faceChest)
{
if (a.getType() == Material.SIGN_POST || a.getType() == Material.WALL_SIGN)
{
Sign sign = new CraftSign(a);
if (sign.getLine(0).equalsIgnoreCase("§1[Protection]"))
public void run()
{
return true;
user.getInventory().addItem(is);
user.updateInventory();
}
}
}
}
});
}
return false;
}
}

View File

@@ -1,250 +0,0 @@
package com.earth2me.essentials;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.craftbukkit.block.CraftSign;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.inventory.ItemStack;
public class EssentialsEcoBlockListener extends BlockListener
{
private final IEssentials ess;
private static final Logger logger = Logger.getLogger("Minecraft");
public EssentialsEcoBlockListener(Essentials ess)
{
this.ess = ess;
}
@Override
public void onBlockBreak(BlockBreakEvent event)
{
if (event.isCancelled())
{
return;
}
if (ess.getSettings().areSignsDisabled())
{
return;
}
User user = ess.getUser(event.getPlayer());
String username = user.getName().substring(0, user.getName().length() > 13 ? 13 : user.getName().length());
if (event.getBlock().getType() != Material.WALL_SIGN && event.getBlock().getType() != Material.SIGN_POST)
{
return;
}
Sign sign = new CraftSign(event.getBlock());
if (sign.getLine(0).equals("§1[Trade]"))
{
if (!sign.getLine(3).substring(2).equals(username))
{
if (!user.isOp())
{
event.setCancelled(true);
}
return;
}
try
{
String[] l1 = sign.getLines()[1].split("[ :-]+");
String[] l2 = sign.getLines()[2].split("[ :-]+");
boolean m1 = l1[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
boolean m2 = l2[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
double r1 = Double.parseDouble(l1[m1 ? 1 : 2]);
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
if ((!m1 & q1 < 1) || (!m2 & q2 < 1))
{
throw new Exception(Util.i18n("moreThanZero"));
}
ItemStack i1 = m1 || r1 <= 0 ? null : ItemDb.get(l1[1], (int)r1);
ItemStack i2 = m2 || r2 <= 0 ? null : ItemDb.get(l2[1], (int)r2);
if (m1)
{
user.giveMoney(r1);
}
else if (i1 != null)
{
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(i1);
for (ItemStack itemStack : leftOver.values())
{
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
}
}
if (m2)
{
user.giveMoney(r2);
}
else if (i2 != null)
{
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(i2);
for (ItemStack itemStack : leftOver.values())
{
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
}
}
user.updateInventory();
sign.setType(Material.AIR);
}
catch (Throwable ex)
{
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
if (ess.getSettings().isDebug())
{
logger.log(Level.WARNING, ex.getMessage(), ex);
}
}
return;
}
}
@Override
public void onSignChange(SignChangeEvent event)
{
if (ess.getSettings().areSignsDisabled())
{
return;
}
User user = ess.getUser(event.getPlayer());
String username = user.getName().substring(0, user.getName().length() > 13 ? 13 : user.getName().length());
if ((event.getLine(0).equalsIgnoreCase("[Buy]") || event.getLine(0).equalsIgnoreCase("#1[Buy]")) && user.isAuthorized("essentials.signs.buy.create"))
{
try
{
event.setLine(0, "§1[Buy]");
event.setLine(1, "" + Math.abs(Integer.parseInt(event.getLine(1))));
ItemStack is = ItemDb.get(event.getLine(2));
if (is.getTypeId() == 0 || Math.abs(Integer.parseInt(event.getLine(1))) == 0)
{
throw new Exception("Don't sell air.");
}
double price = Double.parseDouble(event.getLine(3).replaceAll("[^0-9\\.]", ""));
event.setLine(3, Util.formatCurrency(price));
}
catch (Throwable ex)
{
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
if (ess.getSettings().isDebug())
{
logger.log(Level.WARNING, ex.getMessage(), ex);
}
event.setLine(0, "§4[Buy]");
event.setLine(1, "#");
event.setLine(2, "Item");
event.setLine(3, "$Price");
}
return;
}
if ((event.getLine(0).equalsIgnoreCase("[Sell]") || event.getLine(0).equalsIgnoreCase("#1[Sell]")) && user.isAuthorized("essentials.signs.sell.create"))
{
try
{
event.setLine(0, "§1[Sell]");
event.setLine(1, "" + Math.abs(Integer.parseInt(event.getLine(1))));
ItemStack is = ItemDb.get(event.getLine(2));
if (is.getTypeId() == 0 || Math.abs(Integer.parseInt(event.getLine(1))) == 0)
{
throw new Exception("Can't buy air.");
}
double price = Double.parseDouble(event.getLine(3).replaceAll("[^0-9\\.]", ""));
event.setLine(3, Util.formatCurrency(price));
}
catch (Throwable ex)
{
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
if (ess.getSettings().isDebug())
{
logger.log(Level.WARNING, ex.getMessage(), ex);
}
event.setLine(0, "§4[Sell]");
event.setLine(1, "#");
event.setLine(2, "Item");
event.setLine(3, "$Price");
}
return;
}
if ((event.getLine(0).equalsIgnoreCase("[Trade]") || event.getLine(0).equalsIgnoreCase("#1[Trade]")) && user.isAuthorized("essentials.signs.trade.create"))
{
try
{
String[] l1 = event.getLine(1).split("[ :-]+");
String[] l2 = event.getLine(2).split("[ :-]+");
boolean m1 = l1[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
boolean m2 = l2[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
if (m1 ? l1.length != 1 : l1.length != 2)
{
throw new Exception(Util.format("invalidSignLine", 2));
}
if (m2 ? l2.length != 2 : l2.length != 3)
{
throw new Exception(Util.format("invalidSignLine", 3));
}
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
r2 = m2 ? r2 : r2 - r2 % q2;
if ((!m1 & q1 < 1) || (!m2 & q2 < 1) || r2 < 1)
{
throw new Exception(Util.i18n("moreThanZero"));
}
if (!m1)
{
ItemDb.get(l1[1]);
}
if (m2)
{
if (user.getMoney() < r2)
{
throw new Exception(Util.i18n("notEnoughMoney"));
}
user.takeMoney(r2);
//user.sendMessage("r2: " + r2 + " q2: " + q2);
}
else
{
ItemStack i2 = ItemDb.get(l2[1], (int)r2);
if (!InventoryWorkaround.containsItem(user.getInventory(), true, i2))
{
throw new Exception(Util.format("missingItems", (int)r2, l2[1]));
}
InventoryWorkaround.removeItem(user.getInventory(), true, i2);
user.updateInventory();
}
event.setLine(0, "§1[Trade]");
event.setLine(1, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]) + ":0");
event.setLine(2, (m2 ? Util.formatCurrency(q2) : (int)q2 + " " + l2[1]) + ":" + (m2 ? Util.roundDouble(r2) : "" + (int)r2));
event.setLine(3, "§8" + username);
}
catch (Throwable ex)
{
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
if (ess.getSettings().isDebug())
{
logger.log(Level.WARNING, ex.getMessage(), ex);
}
event.setLine(0, "§4[Trade]");
event.setLine(1, "# ItemOr" + ess.getSettings().getCurrencySymbol());
event.setLine(2, "# ItemOr" + ess.getSettings().getCurrencySymbol() + ":#");
event.setLine(3, "§8" + username);
}
return;
}
}
}

View File

@@ -1,211 +0,0 @@
package com.earth2me.essentials;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Material;
import org.bukkit.block.Sign;
import org.bukkit.craftbukkit.block.CraftSign;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.inventory.ItemStack;
public class EssentialsEcoPlayerListener extends PlayerListener
{
private final IEssentials ess;
private static final Logger logger = Logger.getLogger("Minecraft");
EssentialsEcoPlayerListener(IEssentials ess)
{
this.ess = ess;
}
@Override
public void onPlayerInteract(PlayerInteractEvent event)
{
if (ess.getSettings().areSignsDisabled())
{
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
return;
}
User user = ess.getUser(event.getPlayer());
String username = user.getName().substring(0, user.getName().length() > 13 ? 13 : user.getName().length());
if (event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST)
{
return;
}
Sign sign = new CraftSign(event.getClickedBlock());
if (sign.getLine(0).equals("§1[Buy]") && user.isAuthorized("essentials.signs.buy.use"))
{
try
{
int amount = Integer.parseInt(sign.getLine(1));
ItemStack item = ItemDb.get(sign.getLine(2), amount);
double cost = Double.parseDouble(sign.getLine(3).substring(1));
if (user.getMoney() < cost)
{
throw new Exception(Util.i18n("notEnoughMoney"));
}
user.takeMoney(cost);
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(item);
for (ItemStack itemStack : leftOver.values())
{
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
}
user.updateInventory();
}
catch (Throwable ex)
{
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
if (ess.getSettings().isDebug())
{
logger.log(Level.WARNING, ex.getMessage(), ex);
}
}
return;
}
if (sign.getLine(0).equals("§1[Sell]") && user.isAuthorized("essentials.signs.sell.use"))
{
try
{
int amount = Integer.parseInt(sign.getLine(1));
ItemStack item = ItemDb.get(sign.getLine(2), amount);
double cost = Double.parseDouble(sign.getLine(3).substring(1));
if (!InventoryWorkaround.containsItem(user.getInventory(), true, item))
{
throw new Exception(Util.format("missingItems", amount, sign.getLine(2)));
}
user.giveMoney(cost);
InventoryWorkaround.removeItem(user.getInventory(), true, item);
user.updateInventory();
}
catch (Throwable ex)
{
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
if (ess.getSettings().isDebug())
{
logger.log(Level.WARNING, ex.getMessage(), ex);
}
}
return;
}
if (sign.getLine(0).equals("§1[Trade]") && user.isAuthorized("essentials.signs.trade.use"))
{
try
{
String[] l1 = sign.getLine(1).split("[ :-]+");
String[] l2 = sign.getLine(2).split("[ :-]+");
boolean m1 = l1[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
boolean m2 = l2[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
double r1 = Double.parseDouble(l1[m1 ? 1 : 2]);
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
r1 = m1 ? r1 : r1 - r1 % q1;
r2 = m2 ? r2 : r2 - r2 % q2;
if ((!m1 & q1 < 1) || (!m2 & q2 < 1))
{
throw new Exception(Util.i18n("moreThanZero"));
}
ItemStack i1 = m1 || r1 <= 0 ? null : ItemDb.get(l1[1], (int)r1);
ItemStack qi1 = m1 ? null : ItemDb.get(l1[1], (int)q1);
ItemStack qi2 = m2 ? null : ItemDb.get(l2[1], (int)q2);
if (username.equals(sign.getLine(3).substring(2)))
{
if (m1)
{
user.giveMoney(r1);
}
else if (i1 != null)
{
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(i1);
for (ItemStack itemStack : leftOver.values())
{
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
}
user.updateInventory();
}
r1 = 0;
sign.setLine(1, (m1 ? Util.formatCurrency(q1) : ((int)q1) + " " + l1[1]) + ":0");
sign.update();
}
else
{
if (m1)
{
if (user.getMoney() < q1)
{
throw new Exception(Util.i18n("notEnoughMoney"));
}
}
else
{
if (!InventoryWorkaround.containsItem(user.getInventory(), true, qi1))
{
throw new Exception(Util.format("missingItems", (int)q1, l1[1]));
}
}
if (r2 < q2)
{
throw new Exception(Util.i18n("tradeSignEmpty"));
}
if (m1)
{
user.takeMoney(q1);
}
else
{
InventoryWorkaround.removeItem(user.getInventory(), true, qi1);
}
if (m2)
{
user.giveMoney(q2);
}
else
{
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(qi2);
for (ItemStack itemStack : leftOver.values())
{
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
}
}
user.updateInventory();
r1 += q1;
r2 -= q2;
sign.setLine(0, "§1[Trade]");
sign.setLine(1, (m1 ? Util.formatCurrency(q1) : ((int)q1) + " " + l1[1]) + ":" + (m1 ? Util.roundDouble(r1) : "" + (int)r1));
sign.setLine(2, (m2 ? Util.formatCurrency(q2) : ((int)q2) + " " + l2[1]) + ":" + (m2 ? Util.roundDouble(r2) : "" + (int)r2));
sign.update();
user.sendMessage(Util.i18n("tradeCompleted"));
}
}
catch (Throwable ex)
{
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
if (ess.getSettings().isDebug())
{
logger.log(Level.WARNING, ex.getMessage(), ex);
}
}
return;
}
}
}

View File

@@ -1,24 +1,24 @@
package com.earth2me.essentials;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.server.InventoryPlayer;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.craftbukkit.block.CraftSign;
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
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.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerEggThrowEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
@@ -34,57 +34,60 @@ import org.bukkit.inventory.ItemStack;
public class EssentialsPlayerListener extends PlayerListener
{
private static final Logger logger = Logger.getLogger("Minecraft");
private final Server server;
private final IEssentials ess;
private final EssentialsBlockListener essBlockListener;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private final transient Server server;
private final transient IEssentials ess;
public EssentialsPlayerListener(IEssentials parent)
public EssentialsPlayerListener(final IEssentials parent)
{
this.ess = parent;
this.server = parent.getServer();
essBlockListener = new EssentialsBlockListener(parent);
}
@Override
public void onPlayerRespawn(PlayerRespawnEvent event)
public void onPlayerRespawn(final PlayerRespawnEvent event)
{
User user = ess.getUser(event.getPlayer());
final User user = ess.getUser(event.getPlayer());
user.setDisplayName(user.getNick());
updateCompass(user);
if (user.isJailed() && user.getJail() != null && !user.getJail().isEmpty()) {
try
{
event.setRespawnLocation(ess.getJail().getJail(user.getJail()));
}
catch (Exception ex)
{
}
if (ess.getSettings().changeDisplayName())
{
user.setDisplayName(user.getNick());
}
}
@Override
public void onPlayerChat(PlayerChatEvent event)
public void onPlayerChat(final PlayerChatEvent event)
{
User user = ess.getUser(event.getPlayer());
final User user = ess.getUser(event.getPlayer());
if (user.isMuted())
{
event.setCancelled(true);
logger.info(Util.format("mutedUserSpeaks", user.getName()));
user.sendMessage(Util.i18n("playerMuted"));
LOGGER.info(Util.format("mutedUserSpeaks", user.getName()));
}
Iterator<Player> it = event.getRecipients().iterator();
final Iterator<Player> it = event.getRecipients().iterator();
while (it.hasNext())
{
User u = ess.getUser(it.next());
final User u = ess.getUser(it.next());
if (u.isIgnoredPlayer(user.getName()))
{
it.remove();
}
}
if (user.isAfk())
{
user.setAfk(false);
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
}
if (ess.getSettings().changeDisplayName())
{
user.setDisplayName(user.getNick());
}
}
@Override
public void onPlayerMove(PlayerMoveEvent event)
public void onPlayerMove(final PlayerMoveEvent event)
{
if (event.isCancelled())
{
@@ -92,13 +95,19 @@ public class EssentialsPlayerListener extends PlayerListener
}
final User user = ess.getUser(event.getPlayer());
if (user.isAfk())
{
user.setAfk(false);
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
}
if (!ess.getSettings().getNetherPortalsEnabled())
{
return;
}
final Block block = event.getPlayer().getWorld().getBlockAt(event.getTo().getBlockX(), event.getTo().getBlockY(), event.getTo().getBlockZ());
List<World> worlds = server.getWorlds();
final List<World> worlds = server.getWorlds();
if (block.getType() == Material.PORTAL && worlds.size() > 1 && user.isAuthorized("essentials.portal"))
{
@@ -107,17 +116,19 @@ public class EssentialsPlayerListener extends PlayerListener
return;
}
Location loc = event.getTo();
World nether = server.getWorld(ess.getSettings().getNetherName());
if (nether == null) {
if (nether == null)
{
for (World world : worlds)
{
if (world.getEnvironment() == World.Environment.NETHER) {
if (world.getEnvironment() == World.Environment.NETHER)
{
nether = world;
break;
}
}
if (nether == null) {
if (nether == null)
{
return;
}
}
@@ -128,7 +139,7 @@ public class EssentialsPlayerListener extends PlayerListener
{
factor = ess.getSettings().getNetherRatio();
}
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();
}
@@ -137,6 +148,7 @@ public class EssentialsPlayerListener extends PlayerListener
factor = 1.0;
}
Location loc = event.getTo();
int x = loc.getBlockX();
int y = loc.getBlockY();
int z = loc.getBlockZ();
@@ -161,14 +173,14 @@ public class EssentialsPlayerListener extends PlayerListener
if (world.getEnvironment() == World.Environment.NETHER || ess.getSettings().getGenerateExitPortals())
{
portal = NetherPortal.createPortal(dest);
logger.info(Util.format("userCreatedPortal", event.getPlayer().getName()));
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()));
LOGGER.info(Util.format("userUsedPortal", event.getPlayer().getName()));
user.sendMessage(Util.i18n("usingPortal"));
loc = portal.getSpawn();
}
@@ -177,7 +189,7 @@ public class EssentialsPlayerListener extends PlayerListener
event.setTo(loc);
try
{
user.getTeleport().now(loc, new Charge("portal", ess));
user.getTeleport().now(loc, new Trade("portal", ess));
}
catch (Exception ex)
{
@@ -194,21 +206,24 @@ public class EssentialsPlayerListener extends PlayerListener
}
@Override
public void onPlayerQuit(PlayerQuitEvent event)
public void onPlayerQuit(final PlayerQuitEvent event)
{
User user = ess.getUser(event.getPlayer());
final User user = ess.getUser(event.getPlayer());
if (ess.getSettings().removeGodOnDisconnect() && user.isGodModeEnabled())
{
user.toggleGodModeEnabled();
}
if (user.getSavedInventory() != null)
{
user.getInventory().setContents(user.getSavedInventory());
user.setSavedInventory(null);
}
user.dispose();
if (!ess.getSettings().getReclaimSetting())
{
return;
}
user.dispose();
Thread thread = new Thread(new Runnable()
final Thread thread = new Thread(new Runnable()
{
public void run()
{
@@ -221,7 +236,7 @@ public class EssentialsPlayerListener extends PlayerListener
rt.gc();
mem = rt.freeMemory() - mem;
mem /= 1024 * 1024;
logger.log(Level.INFO, Util.format("freedMemory", mem));
LOGGER.log(Level.INFO, Util.format("freedMemory", mem));
}
catch (InterruptedException ex)
{
@@ -234,20 +249,28 @@ public class EssentialsPlayerListener extends PlayerListener
}
@Override
public void onPlayerJoin(PlayerJoinEvent event)
public void onPlayerJoin(final PlayerJoinEvent event)
{
ess.getBackup().onPlayerJoin();
User user = ess.getUser(event.getPlayer());
final User user = ess.getUser(event.getPlayer());
//we do not know the ip address on playerlogin so we need to do this here.
if (user.isIpBanned())
{
String banReason = user.getBanReason();
final String banReason = user.getBanReason();
user.kickPlayer(banReason != null && !banReason.isEmpty() ? banReason : Util.i18n("defaultBanReason"));
return;
}
user.setDisplayName(user.getNick());
if (ess.getSettings().changeDisplayName())
{
user.setDisplayName(user.getNick());
}
user.setAfk(false);
if (user.isAuthorized("essentials.sleepingignored"))
{
user.setSleepingIgnored(true);
}
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
{
@@ -263,7 +286,7 @@ public class EssentialsPlayerListener extends PlayerListener
if (!ess.getSettings().isCommandDisabled("mail") && user.isAuthorized("essentials.mail"))
{
List<String> mail = user.getMails();
final List<String> mail = user.getMails();
if (mail.isEmpty())
{
user.sendMessage(Util.i18n("noNewMail"));
@@ -276,18 +299,18 @@ public class EssentialsPlayerListener extends PlayerListener
}
@Override
public void onPlayerLogin(PlayerLoginEvent event)
public void onPlayerLogin(final PlayerLoginEvent event)
{
if (event.getResult() != Result.ALLOWED)
{
return;
}
User user = ess.getUser(event.getPlayer());
final User user = ess.getUser(event.getPlayer());
user.setNPC(false);
if (user.isBanned())
{
String banReason = user.getBanReason();
final String banReason = user.getBanReason();
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() ? banReason : Util.i18n("defaultBanReason"));
return;
}
@@ -302,7 +325,7 @@ public class EssentialsPlayerListener extends PlayerListener
updateCompass(user);
}
private void updateCompass(User user)
private void updateCompass(final User user)
{
try
{
@@ -320,24 +343,16 @@ public class EssentialsPlayerListener extends PlayerListener
{
return;
}
User user = ess.getUser(event.getPlayer());
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
final User user = ess.getUser(event.getPlayer());
if (ess.getSettings().changeDisplayName())
{
return;
user.setDisplayName(user.getNick());
}
try
{
event.setTo(ess.getJail().getJail(user.getJail()));
}
catch (Exception ex)
{
logger.log(Level.WARNING, Util.i18n("returnPlayerToJailError"), ex);
}
user.sendMessage(Util.i18n("jailMessage"));
updateCompass(user);
}
@Override
public void onPlayerInteract(PlayerInteractEvent event)
public void onPlayerInteract(final PlayerInteractEvent event)
{
if (event.isCancelled())
{
@@ -347,29 +362,12 @@ public class EssentialsPlayerListener extends PlayerListener
{
return;
}
User user = ess.getUser(event.getPlayer());
if (user.isJailed())
{
event.setCancelled(true);
return;
}
if (!ess.getSettings().areSignsDisabled() && EssentialsBlockListener.protectedBlocks.contains(event.getClickedBlock().getType()))
{
if (!user.isAuthorized("essentials.signs.protection.override"))
{
if (essBlockListener.isBlockProtected(event.getClickedBlock(), user))
{
event.setCancelled(true);
user.sendMessage(Util.format("noAccessPermission", event.getClickedBlock().getType().toString().toLowerCase()));
return;
}
}
}
if (ess.getSettings().getBedSetsHome() && event.getClickedBlock().getType() == Material.BED_BLOCK)
{
try
{
final User user = ess.getUser(event.getPlayer());
user.setHome();
user.sendMessage(Util.i18n("homeSetToBed"));
}
@@ -377,158 +375,13 @@ public class EssentialsPlayerListener extends PlayerListener
{
}
}
if (ess.getSettings().areSignsDisabled())
{
return;
}
if (event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST)
{
return;
}
Sign sign = new CraftSign(event.getClickedBlock());
try
{
if (sign.getLine(0).equals("§1[Free]") && user.isAuthorized("essentials.signs.free.use"))
{
ItemStack item = ItemDb.get(sign.getLine(1));
CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle()));
inv.clear();
item.setAmount(9 * 4 * 64);
inv.addItem(item);
user.showInventory(inv);
return;
}
if (sign.getLine(0).equals("§1[Disposal]") && user.isAuthorized("essentials.signs.disposal.use"))
{
CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle()));
inv.clear();
user.showInventory(inv);
return;
}
if (sign.getLine(0).equals("§1[Heal]") && user.isAuthorized("essentials.signs.heal.use"))
{
if (!sign.getLine(1).isEmpty())
{
String[] l1 = sign.getLine(1).split("[ :-]+");
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
if (!m1 && (int)q1 < 1)
{
throw new Exception(Util.i18n("moreThanZero"));
}
if (m1)
{
if (user.getMoney() < q1)
{
throw new Exception(Util.i18n("notEnoughMoney"));
}
user.takeMoney(q1);
user.sendMessage(Util.format("moneyTaken", Util.formatCurrency(q1)));
}
else
{
ItemStack i = ItemDb.get(l1[1], (int)q1);
if (!InventoryWorkaround.containsItem(user.getInventory(), true, i))
{
throw new Exception(Util.format("missingItems", (int)q1, l1[1]));
}
InventoryWorkaround.removeItem(user.getInventory(), true, i);
user.updateInventory();
}
}
user.setHealth(20);
user.sendMessage(Util.i18n("youAreHealed"));
return;
}
if (sign.getLine(0).equals("§1[Mail]") && user.isAuthorized("essentials.signs.mail.use") && user.isAuthorized("essentials.mail"))
{
List<String> mail = user.getMails();
if (mail.isEmpty())
{
user.sendMessage(Util.i18n("noNewMail"));
return;
}
for (String s : mail)
{
user.sendMessage(s);
}
user.sendMessage(Util.i18n("markMailAsRead"));
return;
}
if (sign.getLine(0).equals("§1[Balance]") && user.isAuthorized("essentials.signs.balance.use"))
{
user.sendMessage(Util.format("balance", user.getMoney()));
return;
}
if (sign.getLine(0).equals("§1[Warp]"))
{
if (!sign.getLine(2).isEmpty())
{
if (sign.getLine(2).equals("§2Everyone"))
{
Charge charge = chargeUserForWarp(sign, user);
user.getTeleport().warp(sign.getLine(1), charge);
return;
}
if (user.inGroup(sign.getLine(2)))
{
Charge charge = chargeUserForWarp(sign, user);
user.getTeleport().warp(sign.getLine(1), charge);
return;
}
}
if (user.isAuthorized("essentials.signs.warp.use")
&& (!ess.getSettings().getPerWarpPermission() || user.isAuthorized("essentials.warp." + sign.getLine(1))))
{
Charge charge = chargeUserForWarp(sign, user);
user.getTeleport().warp(sign.getLine(1), charge);
}
return;
}
}
catch (Throwable ex)
{
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
if (ess.getSettings().isDebug())
{
logger.log(Level.WARNING, ex.getMessage(), ex);
}
}
}
private Charge chargeUserForWarp(Sign sign, User user) throws Exception
{
if (!sign.getLine(3).isEmpty())
{
String[] l1 = sign.getLine(3).split("[ :-]+");
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
if (!m1 && (int)q1 < 1)
{
throw new Exception(Util.i18n("moreThanZero"));
}
if (m1)
{
return new Charge(q1, ess);
}
else
{
ItemStack i = ItemDb.get(l1[1], (int)q1);
return new Charge(i, ess);
}
}
return new Charge("warpsign", ess);
}
@Override
public void onPlayerEggThrow(PlayerEggThrowEvent event)
public void onPlayerEggThrow(final PlayerEggThrowEvent event)
{
User user = ess.getUser(event.getPlayer());
ItemStack is = new ItemStack(Material.EGG, 1);
final User user = ess.getUser(event.getPlayer());
final ItemStack is = new ItemStack(Material.EGG, 1);
if (user.hasUnlimited(is))
{
user.getInventory().addItem(is);
@@ -537,7 +390,7 @@ public class EssentialsPlayerListener extends PlayerListener
}
@Override
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event)
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
{
final User user = ess.getUser(event.getPlayer());
if (user.hasUnlimited(new ItemStack(event.getBucket())))
@@ -554,24 +407,24 @@ public class EssentialsPlayerListener extends PlayerListener
}
@Override
public void onPlayerAnimation(PlayerAnimationEvent event)
public void onPlayerAnimation(final PlayerAnimationEvent event)
{
usePowertools(event);
}
private void usePowertools(PlayerAnimationEvent event)
private void usePowertools(final PlayerAnimationEvent event)
{
if (event.getAnimationType() != PlayerAnimationType.ARM_SWING)
{
return;
}
User user = ess.getUser(event.getPlayer());
ItemStack is = user.getItemInHand();
final User user = ess.getUser(event.getPlayer());
final ItemStack is = user.getItemInHand();
if (is == null || is.getType() == Material.AIR)
{
return;
}
String command = user.getPowertool(is);
final String command = user.getPowertool(is);
if (command == null || command.isEmpty())
{
return;
@@ -593,4 +446,31 @@ public class EssentialsPlayerListener extends PlayerListener
user.getServer().dispatchCommand(user, command);
}
}
@Override
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
{
if (event.isCancelled())
{
return;
}
final User user = ess.getUser(event.getPlayer());
final String cmd = event.getMessage().toLowerCase().split(" ")[0].replace("/", "").toLowerCase();
final List<String> commands = Arrays.asList("msg", "r", "mail", "m", "t", "emsg", "tell", "er", "reply", "ereply", "email");
if (commands.contains(cmd))
{
for (Player player : ess.getServer().getOnlinePlayers())
{
if (ess.getUser(player).isSocialSpyEnabled())
{
player.sendMessage(user.getDisplayName() + " : " + event.getMessage());
}
}
}
if (user.isAfk())
{
user.setAfk(false);
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
}
}
}

View File

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

View File

@@ -3,7 +3,6 @@ package com.earth2me.essentials;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Player;
@@ -25,7 +24,7 @@ public class EssentialsTimer implements Runnable, IConf
continue;
}
String name = string.substring(0, string.length()-4);
User u = ess.getUser(new OfflinePlayer(name));
User u = ess.getUser(new OfflinePlayer(name, ess));
allUsers.add(u);
}
}
@@ -43,8 +42,7 @@ public class EssentialsTimer implements Runnable, IConf
for (User user: allUsers) {
if (user.getBanTimeout() > 0 && user.getBanTimeout() < currentTime) {
user.setBanTimeout(0);
((CraftServer)ess.getServer()).getHandle().b(user.getName());
ess.loadBanList();
ess.getBans().unbanByName(user.getName());
}
if (user.getMuteTimeout() > 0 && user.getMuteTimeout() < currentTime && user.isMuted()) {
user.setMuteTimeout(0);

View File

@@ -192,7 +192,7 @@ public class EssentialsUpgrade
usersConfig.load();
for (String username : usersConfig.getKeys(null))
{
User user = new User(new OfflinePlayer(username), ess);
User user = new User(new OfflinePlayer(username, ess), ess);
String nickname = usersConfig.getString(username + ".nickname");
if (nickname != null && !nickname.isEmpty() && !nickname.equals(username))
{

View File

@@ -1,6 +1,7 @@
package com.earth2me.essentials;
import java.util.List;
import java.util.UUID;
import org.bukkit.BlockChangeDelegate;
import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
@@ -8,6 +9,7 @@ import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.TreeType;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Boat;
@@ -172,26 +174,6 @@ public class FakeWorld implements World
throw new UnsupportedOperationException("Not supported yet.");
}
public Minecart spawnMinecart(Location lctn)
{
throw new UnsupportedOperationException("Not supported yet.");
}
public StorageMinecart spawnStorageMinecart(Location lctn)
{
throw new UnsupportedOperationException("Not supported yet.");
}
public PoweredMinecart spawnPoweredMinecart(Location lctn)
{
throw new UnsupportedOperationException("Not supported yet.");
}
public Boat spawnBoat(Location lctn)
{
throw new UnsupportedOperationException("Not supported yet.");
}
public LivingEntity spawnCreature(Location lctn, CreatureType ct)
{
throw new UnsupportedOperationException("Not supported yet.");
@@ -391,5 +373,36 @@ public class FakeWorld implements World
{
throw new UnsupportedOperationException("Not supported yet.");
}
public UUID getUID()
{
throw new UnsupportedOperationException("Not supported yet.");
}
public Block getHighestBlockAt(int i, int i1)
{
throw new UnsupportedOperationException("Not supported yet.");
}
public Block getHighestBlockAt(Location lctn)
{
throw new UnsupportedOperationException("Not supported yet.");
}
public Biome getBiome(int i, int i1)
{
throw new UnsupportedOperationException("Not supported yet.");
}
public double getTemperature(int i, int i1)
{
throw new UnsupportedOperationException("Not supported yet.");
}
public double getHumidity(int i, int i1)
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -1,68 +1,69 @@
package com.earth2me.essentials;
import com.earth2me.essentials.register.payment.Methods;
import java.io.File;
import java.util.List;
import org.bukkit.Server;
import java.util.Map;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.Plugin;
public interface IEssentials
public interface IEssentials extends Plugin
{
void addReloadListener(IConf listener);
void reload();
boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath);
boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix);
User getUser(Object base);
User getOfflineUser(String name);
World getWorld(String name);
int broadcastMessage(String name, String message);
Settings getSettings();
ISettings getSettings();
CraftScheduler getScheduler();
String[] getMotd(CommandSender sender, String def);
String[] getLines(CommandSender sender, String node, String def);
Jail getJail();
Warps getWarps();
Worth getWorth();
Backup getBackup();
Spawn getSpawn();
void loadBanList();
public boolean isRegisterFallbackEnabled();
public Methods getPaymentMethod();
Server getServer();
File getDataFolder();
PluginDescriptionFile getDescription();
Methods getPaymentMethod();
int scheduleAsyncDelayedTask(Runnable run);
int scheduleSyncDelayedTask(Runnable run);
int scheduleSyncDelayedTask(Runnable run, long delay);
int scheduleSyncRepeatingTask(final Runnable run, long delay, long period);
List<String> getBans();
BanWorkaround getBans();
List<String> getBannedIps();
TNTExplodeListener getTNTListener();
IPermissionsHandler getPermissionsHandler();
void setPermissionsHandler(IPermissionsHandler handler);
void showError(final CommandSender sender, final Throwable exception, final String commandLabel);
Map<String, User> getAllUsers();
ItemDb getItemDb();
}

View File

@@ -0,0 +1,21 @@
package com.earth2me.essentials;
import org.bukkit.entity.Player;
public interface IPermissionsHandler
{
String getGroup(Player base);
boolean canBuild(Player base, String group);
boolean inGroup(Player base, String group);
boolean hasPermission(Player base, String node);
String getPrefix(Player base);
String getSuffix(Player base);
}

View File

@@ -0,0 +1,135 @@
package com.earth2me.essentials;
import com.earth2me.essentials.commands.IEssentialsCommand;
import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
public interface ISettings extends IConf
{
boolean areSignsDisabled();
String format(String format, IUser user);
String getAnnounceNewPlayerFormat(IUser user);
boolean getAnnounceNewPlayers();
String getBackupCommand();
long getBackupInterval();
boolean getBedSetsHome();
String getChatFormat(String group);
int getChatRadius();
double getCommandCost(IEssentialsCommand cmd);
double getCommandCost(String label);
String getCurrencySymbol();
int getDefaultStackSize();
boolean getGenerateExitPortals();
double getHealCooldown();
Object getKit(String name);
Map<String, Object> getKits();
String getLocale();
String getNetherName();
boolean getNetherPortalsEnabled();
double getNetherRatio();
String getNewbieSpawn();
String getNicknamePrefix();
ChatColor getOperatorColor() throws Exception;
boolean getPerWarpPermission();
boolean getProtectBoolean(final String configName, boolean def);
int getProtectCreeperMaxHeight();
List<Integer> getProtectList(final String configName);
boolean getProtectPreventSpawn(final String creatureName);
String getProtectString(final String configName);
boolean getReclaimSetting();
boolean getRespawnAtHome();
boolean getSortListByGroups();
int getSpawnMobLimit();
int getStartingBalance();
double getTeleportCooldown();
double getTeleportDelay();
boolean hidePermissionlessHelp();
boolean isCommandDisabled(final IEssentialsCommand cmd);
boolean isCommandDisabled(String label);
boolean isCommandOverridden(String name);
boolean isCommandRestricted(IEssentialsCommand cmd);
boolean isCommandRestricted(String label);
boolean isDebug();
boolean isEcoDisabled();
boolean isNetherEnabled();
boolean isTradeInStacks(int id);
List<Integer> itemSpawnBlacklist();
boolean permissionBasedItemSpawn();
void reloadConfig();
boolean showNonEssCommandsInHelp();
boolean spawnIfNoHome();
boolean use1to1RatioInNether();
boolean warnOnBuildDisallow();
boolean warnOnSmite();
double getMaxMoney();
boolean isEcoLogEnabled();
boolean removeGodOnDisconnect();
boolean changeDisplayName();
boolean isPlayerCommand(String string);
public boolean useBukkitPermissions();
public boolean addPrefixSuffix();
}

View File

@@ -22,6 +22,8 @@ public interface IUser
boolean isAuthorized(String node);
boolean isAuthorized(IEssentialsCommand cmd);
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
void setLastTeleportTimestamp(long time);
@@ -33,6 +35,8 @@ public interface IUser
void takeMoney(double value);
void giveMoney(double value);
PlayerInventory getInventory();
void updateInventory();

View File

@@ -1,7 +1,9 @@
package com.earth2me.essentials;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.Item;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@@ -17,18 +19,18 @@ public final class InventoryWorkaround
private InventoryWorkaround()
{
}
public static int first(Inventory ci, ItemStack item, boolean forceDurability, boolean forceAmount)
public static int first(final Inventory inventory, final ItemStack item, final boolean forceDurability, final boolean forceAmount)
{
return next(ci, item, 0, forceDurability, forceAmount);
return next(inventory, item, 0, forceDurability, forceAmount);
}
public static int next(Inventory ci, ItemStack item, int start, boolean forceDurability, boolean forceAmount)
public static int next(final Inventory cinventory, final ItemStack item, final int start, final boolean forceDurability, final boolean forceAmount)
{
ItemStack[] inventory = ci.getContents();
final ItemStack[] inventory = cinventory.getContents();
for (int i = start; i < inventory.length; i++)
{
ItemStack cItem = inventory[i];
final ItemStack cItem = inventory[i];
if (cItem == null)
{
continue;
@@ -41,15 +43,138 @@ public final class InventoryWorkaround
return -1;
}
public static HashMap<Integer, ItemStack> removeItem(Inventory ci, boolean forceDurability, ItemStack... items)
public static int firstPartial(final Inventory cinventory, final ItemStack item, final boolean forceDurability)
{
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
if (item == null)
{
return -1;
}
final ItemStack[] inventory = cinventory.getContents();
for (int i = 0; i < inventory.length; i++)
{
final ItemStack cItem = inventory[i];
if (cItem == null)
{
continue;
}
if (item.getTypeId() == cItem.getTypeId() && cItem.getAmount() < cItem.getType().getMaxStackSize() && (!forceDurability || cItem.getDurability() == item.getDurability()))
{
return i;
}
}
return -1;
}
public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
{
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
/* TODO: some optimization
* - Create a 'firstPartial' with a 'fromIndex'
* - Record the lastPartial per Material
* - Cache firstEmpty result
*/
// combine items
ItemStack[] combined = new ItemStack[items.length];
for (int i = 0; i < items.length; i++)
{
if (items[i] == null || items[i].getAmount() < 1)
{
continue;
}
for (int j = 0; j < combined.length; j++)
{
if (combined[j] == null)
{
combined[j] = new ItemStack(items[i].getType(), items[i].getAmount(), items[i].getDurability());
break;
}
if (combined[j].getTypeId() == items[i].getTypeId() && (!forceDurability || combined[j].getDurability() == items[i].getDurability()))
{
combined[j].setAmount(combined[j].getAmount() + items[i].getAmount());
break;
}
}
}
for (int i = 0; i < combined.length; i++)
{
final ItemStack item = combined[i];
if (item == null)
{
continue;
}
while (true)
{
// Do we already have a stack of it?
final int firstPartial = firstPartial(cinventory, item, forceDurability);
// Drat! no partial stack
if (firstPartial == -1)
{
// Find a free spot!
final int firstFree = cinventory.firstEmpty();
if (firstFree == -1)
{
// No space at all!
leftover.put(i, item);
break;
}
else
{
// More than a single stack!
if (item.getAmount() > item.getType().getMaxStackSize())
{
cinventory.setItem(firstFree, new CraftItemStack(item.getTypeId(), item.getType().getMaxStackSize(), item.getDurability()));
item.setAmount(item.getAmount() - item.getType().getMaxStackSize());
}
else
{
// Just store it
cinventory.setItem(firstFree, item);
break;
}
}
}
else
{
// So, apparently it might only partially fit, well lets do just that
final ItemStack partialItem = cinventory.getItem(firstPartial);
final int amount = item.getAmount();
final int partialAmount = partialItem.getAmount();
final int maxAmount = partialItem.getType().getMaxStackSize();
// Check if it fully fits
if (amount + partialAmount <= maxAmount)
{
partialItem.setAmount(amount + partialAmount);
break;
}
// It fits partially
partialItem.setAmount(maxAmount);
item.setAmount(amount + partialAmount - maxAmount);
}
}
}
return leftover;
}
public static Map<Integer, ItemStack> removeItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
{
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
// TODO: optimization
for (int i = 0; i < items.length; i++)
{
ItemStack item = items[i];
final ItemStack item = items[i];
if (item == null)
{
continue;
@@ -66,7 +191,7 @@ public final class InventoryWorkaround
}
// get first Item, ignore the amount
int first = first(ci, item, forceDurability, false);
final int first = first(cinventory, item, forceDurability, false);
// Drat! we don't have this type in the inventory
if (first == -1)
@@ -77,20 +202,20 @@ public final class InventoryWorkaround
}
else
{
ItemStack itemStack = ci.getItem(first);
int amount = itemStack.getAmount();
final ItemStack itemStack = cinventory.getItem(first);
final int amount = itemStack.getAmount();
if (amount <= toDelete)
{
toDelete -= amount;
// clear the slot, all used up
ci.clear(first);
cinventory.clear(first);
}
else
{
// split the stack and store
itemStack.setAmount(amount - toDelete);
ci.setItem(first, itemStack);
cinventory.setItem(first, itemStack);
toDelete = 0;
}
}
@@ -99,9 +224,9 @@ public final class InventoryWorkaround
return leftover;
}
public static boolean containsItem(Inventory ci, boolean forceDurability, ItemStack... items)
public static boolean containsItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
{
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
// TODO: optimization
@@ -131,7 +256,7 @@ public final class InventoryWorkaround
for (int i = 0; i < combined.length; i++)
{
ItemStack item = combined[i];
final ItemStack item = combined[i];
if (item == null)
{
continue;
@@ -147,7 +272,7 @@ public final class InventoryWorkaround
break;
}
int slot = next(ci, item, position, forceDurability, false);
final int slot = next(cinventory, item, position, forceDurability, false);
// Drat! we don't have this type in the inventory
if (slot == -1)
@@ -157,8 +282,8 @@ public final class InventoryWorkaround
}
else
{
ItemStack itemStack = ci.getItem(slot);
int amount = itemStack.getAmount();
final ItemStack itemStack = cinventory.getItem(slot);
final int amount = itemStack.getAmount();
if (amount <= mustHave)
{
@@ -175,17 +300,19 @@ public final class InventoryWorkaround
return leftover.isEmpty();
}
public static Item[] dropItem(Location loc, ItemStack itm)
public static Item[] dropItem(final Location loc, final ItemStack itm)
{
int maxStackSize = itm.getType().getMaxStackSize();
int stacks = itm.getAmount() / maxStackSize;
int leftover = itm.getAmount() % maxStackSize;
final int maxStackSize = itm.getType().getMaxStackSize();
final int stacks = itm.getAmount() / maxStackSize;
final int leftover = itm.getAmount() % maxStackSize;
Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
for (int i = 0; i < stacks; i++) {
itemStacks[i] = loc.getWorld().dropItem(loc, new ItemStack(itm.getType(), maxStackSize, itm.getDurability()));
for (int i = 0; i < stacks; i++)
{
itemStacks[i] = loc.getWorld().dropItem(loc, new ItemStack(itm.getType(), maxStackSize, itm.getDurability()));
}
if (leftover > 0) {
itemStacks[stacks] = loc.getWorld().dropItem(loc, new ItemStack(itm.getType(), leftover, itm.getDurability()));
if (leftover > 0)
{
itemStacks[stacks] = loc.getWorld().dropItem(loc, new ItemStack(itm.getType(), leftover, itm.getDurability()));
}
return itemStacks;
}

View File

@@ -7,30 +7,31 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public final class ItemDb
public class ItemDb implements IConf
{
private ItemDb()
{
}
private final static Logger logger = Logger.getLogger("Minecraft");
private static Map<String, Integer> items = new HashMap<String, Integer>();
private static Map<String, Short> durabilities = new HashMap<String, Short>();
private final transient IEssentials ess;
public static void load(File folder, String fname) throws IOException
public ItemDb(IEssentials ess)
{
folder.mkdirs();
File file = new File(folder, fname);
this.ess = ess;
}
private final static Logger LOGGER = Logger.getLogger("Minecraft");
private final transient Map<String, Integer> items = new HashMap<String, Integer>();
private final transient Map<String, Short> durabilities = new HashMap<String, Short>();
public void reloadConfig()
{
final File file = new File(ess.getDataFolder(), "items.csv");
if (!file.exists())
{
file.createNewFile();
InputStream res = ItemDb.class.getResourceAsStream("/items.csv");
final InputStream res = ItemDb.class.getResourceAsStream("/items.csv");
FileWriter tx = null;
try
{
@@ -41,6 +42,11 @@ public final class ItemDb
}
tx.flush();
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, Util.i18n("itemsCsvNotLoaded"), ex);
return;
}
finally
{
try
@@ -63,52 +69,67 @@ public final class ItemDb
}
}
BufferedReader rx = new BufferedReader(new FileReader(file));
BufferedReader rx = null;
try
{
rx = new BufferedReader(new FileReader(file));
durabilities.clear();
items.clear();
for (int i = 0; rx.ready(); i++)
{
try
{
String line = rx.readLine().trim().toLowerCase();
final String line = rx.readLine().trim().toLowerCase();
if (line.startsWith("#"))
{
continue;
}
String[] parts = line.split("[^a-z0-9]");
final String[] parts = line.split("[^a-z0-9]");
if (parts.length < 2)
{
continue;
}
int numeric = Integer.parseInt(parts[1]);
final int numeric = Integer.parseInt(parts[1]);
durabilities.put(parts[0].toLowerCase(), parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0);
items.put(parts[0].toLowerCase(), numeric);
}
catch (Exception ex)
{
logger.warning(Util.format("parseError", fname, i));
LOGGER.warning(Util.format("parseError", "items.csv", i));
}
}
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, Util.i18n("itemsCsvNotLoaded"), ex);
}
finally
{
rx.close();
if (rx != null) {
try
{
rx.close();
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
}
}
}
}
public static ItemStack get(String id, int quantity) throws Exception
public ItemStack get(final String id, final int quantity) throws Exception
{
ItemStack retval = get(id.toLowerCase());
final ItemStack retval = get(id.toLowerCase());
retval.setAmount(quantity);
return retval;
}
public static ItemStack get(String id) throws Exception
public ItemStack get(final String id) throws Exception
{
int itemid = 0;
String itemname = null;
@@ -127,11 +148,11 @@ public final class ItemDb
itemname = id.split("[:+',;.]")[0].toLowerCase();
metaData = Short.parseShort(id.split("[:+',;.]")[1]);
}
else
else
{
itemname = id.toLowerCase();
}
if (itemname != null)
{
if (items.containsKey(itemname))
@@ -148,13 +169,13 @@ public final class ItemDb
}
}
Material mat = Material.getMaterial(itemid);
final Material mat = Material.getMaterial(itemid);
if (mat == null)
{
throw new Exception(Util.format("unknownItemId", itemid));
}
ItemStack retval = new ItemStack(mat);
retval.setAmount(Essentials.getStatic().getSettings().getDefaultStackSize());
final ItemStack retval = new ItemStack(mat);
retval.setAmount(ess.getSettings().getDefaultStackSize());
retval.setDurability(metaData);
return retval;
}

View File

@@ -42,7 +42,10 @@ public class Jail extends BlockListener implements IConf
public void sendToJail(User user, String jail) throws Exception
{
user.getTeleport().now(getJail(jail));
if (!(user.getBase() instanceof OfflinePlayer))
{
user.getTeleport().now(getJail(jail));
}
user.setJail(jail);
}

View File

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

View File

@@ -1,75 +1,55 @@
package com.earth2me.essentials;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.server.Entity;
import net.minecraft.server.WorldServer;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public enum Mob
{
CHICKEN("Chicken", Enemies.FRIENDLY),
COW("Cow", Enemies.FRIENDLY),
CREEPER("Creeper", Enemies.ENEMY),
GHAST("Ghast", Enemies.ENEMY),
GIANT("Giant", "GiantZombie", Enemies.ENEMY),
PIG("Pig", Enemies.FRIENDLY),
PIGZOMB("PigZombie", Enemies.NEUTRAL),
SHEEP("Sheep", Enemies.FRIENDLY, ""),
SKELETON("Skeleton", Enemies.ENEMY),
SLIME("Slime", Enemies.ENEMY),
SPIDER("Spider", Enemies.ENEMY),
SQUID("Squid", Enemies.FRIENDLY),
ZOMBIE("Zombie", Enemies.ENEMY),
MONSTER("Monster", Enemies.ENEMY),
WOLF("Wolf", Enemies.NEUTRAL);
CHICKEN("Chicken", Enemies.FRIENDLY, CreatureType.CHICKEN),
COW("Cow", Enemies.FRIENDLY, CreatureType.COW),
CREEPER("Creeper", Enemies.ENEMY, CreatureType.CREEPER),
GHAST("Ghast", Enemies.ENEMY, CreatureType.GHAST),
GIANT("Giant", Enemies.ENEMY, CreatureType.GIANT),
PIG("Pig", Enemies.FRIENDLY, CreatureType.PIG),
PIGZOMB("PigZombie", Enemies.NEUTRAL, CreatureType.PIG_ZOMBIE),
SHEEP("Sheep", Enemies.FRIENDLY, "", CreatureType.SHEEP),
SKELETON("Skeleton", Enemies.ENEMY, CreatureType.SKELETON),
SLIME("Slime", Enemies.ENEMY, CreatureType.SLIME),
SPIDER("Spider", Enemies.ENEMY, CreatureType.SPIDER),
SQUID("Squid", Enemies.FRIENDLY, CreatureType.SQUID),
ZOMBIE("Zombie", Enemies.ENEMY, CreatureType.ZOMBIE),
MONSTER("Monster", Enemies.ENEMY, CreatureType.MONSTER),
WOLF("Wolf", Enemies.NEUTRAL, CreatureType.WOLF);
public static final Logger logger = Logger.getLogger("Minecraft");
private Mob(String n, Enemies en, String s)
private Mob(String n, Enemies en, String s, CreatureType type)
{
this.s = s;
this.suffix = s;
this.name = n;
this.craftClass = n;
this.entityClass = n;
this.type = en;
this.bukkitType = type;
}
private Mob(String n, Enemies en)
private Mob(String n, Enemies en, CreatureType type)
{
this.name = n;
this.craftClass = n;
this.entityClass = n;
this.type = en;
this.bukkitType = type;
}
private Mob(String n, String ec, Enemies en)
{
this.name = n;
this.craftClass = n;
this.entityClass = ec;
this.type = en;
}
private Mob(String n, String ec, String cc, Enemies en)
{
this.name = n;
this.entityClass = ec;
this.craftClass = cc;
this.type = en;
}
public String s = "s";
public String name;
public Enemies type;
private String entityClass;
private String craftClass;
public String suffix = "s";
final public String name;
final public Enemies type;
final private CreatureType bukkitType;
private static final Map<String, Mob> hashMap = new HashMap<String, Mob>();
static
@@ -80,24 +60,16 @@ public enum Mob
}
}
@SuppressWarnings(
public LivingEntity spawn(final Player player, final Server server, final Location loc) throws MobException
{
"unchecked", "CallToThreadDumpStack"
})
public CraftEntity spawn(Player player, Server server) throws MobException
{
try
final LivingEntity entity = player.getWorld().spawnCreature(loc, this.bukkitType);
if (entity == null)
{
WorldServer world = ((org.bukkit.craftbukkit.CraftWorld)player.getWorld()).getHandle();
Constructor<CraftEntity> craft = (Constructor<CraftEntity>)ClassLoader.getSystemClassLoader().loadClass("org.bukkit.craftbukkit.entity.Craft" + craftClass).getConstructors()[0];
Constructor<Entity> entity = (Constructor<Entity>)ClassLoader.getSystemClassLoader().loadClass("net.minecraft.server.Entity" + entityClass).getConstructors()[0];
return craft.newInstance((CraftServer)server, entity.newInstance(world));
}
catch (Exception ex)
{
logger.log(Level.WARNING, Util.i18n("unableToSpawnMob"), ex);
throw new MobException(ex);
logger.log(Level.WARNING, Util.i18n("unableToSpawnMob"));
throw new MobException();
}
return entity;
}
@@ -107,22 +79,17 @@ public enum Mob
NEUTRAL("neutral"),
ENEMY("enemy");
private Enemies(String t)
private Enemies(final String t)
{
this.type = t;
}
protected String type;
final protected String type;
}
public static class MobException extends Exception
{
private static final long serialVersionUID = 1L;
private MobException(Exception ex)
{
super(ex);
}
}
public static Mob fromName(String n)

View File

@@ -3,6 +3,7 @@ package com.earth2me.essentials;
import java.net.InetSocketAddress;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Achievement;
import org.bukkit.Effect;
@@ -23,19 +24,26 @@ import org.bukkit.entity.Vehicle;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
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 OfflinePlayer implements Player
{
private final String name;
final transient IEssentials ess;
private Location location = new Location(null, 0, 0, 0, 0, 0);
private World world = null;
private World world;
private UUID uniqueId = UUID.randomUUID();
public OfflinePlayer(String name)
public OfflinePlayer(String name, IEssentials ess)
{
this.name = name;
this.ess = ess;
this.world = ess.getServer().getWorlds().get(0);
}
public boolean isOnline()
@@ -141,7 +149,7 @@ public class OfflinePlayer implements Player
{
return world;
}
public void setLocation(Location loc)
{
location = loc;
@@ -258,7 +266,7 @@ public class OfflinePlayer implements Player
public Server getServer()
{
return Essentials.getStatic() == null ? null : Essentials.getStatic().getServer();
return ess == null ? null : ess.getServer();
}
public Vector getMomentum()
@@ -296,7 +304,8 @@ public class OfflinePlayer implements Player
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
}
public void sendRawMessage(String string) {
public void sendRawMessage(String string)
{
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
}
@@ -509,4 +518,62 @@ public class OfflinePlayer implements Player
{
throw new UnsupportedOperationException("Not supported yet.");
}
public boolean isPermissionSet(String string)
{
return false;
}
public boolean isPermissionSet(Permission prmsn)
{
return false;
}
public boolean hasPermission(String string)
{
return false;
}
public boolean hasPermission(Permission prmsn)
{
return false;
}
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
public PermissionAttachment addAttachment(Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln, int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
public PermissionAttachment addAttachment(Plugin plugin, int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
public void removeAttachment(PermissionAttachment pa)
{
throw new UnsupportedOperationException("Not supported yet.");
}
public void recalculatePermissions()
{
}
public Set<PermissionAttachmentInfo> getEffectivePermissions()
{
throw new UnsupportedOperationException("Not supported yet.");
}
public void setOp(boolean bln)
{
}
}

View File

@@ -0,0 +1,50 @@
package com.earth2me.essentials;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class Permissions2Handler implements IPermissionsHandler
{
private final transient PermissionHandler permissionHandler;
Permissions2Handler(final Plugin permissionsPlugin)
{
permissionHandler = ((Permissions)permissionsPlugin).getHandler();
}
public String getGroup(final Player base)
{
final String group = permissionHandler.getGroup(base.getWorld().getName(), base.getName());
return group == null ? "default" : group;
}
public boolean canBuild(final Player base, final String group)
{
return permissionHandler.canGroupBuild(base.getWorld().getName(), getGroup(base));
}
public boolean inGroup(final Player base, final String group)
{
return permissionHandler.inGroup(base.getWorld().getName(), base.getName(), group);
}
public boolean hasPermission(final Player base, final String node)
{
return permissionHandler.permission(base, node);
}
public String getPrefix(final Player base)
{
final String prefix = permissionHandler.getGroupPrefix(base.getWorld().getName(), getGroup(base));
return prefix == null ? "" : prefix;
}
public String getSuffix(final Player base)
{
final String suffix = permissionHandler.getGroupSuffix(base.getWorld().getName(), getGroup(base));
return suffix == null ? "" : suffix;
}
}

View File

@@ -0,0 +1,48 @@
package com.earth2me.essentials;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class Permissions3Handler implements IPermissionsHandler
{
private final transient PermissionHandler permissionHandler;
Permissions3Handler(final Plugin permissionsPlugin)
{
permissionHandler = ((Permissions)permissionsPlugin).getHandler();
}
public String getGroup(final Player base)
{
return permissionHandler.getPrimaryGroup(base.getWorld().getName(), base.getName());
}
public boolean canBuild(final Player base, final String group)
{
return permissionHandler.canUserBuild(base.getWorld().getName(), base.getName());
}
public boolean inGroup(final Player base, final String group)
{
return permissionHandler.inGroup(base.getWorld().getName(), base.getName(), group);
}
public boolean hasPermission(final Player base, final String node)
{
return permissionHandler.has(base, node);
}
public String getPrefix(final Player base)
{
return permissionHandler.getUserPrefix(base.getWorld().getName(), base.getName());
}
public String getSuffix(final Player base)
{
return permissionHandler.getUserSuffix(base.getWorld().getName(), base.getName());
}
}

View File

@@ -0,0 +1,74 @@
package com.earth2me.essentials;
import org.bukkit.entity.Player;
import ru.tehkode.permissions.PermissionManager;
import ru.tehkode.permissions.PermissionUser;
import ru.tehkode.permissions.bukkit.PermissionsEx;
class PermissionsExHandler implements IPermissionsHandler
{
private final transient PermissionManager manager;
public PermissionsExHandler()
{
manager = PermissionsEx.getPermissionManager();
}
public String getGroup(Player base)
{
final PermissionUser user = manager.getUser(base.getName());
if (user == null)
{
return "default";
}
return user.getGroupsNames()[0];
}
public boolean canBuild(Player base, String group)
{
final PermissionUser user = manager.getUser(base.getName());
if (user == null)
{
return true;
}
return user.getOptionBoolean("build", base.getWorld().getName(), true);
}
public boolean inGroup(Player base, String group)
{
final PermissionUser user = manager.getUser(base.getName());
if (user == null)
{
return false;
}
return user.inGroup(group);
}
public boolean hasPermission(Player base, String node)
{
return manager.has(base.getName(), node, base.getWorld().getName());
}
public String getPrefix(Player base)
{
final PermissionUser user = manager.getUser(base.getName());
if (user == null)
{
return "";
}
return user.getPrefix();
}
public String getSuffix(Player base)
{
final PermissionUser user = manager.getUser(base.getName());
if (user == null)
{
return "";
}
return user.getSuffix();
}
}

View File

@@ -19,12 +19,12 @@ public class PlayerExtension extends PlayerWrapper
public boolean isBanned()
{
return ess.getBans().contains(getName());
return ess.getBans().isNameBanned(this.getName());
}
public boolean isIpBanned()
{
return ess.getBannedIps().contains(getAddress().getAddress().toString().replace("/", ""));
return ess.getBans().isIpBanned(getAddress().getAddress().getHostAddress());
}
public float getCorrectedYaw()
@@ -53,38 +53,17 @@ public class PlayerExtension extends PlayerWrapper
public String getGroup()
{
try
{
return com.nijikokun.bukkit.Permissions.Permissions.Security.getGroup(getWorld().getName(), getName());
}
catch (Throwable ex)
{
return "default";
}
return ess.getPermissionsHandler().getGroup(base);
}
public boolean inGroup(String group)
{
try
{
return com.nijikokun.bukkit.Permissions.Permissions.Security.inGroup(getWorld().getName(), getName(), group);
}
catch (Throwable ex)
{
return false;
}
return ess.getPermissionsHandler().inGroup(base, group);
}
public boolean canBuild()
{
try
{
return isOp() || com.nijikokun.bukkit.Permissions.Permissions.Security.canGroupBuild(getWorld().getName(), getGroup());
}
catch (Throwable ex)
{
return true;
}
return ess.getPermissionsHandler().canBuild(base, getGroup());
}
public EntityPlayer getHandle()

View File

@@ -7,6 +7,10 @@ import org.bukkit.block.Block;
import org.bukkit.entity.*;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.*;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector;
public class PlayerWrapper implements Player
@@ -560,4 +564,64 @@ public class PlayerWrapper implements Player
{
base.resetPlayerTime();
}
public boolean isPermissionSet(String string)
{
return base.isPermissionSet(string);
}
public boolean isPermissionSet(Permission prmsn)
{
return base.isPermissionSet(prmsn);
}
public boolean hasPermission(String string)
{
return base.hasPermission(string);
}
public boolean hasPermission(Permission prmsn)
{
return base.hasPermission(prmsn);
}
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln)
{
return base.addAttachment(plugin, string, bln);
}
public PermissionAttachment addAttachment(Plugin plugin)
{
return base.addAttachment(plugin);
}
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln, int i)
{
return base.addAttachment(plugin, string, bln, i);
}
public PermissionAttachment addAttachment(Plugin plugin, int i)
{
return base.addAttachment(plugin, i);
}
public void removeAttachment(PermissionAttachment pa)
{
throw new UnsupportedOperationException("Not supported yet.");
}
public void recalculatePermissions()
{
base.recalculatePermissions();
}
public Set<PermissionAttachmentInfo> getEffectivePermissions()
{
return base.getEffectivePermissions();
}
public void setOp(boolean bln)
{
base.setOp(bln);
}
}

View File

@@ -6,65 +6,74 @@ import org.bukkit.ChatColor;
import com.earth2me.essentials.commands.IEssentialsCommand;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.entity.CreatureType;
import org.bukkit.inventory.ItemStack;
public class Settings implements IConf
public class Settings implements ISettings
{
private final EssentialsConf config;
private final transient EssentialsConf config;
private final static Logger logger = Logger.getLogger("Minecraft");
private final transient IEssentials ess;
public Settings(File dataFolder)
public Settings(IEssentials ess)
{
config = new EssentialsConf(new File(dataFolder, "config.yml"));
this.ess = ess;
config = new EssentialsConf(new File(ess.getDataFolder(), "config.yml"));
config.setTemplateName("/config.yml");
config.load();
reloadConfig();
}
@Override
public boolean getRespawnAtHome()
{
return config.getBoolean("respawn-at-home", false);
}
@Override
public boolean getBedSetsHome()
{
return config.getBoolean("bed-sethome", false);
}
@Override
public int getChatRadius()
{
return config.getInt("chat.radius", config.getInt("chat-radius", 0));
}
@Override
public double getTeleportDelay()
{
return config.getDouble("teleport-delay", 0);
}
@Override
public int getDefaultStackSize()
{
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)
{
return isCommandDisabled(cmd.getName());
}
@Override
public boolean isCommandDisabled(String label)
{
for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0)))
@@ -75,11 +84,13 @@ public class Settings implements IConf
return config.getBoolean("disable-" + label.toLowerCase(), false);
}
@Override
public boolean isCommandRestricted(IEssentialsCommand cmd)
{
return isCommandRestricted(cmd.getName());
}
@Override
public boolean isCommandRestricted(String label)
{
for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0)))
@@ -89,7 +100,19 @@ public class Settings implements IConf
}
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;
return true;
}
return false;
}
@Override
public boolean isCommandOverridden(String name)
{
List<String> defaultList = new ArrayList<String>(1);
@@ -103,11 +126,13 @@ public class Settings implements IConf
return config.getBoolean("override-" + name.toLowerCase(), false);
}
@Override
public double getCommandCost(IEssentialsCommand cmd)
{
return getCommandCost(cmd.getName());
}
@Override
public double getCommandCost(String label)
{
double cost = config.getDouble("command-costs." + label, 0.0);
@@ -116,26 +141,25 @@ public class Settings implements IConf
return cost;
}
public String getCommandPrefix()
{
return config.getString("command-prefix", "");
}
@Override
public String getNicknamePrefix()
{
return config.getString("nickname-prefix", "~");
}
@Override
public double getTeleportCooldown()
{
return config.getDouble("teleport-cooldown", 60);
}
@Override
public double getHealCooldown()
{
return config.getDouble("heal-cooldown", 60);
}
@Override
public Object getKit(String name)
{
Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits");
@@ -148,11 +172,13 @@ public class Settings implements IConf
return null;
}
@Override
public Map<String, Object> getKits()
{
return (Map<String, Object>)config.getProperty("kits");
}
@Override
public ChatColor getOperatorColor() throws Exception
{
String colorName = config.getString("ops-name-color", null);
@@ -173,257 +199,123 @@ public class Settings implements IConf
return ChatColor.getByCode(Integer.parseInt(colorName, 16));
}
@Override
public boolean getReclaimSetting()
{
return config.getBoolean("reclaim-onlogout", true);
}
@Override
public String getNetherName()
{
return config.getString("nether.folder", "nether");
}
@Override
public boolean isNetherEnabled()
{
return config.getBoolean("nether.enabled", true);
}
@Override
public int getSpawnMobLimit()
{
return config.getInt("spawnmob-limit", 10);
}
@Override
public boolean showNonEssCommandsInHelp()
{
return config.getBoolean("non-ess-in-help", true);
}
public Map<String, Boolean> getEpSettings()
@Override
public boolean hidePermissionlessHelp()
{
Map<String, Boolean> epSettings = new HashMap<String, Boolean>();
return config.getBoolean("hide-permissionless-help", true);
}
epSettings.put("protect.protect.signs", config.getBoolean("protect.protect.signs", true));
epSettings.put("protect.protect.rails", config.getBoolean("protect.protect.rails", true));
epSettings.put("protect.protect.block-below", config.getBoolean("protect.protect.block-below", true));
epSettings.put("protect.protect.prevent-block-on-rails", config.getBoolean("protect.protect.prevent-block-on-rails", false));
return epSettings;
}
public Map<String, String> getEpDBSettings()
{
Map<String, String> epSettings = new HashMap<String, String>();
epSettings.put("protect.datatype", config.getString("protect.datatype", "sqlite"));
epSettings.put("protect.username", config.getString("protect.username", "root"));
epSettings.put("protect.password", config.getString("protect.password", "root"));
epSettings.put("protect.mysqlDb", config.getString("protect.mysqlDb", "jdbc:mysql://localhost:3306/minecraft"));
return epSettings;
}
public List<Integer> getEpAlertOnPlacement()
{
final List<Integer> epAlertPlace = new ArrayList<Integer>();
for (String itemName : config.getString("protect.alert.on-placement", "").split(",")) {
itemName = itemName.trim();
if (itemName.isEmpty()) {
continue;
}
ItemStack is;
try {
is = ItemDb.get(itemName);
epAlertPlace.add(is.getTypeId());
} catch (Exception ex) {
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "alert.on-placement"));
}
}
return epAlertPlace;
}
public List<Integer> getEpAlertOnUse()
{
final List<Integer> epAlertUse = new ArrayList<Integer>();
for (String itemName : config.getString("protect.alert.on-use", "").split(",")) {
itemName = itemName.trim();
if (itemName.isEmpty()) {
continue;
}
ItemStack is;
try {
is = ItemDb.get(itemName);
epAlertUse.add(is.getTypeId());
} catch (Exception ex) {
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "alert.on-use"));
}
}
return epAlertUse;
}
public List<Integer> getEpAlertOnBreak()
{
final List<Integer> epAlertPlace = new ArrayList<Integer>();
for (String itemName : config.getString("protect.alert.on-break", "").split(",")) {
itemName = itemName.trim();
if (itemName.isEmpty()) {
continue;
}
ItemStack is;
try {
is = ItemDb.get(itemName);
epAlertPlace.add(is.getTypeId());
} catch (Exception ex) {
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "alert.on-break"));
}
}
return epAlertPlace;
}
public List<Integer> epBlackListPlacement()
{
final List<Integer> epBlacklistPlacement = new ArrayList<Integer>();
for (String itemName : config.getString("protect.blacklist.placement", "").split(",")) {
itemName = itemName.trim();
if (itemName.isEmpty()) {
continue;
}
ItemStack is;
try {
is = ItemDb.get(itemName);
epBlacklistPlacement.add(is.getTypeId());
} catch (Exception ex) {
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "blacklist.placement"));
}
}
return epBlacklistPlacement;
}
public List<Integer> epBlackListUsage()
{
final List<Integer> epBlackListUsage = new ArrayList<Integer>();
for (String itemName : config.getString("protect.blacklist.usage", "").split(",")) {
itemName = itemName.trim();
if (itemName.isEmpty()) {
continue;
}
ItemStack is;
try {
is = ItemDb.get(itemName);
epBlackListUsage.add(is.getTypeId());
} catch (Exception ex) {
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "blacklist.usage"));
}
}
return epBlackListUsage;
}
public Map<String, Boolean> getEpGuardSettings()
{
final Map<String, Boolean> epSettings = new HashMap<String, Boolean>();
epSettings.put("protect.prevent.lava-flow", config.getBoolean("protect.prevent.lava-flow", false));
epSettings.put("protect.prevent.water-flow", config.getBoolean("protect.prevent.water-flow", false));
epSettings.put("protect.prevent.water-bucket-flow", config.getBoolean("protect.prevent.water-bucket-flow", false));
epSettings.put("protect.prevent.fire-spread", config.getBoolean("protect.prevent.fire-spread", true));
epSettings.put("protect.prevent.flint-fire", config.getBoolean("protect.prevent.flint-fire", false));
epSettings.put("protect.prevent.portal-creation", config.getBoolean("protect.prevent.portal-creation", false));
epSettings.put("protect.prevent.lava-fire-spread", config.getBoolean("protect.prevent.lava-fire-spread", true));
epSettings.put("protect.prevent.tnt-explosion", config.getBoolean("protect.prevent.tnt-explosion", false));
epSettings.put("protect.prevent.creeper-explosion", config.getBoolean("protect.prevent.creeper-explosion", false));
epSettings.put("protect.prevent.creeper-playerdamage", config.getBoolean("protect.prevent.creeper-playerdamage", false));
epSettings.put("protect.prevent.creeper-blockdamage", config.getBoolean("protect.prevent.creeper-blockdamage", false));
epSettings.put("protect.prevent.entitytarget", config.getBoolean("protect.prevent.entitytarget", false));
for (CreatureType ct : CreatureType.values()) {
final String name = ct.toString().toLowerCase();
epSettings.put("protect.prevent.spawn."+name, config.getBoolean("protect.prevent.spawn."+name, false));
}
epSettings.put("protect.prevent.lightning-fire-spread", config.getBoolean("protect.prevent.lightning-fire-spread", true));
return epSettings;
}
public Map<String, Boolean> getEpPlayerSettings()
{
final Map<String, Boolean> epPlayerSettings = new HashMap<String, Boolean>();
epPlayerSettings.put("protect.disable.fall", config.getBoolean("protect.disable.fall", false));
epPlayerSettings.put("protect.disable.pvp", config.getBoolean("protect.disable.pvp", false));
epPlayerSettings.put("protect.disable.drown", config.getBoolean("protect.disable.drown", false));
epPlayerSettings.put("protect.disable.suffocate", config.getBoolean("protect.disable.suffocate", false));
epPlayerSettings.put("protect.disable.lavadmg", config.getBoolean("protect.disable.lavadmg", false));
epPlayerSettings.put("protect.disable.projectiles", config.getBoolean("protect.disable.projectiles", false));
epPlayerSettings.put("protect.disable.contactdmg", config.getBoolean("protect.disable.contactdmg", false));
epPlayerSettings.put("protect.disable.firedmg", config.getBoolean("protect.disable.firedmg", false));
epPlayerSettings.put("protect.disable.build", config.getBoolean("protect.disable.build", false));
epPlayerSettings.put("protect.disable.lightning", config.getBoolean("protect.disable.lightning", false));
epPlayerSettings.put("protect.disable.weather.lightning", config.getBoolean("protect.disable.weather.lightning", false));
epPlayerSettings.put("protect.disable.weather.storm", config.getBoolean("protect.disable.weather.storm", false));
epPlayerSettings.put("protect.disable.weather.thunder", config.getBoolean("protect.disable.weather.thunder", false));
return epPlayerSettings;
}
public int getEpCreeperMaxHeight()
@Override
public int getProtectCreeperMaxHeight()
{
return config.getInt("protect.creeper.max-height", -1);
}
@Override
public boolean areSignsDisabled()
{
return config.getBoolean("signs-disabled", false);
}
@Override
public long getBackupInterval()
{
return config.getInt("backup.interval", 1440); // 1440 = 24 * 60
}
@Override
public String getBackupCommand()
{
return config.getString("backup.command", null);
}
@Override
public String getChatFormat(String group)
{
return config.getString("chat.group-formats." + (group == null ? "Default" : group),
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
}
@Override
public boolean getGenerateExitPortals()
{
return config.getBoolean("nether.generate-exit-portals", true);
}
@Override
public boolean getAnnounceNewPlayers()
{
return !config.getString("newbies.announce-format", "-").isEmpty();
}
@Override
public String getAnnounceNewPlayerFormat(IUser user)
{
return format(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!"), user);
}
@Override
public String format(String format, IUser user)
{
return format.replace('&', '§').replace("§§", "&").replace("{PLAYER}", user.getDisplayName()).replace("{DISPLAYNAME}", user.getDisplayName()).replace("{GROUP}", user.getGroup()).replace("{USERNAME}", user.getName()).replace("{ADDRESS}", user.getAddress().toString());
}
@Override
public String getNewbieSpawn()
{
return config.getString("newbies.spawnpoint", "default");
}
@Override
public boolean getPerWarpPermission()
{
return config.getBoolean("per-warp-permission", false);
}
@Override
public boolean getSortListByGroups()
{
return config.getBoolean("sort-list-by-groups", true);
}
@Override
public void reloadConfig() {
config.load();
}
public ArrayList<Integer> itemSpawnBlacklist()
@Override
public List<Integer> itemSpawnBlacklist()
{
ArrayList<Integer> epItemSpwn = new ArrayList<Integer>();
final List<Integer> epItemSpwn = new ArrayList<Integer>();
for (String itemName : config.getString("item-spawn-blacklist", "").split(",")) {
itemName = itemName.trim();
if (itemName.isEmpty()) {
@@ -431,7 +323,7 @@ public class Settings implements IConf
}
ItemStack is;
try {
is = ItemDb.get(itemName);
is = ess.getItemDb().get(itemName);
epItemSpwn.add(is.getTypeId());
} catch (Exception ex) {
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "item-spawn-blacklist"));
@@ -440,40 +332,25 @@ public class Settings implements IConf
return epItemSpwn;
}
public ArrayList<Integer> epBlockBreakingBlacklist()
{
ArrayList<Integer> epBreakList = new ArrayList<Integer>();
for (String itemName : config.getString("protect.blacklist.break", "").split(",")) {
itemName = itemName.trim();
if (itemName.isEmpty()) {
continue;
}
ItemStack is;
try {
is = ItemDb.get(itemName);
epBreakList.add(is.getTypeId());
} catch (Exception ex) {
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "blacklist.break"));
}
}
return epBreakList;
}
@Override
public boolean spawnIfNoHome()
{
return config.getBoolean("spawn-if-no-home", false);
}
@Override
public boolean warnOnBuildDisallow()
{
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)) {
@@ -482,38 +359,118 @@ public class Settings implements IConf
return config.getDouble("nether.ratio", 16.0);
}
@Override
public boolean isDebug()
{
return config.getBoolean("debug", false);
}
@Override
public boolean warnOnSmite()
{
return config.getBoolean("warn-on-smite" ,true);
}
@Override
public boolean permissionBasedItemSpawn()
{
return config.getBoolean("permission-based-item-spawn", false);
}
@Override
public String getLocale()
{
return config.getString("locale", "");
}
@Override
public String getCurrencySymbol()
{
return config.getString("currency-symbol", "$").substring(0, 1).replaceAll("[0-9]", "$");
}
@Override
public boolean isTradeInStacks(int id)
{
return config.getBoolean("trade-in-stacks-" + id, false);
}
@Override
public boolean isEcoDisabled()
{
return config.getBoolean("disable-eco", false);
}
@Override
public boolean getProtectPreventSpawn(final String creatureName)
{
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(",")) {
itemName = itemName.trim();
if (itemName.isEmpty()) {
continue;
}
ItemStack itemStack;
try {
itemStack = ess.getItemDb().get(itemName);
list.add(itemStack.getTypeId());
} catch (Exception ex) {
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, configName));
}
}
return list;
}
@Override
public String getProtectString(final String configName)
{
return config.getString(configName, null);
}
@Override
public boolean getProtectBoolean(final String configName, boolean def)
{
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) {
max = max < 0 ? -MAXMONEY : MAXMONEY;
}
return max;
}
public boolean isEcoLogEnabled()
{
return config.getBoolean("economy-log-enabled", false);
}
public boolean removeGodOnDisconnect()
{
return config.getBoolean("remove-god-on-disconnect", false);
}
public boolean changeDisplayName()
{
return config.getBoolean("change-displayname", true);
}
public boolean useBukkitPermissions()
{
return config.getBoolean("use-bukkit-permissions", false);
}
public boolean addPrefixSuffix()
{
return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat"));
}
}

View File

@@ -0,0 +1,82 @@
package com.earth2me.essentials;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.minecraft.server.ChunkPosition;
import net.minecraft.server.Packet60Explosion;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityListener;
public class TNTExplodeListener extends EntityListener implements Runnable
{
private final IEssentials ess;
private boolean enabled = false;
private int timer = -1;
public TNTExplodeListener(IEssentials ess)
{
this.ess = ess;
}
public void enable()
{
if (!enabled)
{
enabled = true;
timer = ess.scheduleSyncDelayedTask(this, 1000);
return;
}
if (timer != -1) {
ess.getScheduler().cancelTask(timer);
timer = ess.scheduleSyncDelayedTask(this, 1000);
}
}
@Override
public void onEntityExplode(final EntityExplodeEvent event)
{
if (!enabled)
{
return;
}
if (event.getEntity() instanceof LivingEntity)
{
return;
}
final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
final Player[] players = ess.getServer().getOnlinePlayers();
final List<ChunkPosition> blocksUnderPlayers = new ArrayList<ChunkPosition>(players.length);
final Location loc = event.getLocation();
for (Player player : players)
{
if (player.getWorld().equals(loc.getWorld()))
{
blocksUnderPlayers.add(new ChunkPosition(player.getLocation().getBlockX(), player.getLocation().getBlockY() - 1, player.getLocation().getBlockZ()));
}
}
for (Block block : event.blockList())
{
final ChunkPosition cp = new ChunkPosition(block.getX(), block.getY(), block.getZ());
if (!blocksUnderPlayers.contains(cp))
{
set.add(cp);
}
}
((CraftServer)ess.getServer()).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0F, set));
event.setCancelled(true);
}
public void run()
{
enabled = false;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,6 @@ package com.earth2me.essentials;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
@@ -10,6 +9,7 @@ import org.bukkit.entity.Entity;
public class Teleport implements Runnable
{
private static final double MOVE_CONSTANT = 0.3;
private static class Target
{
private final Location location;
@@ -48,18 +48,18 @@ public class Teleport implements Runnable
private long initY;
private long initZ;
private Target teleportTarget;
private Charge chargeFor;
private Trade chargeFor;
private final IEssentials ess;
private static final Logger logger = Logger.getLogger("Minecraft");
private void initTimer(long delay, Target target, Charge chargeFor)
private void initTimer(long delay, Target target, Trade chargeFor)
{
this.started = System.currentTimeMillis();
this.delay = delay;
this.health = user.getHealth();
this.initX = Math.round(user.getLocation().getX() * 10000);
this.initY = Math.round(user.getLocation().getY() * 10000);
this.initZ = Math.round(user.getLocation().getZ() * 10000);
this.initX = Math.round(user.getLocation().getX()*MOVE_CONSTANT);
this.initY = Math.round(user.getLocation().getY()*MOVE_CONSTANT);
this.initZ = Math.round(user.getLocation().getZ()*MOVE_CONSTANT);
this.teleportTarget = target;
this.chargeFor = chargeFor;
}
@@ -72,9 +72,9 @@ public class Teleport implements Runnable
cancel();
return;
}
if (Math.round(user.getLocation().getX() * 10000) != initX
|| Math.round(user.getLocation().getY() * 10000) != initY
|| Math.round(user.getLocation().getZ() * 10000) != initZ
if (Math.round(user.getLocation().getX()*MOVE_CONSTANT) != initX
|| Math.round(user.getLocation().getY()*MOVE_CONSTANT) != initY
|| Math.round(user.getLocation().getZ()*MOVE_CONSTANT) != initZ
|| user.getHealth() < health)
{ // user moved, cancel teleport
cancel(true);
@@ -101,11 +101,7 @@ public class Teleport implements Runnable
}
catch (Throwable ex)
{
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
if (ess.getSettings().isDebug())
{
logger.log(Level.WARNING, ex.getMessage(), ex);
}
ess.showError(user.getBase(), ex, "teleport");
}
return;
}
@@ -122,12 +118,12 @@ public class Teleport implements Runnable
this.ess = ess;
}
public void respawn(Spawn spawn, Charge chargeFor) throws Exception
public void respawn(Spawn spawn, Trade chargeFor) throws Exception
{
teleport(new Target(spawn.getSpawn(user.getGroup())), chargeFor);
}
public void warp(String warp, Charge chargeFor) throws Exception
public void warp(String warp, Trade chargeFor) throws Exception
{
Location loc = ess.getWarps().getWarp(warp);
teleport(new Target(loc), chargeFor);
@@ -181,17 +177,17 @@ public class Teleport implements Runnable
cancel(false);
}
public void teleport(Location loc, Charge chargeFor) throws Exception
public void teleport(Location loc, Trade chargeFor) throws Exception
{
teleport(new Target(loc), chargeFor);
}
public void teleport(Entity entity, Charge chargeFor) throws Exception
public void teleport(Entity entity, Trade chargeFor) throws Exception
{
teleport(new Target(entity), chargeFor);
}
private void teleport(Target target, Charge chargeFor) throws Exception
private void teleport(Target target, Trade chargeFor) throws Exception
{
double delay = ess.getSettings().getTeleportDelay();
@@ -234,20 +230,23 @@ public class Teleport implements Runnable
now(new Target(loc));
}
public void now(Location loc, Charge chargeFor) throws Exception
public void now(Location loc, Trade chargeFor) throws Exception
{
cooldown(false);
chargeFor.charge(user);
now(new Target(loc));
}
public void now(Entity entity) throws Exception
public void now(Entity entity, boolean cooldown) throws Exception
{
cooldown(false);
if (cooldown)
{
cooldown(false);
}
now(new Target(entity));
}
public void back(Charge chargeFor) throws Exception
public void back(Trade chargeFor) throws Exception
{
teleport(new Target(user.getLastLocation()), chargeFor);
}
@@ -257,12 +256,12 @@ public class Teleport implements Runnable
back(null);
}
public void home(Charge chargeFor) throws Exception
public void home(Trade chargeFor) throws Exception
{
home(user, chargeFor);
}
public void home(IUser user, Charge chargeFor) throws Exception
public void home(IUser user, Trade chargeFor) throws Exception
{
Location loc = user.getHome(this.user.getLocation());
if (loc == null)

View File

@@ -0,0 +1,243 @@
package com.earth2me.essentials;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.util.Date;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;
public class Trade
{
private final transient String command;
private final transient Double money;
private final transient ItemStack itemStack;
private final transient IEssentials ess;
public Trade(final String command, final IEssentials ess)
{
this(command, null, null, ess);
}
public Trade(final double money, final IEssentials ess)
{
this(null, money, null, ess);
}
public Trade(final ItemStack items, final IEssentials ess)
{
this(null, null, items, ess);
}
private Trade(final String command, final Double money, final ItemStack item, final IEssentials ess)
{
this.command = command;
this.money = money;
this.itemStack = item;
this.ess = ess;
}
public void isAffordableFor(final IUser user) throws ChargeException
{
final double mon = user.getMoney();
if (getMoney() != null
&& mon < getMoney()
&& getMoney() > 0
&& !user.isAuthorized("essentials.eco.loan"))
{
throw new ChargeException(Util.i18n("notEnoughMoney"));
}
if (getItemStack() != null
&& !InventoryWorkaround.containsItem(user.getInventory(), true, itemStack))
{
throw new ChargeException(Util.format("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase().replace("_", " ")));
}
if (command != null && !command.isEmpty()
&& !user.isAuthorized("essentials.nocommandcost.all")
&& !user.isAuthorized("essentials.nocommandcost." + command)
&& mon < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
&& 0 < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
&& !user.isAuthorized("essentials.eco.loan"))
{
throw new ChargeException(Util.i18n("notEnoughMoney"));
}
}
public void pay(final IUser user)
{
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())
{
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
}
user.updateInventory();
}
}
public void charge(final IUser user) throws ChargeException
{
if (getMoney() != null)
{
final double mon = user.getMoney();
if (mon < getMoney() && getMoney() > 0 && !user.isAuthorized("essentials.eco.loan"))
{
throw new ChargeException(Util.i18n("notEnoughMoney"));
}
user.takeMoney(getMoney());
}
if (getItemStack() != null)
{
if (!InventoryWorkaround.containsItem(user.getInventory(), true, itemStack))
{
throw new ChargeException(Util.format("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase().replace("_", " ")));
}
InventoryWorkaround.removeItem(user.getInventory(), true, getItemStack());
user.updateInventory();
}
if (command != null && !command.isEmpty()
&& !user.isAuthorized("essentials.nocommandcost.all")
&& !user.isAuthorized("essentials.nocommandcost." + command))
{
final double mon = user.getMoney();
final double cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
if (mon < cost && cost > 0 && !user.isAuthorized("essentials.eco.loan"))
{
throw new ChargeException(Util.i18n("notEnoughMoney"));
}
user.takeMoney(cost);
}
}
public Double getMoney()
{
return money;
}
public ItemStack getItemStack()
{
return itemStack;
}
private static FileWriter fw = null;
public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess)
{
if (!ess.getSettings().isEcoLogEnabled())
{
return;
}
if (fw == null)
{
try
{
fw = new FileWriter(new File(ess.getDataFolder(), "trade.log"), true);
}
catch (IOException ex)
{
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
}
}
StringBuilder sb = new StringBuilder();
sb.append(type).append(",").append(subtype).append(",").append(event).append(",\"");
sb.append(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(new Date()));
sb.append("\",\"");
if (sender != null)
{
sb.append(sender);
}
sb.append("\",");
if (charge == null)
{
sb.append("\"\",\"\",\"\"");
}
else
{
if (charge.getItemStack() != null)
{
sb.append(charge.getItemStack().getAmount()).append(",");
sb.append(charge.getItemStack().getType().toString()).append(",");
sb.append(charge.getItemStack().getDurability());
}
if (charge.getMoney() != null)
{
sb.append(charge.getMoney()).append(",");
sb.append("money").append(",");
sb.append(ess.getSettings().getCurrencySymbol());
}
}
sb.append(",\"");
if (receiver != null)
{
sb.append(receiver);
}
sb.append("\",");
if (pay == null)
{
sb.append("\"\",\"\",\"\"");
}
else
{
if (pay.getItemStack() != null)
{
sb.append(pay.getItemStack().getAmount()).append(",");
sb.append(pay.getItemStack().getType().toString()).append(",");
sb.append(pay.getItemStack().getDurability());
}
if (pay.getMoney() != null)
{
sb.append(pay.getMoney()).append(",");
sb.append("money").append(",");
sb.append(ess.getSettings().getCurrencySymbol());
}
}
if (loc == null)
{
sb.append(",\"\",\"\",\"\",\"\"");
}
else
{
sb.append(",\"");
sb.append(loc.getWorld().getName()).append("\",");
sb.append(loc.getBlockX()).append(",");
sb.append(loc.getBlockY()).append(",");
sb.append(loc.getBlockZ()).append(",");
}
sb.append("\n");
try
{
fw.write(sb.toString());
fw.flush();
}
catch (IOException ex)
{
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
}
}
public static void closeLog()
{
if (fw != null) {
try
{
fw.close();
}
catch (IOException ex)
{
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
}
fw = null;
}
}
}

View File

@@ -19,6 +19,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
private boolean teleportRequestHere;
private final Teleport teleport;
private long lastActivity;
private boolean hidden = false;
User(Player base, IEssentials ess)
{
@@ -34,7 +35,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
public boolean isAuthorized(IEssentialsCommand cmd)
{
return isAuthorized("essentials." + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
return isAuthorized(cmd, "essentials.");
}
public boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix)
{
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
}
public boolean isAuthorized(String node)
@@ -49,15 +55,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return false;
}
try
{
return com.nijikokun.bukkit.Permissions.Permissions.Security.permission(base, node);
}
catch (Throwable ex)
{
String[] cmds = node.split("\\.", 2);
return !ess.getSettings().isCommandRestricted(cmds[cmds.length - 1]);
}
return ess.getPermissionsHandler().hasPermission(this, node);
}
public void healCooldown() throws Exception
@@ -79,13 +77,22 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
public void giveMoney(double value)
{
giveMoney(value, null);
}
public void giveMoney(double value, CommandSender initiator)
{
if (value == 0)
{
return;
}
setMoney(getMoney() + value);
sendMessage(Util.format("addedToAccount", Util.formatCurrency(value)));
sendMessage(Util.format("addedToAccount", Util.formatCurrency(value, ess)));
if (initiator != null)
{
initiator.sendMessage((Util.format("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())));
}
}
public void payUser(User reciever, double value) throws Exception
@@ -102,19 +109,28 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
setMoney(getMoney() - value);
reciever.setMoney(reciever.getMoney() + value);
sendMessage(Util.format("moneySentTo", Util.formatCurrency(value), reciever.getDisplayName()));
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value), getDisplayName()));
sendMessage(Util.format("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
}
}
public void takeMoney(double value)
{
takeMoney(value, null);
}
public void takeMoney(double value, CommandSender initiator)
{
if (value == 0)
{
return;
}
setMoney(getMoney() - value);
sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value)));
sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value, ess)));
if (initiator != null)
{
initiator.sendMessage((Util.format("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())));
}
}
public boolean canAfford(double cost)
@@ -125,7 +141,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
public void dispose()
{
this.base = new OfflinePlayer(getName());
this.base = new OfflinePlayer(getName(), ess);
}
public boolean getJustPortaled()
@@ -160,8 +176,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
return false;
}
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User) o).getDisplayName()));
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)o).getDisplayName()));
}
@Override
@@ -208,26 +224,42 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
public String getNick()
{
String nickname = getNickname();
if (ess.getSettings().isCommandDisabled("nick") || nickname == null || nickname.isEmpty() || nickname.equals(getName()))
final StringBuilder nickname = new StringBuilder();
final String nick = getNickname();
if (ess.getSettings().isCommandDisabled("nick") || nick == null || nick.isEmpty() || nick.equals(getName()))
{
nickname = getName();
nickname.append(getName());
}
else
{
nickname = ess.getSettings().getNicknamePrefix() + nickname;
nickname.append(ess.getSettings().getNicknamePrefix()).append(nick);
}
if (isOp())
{
try
{
nickname = ess.getSettings().getOperatorColor().toString() + nickname + "§f";
nickname.insert(0, ess.getSettings().getOperatorColor().toString());
nickname.append("§f");
}
catch(Exception e)
catch (Exception e)
{
}
}
return nickname;
if (ess.getSettings().addPrefixSuffix())
{
final String prefix = ess.getPermissionsHandler().getPrefix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
final String suffix = ess.getPermissionsHandler().getSuffix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
nickname.insert(0, prefix);
nickname.append(suffix);
if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
{
nickname.append("§f");
}
}
return nickname.toString();
}
public Teleport getTeleport()
@@ -248,19 +280,20 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
@Override
public double getMoney()
{
if (ess.isRegisterFallbackEnabled() && ess.getPaymentMethod().hasMethod())
if (ess.getPaymentMethod().hasMethod())
{
try
{
Method method = ess.getPaymentMethod().getMethod();
if (!method.hasAccount(this.getName())) {
if (!method.hasAccount(this.getName()))
{
throw new Exception();
}
Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
return account.balance();
}
catch (Throwable ex)
{
{
}
}
return super.getMoney();
@@ -269,12 +302,13 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
@Override
public void setMoney(double value)
{
if (ess.isRegisterFallbackEnabled() && ess.getPaymentMethod().hasMethod())
if (ess.getPaymentMethod().hasMethod())
{
try
{
Method method = ess.getPaymentMethod().getMethod();
if (!method.hasAccount(this.getName())) {
if (!method.hasAccount(this.getName()))
{
throw new Exception();
}
Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
@@ -286,4 +320,29 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
super.setMoney(value);
}
}
@Override
public void setAfk(boolean set)
{
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
super.setAfk(set);
}
@Override
public boolean toggleAfk()
{
boolean now = super.toggleAfk();
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now);
return now;
}
public boolean isHidden()
{
return hidden;
}
public void setHidden(boolean hidden)
{
this.hidden = hidden;
}
}

View File

@@ -58,18 +58,20 @@ public abstract class UserData extends PlayerExtension implements IConf
isSocialSpyEnabled = _isSocialSpyEnabled();
isNPC = _isNPC();
}
private double money;
private double _getMoney() {
private double _getMoney()
{
double money = ess.getSettings().getStartingBalance();
if (config.hasProperty("money"))
{
return config.getDouble("money", ess.getSettings().getStartingBalance());
money = config.getDouble("money", money);
}
else
if (Math.abs(money) > ess.getSettings().getMaxMoney())
{
return ess.getSettings().getStartingBalance();
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
}
return money;
}
public double getMoney()
@@ -80,6 +82,10 @@ public abstract class UserData extends PlayerExtension implements IConf
public void setMoney(double value)
{
money = value;
if (Math.abs(money) > ess.getSettings().getMaxMoney())
{
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
}
config.setProperty("money", value);
config.save();
}
@@ -92,7 +98,7 @@ public abstract class UserData extends PlayerExtension implements IConf
}
return false;
}
public Location getHome(Location location)
{
if (!hasHome())
@@ -324,7 +330,7 @@ public abstract class UserData extends PlayerExtension implements IConf
private ItemStack[] _getSavedInventory()
{
int size = config.getInt("inventory.size", 0);
if (size < 1 || size > getInventory().getSize())
if (size < 1 || (getInventory() != null && size > getInventory().getSize()))
{
return null;
}
@@ -383,6 +389,7 @@ public abstract class UserData extends PlayerExtension implements IConf
setTeleportEnabled(ret);
return ret;
}
public boolean toggleSocialSpy()
{
boolean ret = !isSocialSpyEnabled();
@@ -622,7 +629,6 @@ public abstract class UserData extends PlayerExtension implements IConf
setAfk(ret);
return ret;
}
private boolean newplayer;
private boolean getNew()
@@ -641,7 +647,6 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("newplayer", set);
config.save();
}
private String geolocation;
private String _getGeoLocation()
@@ -668,38 +673,36 @@ public abstract class UserData extends PlayerExtension implements IConf
}
config.save();
}
private boolean isSocialSpyEnabled;
private boolean _isSocialSpyEnabled()
{
return config.getBoolean("socialspy", false);
}
public boolean isSocialSpyEnabled()
{
return isSocialSpyEnabled;
}
public void setSocialSpyEnabled(boolean status)
{
isSocialSpyEnabled = status;
config.setProperty("socialspy", status);
config.save();
}
private boolean isNPC;
private boolean _isNPC()
{
return config.getBoolean("npc", false);
}
public boolean isNPC()
{
return isNPC;
}
public void setNPC(boolean set)
{
isNPC = set;

View File

@@ -216,21 +216,21 @@ public class Util
return c.getTimeInMillis();
}
public static Location getSafeDestination(Location loc) throws Exception
public static Location getSafeDestination(final Location loc) throws Exception
{
if (loc == null)
if (loc == null || loc.getWorld() == null)
{
throw new Exception(Util.i18n("destinationNotSet"));
}
World world = loc.getWorld();
double x = Math.floor(loc.getX()) + 0.5;
double y = Math.floor(loc.getY());
double z = Math.floor(loc.getZ()) + 0.5;
final World world = loc.getWorld();
int x = loc.getBlockX();
int y = loc.getBlockY();
int z = loc.getBlockZ();
while (isBlockAboveAir(world, x, y, z))
{
y -= 1.0D;
if (y < 0.0D)
y -= 1;
if (y < 0)
{
throw new Exception(Util.i18n("holeInFloor"));
}
@@ -238,33 +238,33 @@ public class Util
while (isBlockUnsafe(world, x, y, z))
{
y += 1.0D;
if (y >= 110.0D)
y += 1;
if (y >= 127)
{
x += 1.0D;
x += 1;
break;
}
}
while (isBlockUnsafe(world, x, y, z))
{
y -= 1.0D;
if (y <= 1.0D)
y -= 1;
if (y <= 1)
{
y = 110.0D;
x += 1.0D;
y = 127;
x += 1;
}
}
return new Location(world, x, y, z, loc.getYaw(), loc.getPitch());
return new Location(world, x + 0.5D, y, z + 0.5D, loc.getYaw(), loc.getPitch());
}
private static boolean isBlockAboveAir(World world, double x, double y, double z)
private static boolean isBlockAboveAir(final World world, final int x, final int y, final int z)
{
return world.getBlockAt((int)Math.floor(x), (int)Math.floor(y - 1.0D), (int)Math.floor(z)).getType() == Material.AIR;
return world.getBlockAt(x, y - 1, z).getType() == Material.AIR;
}
public static boolean isBlockUnsafe(World world, double x, double y, double z)
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z)
{
Block below = world.getBlockAt((int)Math.floor(x), (int)Math.floor(y - 1.0D), (int)Math.floor(z));
final Block below = world.getBlockAt(x, y - 1, z);
if (below.getType() == Material.LAVA || below.getType() == Material.STATIONARY_LAVA)
{
return true;
@@ -275,8 +275,8 @@ public class Util
return true;
}
if ((world.getBlockAt((int)Math.floor(x), (int)Math.floor(y), (int)Math.floor(z)).getType() != Material.AIR)
|| (world.getBlockAt((int)Math.floor(x), (int)Math.floor(y + 1.0D), (int)Math.floor(z)).getType() != Material.AIR))
if ((world.getBlockAt(x, y, z).getType() != Material.AIR)
|| (world.getBlockAt(x, y + 1, z).getType() != Material.AIR))
{
return true;
}
@@ -284,9 +284,9 @@ public class Util
}
private static DecimalFormat df = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
public static String formatCurrency(double value)
public static String formatCurrency(final double value, final IEssentials ess)
{
String str = Essentials.getStatic().getSettings().getCurrencySymbol() + df.format(value);
String str = ess.getSettings().getCurrencySymbol() + df.format(value);
if (str.endsWith(".00"))
{
str = str.substring(0, str.length() - 3);
@@ -294,7 +294,7 @@ public class Util
return str;
}
public static double roundDouble(double d)
public static double roundDouble(final double d)
{
return Math.round(d * 100.0) / 100.0;
}
@@ -307,19 +307,21 @@ public class Util
private static class ConfigClassLoader extends ClassLoader
{
private final File dataFolder;
private final ClassLoader cl;
private final transient File dataFolder;
private final transient ClassLoader cl;
private final transient IEssentials ess;
public ConfigClassLoader(File dataFolder, ClassLoader cl)
public ConfigClassLoader(final ClassLoader cl, final IEssentials ess)
{
this.dataFolder = dataFolder;
this.ess = ess;
this.dataFolder = ess.getDataFolder();
this.cl = cl;
}
@Override
public URL getResource(String string)
public URL getResource(final String string)
{
File file = new File(dataFolder, string);
final File file = new File(dataFolder, string);
if (file.exists())
{
try
@@ -341,17 +343,18 @@ public class Util
}
@Override
public InputStream getResourceAsStream(String string)
public InputStream getResourceAsStream(final String string)
{
File file = new File(dataFolder, string);
final File file = new File(dataFolder, string);
if (file.exists())
{
BufferedReader br = null;
try
{
BufferedReader br = new BufferedReader(new FileReader(file));
String version = br.readLine();
br.close();
if (version == null || !version.equals("#version: " + Essentials.getStatic().getDescription().getVersion()))
br = new BufferedReader(new FileReader(file));
final String version = br.readLine();
if (version == null || !version.equals("#version: " + ess.getDescription().getVersion()))
{
logger.log(Level.WARNING, String.format("Translation file %s is not updated for Essentials version. Will use default.", file));
return cl.getResourceAsStream(string);
@@ -362,36 +365,49 @@ public class Util
{
return cl.getResourceAsStream(string);
}
finally
{
if (br != null)
{
try
{
br.close();
}
catch (IOException ex)
{
}
}
}
}
return cl.getResourceAsStream(string);
}
@Override
public Enumeration<URL> getResources(String string) throws IOException
public Enumeration<URL> getResources(final String string) throws IOException
{
return cl.getResources(string);
}
@Override
public Class<?> loadClass(String string) throws ClassNotFoundException
public Class<?> loadClass(final String string) throws ClassNotFoundException
{
return cl.loadClass(string);
}
@Override
public synchronized void setClassAssertionStatus(String string, boolean bln)
public synchronized void setClassAssertionStatus(final String string, final boolean bln)
{
cl.setClassAssertionStatus(string, bln);
}
@Override
public synchronized void setDefaultAssertionStatus(boolean bln)
public synchronized void setDefaultAssertionStatus(final boolean bln)
{
cl.setDefaultAssertionStatus(bln);
}
@Override
public synchronized void setPackageAssertionStatus(String string, boolean bln)
public synchronized void setPackageAssertionStatus(final String string, final boolean bln)
{
cl.setPackageAssertionStatus(string, bln);
}
@@ -420,7 +436,7 @@ public class Util
return mf.format(objects);
}
public static void updateLocale(String loc, File dataFolder)
public static void updateLocale(String loc, IEssentials ess)
{
if (loc == null || loc.isEmpty())
{
@@ -440,10 +456,27 @@ public class Util
currentLocale = new Locale(parts[0], parts[1], parts[2]);
}
logger.log(Level.INFO, String.format("Using locale %s", currentLocale.toString()));
bundle = ResourceBundle.getBundle("messages", currentLocale, new ConfigClassLoader(dataFolder, Util.class.getClassLoader()));
bundle = ResourceBundle.getBundle("messages", currentLocale, new ConfigClassLoader(Util.class.getClassLoader(), ess));
if (!bundle.keySet().containsAll(defaultBundle.keySet()))
{
logger.log(Level.WARNING, String.format("Translation file %s does not contain all translation keys.", currentLocale.toString()));
}
}
public static String joinList(Object... list)
{
final StringBuilder buf = new StringBuilder();
boolean first = true;
for (Object each : list)
{
if (!first)
{
buf.append(", ");
}
first = false;
buf.append(each);
}
return buf.toString();
}
}

View File

@@ -1,7 +1,7 @@
package com.earth2me.essentials.api;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.EssentialsConf;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.io.File;
@@ -9,6 +9,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.entity.Player;
/**
* Instead of using this api directly, we recommend to use the register plugin:
* http://bit.ly/RegisterMethod
@@ -19,10 +20,19 @@ public final class Economy
{
}
private static final Logger logger = Logger.getLogger("Minecraft");
private static IEssentials ess;
/**
* @param aEss the ess to set
*/
public static void setEss(IEssentials aEss)
{
ess = aEss;
}
private static void createNPCFile(String name)
{
File folder = new File(Essentials.getStatic().getDataFolder(), "userdata");
File folder = new File(ess.getDataFolder(), "userdata");
if (!folder.exists())
{
folder.mkdirs();
@@ -30,13 +40,13 @@ public final class Economy
EssentialsConf npcConfig = new EssentialsConf(new File(folder, Util.sanitizeFileName(name) + ".yml"));
npcConfig.load();
npcConfig.setProperty("npc", true);
npcConfig.setProperty("money", Essentials.getStatic().getSettings().getStartingBalance());
npcConfig.setProperty("money", ess.getSettings().getStartingBalance());
npcConfig.save();
}
private static void deleteNPC(String name)
{
File folder = new File(Essentials.getStatic().getDataFolder(), "userdata");
File folder = new File(ess.getDataFolder(), "userdata");
if (!folder.exists())
{
folder.mkdirs();
@@ -44,24 +54,27 @@ public final class Economy
File config = new File(folder, Util.sanitizeFileName(name) + ".yml");
EssentialsConf npcConfig = new EssentialsConf(config);
npcConfig.load();
if (npcConfig.hasProperty("npc") && npcConfig.getBoolean("npc", false)) {
if (!config.delete()) {
if (npcConfig.hasProperty("npc") && npcConfig.getBoolean("npc", false))
{
if (!config.delete())
{
logger.log(Level.WARNING, Util.format("deleteFileError", config));
}
ess.getAllUsers().remove(name.toLowerCase());
}
}
private static User getUserByName(String name)
{
User user;
Player player = Essentials.getStatic().getServer().getPlayer(name);
Player player = ess.getServer().getPlayer(name);
if (player != null)
{
user = Essentials.getStatic().getUser(player);
user = ess.getUser(player);
}
else
{
user = Essentials.getStatic().getOfflineUser(name);
user = ess.getOfflineUser(name);
}
return user;
}
@@ -75,7 +88,8 @@ public final class Economy
public static double getMoney(String name) throws UserDoesNotExistException
{
User user = getUserByName(name);
if (user == null) {
if (user == null)
{
throw new UserDoesNotExistException(name);
}
return user.getMoney();
@@ -91,7 +105,8 @@ public final class Economy
public static void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException
{
User user = getUserByName(name);
if (user == null) {
if (user == null)
{
throw new UserDoesNotExistException(name);
}
if (balance < 0.0 && !user.isAuthorized("essentials.eco.loan"))
@@ -113,7 +128,7 @@ public final class Economy
double result = getMoney(name) + amount;
setMoney(name, result);
}
/**
* Substracts money from the balance of a user
* @param name Name of the user
@@ -161,7 +176,7 @@ public final class Economy
*/
public static void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException
{
setMoney(name, Essentials.getStatic().getSettings().getStartingBalance());
setMoney(name, ess.getSettings().getStartingBalance());
}
/**
@@ -216,18 +231,19 @@ public final class Economy
*/
public static String format(double amount)
{
return Util.formatCurrency(amount);
return Util.formatCurrency(amount, ess);
}
/**
* Test if a player exists to avoid the UserDoesNotExistException
* @param name Name of the user
* @return true, if the user exists
*/
public static boolean playerExists(String name) {
public static boolean playerExists(String name)
{
return getUserByName(name) != null;
}
/**
* Test if a player is a npc
* @param name Name of the player
@@ -237,12 +253,13 @@ public final class Economy
public static boolean isNPC(String name) throws UserDoesNotExistException
{
User user = getUserByName(name);
if (user == null) {
if (user == null)
{
throw new UserDoesNotExistException(name);
}
return user.isNPC();
}
/**
* Creates dummy files for a npc, if there is no player yet with that name.
* @param name Name of the player
@@ -251,7 +268,8 @@ public final class Economy
public static boolean createNPC(String name)
{
User user = getUserByName(name);
if (user == null) {
if (user == null)
{
createNPCFile(name);
return true;
}
@@ -266,7 +284,8 @@ public final class Economy
public static void removeNPC(String name) throws UserDoesNotExistException
{
User user = getUserByName(name);
if (user == null) {
if (user == null)
{
throw new UserDoesNotExistException(name);
}
deleteNPC(name);

View File

@@ -17,11 +17,29 @@ public class Commandafk extends EssentialsCommand
{
charge(user);
if (args.length > 0 && user.isAuthorized("essentials.afk.others"))
{
User afkUser = ess.getUser(ess.getServer().matchPlayer(args[0]));
if (afkUser != null)
{
toggleAfk(afkUser);
}
}
else
{
toggleAfk(user);
}
}
private final void toggleAfk(User user)
{
if (!user.toggleAfk())
{
user.sendMessage(Util.i18n("markedAsNotAway"));
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
} else {
}
else
{
user.sendMessage(Util.i18n("markedAsAway"));
ess.broadcastMessage(user.getName(), Util.format("userIsAway", user.getDisplayName()));
}

View File

@@ -1,12 +1,10 @@
package com.earth2me.essentials.commands;
import net.minecraft.server.EntityTNTPrimed;
import net.minecraft.server.World;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.craftbukkit.CraftWorld;
import com.earth2me.essentials.User;
import com.earth2me.essentials.TargetBlock;
import org.bukkit.entity.TNTPrimed;
public class Commandantioch extends EssentialsCommand
@@ -17,17 +15,13 @@ public class Commandantioch extends EssentialsCommand
}
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
charge(user);
ess.broadcastMessage(user.getName(), "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
ess.broadcastMessage(user.getName(), "who being naughty in My sight, shall snuff it.");
Location loc = user.getLocation();
World world = ((CraftWorld)user.getWorld()).getHandle();
loc = new TargetBlock(user).getTargetBlock().getLocation();
EntityTNTPrimed tnt = new EntityTNTPrimed(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
world.addEntity(tnt);
world.makeSound(tnt, "random.fuse", 1.0F, 1.0F);
final Location loc = new TargetBlock(user).getTargetBlock().getLocation();
loc.getWorld().spawn(loc, TNTPrimed.class);
}
}

View File

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

View File

@@ -20,7 +20,7 @@ public class Commandbalance extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
sender.sendMessage(Util.format("balance", Util.formatCurrency(getPlayer(server, args, 0).getMoney())));
sender.sendMessage(Util.format("balance", Util.formatCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
}
@Override
@@ -31,7 +31,7 @@ public class Commandbalance extends EssentialsCommand
|| !(user.isAuthorized("essentials.balance.others")
|| user.isAuthorized("essentials.balance.other"))
? user
: getPlayer(server, args, 0)).getMoney();
user.sendMessage(Util.format("balance", Util.formatCurrency(bal)));
: getPlayer(server, args, 0, true)).getMoney();
user.sendMessage(Util.format("balance", Util.formatCurrency(bal, ess)));
}
}

View File

@@ -0,0 +1,67 @@
package com.earth2me.essentials.commands;
import java.util.Map.Entry;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.command.CommandSender;
public class Commandbalancetop extends EssentialsCommand
{
public Commandbalancetop()
{
super("balancetop");
}
@Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
int max = 10;
if (args.length > 0)
{
try
{
if (Integer.parseInt(args[0]) < 10)
{
max = Integer.parseInt(args[0]);
}
}
catch (NumberFormatException ex)
{
//catch it because they tried to enter a string not number.
}
}
final Map<User, Double> balances = new HashMap<User, Double>();
for (User u : ess.getAllUsers().values())
{
balances.put(u, u.getMoney());
}
final List<Map.Entry<User, Double>> sortedEntries = new ArrayList<Map.Entry<User, Double>>(balances.entrySet());
Collections.sort(sortedEntries, new Comparator<Map.Entry<User, Double>>()
{
public int compare(final Entry<User, Double> entry1, final Entry<User, Double> entry2)
{
return -entry1.getValue().compareTo(entry2.getValue());
}
});
int count = 0;
sender.sendMessage(Util.format("balanceTop", max));
for (Map.Entry<User, Double> entry : sortedEntries)
{
if (count == max)
{
break;
}
sender.sendMessage(entry.getKey().getDisplayName() + ", " + Util.formatCurrency(entry.getValue(), ess));
count++;
}
}
}

View File

@@ -1,10 +1,11 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.CraftServer;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.entity.Player;
public class Commandban extends EssentialsCommand
@@ -15,31 +16,50 @@ public class Commandban 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();
}
User p = null;
if (server.matchPlayer(args[0]).isEmpty())
final User player = getPlayer(server, args, 0, true);
if (player.getBase() instanceof OfflinePlayer)
{
((CraftServer)server).getHandle().a(args[0]);
sender.sendMessage(Util.format("playerBanned",args[0]));
if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
{
sender.sendMessage(Util.i18n("banExempt"));
return;
}
}
else
{
p = ess.getUser(server.matchPlayer(args[0]).get(0));
String banReason = Util.i18n("defaultBanReason");
if(args.length > 1) {
banReason = getFinalArg(args, 1);
p.setBanReason(commandLabel);
if (player.isAuthorized("essentials.ban.exempt"))
{
sender.sendMessage(Util.i18n("banExempt"));
return;
}
}
String banReason;
if (args.length > 1)
{
banReason = getFinalArg(args, 1);
player.setBanReason(commandLabel);
}
else
{
banReason = Util.i18n("defaultBanReason");
}
player.kickPlayer(banReason);
ess.getBans().banByName(player.getName());
for(Player p : server.getOnlinePlayers())
{
User u = ess.getUser(p);
if(u.isAuthorized("essentials.ban.notify"))
{
p.sendMessage(Util.format("playerBanned", player.getName(), banReason));
}
p.kickPlayer(banReason);
((CraftServer)server).getHandle().a(p.getName());
sender.sendMessage(Util.format("playerBanned", p.getName()));
}
ess.loadBanList();
}
}

View File

@@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.CraftServer;
public class Commandbanip extends EssentialsCommand
@@ -21,9 +20,7 @@ public class Commandbanip extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
((CraftServer)server).getHandle().c(args[0]);
ess.getBans().banByIp(args[0]);
sender.sendMessage(Util.i18n("banIpAddress"));
ess.loadBanList();
}
}

View File

@@ -17,7 +17,7 @@ public class Commandbigtree extends EssentialsCommand
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
TreeType tree = TreeType.TREE;
TreeType tree;
if (args.length > 0 && args[0].equalsIgnoreCase("redwood"))
{
tree = TreeType.TALL_REDWOOD;
@@ -36,7 +36,7 @@ public class Commandbigtree extends EssentialsCommand
double z = user.getLocation().getZ();
// offset tree in direction player is facing
int r = (int)user.getCorrectedYaw();
final int r = (int)user.getCorrectedYaw();
if (r < 68 || r > 292) // north
{
x -= 3.0D;
@@ -54,8 +54,8 @@ public class Commandbigtree extends EssentialsCommand
z += 3.0D;
}
Location safeLocation = Util.getSafeDestination(new Location(user.getWorld(), x, y, z));
boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
final Location safeLocation = Util.getSafeDestination(new Location(user.getWorld(), x, y, z));
final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
if (success)
{
charge(user);

View File

@@ -6,7 +6,6 @@ import org.bukkit.entity.Player;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.List;
import org.bukkit.ChatColor;
public class Commandclearinventory extends EssentialsCommand

View File

@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.Essentials;
import org.bukkit.entity.Player;
import com.earth2me.essentials.User;
@@ -56,28 +55,24 @@ public class Commandeco extends EssentialsCommand
}
else
{
for (Player p : server.matchPlayer(args[1]))
User u = getPlayer(server, args, 1, true);
switch (cmd)
{
User u = ess.getUser(p);
switch (cmd)
{
case GIVE:
u.giveMoney(amount);
break;
case GIVE:
u.giveMoney(amount, sender);
break;
case TAKE:
u.takeMoney(amount);
break;
case TAKE:
u.takeMoney(amount, sender);
break;
case RESET:
u.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
break;
}
case RESET:
u.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
break;
}
}
}
private enum EcoCommands
{
GIVE, TAKE, RESET

View File

@@ -1,8 +1,14 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandessentials extends EssentialsCommand
@@ -11,12 +17,102 @@ public class Commandessentials extends EssentialsCommand
{
super("essentials");
}
private transient int taskid;
private final transient Map<Player, Block> noteBlocks = new HashMap<Player, Block>();
@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
{
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
noteMap.put("1F#", (byte)0x0);
noteMap.put("1G", (byte)0x1);
noteMap.put("1G#", (byte)0x2);
noteMap.put("1A", (byte)0x3);
noteMap.put("1A#", (byte)0x4);
noteMap.put("1B", (byte)0x5);
noteMap.put("1C", (byte)0x6);
noteMap.put("1C#", (byte)0x7);
noteMap.put("1D", (byte)0x8);
noteMap.put("1D#", (byte)0x9);
noteMap.put("1E", (byte)0xA);
noteMap.put("1F", (byte)0xB);
noteMap.put("2F#", (byte)(0x0 + 0xC));
noteMap.put("2G", (byte)(0x1 + 0xC));
noteMap.put("2G#", (byte)(0x2 + 0xC));
noteMap.put("2A", (byte)(0x3 + 0xC));
noteMap.put("2A#", (byte)(0x4 + 0xC));
noteMap.put("2B", (byte)(0x5 + 0xC));
noteMap.put("2C", (byte)(0x6 + 0xC));
noteMap.put("2C#", (byte)(0x7 + 0xC));
noteMap.put("2D", (byte)(0x8 + 0xC));
noteMap.put("2D#", (byte)(0x9 + 0xC));
noteMap.put("2E", (byte)(0xA + 0xC));
noteMap.put("2F", (byte)(0xB + 0xC));
if (args.length > 0 && args[0].equalsIgnoreCase("nya"))
{
if (!noteBlocks.isEmpty())
{
return;
}
final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1B,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,";
final String[] tune = tuneStr.split(",");
for (Player player : server.getOnlinePlayers())
{
final Location loc = player.getLocation();
loc.add(0, 3, 0);
while (loc.getBlockY() < player.getLocation().getBlockY() + 10 && loc.getBlock().getTypeId() != 0)
{
loc.add(0, 1, 0);
}
if (loc.getBlock().getTypeId() == 0)
{
noteBlocks.put(player, loc.getBlock());
loc.getBlock().setType(Material.NOTE_BLOCK);
}
}
taskid = ess.scheduleSyncRepeatingTask(new Runnable()
{
int i = 0;
public void run()
{
final String note = tune[i];
i++;
if (i >= tune.length)
{
Commandessentials.this.stopTune();
}
if (note.isEmpty())
{
return;
}
Map<Player, Block> noteBlocks = Commandessentials.this.noteBlocks;
for (Player player : server.getOnlinePlayers())
{
Block block = noteBlocks.get(player);
if (block == null)
{
continue;
}
player.playNote(block.getLocation(), (byte)0, noteMap.get(note));
}
}
}, 20, 2);
return;
}
ess.reload();
charge(sender);
sender.sendMessage(Util.format("essentialsReload", ess.getDescription().getVersion()));
}
private void stopTune()
{
ess.getScheduler().cancelTask(taskid);
for (Block block : noteBlocks.values())
{
block.setType(Material.AIR);
}
noteBlocks.clear();
}
}

View File

@@ -0,0 +1,24 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.entity.Fireball;
import org.bukkit.util.Vector;
public class Commandfireball extends EssentialsCommand
{
public Commandfireball()
{
super("fireball");
}
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
charge(user);
final Vector direction = user.getEyeLocation().getDirection().multiply(2);
user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), Fireball.class);
}
}

View File

@@ -18,7 +18,8 @@ public class Commandgc extends EssentialsCommand
{
charge(sender);
sender.sendMessage(Util.format("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
sender.sendMessage(Util.format("gcmin", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
sender.sendMessage(Util.format("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
sender.sendMessage(Util.format("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
for (World w : server.getWorlds())
{
sender.sendMessage(

View File

@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.ItemDb;
import com.earth2me.essentials.User;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -25,7 +24,7 @@ public class Commandgive extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
ItemStack stack = ItemDb.get(args[1]);
ItemStack stack = ess.getItemDb().get(args[1]);
String itemname = stack.getType().toString().toLowerCase().replace("_", "");
if (sender instanceof Player

View File

@@ -43,6 +43,10 @@ public class Commandgod extends EssentialsCommand
for (Player p : server.matchPlayer(name))
{
User u = ess.getUser(p);
if (u.isHidden())
{
continue;
}
boolean enabled = u.toggleGodModeEnabled();
u.sendMessage(Util.format("godMode", (enabled ? Util.i18n("enabled") : Util.i18n("disabled"))));
sender.sendMessage(Util.format("godMode",Util.format(enabled ? "godEnabledFor": "godDisabledFor", p.getDisplayName())));

View File

@@ -53,13 +53,17 @@ public class Commandheal extends EssentialsCommand
private void healOtherPlayers(Server server, CommandSender sender, String name)
{
List<Player> players = server.matchPlayer(name);
if(players.isEmpty())
if (players.isEmpty())
{
sender.sendMessage(Util.i18n("playerNotFound"));
return;
}
for (Player p : players)
{
if (ess.getUser(p).isHidden())
{
continue;
}
p.setHealth(20);
sender.sendMessage(Util.format("healOther", p.getDisplayName()));
}

View File

@@ -30,24 +30,44 @@ public class Commandhelp extends EssentialsCommand
@Override
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
int page;
int page = 1;
String match = "";
try
{
page = args.length > 0 ? Integer.parseInt(args[0]) : 1;
if (args.length > 0)
{
match = args[0].toLowerCase();
page = Integer.parseInt(args[args.length - 1]);
if (args.length == 1)
{
match = "";
}
}
}
catch (Exception ex)
{
page = 1;
if (args.length == 1)
{
match = args[0].toLowerCase();
}
}
List<String> lines = getHelpLines(user);
int start = (page - 1) * 9;
int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
user.sendMessage(Util.format("helpPages", page, pages));
for (int i = start; i < lines.size() && i < start + 9; i++)
List<String> lines = getHelpLines(user, match);
if (lines.size() > 0)
{
user.sendMessage(lines.get(i));
int start = (page - 1) * 9;
int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
user.sendMessage(Util.format("helpPages", page, pages));
for (int i = start; i < lines.size() && i < start + 9; i++)
{
user.sendMessage(lines.get(i));
}
}
else
{
user.sendMessage(Util.i18n("noHelpFound"));
}
}
@@ -58,13 +78,13 @@ public class Commandhelp extends EssentialsCommand
}
@SuppressWarnings("CallToThreadDumpStack")
private List<String> getHelpLines(User user) throws Exception
private List<String> getHelpLines(User user, String match) throws Exception
{
List<String> retval = new ArrayList<String>();
File helpFile = new File(ess.getDataFolder(), "help_"+Util.sanitizeFileName(user.getName()) +".txt");
File helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getName()) + ".txt");
if (!helpFile.exists())
{
helpFile = new File(ess.getDataFolder(), "help_"+Util.sanitizeFileName(user.getGroup()) +".txt");
helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getGroup()) + ".txt");
}
if (!helpFile.exists())
{
@@ -73,8 +93,9 @@ public class Commandhelp extends EssentialsCommand
if (helpFile.exists())
{
final BufferedReader bufferedReader = new BufferedReader(new FileReader(helpFile));
try {
try
{
while (bufferedReader.ready())
{
final String line = bufferedReader.readLine();
@@ -98,6 +119,12 @@ public class Commandhelp extends EssentialsCommand
final HashMap<String, HashMap<String, String>> cmds = (HashMap<String, HashMap<String, String>>)desc.getCommands();
for (Entry<String, HashMap<String, String>> k : cmds.entrySet())
{
if ((!match.equalsIgnoreCase("")) && (!k.getKey().toLowerCase().contains(match))
&& (!k.getValue().get("description").toLowerCase().contains(match)))
{
continue;
}
if (p.getDescription().getName().toLowerCase().contains("essentials"))
{
final String node = "essentials." + k.getKey();
@@ -119,9 +146,19 @@ public class Commandhelp extends EssentialsCommand
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
}
}
else if (value.containsKey("permissions") && value.get("permissions") != null && !(value.get("permissions").equals("")))
{
if (user.isAuthorized(value.get("permissions")))
{
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
}
}
else
{
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
if (!ess.getSettings().hidePermissionlessHelp())
{
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
}
}
}
@@ -136,7 +173,7 @@ public class Commandhelp extends EssentialsCommand
{
if (!reported)
{
logger.log(Level.WARNING, "Error getting help for:" + pluginName, ex);
logger.log(Level.WARNING, Util.format("commandHelpFailedForPlugin", pluginName), ex);
}
reported = true;
continue;

View File

@@ -4,6 +4,7 @@ import org.bukkit.Server;
import org.bukkit.entity.Player;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.logging.Level;
public class Commandhelpop extends EssentialsCommand
@@ -22,6 +23,8 @@ public class Commandhelpop extends EssentialsCommand
}
charge(user);
final String message = Util.format("helpOp", user.getDisplayName(), getFinalArg(args, 0));
logger.log(Level.INFO, message);
for (Player p : server.getOnlinePlayers())
{
User u = ess.getUser(p);
@@ -29,7 +32,7 @@ public class Commandhelpop extends EssentialsCommand
{
continue;
}
u.sendMessage(Util.format("helpOp", user.getDisplayName(), getFinalArg(args, 0)));
u.sendMessage(message);
}
}
}

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Charge;
import com.earth2me.essentials.Trade;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@@ -16,7 +16,7 @@ public class Commandhome extends EssentialsCommand
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
Charge charge = new Charge(this.getName(), ess);
Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
if(args.length > 0 && user.isAuthorized("essentials.home.others"))
{

View File

@@ -1,10 +1,8 @@
package com.earth2me.essentials.commands;
import org.bukkit.Server;
import com.earth2me.essentials.ItemDb;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@@ -23,7 +21,7 @@ public class Commanditem extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
ItemStack stack = ItemDb.get(args[0]);
ItemStack stack = ess.getItemDb().get(args[0]);
String itemname = stack.getType().toString().toLowerCase().replace("_", "");
if (ess.getSettings().permissionBasedItemSpawn()

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Charge;
import com.earth2me.essentials.Trade;
import org.bukkit.Location;
import org.bukkit.Server;
import com.earth2me.essentials.TargetBlock;
@@ -36,7 +36,7 @@ public class Commandjump extends EssentialsCommand
throw new Exception(Util.i18n("jumpError"), ex);
}
Charge charge = new Charge(this.getName(), ess);
Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
user.getTeleport().teleport(loc, charge);
}

View File

@@ -4,7 +4,6 @@ import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.ChatColor;
public class Commandkick extends EssentialsCommand
@@ -13,7 +12,7 @@ public class Commandkick extends EssentialsCommand
{
super("kick");
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
@@ -21,19 +20,16 @@ public class Commandkick extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
User u;
try
User u = getPlayer(server, args, 0);
if (u.isAuthorized("essentials.kick.exempt"))
{
u = ess.getUser(server.matchPlayer(args[0]).get(0));
}
catch (Throwable ex)
{
sender.sendMessage(Util.i18n("playerNotFound"));
sender.sendMessage(Util.i18n("kickExempt"));
return;
}
charge(sender);
u.kickPlayer(args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault"));
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault");
u.kickPlayer(kickReason);
server.broadcastMessage(Util.format("playerKicked", u.getName(), kickReason));
}
}

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Charge;
import com.earth2me.essentials.Trade;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
@@ -109,7 +109,7 @@ public class Commandkit extends EssentialsCommand
items = (List<String>)kit;
}
Charge charge = new Charge("kit-" + kitName, ess);
Trade charge = new Trade("kit-" + kitName, ess);
try
{
charge.isAffordableFor(user);

View File

@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.Essentials;
import org.bukkit.entity.Player;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@@ -25,9 +24,33 @@ public class Commandlist extends EssentialsCommand
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
boolean showhidden = false;
if (sender instanceof Player)
{
if (ess.getUser(sender).isAuthorized("essentials.list.hidden"))
{
showhidden = true;
}
}
else
{
showhidden = true;
}
int playerHidden = 0;
for (Player p : server.getOnlinePlayers())
{
if (ess.getUser(p).isHidden())
{
playerHidden++;
}
}
charge(sender);
StringBuilder online = new StringBuilder();
online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length);
online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length - playerHidden);
if (showhidden && playerHidden > 0)
{
online.append(ChatColor.GRAY).append("/").append(playerHidden);
}
online.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(server.getMaxPlayers());
online.append(ChatColor.BLUE).append(" players online.");
sender.sendMessage(online.toString());
@@ -38,6 +61,10 @@ public class Commandlist extends EssentialsCommand
for (Player p : server.getOnlinePlayers())
{
User u = ess.getUser(p);
if (u.isHidden() && !showhidden)
{
continue;
}
String group = u.getGroup();
List<User> list = sort.get(group);
if (list == null)
@@ -70,7 +97,12 @@ public class Commandlist extends EssentialsCommand
{
groupString.append("§7[AFK]§f");
}
if (user.isHidden())
{
groupString.append("§7[HIDDEN]§f");
}
groupString.append(user.getDisplayName());
groupString.append("§f");
}
sender.sendMessage(groupString.toString());
}
@@ -80,7 +112,12 @@ public class Commandlist extends EssentialsCommand
List<User> users = new ArrayList<User>();
for (Player p : server.getOnlinePlayers())
{
users.add(ess.getUser(p));
final User u = ess.getUser(p);
if (u.isHidden() && !showhidden)
{
continue;
}
users.add(u);
}
Collections.sort(users);
@@ -101,7 +138,12 @@ public class Commandlist extends EssentialsCommand
{
onlineUsers.append("§7[AFK]§f");
}
if (user.isHidden())
{
onlineUsers.append("§7[HIDDEN]§f");
}
onlineUsers.append(user.getDisplayName());
onlineUsers.append("§f");
}
sender.sendMessage(onlineUsers.toString());
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.Server;
import org.bukkit.entity.Player;
import com.earth2me.essentials.Console;
import com.earth2me.essentials.IReplyTo;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.command.CommandSender;
@@ -47,12 +48,28 @@ public class Commandmsg extends EssentialsCommand
sender.sendMessage(Util.i18n("playerNotFound"));
return;
}
int i = 0;
for (Player p : matches)
{
final User u = ess.getUser(p);
if (u.isHidden())
{
i++;
}
}
if (i == matches.size())
{
sender.sendMessage(Util.i18n("playerNotFound"));
return;
}
charge(sender);
for (Player p : matches)
{
{
sender.sendMessage(Util.format("msgFormat", translatedMe, p.getDisplayName(), message));
if (sender instanceof Player && ess.getUser(p).isIgnoredPlayer(((Player)sender).getName()))
final User u = ess.getUser(p);
if (sender instanceof Player && (u.isIgnoredPlayer(((Player)sender).getName()) || u.isHidden()))
{
continue;
}

View File

@@ -21,7 +21,12 @@ public class Commandmute extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
User p = getPlayer(server, args, 0);
User p = getPlayer(server, args, 0, true);
if (!p.isMuted() && p.isAuthorized("essentials.mute.exempt"))
{
sender.sendMessage(Util.i18n("muteExempt"));
return;
}
long muteTimestamp = 0;
if (args.length > 1)
{
@@ -30,13 +35,18 @@ public class Commandmute extends EssentialsCommand
}
p.setMuteTimeout(muteTimestamp);
charge(sender);
boolean muted = p.toggleMuted();
sender.sendMessage(
p.toggleMuted()
muted
? (muteTimestamp > 0
? Util.format("mutedPlayerFor", p.getDisplayName(), Util.formatDateDiff(muteTimestamp))
: Util.format("mutedPlayer", p.getDisplayName()))
: Util.format("unmutedPlayer", p.getDisplayName()));
p.sendMessage(
muted
? (muteTimestamp > 0
? Util.format("playerMutedFor", Util.formatDateDiff(muteTimestamp))
: Util.i18n("playerMuted"))
: Util.i18n("playerUnmuted"));
}
}

View File

@@ -0,0 +1,58 @@
package com.earth2me.essentials.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
public class Commandnuke extends EssentialsCommand
{
public Commandnuke()
{
super("nuke");
}
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException
{
List<Player> targets;
if (args.length > 0)
{
targets = new ArrayList<Player>();
int pos = 0;
for (String arg : args)
{
targets.add(getPlayer(server, args, pos));
pos++;
}
}
else
{
targets = Arrays.asList(server.getOnlinePlayers());
}
ess.getTNTListener().enable();
for (Player player : targets)
{
if (player == null) {
continue;
}
player.sendMessage("May death rain upon them");
final Location loc = player.getLocation();
final World world = loc.getWorld();
for (int x = -10; x <= 10; x += 5)
{
for (int z = -10; z <= 10; z += 5)
{
final Location tntloc = new Location(world, loc.getBlockX() + x, 127, loc.getBlockZ() + z);
final TNTPrimed tnt = world.spawn(tntloc, TNTPrimed.class);
}
}
}
}
}

View File

@@ -25,6 +25,10 @@ public class Commandpay extends EssentialsCommand
for (Player p : server.matchPlayer(args[0]))
{
User u = ess.getUser(p);
if (u.isHidden())
{
continue;
}
user.payUser(u, amount);
}
}

View File

@@ -4,6 +4,7 @@ import org.bukkit.Server;
import org.bukkit.entity.Player;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.ChatColor;
public class Commandrealname extends EssentialsCommand
@@ -20,15 +21,19 @@ public class Commandrealname extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
String whois = args[0].toLowerCase();
final String whois = args[0].toLowerCase();
charge(user);
for (Player p : server.getOnlinePlayers())
{
User u = ess.getUser(p);
String dn = u.getDisplayName().toLowerCase();
if (!whois.equals(dn)
&& !whois.equals(ess.getSettings().getNicknamePrefix() + dn)
&& !whois.equals(u.getName().toLowerCase()))
final User u = ess.getUser(p);
if (u.isHidden())
{
continue;
}
final String displayName = ChatColor.stripColor(u.getDisplayName()).toLowerCase();
if (!whois.equals(displayName)
&& !displayName.equals(ChatColor.stripColor(ess.getSettings().getNicknamePrefix()) + whois)
&& !whois.equalsIgnoreCase(u.getName()))
{
continue;
}

View File

@@ -1,9 +1,8 @@
package com.earth2me.essentials.commands;
import org.bukkit.Server;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.InventoryWorkaround;
import com.earth2me.essentials.ItemDb;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.logging.Level;
@@ -68,7 +67,7 @@ public class Commandsell extends EssentialsCommand
}
if (is == null)
{
is = ItemDb.get(args[0]);
is = ess.getItemDb().get(args[0]);
}
sellItem(user, is, args, false);
}
@@ -151,11 +150,13 @@ public class Commandsell extends EssentialsCommand
}
charge(user);
InventoryWorkaround.removeItem(user.getInventory(), true, new ItemStack(is.getType(), amount, is.getDurability()));
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);
user.giveMoney(worth * amount);
user.sendMessage(Util.format("itemSold", Util.formatCurrency(worth * amount), amount, Util.formatCurrency(worth)));
logger.log(Level.INFO, Util.format("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(), Util.formatCurrency(worth * amount), amount, Util.formatCurrency(worth)));
user.sendMessage(Util.format("itemSold", Util.formatCurrency(worth * amount, ess), amount, 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

@@ -11,12 +11,35 @@ public class Commandsethome extends EssentialsCommand
{
super("sethome");
}
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
user.setHome(args.length > 0 && args[0].equalsIgnoreCase("default"));
if (args.length > 0)
{
if (args.length < 2)
{
user.setHome(args[0].equalsIgnoreCase("default"));
}
else
{
if (user.isAuthorized("essentials.sethome.others"))
{
User usersHome = ess.getUser(ess.getServer().getPlayer(args[0]));
if(usersHome == null)
{
usersHome = ess.getOfflineUser(args[0]);
}
usersHome.setHome(user.getLocation(), args[1].equalsIgnoreCase("default"));
}
}
}
else
{
user.setHome(false);
}
charge(user);
user.sendMessage(Util.i18n("homeSet"));
}
}

View File

@@ -1,7 +1,6 @@
package com.earth2me.essentials.commands;
import org.bukkit.Server;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@@ -16,6 +15,7 @@ public class Commandsetjail extends EssentialsCommand
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();

View File

@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import org.bukkit.Location;
import org.bukkit.Server;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;

View File

@@ -1,8 +1,6 @@
package com.earth2me.essentials.commands;
import org.bukkit.Server;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.ItemDb;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.inventory.ItemStack;
@@ -23,7 +21,7 @@ public class Commandsetworth extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
ItemStack stack = ItemDb.get(args[0]);
ItemStack stack = ess.getItemDb().get(args[0]);
charge(user);
ess.getWorth().setPrice(stack, Double.parseDouble(args[1]));
user.sendMessage(Util.i18n("worthSet"));

View File

@@ -5,7 +5,7 @@ import com.earth2me.essentials.Util;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.block.CraftCreatureSpawner;
import org.bukkit.entity.CreatureType;
@@ -19,12 +19,12 @@ public class Commandspawner extends EssentialsCommand
@Override
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
if (args.length < 1)
if (args.length < 1 || args[0].length() < 2)
{
throw new NotEnoughArgumentsException();
}
Block target = user.getTarget().getTargetBlock();
final Block target = user.getTarget().getTargetBlock();
if (target.getType() != Material.MOB_SPAWNER)
{
throw new Exception(Util.i18n("mobSpawnTarget"));
@@ -33,7 +33,8 @@ public class Commandspawner extends EssentialsCommand
charge(user);
try
{
((CreatureSpawner)target).setCreatureType(CreatureType.fromName(args[0]));
final String name = args[0].substring(0, 1).toUpperCase() + args[0].substring(1).toLowerCase();
new CraftCreatureSpawner(target).setCreatureType(CreatureType.fromName(name));
}
catch (Throwable ex)
{

View File

@@ -1,10 +1,7 @@
package com.earth2me.essentials.commands;
import net.minecraft.server.WorldServer;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.craftbukkit.entity.CraftEntity;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Mob;
import com.earth2me.essentials.Mob.MobException;
@@ -15,11 +12,11 @@ import net.minecraft.server.PathEntity;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.entity.CraftCreeper;
import org.bukkit.craftbukkit.entity.CraftSheep;
import org.bukkit.craftbukkit.entity.CraftSlime;
import org.bukkit.craftbukkit.entity.CraftWolf;
import org.bukkit.entity.Entity;
public class Commandspawnmob extends EssentialsCommand
@@ -61,10 +58,16 @@ public class Commandspawnmob extends EssentialsCommand
}
}
if (ess.getSettings().getProtectPreventSpawn(mobType.toLowerCase())
|| (mountType != null && ess.getSettings().getProtectPreventSpawn(mountType.toLowerCase())))
{
user.sendMessage(Util.i18n("unableToSpawnMob"));
return;
}
CraftEntity spawnedMob = null;
Entity spawnedMob = null;
Mob mob = null;
CraftEntity spawnedMount = null;
Entity spawnedMount = null;
Mob mobMount = null;
mob = Mob.fromName(mobType);
@@ -74,16 +77,6 @@ public class Commandspawnmob extends EssentialsCommand
return;
}
charge(user);
WorldServer world = ((CraftWorld)user.getWorld()).getHandle();
try
{
spawnedMob = mob.spawn(user, server);
}
catch (MobException e)
{
user.sendMessage(Util.i18n("unableToSpawnMob"));
return;
}
int[] ignore =
{
8, 9
@@ -96,8 +89,16 @@ public class Commandspawnmob extends EssentialsCommand
loc.setY(loc.getY() + 1);
block = user.getWorld().getBlockAt(loc);
}
spawnedMob.teleportTo(loc);
world.addEntity(spawnedMob.getHandle());
try
{
spawnedMob = mob.spawn(user, server, loc);
}
catch (MobException e)
{
user.sendMessage(Util.i18n("unableToSpawnMob"));
return;
}
if (mountType != null)
{
@@ -109,16 +110,14 @@ public class Commandspawnmob extends EssentialsCommand
}
try
{
spawnedMount = mobMount.spawn(user, server);
spawnedMount = mobMount.spawn(user, server, loc);
}
catch (MobException e)
{
user.sendMessage(Util.i18n("unableToSpawnMob"));
return;
}
spawnedMount.teleportTo(spawnedMob);
spawnedMount.getHandle().setPassengerOf(spawnedMob.getHandle());
world.addEntity(spawnedMount.getHandle());
spawnedMob.setPassenger(spawnedMount);
}
if (mobData != null)
{
@@ -142,23 +141,19 @@ public class Commandspawnmob extends EssentialsCommand
{
for (int i = 1; i < mobCount; i++)
{
spawnedMob = mob.spawn(user, server);
spawnedMob.teleportTo(loc);
world.addEntity(spawnedMob.getHandle());
spawnedMob = mob.spawn(user, server, loc);
if (mobMount != null)
{
try
{
spawnedMount = mobMount.spawn(user, server);
spawnedMount = mobMount.spawn(user, server, loc);
}
catch (MobException e)
{
user.sendMessage(Util.i18n("unableToSpawnMob"));
return;
}
spawnedMount.teleportTo(spawnedMob);
spawnedMount.getHandle().setPassengerOf(spawnedMob.getHandle());
world.addEntity(spawnedMount.getHandle());
spawnedMob.setPassenger(spawnedMount);
}
if (mobData != null)
{
@@ -169,7 +164,7 @@ public class Commandspawnmob extends EssentialsCommand
changeMobData(mobMount.name, spawnedMount, mountData, user);
}
}
user.sendMessage(args[1] + " " + mob.name.toLowerCase() + mob.s + Util.i18n("spawned"));
user.sendMessage(args[1] + " " + mob.name.toLowerCase() + mob.suffix + " " + Util.i18n("spawned"));
}
catch (MobException e1)
{
@@ -195,7 +190,7 @@ public class Commandspawnmob extends EssentialsCommand
return s.toUpperCase().charAt(0) + s.toLowerCase().substring(1);
}
private void changeMobData(String type, CraftEntity spawned, String data, User user) throws Exception
private void changeMobData(String type, Entity spawned, String data, User user) throws Exception
{
if ("Slime".equalsIgnoreCase(type))
{
@@ -222,18 +217,19 @@ public class Commandspawnmob extends EssentialsCommand
if ("Wolf".equalsIgnoreCase(type) && data.equalsIgnoreCase("tamed"))
{
EntityWolf wolf = ((CraftWolf)spawned).getHandle();
wolf.d(true);
wolf.a((PathEntity)null);
wolf.setTamed(true);
wolf.setPathEntity((PathEntity)null);
wolf.setSitting(true);
wolf.health = 20;
wolf.a(user.getName());
wolf.setOwnerName(user.getName());
wolf.world.a(wolf, (byte)7);
}
if ("Wolf".equalsIgnoreCase(type) && data.equalsIgnoreCase("angry"))
{
((CraftWolf)spawned).setAngry(true);
}
if ("Creeper".equalsIgnoreCase(type) && data.equalsIgnoreCase("powered")) {
if ("Creeper".equalsIgnoreCase(type) && data.equalsIgnoreCase("powered"))
{
((CraftCreeper)spawned).setPowered(true);
}
}

View File

@@ -1,11 +1,11 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.CraftServer;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.entity.Player;
public class Commandtempban extends EssentialsCommand
@@ -16,37 +16,38 @@ public class Commandtempban extends EssentialsCommand
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
throw new NotEnoughArgumentsException();
}
User p = null;
try
final User player = getPlayer(server, args, 0, true);
if (player.getBase() instanceof OfflinePlayer)
{
p = getPlayer(server, args, 0);
if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.tempban.offline"))
{
sender.sendMessage(Util.i18n("tempbanExempt"));
return;
}
}
catch (NoSuchFieldException ex)
else
{
p = ess.getOfflineUser(args[0]);
}
if (p == null)
{
sender.sendMessage(Util.format("playerNotFound"));
if (player.isAuthorized("essentials.tempban.exempt"))
{
sender.sendMessage(Util.i18n("tempbanExempt"));
return;
}
}
final String time = getFinalArg(args, 1);
final long banTimestamp = Util.parseDateDiff(time, true);
String time = getFinalArg(args, 1);
long banTimestamp = Util.parseDateDiff(time, true);
p = ess.getUser(server.matchPlayer(args[0]).get(0));
String banReason = Util.format("tempBanned", Util.formatDateDiff(banTimestamp));
p.setBanReason(banReason);
p.setBanTimeout(banTimestamp);
p.kickPlayer(banReason);
((CraftServer)server).getHandle().a(p.getName());
sender.sendMessage(Util.format("playerBanned", p.getName()));
Essentials.getStatic().loadBanList();
final String banReason = Util.format("tempBanned", Util.formatDateDiff(banTimestamp));
player.setBanReason(banReason);
player.setBanTimeout(banTimestamp);
player.kickPlayer(banReason);
ess.getBans().banByName(player.getName());
server.broadcastMessage(Util.format("playerBanned", player.getName(), banReason));
}
}

View File

@@ -21,33 +21,28 @@ public class Commandtime extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
if (user.isAuthorized("essentials.time.world"))
if (args.length < 2)
{
final World world = user.getWorld();
if (user.isAuthorized("essentials.time.world"))
{
final World world = user.getWorld();
charge(user);
setWorldTime(world, args[0]);
charge(user);
setWorldTime(world, args[0]);
}
else
{
charge(user);
setPlayerTime(user, args[0]);
}
}
else
{
if (user.isAuthorized("essentials.time.player"))
if (user.isAuthorized("essentials.time.others"))
{
long time = user.getPlayerTime();
time -= time % 24000;
if ("day".equalsIgnoreCase(args[0]))
{
final World world = user.getWorld();
user.setPlayerTime(time + 24000 - world.getTime(), true);
return;
}
if ("night".equalsIgnoreCase(args[0]))
{
final World world = user.getWorld();
user.setPlayerTime(time + 37700 - world.getTime(), true);
return;
}
throw new Exception(Util.i18n("onlyDayNight"));
User u = getPlayer(server, args, 1);
charge(user);
setPlayerTime(u, args[0]);
}
}
}
@@ -59,9 +54,17 @@ public class Commandtime extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
for (World world : server.getWorlds())
if (args.length < 2)
{
setWorldTime(world, args[0]);
for (World world : server.getWorlds())
{
setWorldTime(world, args[0]);
}
}
else
{
User u = getPlayer(server, args, 1);
setPlayerTime(u, args[0]);
}
sender.sendMessage(Util.i18n("timeSet"));
@@ -83,4 +86,28 @@ public class Commandtime extends EssentialsCommand
}
throw new Exception(Util.i18n("onlyDayNight"));
}
private void setPlayerTime(final User user, final String timeString) throws Exception
{
long time = user.getPlayerTime();
time -= time % 24000;
if ("day".equalsIgnoreCase(timeString))
{
final World world = user.getWorld();
user.setPlayerTime(time + 24000 - world.getTime(), true);
return;
}
if ("night".equalsIgnoreCase(timeString))
{
final World world = user.getWorld();
user.setPlayerTime(time + 37700 - world.getTime(), true);
return;
}
if ("reset".equalsIgnoreCase(timeString))
{
user.resetPlayerTime();
return;
}
throw new Exception(Util.i18n("onlyDayNight"));
}
}

View File

@@ -1,10 +1,11 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.entity.Player;
public class Commandtogglejail extends EssentialsCommand
@@ -22,21 +23,40 @@ public class Commandtogglejail extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
User p = getPlayer(server, args, 0);
if (p.isAuthorized("essentials.jail.exempt"))
{
sender.sendMessage(Util.i18n("mayNotJail"));
return;
}
User p = getPlayer(server, args, 0, true);
if (args.length >= 2 && !p.isJailed())
{
if (p.getBase() instanceof OfflinePlayer)
{
if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.togglejail.offline"))
{
sender.sendMessage(Util.i18n("mayNotJail"));
return;
}
}
else
{
if (p.isAuthorized("essentials.jail.exempt"))
{
sender.sendMessage(Util.i18n("mayNotJail"));
return;
}
}
charge(sender);
p.setJailed(true);
p.sendMessage(Util.i18n("userJailed"));
p.setJail(null);
ess.getJail().sendToJail(p, args[1]);
if (!(p.getBase() instanceof OfflinePlayer))
{
ess.getJail().sendToJail(p, args[1]);
}
else
{
// Check if jail exists
ess.getJail().getJail(args[1]);
}
p.setJail(args[1]);
long timeDiff = 0;
if (args.length > 2)
@@ -57,7 +77,7 @@ public class Commandtogglejail extends EssentialsCommand
return;
}
if (args.length >= 2 && p.isJailed() && !args[1].equalsIgnoreCase(p.getJail()))
if (args.length >= 2 && p.isJailed() && args[1].equalsIgnoreCase(p.getJail()))
{
String time = getFinalArg(args, 2);
long timeDiff = Util.parseDateDiff(time, true);
@@ -76,7 +96,10 @@ public class Commandtogglejail extends EssentialsCommand
p.setJailTimeout(0);
p.sendMessage("§7You have been released");
p.setJail(null);
p.getTeleport().back();
if (!(p.getBase() instanceof OfflinePlayer))
{
p.getTeleport().back();
}
sender.sendMessage("§7Player " + p.getName() + " unjailed.");
}
}

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Charge;
import com.earth2me.essentials.Trade;
import org.bukkit.Location;
import org.bukkit.Server;
import com.earth2me.essentials.User;
@@ -21,7 +21,7 @@ public class Commandtop extends EssentialsCommand
int topZ = user.getLocation().getBlockZ();
int topY = user.getWorld().getHighestBlockYAt(topX, topZ);
charge(user);
user.getTeleport().teleport(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), new Charge(this.getName(), ess));
user.getTeleport().teleport(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), new Trade(this.getName(), ess));
user.sendMessage(Util.i18n("teleportTop"));
}
}

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Charge;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.Console;
import org.bukkit.Server;
import com.earth2me.essentials.User;
@@ -30,7 +30,7 @@ public class Commandtp extends EssentialsCommand
throw new Exception(Util.format("teleportDisabled", p.getDisplayName()));
}
user.sendMessage(Util.i18n("teleporting"));
Charge charge = new Charge(this.getName(), ess);
Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
user.getTeleport().teleport(p, charge);
break;
@@ -44,7 +44,7 @@ public class Commandtp extends EssentialsCommand
charge(user);
User target = getPlayer(server, args, 0);
User toPlayer = getPlayer(server, args, 1);
target.getTeleport().now(toPlayer);
target.getTeleport().now(toPlayer, false);
target.sendMessage(Util.format("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
break;
}
@@ -61,7 +61,7 @@ public class Commandtp extends EssentialsCommand
sender.sendMessage(Util.i18n("teleporting"));
User target = getPlayer(server, args, 0);
User toPlayer = getPlayer(server, args, 1);
target.getTeleport().now(toPlayer);
target.getTeleport().now(toPlayer, false);
target.sendMessage(Util.format("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
}
}

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Charge;
import com.earth2me.essentials.Trade;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@@ -23,7 +23,7 @@ public class Commandtpaccept extends EssentialsCommand
throw new Exception(Util.i18n("noPendingRequest"));
}
Charge charge = new Charge(this.getName(), ess);
Trade charge = new Trade(this.getName(), ess);
if (user.isTeleportRequestHere())
{
charge.isAffordableFor(user);

View File

@@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.logging.Level;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -46,15 +45,11 @@ public class Commandtpall extends EssentialsCommand
}
try
{
u.getTeleport().now(p);
u.getTeleport().now(p, false);
}
catch (Exception ex)
{
sender.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
if (ess.getSettings().isDebug())
{
logger.log(Level.WARNING, ex.getMessage(), ex);
}
ess.showError(sender, ex, getName());
}
}
}

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Charge;
import com.earth2me.essentials.Trade;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@@ -21,7 +21,7 @@ public class Commandtphere extends EssentialsCommand
{
throw new Exception(Util.format("teleportDisabled", p.getDisplayName()));
}
p.getTeleport().teleport(user, new Charge(this.getName(), ess));
p.getTeleport().teleport(user, new Trade(this.getName(), ess));
user.sendMessage(Util.i18n("teleporting"));
p.sendMessage(Util.i18n("teleporting"));
}

View File

@@ -23,7 +23,7 @@ public class Commandtpo extends EssentialsCommand
//Just basically the old tp command
User p = getPlayer(server, args, 0);
charge(user);
user.getTeleport().now(p);
user.getTeleport().now(p, false);
user.sendMessage(Util.i18n("teleporting"));
}
}

View File

@@ -23,7 +23,7 @@ public class Commandtpohere extends EssentialsCommand
//Just basically the old tphere command
User p = getPlayer(server, args, 0);
charge(user);
p.getTeleport().now(user);
p.getTeleport().now(user, false);
user.sendMessage(Util.i18n("teleporting"));
}
}

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Charge;
import com.earth2me.essentials.Trade;
import org.bukkit.Location;
import org.bukkit.Server;
import com.earth2me.essentials.User;
@@ -26,7 +26,7 @@ public class Commandtppos extends EssentialsCommand
int y = Integer.parseInt(args[1]);
int z = Integer.parseInt(args[2]);
Location l = new Location(user.getWorld(), x, y, z);
Charge charge = new Charge(this.getName(), ess);
Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
user.sendMessage(Util.i18n("teleporting"));
user.getTeleport().teleport(l, charge);

View File

@@ -1,9 +1,9 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.CraftServer;
public class Commandunban extends EssentialsCommand
@@ -14,15 +14,15 @@ public class Commandunban 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();
}
((CraftServer)server).getHandle().b(args[0]);
User u = getPlayer(server, args, 0, true);
ess.getBans().unbanByName(u.getName());
sender.sendMessage(Util.i18n("unbannedPlayer"));
ess.loadBanList();
}
}

View File

@@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.CraftServer;
public class Commandunbanip extends EssentialsCommand
@@ -14,15 +13,14 @@ public class Commandunbanip 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();
}
((CraftServer)server).getHandle().d(args[0]);
ess.getBans().unbanByIp(args[0]);
sender.sendMessage(Util.i18n("unbannedIP"));
ess.loadBanList();
}
}

View File

@@ -1,7 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.InventoryWorkaround;
import com.earth2me.essentials.ItemDb;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.List;
@@ -56,7 +55,8 @@ public class Commandunlimited extends EssentialsCommand
return;
}
ItemStack stack = ItemDb.get(args[0], 1);
final ItemStack stack = ess.getItemDb().get(args[0], 1);
stack.setAmount(Math.min(stack.getType().getMaxStackSize(), 2));
String itemname = stack.getType().toString().toLowerCase().replace("_", "");
if (!user.isAuthorized("essentials.unlimited.item-all")

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Charge;
import com.earth2me.essentials.Trade;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@@ -73,7 +73,7 @@ public class Commandwarp extends EssentialsCommand
private void warpUser(User user, String name) throws Exception
{
Charge charge = new Charge(this.getName(), ess);
Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
if (ess.getSettings().getPerWarpPermission())
{

View File

@@ -22,12 +22,28 @@ public class Commandwhois extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
boolean showhidden = false;
if (sender instanceof Player)
{
if (ess.getUser(sender).isAuthorized("essentials.list.hidden"))
{
showhidden = true;
}
}
else
{
showhidden = true;
}
String whois = args[0].toLowerCase();
charge(sender);
int prefixLength = ChatColor.stripColor(ess.getSettings().getNicknamePrefix()).length();
for (Player p : server.getOnlinePlayers())
{
User u = ess.getUser(p);
if (u.isHidden() && !showhidden)
{
continue;
}
String dn = ChatColor.stripColor(u.getNick());
if (!whois.equalsIgnoreCase(dn)
&& !whois.equalsIgnoreCase(dn.substring(prefixLength))
@@ -41,7 +57,7 @@ public class Commandwhois extends EssentialsCommand
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())));
sender.sendMessage(Util.format("whoisMoney", Util.formatCurrency(u.getMoney(), ess)));
}
sender.sendMessage(u.isAfk()
? Util.i18n("whoisStatusAway")

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Charge;
import com.earth2me.essentials.Trade;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Server;
@@ -68,7 +68,7 @@ public class Commandworld extends EssentialsCommand
Location loc = user.getLocation();
loc = new Location(world, loc.getBlockX() * factor + .5, loc.getBlockY(), loc.getBlockZ() * factor + .5);
Charge charge = new Charge(this.getName(), ess);
Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
user.getTeleport().teleport(loc, charge);
}

View File

@@ -1,7 +1,6 @@
package com.earth2me.essentials.commands;
import org.bukkit.Server;
import com.earth2me.essentials.ItemDb;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.inventory.ItemStack;
@@ -22,7 +21,7 @@ public class Commandworth extends EssentialsCommand
if (args.length > 0)
{
is = ItemDb.get(args[0]);
is = ess.getItemDb().get(args[0]);
}
try
@@ -49,13 +48,13 @@ public class Commandworth extends EssentialsCommand
? Util.format("worthMeta",
is.getType().toString().toLowerCase().replace("_", ""),
is.getDurability(),
Util.formatCurrency(worth * amount),
Util.formatCurrency(worth * amount, ess),
amount,
Util.formatCurrency(worth))
Util.formatCurrency(worth, ess))
: Util.format("worth",
is.getType().toString().toLowerCase().replace("_", ""),
Util.formatCurrency(worth * amount),
Util.formatCurrency(worth * amount, ess),
amount,
Util.formatCurrency(worth)));
Util.formatCurrency(worth, ess)));
}
}

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