Compare commits

...
Author SHA1 Message Date
KHobbits 1101a3243d Fix tpo syntax error. 2012-03-29 22:32:16 +01:00
KHobbits c7638efc7e Iaccidentally's changes to pt TL. 2012-03-29 21:17:50 +01:00
KHobbits d90053c8c4 Update TL header. 2012-03-29 18:49:56 +01:00
KHobbits 6235983ddd New translation messages 2012-03-29 18:37:22 +01:00
KHobbits 7a249abc67 Update default permissions. 2012-03-29 18:14:24 +01:00
KHobbits c2c613b652 Missing air materials. 2012-03-29 16:41:13 +01:00
ElgarL 590357004d Merge branch 'groupmanager' of https://elgarl@github.com/essentials/Essentials.git into groupmanager 2012-03-29 14:09:07 +01:00
ElgarL 9dbeb1407c Catch errors caused by bad indentation in yml's. 2012-03-29 14:02:53 +01:00
ElgarL 1ef8ab70d1 Stop attempting to push empty permissions when players edit the yml's
incorrectly.
2012-03-29 13:41:59 +01:00
KHobbits c09ada201c Interact event cleanup 2012-03-29 03:06:52 +01:00
KHobbits d7139cb16c Update to CB #2126 B #1425
Min CB version changed to 2122
2012-03-29 02:00:51 +01:00
KHobbits 10f82a6723 Fix using /setworth <price> 2012-03-29 00:13:56 +01:00
KHobbits 2aed3af3c4 Merge branch 'groupmanager' of github.com:essentials/Essentials 2012-03-28 17:37:03 +01:00
KHobbits c45d38ca69 Implement all abstract methods. 2012-03-28 15:12:25 +01:00
KHobbits 576642a573 Merge branch 'master' of github.com:essentials/Essentials 2012-03-28 15:03:45 +01:00
KHobbits 9d545dcbf1 Don't register jail listeners, if no jails are set. 2012-03-28 15:03:18 +01:00
snowleo 71d8744840 Fix for the fix 2012-03-28 11:21:31 +02:00
snowleo 32c689e0f5 Fix isAffordableFor in Trade class
This fixes buy signs giving out items, when the player has essentials.eco.loan permission, but min-money in config is set to 0.
2012-03-28 10:36:10 +02:00
KHobbits 5b62661404 Pull example perm files out of the ess jar. 2012-03-28 00:59:51 +01:00
KHobbits a7df8a1a0a Try to reduce lag caused by join spam. 2012-03-27 21:08:06 +01:00
snowleo b14e7c197f Adds pvp protection after teleport 2012-03-27 21:15:11 +02:00
KHobbits 97eed50ccc Adding world permission checks to:
tpaall tpall tpahere tphere tpohere
User is required to have the permission for the world he is in, before he can teleport users outside this world, to it.
2012-03-27 15:28:40 +01:00
ElgarL b8453ac792 Update GlobalGroups.yml for new/changed Towny permission nodes. 2012-03-27 10:14:53 +01:00
ElgarL fe7f479e63 Auto rename all case sensitive world folders to lower case (if
possible).
2012-03-26 20:06:59 +01:00
ElgarL 50ea442bf0 Treat all world names as lower case for file handling (please check in
your worlds folder. You should have no folders with upper case letters
from now).
2012-03-26 19:18:19 +01:00
KHobbits 5d45495371 Fix kit enchants for people without oversized stack permission.
Add permissions lookup to debug mode.
2012-03-26 13:28:32 +01:00
KHobbits e30d900289 Clarify how backup works.
Add option for auto save-all.
2012-03-26 00:49:53 +01:00
KHobbits 2cc96e995b Update tp to check if target player has tptoggle disabled.
Update tpo to allow player to player tp.
2012-03-25 23:32:04 +01:00
KHobbits 47cf1289d7 Don't show 'backup started' on /backup if it hasn't been configured. 2012-03-25 19:10:39 +01:00
KHobbits d2506cd928 Reorder login/join event calls. 2012-03-25 17:27:06 +01:00
KHobbits 1dbb11ea55 Don't override other plugins which allow joining over capacity. 2012-03-25 16:46:36 +01:00
KHobbits b60363b6bd Reduce amount of move event calls being processed. 2012-03-25 16:30:22 +01:00
KHobbits 00033c11bc Update [balance] sign to use currency formatting. 2012-03-25 14:26:08 +01:00
KHobbits c588b78adb Merge branch 'master' of github.com:essentials/Essentials 2012-03-25 14:20:53 +01:00
KHobbits 7bd7992b24 Fix chat format regex. 2012-03-25 14:20:26 +01:00
snowleo 6f86b7400a CopyPaste-Fail 2012-03-25 11:47:26 +02:00
snowleo e13a2c371d Wrong url 2012-03-25 11:45:50 +02:00
snowleo 0cbded9fca This is no longer stored in file, so it's not part of UserData anymore. 2012-03-25 11:44:33 +02:00
snowleo 3e6e71ca41 Optimize metrics 2012-03-25 11:39:19 +02:00
snowleo 1b2e3b1951 AntiCheat has different version numbers, so don't check. 2012-03-25 11:09:13 +02:00
KHobbits e53a480c22 Should probably cancel this at lowest. 2012-03-25 02:55:19 +01:00
KHobbits 7280c1c468 Merge branch 'master' of github.com:essentials/Essentials 2012-03-25 02:34:19 +01:00
KHobbits b7221516dc Invsee now shows a live player inventory in a window, rather than cloning players inventory.
New Permission: essentials.invsee.modify - Player with this permission will be able to add/remove items from the other players inventory.
2012-03-25 02:33:52 +01:00
KHobbits 71aaf81bba Update Essentials/src/config.yml 2012-03-24 23:28:56 +00:00
KHobbits 160c3f428c Mysql is bad. 2012-03-24 23:25:43 +00:00
KHobbits 3c3e8d167f Better English. 2012-03-24 21:12:15 +00:00
KHobbits 7ca2b65c4f New permission check: essentials.list.hidden is now required to /getpos hidden players. 2012-03-24 21:08:45 +00:00
KHobbits a8cbb5c8f5 Extra itemcsv. 2012-03-23 23:13:04 +00:00
KHobbits 72028086c0 'Enabled' looks better than 'true'. 2012-03-23 22:38:01 +00:00
KHobbits dddf529ff5 Make sure items don't stack wrong in [free] signs. 2012-03-23 20:15:03 +00:00
KHobbits b3de0aabae Fix for showing plugins when user has no permission. 2012-03-23 18:26:19 +00:00
KHobbits 77c6a3b730 Wrong colour code symbol. 2012-03-23 17:50:15 +00:00
KHobbits bb54dbb688 Merge remote branch 'remotes/origin/groupmanager' 2012-03-23 17:44:00 +00:00
KHobbits 0a74da88d6 Help command refresh. 2012-03-23 17:16:09 +00:00
KHobbits d0b94938e0 Merge branch 'master' of github.com:essentials/Essentials 2012-03-23 13:53:08 +00:00
snowleo a0cba8e63d Spaaaaaace! So much space! Gotta see it all! 2012-03-23 14:30:00 +01:00
KHobbits a4d7b5dcf8 Merge branch 'master' of github.com:essentials/Essentials 2012-03-23 13:26:12 +00:00
KHobbits c503adabc5 Fix url matching. 2012-03-23 13:26:03 +00:00
snowleo 8a22258945 Fix utf-8 decoding problems. 2012-03-23 14:22:10 +01:00
snowleo 29a190f93a http://youtu.be/8DdeLUA0Fms 2012-03-23 12:11:01 +01:00
KHobbits 5c0b522026 Merge branch 'master' of github.com:essentials/Essentials 2012-03-23 10:18:16 +00:00
KHobbits c46f14665c Adding missing entities to Protect Spawn Blacklist 2012-03-23 10:16:38 +00:00
snowleo 20c973dab2 Fix UTF8 handling in Configuration class 2012-03-23 11:13:44 +01:00
KHobbits 49cb482ca5 Update Essentials/src/config.yml 2012-03-23 10:03:15 +00:00
KHobbits 033c2e22cd Remove white user prefix, if prefix is blank. Messes with EssentialsChat colouring. 2012-03-23 07:56:44 +00:00
KHobbits 2f434291cb Fixing chat color formatting. 2012-03-23 00:19:27 +00:00
KHobbits 42d01471d3 Disabling player list updates by default (can mess with tab completion)
Hopefully this will be reverted if/when patch is found.
2012-03-23 00:15:22 +00:00
KHobbits c5eb1bb105 Improve kit matching, and add enchantments.
Enchanted kit example in config.yml
2012-03-22 23:47:35 +00:00
KHobbits 3c9057f68e Fix jar building. 2012-03-22 23:10:59 +00:00
KHobbits 96f0dd5824 Update CB to 2105 2012-03-22 23:07:23 +00:00
KHobbits 71358629f4 New command: /fly
New perm: essentials.fly.others
2012-03-22 22:59:52 +00:00
KHobbits 284fef00e7 Split formatting perms for signs as well. 2012-03-22 22:26:04 +00:00
KHobbits d20519ef8b New Permission: essentials.chat.url
Without this perm, URLs will be modified not to be links.
2012-03-22 22:19:58 +00:00
KHobbits 0dc1270aed Split colour permissions into 3: color/magic/format 2012-03-22 22:07:13 +00:00
KHobbits cd0d37f73c Update to 1.2.4 (R0.1)
New Minimum CB version: 2100
2012-03-22 20:55:56 +00:00
KHobbits 56fce34539 Extra items in 1.2.4 2012-03-22 20:48:27 +00:00
KHobbits 165a76d492 Add villager professions to /spawnmob 2012-03-22 20:03:52 +00:00
ElgarL 9570e5cfd9 Correct Grammar 2012-03-22 17:54:59 +00:00
ElgarL c6bb10489e Merge pull request #62 from bonney12/groupmanager
Update language and commenting
2012-03-22 10:53:25 -07:00
KHobbits 3d7d4a47d9 Bukkit R0.3 api updates. 2012-03-22 17:26:05 +00:00
KHobbits 968c849b13 Update missing 1.2.3 items in items.csv 2012-03-22 17:25:42 +00:00
KHobbits 1746569e1a Extra Trees 2012-03-22 17:25:13 +00:00
KHobbits 209c91d3de Fixed again. 2012-03-22 12:02:19 +00:00
KHobbits 7d7c1d34cf Fix typo. 2012-03-22 11:57:30 +00:00
KHobbits c3ad486f65 Merge branch 'master' of github.com:essentials/Essentials 2012-03-21 23:55:19 +00:00
KHobbits 7bcec32134 Cleaning up displaynames 2012-03-21 23:54:57 +00:00
KHobbits b19b08dc6e Merge pull request #63 from Iaccidentally/patch-6
update default player-commands to support new and missed commands
2012-03-21 09:25:05 -07:00
Iaccidentally 264e175d6c update default player-commands to support new and missed commands 2012-03-21 13:23:36 -03:00
Michael Bonney bcd4fd9bff Removed Portuguese text, and added English replacements. Made more sense of the sentences, and also changed an incorrect message to it's proper form. 2012-03-21 16:13:34 +00:00
KHobbits 3e88fb44f4 Split if tree for readability. 2012-03-20 15:03:53 +00:00
KHobbits 518b013a63 Teleport check cleanup 2012-03-20 13:26:49 +00:00
KHobbits e752538568 Fix per world teleport permission checking. 2012-03-20 11:53:05 +00:00
KHobbits 970364886c Add 'color' sign type to config file.
Enforce colour permission on signs when essentials signs are enabled.
2012-03-19 08:21:39 +00:00
KHobbits 07f859e38b Missing kit time check from [kit] signs. 2012-03-18 17:15:46 +00:00
KHobbits c806059958 Only show nickname update message in debug mode. 2012-03-18 03:29:49 +00:00
KHobbits 14bce8fd82 Shorten help messages. 2012-03-18 03:01:44 +00:00
KHobbits 17be04cd99 Error and info cleanup. 2012-03-17 20:23:46 +00:00
KHobbits b93847f077 Merge remote branch 'remotes/origin/groupmanager' 2012-03-17 18:20:33 +00:00
ElgarL 6476158462 Don't remove an attachment on a player leaving as Bukkit never forgets
it. This fixes non mirrored permissions being messed up if a player
relogs.
2012-03-17 15:56:40 +00:00
snowleo 6dd73ff9d0 Merge branch 'refs/heads/groupmanager' 2012-03-17 13:38:51 +01:00
ElgarL b72083fb18 Removed some debug spam. 2012-03-17 12:37:23 +00:00
snowleo ca11d4d98b Fix bukkit download url 2012-03-17 11:15:28 +01:00
snowleo 12cb4fd5f8 Fix bukkit download url 2012-03-17 11:12:32 +01:00
KHobbits 4df4eba2a5 Merge remote branch 'remotes/origin/groupmanager' 2012-03-17 08:01:19 +00:00
KHobbits 762105d692 New permission: essentials.tp.others - Allows players to /tp <p1> <p2> replaces old reused permission.
New permission usage: if world-teleport-permissions is true in the config, TP commands will now check for essentials.world.<worldname> when a tp would switch worlds.
2012-03-17 06:10:02 +00:00
KHobbits e4ce814c2f Comments to SetExpFix. 2012-03-17 03:38:32 +00:00
KHobbits 87cd693020 Adding Exp to /whois, shows total exp and ingame level.
Due to the way minecraft calculates levels (flawed formula), its possible to not match calculated level.
2012-03-17 01:43:49 +00:00
KHobbits baadd4b1cb Adding reference to &k in MOTD. 2012-03-16 23:03:22 +00:00
KHobbits adf3755abb Handle permission check failures better. 2012-03-15 23:15:19 +00:00
KHobbits 5c280e7cb7 Add missing methods. 2012-03-15 22:23:26 +00:00
KHobbits 4a149855ab Updating Bukkit/CraftBukkit to match minimum ver. 2012-03-15 22:15:17 +00:00
md_5 cf000b04e4 Fill the entire sign with free goodness 2012-03-15 20:55:56 +11:00
md_5 79cd8d6065 Update minimum CraftBukkit version 2012-03-15 20:51:51 +11:00
md_5 5b930cdc3b Restore [free] and [disposal] signs back to their intended behaviour 2012-03-15 20:48:55 +11:00
snowleo c09329e5be :P 2012-03-15 09:15:28 +01:00
KHobbits c513014732 Graph a little bit extra information. 2012-03-15 08:08:25 +00:00
KHobbits bada36be68 Fix fake explosions. 2012-03-15 06:42:58 +00:00
KHobbits e5e81eda72 Make /nuke drop tnt from a more reasonable height. 2012-03-15 05:09:34 +00:00
KHobbits 45cf2ae960 Make /spawner errors more descriptive. 2012-03-15 04:41:56 +00:00
KHobbits d0d0117411 Add metric opt out toggle ingame. 2012-03-15 03:49:17 +00:00
KHobbits 5d79863cfc Fixing setwarp command. 2012-03-15 02:12:43 +00:00
KHobbits b85756f8b1 Adding some simple feature metrics. 2012-03-15 02:12:27 +00:00
KHobbits 8776f4c1c0 Metrics errors aren't important. 2012-03-15 01:32:08 +00:00
KHobbits 5e8fd3993d Basic module graph. 2012-03-15 01:17:12 +00:00
KHobbits d3033716ca Add Griefcraft metrics to Essentials
Warns on first start, and first staff join, and 5 minute warning before logging starts.
2012-03-15 00:49:22 +00:00
ementalo 6cf2bb5cd9 Adding permissions for overwriting exisitng warps
essentials.warp.overwrite.[warpname] will allow overwrting of exsiting warps
essentials.warp.overwrite.* for all warps
Adding WarpNotFoundException class
2012-03-14 21:16:22 +00:00
KHobbits 267495a406 Fixing warp command costs. 2012-03-13 16:15:01 +00:00
ElgarL a8937f7bf0 Fix a globalgroup inheritance in groups.yml 2012-03-12 22:18:25 +00:00
KHobbits dfd63a81ac Missed a TL key. 2012-03-12 16:50:32 +00:00
KHobbits dfbc1956c9 Fixing a few TL Keys 2012-03-12 15:35:20 +00:00
KHobbits c0490c0890 New TL Key, allow formatting/colouring of help output. 2012-03-12 15:21:37 +00:00
KHobbits 2da802d4b7 New permission: essentials.seen.banreason
With this permission players can see why a user was banned, in /seen.
2012-03-12 15:00:44 +00:00
KHobbits adffbab678 Adding jail time to /whois. 2012-03-12 01:15:10 +00:00
KHobbits e11525ab64 Update offline user check.
Add ban reason to /seen
2012-03-12 01:00:57 +00:00
KHobbits 8dcd591beb Update setworth to allow /setworth <price> ingame
Allow /setworth to be used from console.
2012-03-11 23:59:59 +00:00
KHobbits a40c936bcf New Permission: essentials.lightning.others
With this permission you can use /lightning <player>, without only strike based on direction.
2012-03-11 20:58:54 +00:00
KHobbits 5c2622b390 Add Enderman check to EntityChangeEvent (Should fix sheep eating grass). 2012-03-11 01:46:01 +00:00
KHobbits c7046b696a Use ignoreCancelled on event registration. 2012-03-10 21:42:46 +00:00
KHobbits 9ac5ce8a75 Update info.txt to hint at /einfo. 2012-03-07 12:14:32 +00:00
KHobbits 5c55e18d33 Fixing typo in config.yml 2012-03-06 23:17:10 +00:00
ElgarL 19d233454e change []<> for optional command components 2012-03-06 16:23:57 +00:00
ElgarL 1f761ee1cb Expanded '/manuadd'to accept an optional variable for the world (eg
'/manuadd <player> <group> <world>').
2012-03-06 11:02:48 +00:00
KHobbits 1db5d61945 Merge branch 'release'
Conflicts:
	lib/bukkit.jar
	lib/craftbukkit.jar
2012-03-05 16:25:35 +00:00
KHobbits 1e34a396cd Change starter kit to default to stone tools 2012-03-05 15:51:15 +00:00
KHobbits ba96117f55 Temp fix to disable version check on R7 2012-03-05 14:17:09 +00:00
KHobbits 96b217cbe8 Craftbukkit/Bukkit R7 2012-03-05 08:41:19 +00:00
md_5 0dd5c0370e I dont think free noteblocks are a good idea 2012-03-05 08:37:16 +00:00
KHobbits bdf32cde9e Missed one. 2012-03-05 08:37:15 +00:00
KHobbits e91ed60441 Fixing spawnmob count. 2012-03-05 08:37:15 +00:00
KHobbits 8577202f48 Add listgroups as TL key 2012-03-05 08:37:15 +00:00
KHobbits 7819b9d2f0 Apply colors to group tags. 2012-03-05 08:37:15 +00:00
KHobbits 15c0565923 Build custom mob list /spawnmob 2012-03-05 08:37:14 +00:00
KHobbits 2b25ca2932 CME 2012-03-05 08:37:14 +00:00
KHobbits c7a6677d52 Adding starter/newbie kit to EssentialsSpawn
Optimization to EssentialsSpawn join event.
2012-03-05 08:37:14 +00:00
KHobbits c3d5b32986 Extra command alias. 2012-03-05 08:37:14 +00:00
KHobbits cbfb524195 Allow more currency customization.
Added currency key to messages.
2012-03-05 08:37:14 +00:00
KHobbits b16a1f7237 Adding option to modify all users balances (including offline) /eco reset ** <amount> 2012-03-05 08:37:14 +00:00
KHobbits e28f1b1be3 Half-revert double backflip. 10 points.
(op prefix changes that md-5 broke, thinking I broke op prefixes)
2012-03-05 08:37:14 +00:00
md_5 b512a243e7 Fix op colours, which KHobbits broke! 2012-03-05 08:37:13 +00:00
Chris Ward 873c9880dd Cleanup
Signed-off-by: Chris Ward <chris@chrisgward.com>
2012-03-05 08:35:48 +00:00
Chris Ward e6736e48a5 Cleanup
Signed-off-by: Chris Ward <chris@chrisgward.com>
2012-03-05 08:35:48 +00:00
KHobbits caf598f55b Capital case for formatting. 2012-03-05 08:35:48 +00:00
KHobbits 619e099a04 Force all kits to lowercase. 2012-03-05 08:35:48 +00:00
KHobbits faba1e3604 *make it look like i'm doing something* 2012-03-05 08:35:48 +00:00
KHobbits 7cb728b15f I think switches are better. 2012-03-05 08:35:48 +00:00
KHobbits 3e3c7f0d54 Only update displayname on world change, not every teleport. 2012-03-05 08:35:48 +00:00
KHobbits a45c19a08b Extra command aliases 2012-03-05 08:35:47 +00:00
KHobbits eb74a1de9c Make the antioch message optional. 2012-03-05 08:35:47 +00:00
KHobbits 8450734cf1 Entity event cleanup 2012-03-05 08:35:47 +00:00
KHobbits 016299a1dd Shouldn't really be canceling events at priority monitor, oops. 2012-03-05 08:35:47 +00:00
KHobbits d27ff9abb6 Don't think we need animation event anymore. 2012-03-05 08:35:47 +00:00
Iaccidentally cdf5d45483 update messages.properties for the new bukkit download link (ci.bukkit,org no longer works) 2012-03-05 08:35:46 +00:00
md_5 0b60d4efe2 I dont think free noteblocks are a good idea 2012-03-05 18:40:18 +11:00
md_5 d31e434e4d Allow spamming of this, by reducing explosion damage to 0, same effect, no mess 2012-03-05 18:28:04 +11:00
KHobbits fabc1c3dd9 Missed one. 2012-03-05 00:39:37 +00:00
KHobbits 68fbc40605 Fixing spawnmob count. 2012-03-05 00:22:31 +00:00
KHobbits 8b7c5cf2ed Add listgroups as TL key 2012-03-05 00:19:40 +00:00
KHobbits 1811631b93 Apply colors to group tags. 2012-03-05 00:08:37 +00:00
KHobbits 7cec1564b9 Build custom mob list /spawnmob 2012-03-04 21:54:51 +00:00
KHobbits a75eefcdd4 CME 2012-03-04 21:43:24 +00:00
KHobbits 6a9027da6d Adding starter/newbie kit to EssentialsSpawn
Optimization to EssentialsSpawn join event.
2012-03-04 20:09:25 +00:00
KHobbits e55aa3cea7 Extra command alias. 2012-03-04 16:17:16 +00:00
KHobbits 1ce2c60bf4 Updating Craftbukkit #2034 Bukkit #1378 2012-03-04 16:01:49 +00:00
ElgarL 7ba49afa0b Better reporting when a users.yml is failing to load. 2012-03-04 10:39:39 +00:00
KHobbits 6da705c86f Allow more currency customization.
Added currency key to messages.
2012-03-04 10:11:58 +00:00
KHobbits c3fa56322b Adding option to modify all users balances (including offline) /eco reset ** <amount> 2012-03-04 09:20:03 +00:00
KHobbits 53cfab229b Half-revert double backflip. 10 points.
(op prefix changes that md-5 broke, thinking I broke op prefixes)
2012-03-04 08:18:25 +00:00
KHobbits b62217f301 Merge branch 'master' of github.com:essentials/Essentials 2012-03-04 08:13:29 +00:00
md_5 d9a8453995 Fix op colours, which KHobbits broke! 2012-03-04 15:43:00 +11:00
snowleo e6181928e8 Cleanup of /spawnmob 2012-03-03 17:01:53 +01:00
ElgarL c33499797e Minor change to globalgroups 2012-03-03 14:03:52 +00:00
KHobbits 860f6a41ac Merge branch 'master' of github.com:essentials/Essentials 2012-03-03 13:49:26 +00:00
KHobbits 8aa7b1f301 Update CB #2032 B #1377
Min CB #2015
2012-03-03 13:48:58 +00:00
ElgarL 6efd3eaa27 Fix a silly logic error when testing bukkit perms 2012-03-03 13:47:59 +00:00
ElgarL d2d8d191da Minor optimization when checking bukkit permissions. 2012-03-03 13:00:17 +00:00
md-5 cea5c81d44 Merge pull request #56 from Iaccidentally/patch-4
Allow spawning baby villagers and ocelots
2012-03-03 00:34:00 -08:00
md-5 504f28df1a Merge pull request #55 from chrisward/master
Just a really small cleanup
2012-03-03 00:31:48 -08:00
Chris Ward 74a57553f6 Cleanup
Signed-off-by: Chris Ward <chris@chrisgward.com>
2012-03-03 19:21:27 +11:00
Iaccidentally 35576ab64a add little babbys 2012-03-03 03:04:54 -05:00
KHobbits 33605517ff Capital case for formatting. 2012-03-03 07:09:41 +00:00
Chris Ward 6da6e4d2e8 Cleanup
Signed-off-by: Chris Ward <chris@chrisgward.com>
2012-03-03 18:07:43 +11:00
KHobbits c0fa03ede2 Force all kits to lowercase. 2012-03-03 07:03:54 +00:00
KHobbits 301b609e93 *make it look like i'm doing something* 2012-03-03 05:27:02 +00:00
KHobbits b6bbe237ea I think switches are better. 2012-03-03 05:09:03 +00:00
KHobbits de7ab13c03 Only update displayname on world change, not every teleport. 2012-03-02 19:05:30 +00:00
KHobbits 7a0f4da860 Extra command aliases 2012-03-02 17:05:55 +00:00
KHobbits 1bbbfe1c96 Make the antioch message optional. 2012-03-02 17:03:34 +00:00
KHobbits 25ebe68389 Entity event cleanup 2012-03-02 16:54:12 +00:00
KHobbits 7737d19c5a Shouldn't really be canceling events at priority monitor, oops. 2012-03-02 16:33:20 +00:00
KHobbits 622ca4bf8a Don't think we need animation event anymore. 2012-03-02 16:29:06 +00:00
KHobbits b090afbeb3 Merge pull request #54 from Iaccidentally/patch-3
update messages.properties for the new bukkit download link (ci.bukkit,o...
2012-03-01 20:15:16 -08:00
Iaccidentally dce149511e update messages.properties for the new bukkit download link (ci.bukkit,org no longer works) 2012-03-01 23:10:32 -05:00
snowleo 21a248e94d Will be removed until the next release XD 2012-03-02 01:30:52 +01:00
snowleo f1aed4b521 Better cats 2012-03-02 00:40:50 +01:00
snowleo 7564ebf79e Fix world heights 2012-03-02 00:18:31 +01:00
snowleo b9aecbe1d4 Min version CB# 2004 2012-03-02 00:12:22 +01:00
snowleo 49eb451a76 New eggs 2012-03-02 00:09:50 +01:00
snowleo 64d866a77d New Entities and Items for 1.2 2012-03-02 00:06:57 +01:00
snowleo f75779aa7a CB#2004 B#1368 2012-03-01 23:57:34 +01:00
KHobbits 5622882602 Merge branch 'master' of github.com:essentials/Essentials 2012-03-01 22:37:15 +00:00
KHobbits b3d3928db8 Kit sign cleanup 2012-03-01 22:36:51 +00:00
snowleo 6df3b9008a update inventory 2012-03-01 23:23:23 +01:00
snowleo c36ca65e09 Bukkit broke this sign :( 2012-03-01 23:10:12 +01:00
KHobbits 2e788802fe Fix kit timers resetting on server restart. 2012-03-01 22:04:50 +00:00
KHobbits b0552019f5 Fix version matching. 2012-03-01 21:47:01 +00:00
snowleo dae69622a5 Merge branch 'refs/heads/master' into release 2012-03-01 19:08:52 +01:00
snowleo 696b930fb2 EntityType instead of CreatureType 2012-03-01 19:05:50 +01:00
snowleo e43a62f992 Requires #1988 because of the new Inventory stuff 2012-03-01 19:05:50 +01:00
snowleo 02c1cb05c7 Updated to R6 2012-03-01 19:05:50 +01:00
snowleo b44d738867 CB# 1988 B# 1360 2012-03-01 19:05:49 +01:00
md_5 e1818f7e62 Separate config sections evenly 2012-03-01 19:05:47 +01:00
md_5 e5081db7e4 Remove old, unwanted manifest.mf files 2012-03-01 19:05:47 +01:00
ElgarL ba346bd797 Make 'manload' reload the config correctly. 2012-03-01 19:05:47 +01:00
KHobbits 0670ece7f3 Updating Bukkit: CB #1858, B #1334 2012-03-01 19:05:47 +01:00
snowleo a8da3eebd7 Merge remote-tracking branch 'origin/groupmanager' 2012-03-01 17:33:25 +01:00
snowleo 056303b53c EntityType instead of CreatureType 2012-03-01 17:33:09 +01:00
snowleo 454f7d30de Requires #1988 because of the new Inventory stuff 2012-03-01 16:17:40 +01:00
snowleo 6d1c270976 Updated to R6 2012-03-01 16:16:05 +01:00
snowleo d1001274bb CB# 1988 B# 1360 2012-03-01 16:16:05 +01:00
md_5 3099855562 Merge remote-tracking branch 'origin/master' 2012-03-01 16:23:21 +11:00
md_5 3f26d4ad98 Separate config sections evenly 2012-03-01 14:40:57 +11:00
md_5 bae337cc49 Remove old, unwanted manifest.mf files 2012-03-01 12:27:59 +11:00
ElgarL 3823e7a108 Make 'manload' reload the config correctly. 2012-02-28 10:46:10 +00:00
KHobbits 1c2221f52f Adding option to log all eco api transactions. 2012-02-28 02:45:03 +00:00
KHobbits 1b780a4364 Prevent EssSpawn trying to handle spawning of jailed players. 2012-02-28 02:45:03 +00:00
KHobbits ac3e65a829 Change jail listener to catch respawn at Highest 2012-02-28 02:45:03 +00:00
KHobbits 332f19177e Allow people to hit exactly 'min money'. 2012-02-28 02:45:03 +00:00
KHobbits 6ab57b9abe Cleanup. 2012-02-28 02:45:03 +00:00
KHobbits 862f3aad59 Adjustments to negative eco give/take. 2012-02-28 02:45:03 +00:00
KHobbits e277acf80e Display users new balance on /eco give/take. 2012-02-28 02:45:02 +00:00
KHobbits 9f893e68e9 Add Minimum Balance, to allow people to manage overdrafts. 2012-02-28 02:45:02 +00:00
KHobbits 833a5b2b55 Adding option to log all eco api transactions. 2012-02-27 15:31:43 +00:00
KHobbits 340f0c68eb Prevent EssSpawn trying to handle spawning of jailed players. 2012-02-27 03:40:18 +00:00
KHobbits a5e3182dad Change jail listener to catch respawn at Highest 2012-02-27 03:24:58 +00:00
KHobbits 10ae9c3aa2 Allow people to hit exactly 'min money'. 2012-02-26 05:10:04 +00:00
KHobbits bcf903de92 Cleanup. 2012-02-26 05:06:03 +00:00
KHobbits ad08d27504 Adjustments to negative eco give/take. 2012-02-26 05:01:40 +00:00
KHobbits d24f77dbd5 Display users new balance on /eco give/take. 2012-02-26 04:27:29 +00:00
KHobbits a5b38ce1a4 Add Minimum Balance, to allow people to manage overdrafts. 2012-02-26 04:15:14 +00:00
KHobbits 5d048d2c1d Updating Bukkit: CB #1858, B #1334 2012-02-25 17:57:26 +00:00
KHobbits 13d3cc3306 Lowering min bukkit to r4 - 1838, this build should still be compatible. 2012-02-25 17:40:00 +00:00
KHobbits 9f02fb4dd4 Merge branch 'master' into release 2012-02-25 17:22:39 +00:00
KHobbits 07baa6e611 Merge remote branch 'remotes/origin/groupmanager' 2012-02-25 17:22:01 +00:00
ElgarL 50bd5869bf Prevent promoting players to, and demoting to GlobalGroups. 2012-02-25 09:29:54 +00:00
ElgarL fa49fc91d2 Prevent adding inheritances to globalgroups. These are permissions
collections, not player groups.
2012-02-25 09:22:54 +00:00
KHobbits 28f478dd04 Write to user files less, on money update. 2012-02-23 17:25:00 +00:00
KHobbits 6fb8dad0ec Balance top now has server total on first line.
Balance top will update ess balance backup if using register/vault eco.
2012-02-23 15:17:23 +00:00
KHobbits 9f605e9a88 Fixing upgrade script to allow powertool upgrade. 2012-02-23 14:49:23 +00:00
KHobbits e5b91dae73 Fixing kits for new config classes. 2012-02-22 12:32:51 +00:00
KHobbits e1749fecd1 Extra command aliases. 2012-02-22 01:29:37 +00:00
KHobbits 358edff798 Powertools dispatch commands as delayed tasks (should reduce any conflict issues). 2012-02-22 00:23:04 +00:00
KHobbits 34f13ba89c Switch powertools to use different event.
Reduce multiple triggering of powertool events.
Abort event when used with powertool.
2012-02-22 00:11:21 +00:00
KHobbits 945ba6f8ab Fix powertools with new config format. 2012-02-22 00:10:13 +00:00
KHobbits 46f05ee92f Check to see if home section exists. 2012-02-21 22:19:56 +00:00
KHobbits 6d46fc66ce Fixing home list. 2012-02-21 22:12:37 +00:00
KHobbits ed7fe9213f Fix /sudo message display. 2012-02-21 21:39:25 +00:00
ElgarL 9c68cbae72 Removed BukkitPermsOverride as this is now the default with bukkit
handling child nodes.
2012-02-21 18:40:54 +00:00
ElgarL c0df771539 Update for Bukkit R5 compatability.
Removed some unused variables.
2012-02-21 18:38:08 +00:00
snowleo 9bd0c33fef Never give our user object to other plugins! 2012-02-21 18:41:27 +01:00
KHobbits 8042cefd3d Merge branch 'master' into release 2012-02-19 01:20:50 +00:00
KHobbits 16a0f44b4d Merge remote branch 'remotes/origin/master' into release 2012-02-15 19:09:02 +00:00
KHobbits 1a2acb43ae Merge branch 'master' into release 2012-02-14 23:56:02 +00:00
KHobbits 36d07cb539 Merge branch 'master' into release 2012-02-13 17:35:05 +00:00
KHobbits 6ca1cdec4f Merge branch 'master' into release 2012-02-02 11:41:18 +00:00
KHobbits e2abf05a27 Merge branch 'master' into release 2012-01-30 05:36:03 +00:00
KHobbits d9e6f2975a Merge branch 'master' into release 2012-01-29 21:44:30 +00:00
KHobbits d8ac3587ac Merge branch 'master' into release 2012-01-29 21:39:05 +00:00
KHobbits 85c4fbdf4f Merge branch 'master' into release 2012-01-29 21:20:56 +00:00
KHobbits 5a7f38fa29 Merge branch 'master' into release 2012-01-29 05:00:04 +00:00
KHobbits 417148f5da Merge branch 'master' into release 2012-01-29 01:45:40 +00:00
KHobbits a85cbdd505 Merge branch 'master' into release 2012-01-28 12:59:15 +00:00
snowleo b4d91978c7 Merge branch 'refs/heads/master' into release 2012-01-26 04:51:10 +01:00
KHobbits 16bde87982 Merge branch 'master' into release 2012-01-26 00:31:05 +00:00
ementalo 270533652b Merge branch 'master' into release 2012-01-25 14:29:05 +00:00
KHobbits 03d640260d Merge branch 'master' into release 2012-01-25 00:04:08 +00:00
snowleo f27b2290dc Merge branch 'refs/heads/master' into release 2012-01-24 03:43:49 +01:00
KHobbits efda9beece Merge branch 'master' into release 2012-01-21 17:19:12 +00:00
KHobbits c7c7e5e4ce Merge remote branch 'remotes/origin/master' into release 2012-01-16 12:43:09 +00:00
KHobbits f61f80164d Merge branch 'master' into release 2012-01-14 15:52:55 +00:00
KHobbits d16fef9f7f Merge branch 'master' into release
~ GM needs testing before release ~
2012-01-14 13:16:33 +00:00
snowleo 4425d53664 Only info not a warning if a file is missing 2011-12-20 12:25:30 +01:00
snowleo ee5e015a63 Correctly match release and non release versions of bukkit. 2011-12-20 12:20:41 +01:00
snowleo 839ce3d526 Fix sending our player object to other plugins. 2011-12-20 11:57:51 +01:00
snowleo cc06117210 Merge branch 'refs/heads/master' into release 2011-12-19 12:07:28 +01:00
KHobbits cbd5b6c0f4 Merge remote branch 'remotes/origin/master' into release 2011-12-19 05:04:15 +00:00
snowleo 867e66e774 Merge branch 'refs/heads/master' into release 2011-12-14 11:56:09 +01:00
snowleo 45ffeaffec Merge branch 'refs/heads/master' into release 2011-12-13 23:52:58 +01:00
snowleo f91b622646 Merge branch 'refs/heads/master' into release 2011-12-13 10:32:59 +01:00
KHobbits 40a9c28699 Merge branch 'master' into release 2011-12-12 23:15:48 +00:00
KHobbits 081491d0a1 Merge branch 'master' into release 2011-12-12 23:06:40 +00:00
snowleo 8d0230d6a8 Merge branch 'refs/heads/master' into release 2011-12-08 05:41:00 +01:00
snowleo 37e5260cda Merge branch 'refs/heads/master' into release 2011-11-29 21:55:09 +01:00
snowleo 19b8031933 Merge branch 'refs/heads/master' into release 2011-11-28 22:42:17 +01:00
snowleo 99211fd407 Merge branch 'refs/heads/master' into release 2011-11-28 20:28:05 +01:00
snowleo 3d839c2b21 Merge branch 'refs/heads/master' into release 2011-11-28 20:03:09 +01:00
snowleo e1e7a1cfdb Merge branch 'refs/heads/master' into release 2011-11-28 04:23:38 +01:00
snowleo 0ed7f87ee0 Merge branch 'refs/heads/master' into release 2011-11-27 20:59:19 +01:00
snowleo 579bbc9f2c Merge branch 'refs/heads/master' into release 2011-11-24 04:26:05 +01:00
snowleo e672de949c Merge branch 'refs/heads/master' into release 2011-11-20 21:46:02 +01:00
snowleo f72762bcb2 Merge branch 'refs/heads/master' into release 2011-11-19 16:04:00 +01:00
snowleo 7ecc3c25b0 Merge branch 'refs/heads/master' into release 2011-11-17 19:06:44 +01:00
snowleo adcffba7cf Merge branch 'refs/heads/master' into release 2011-11-17 16:34:39 +01:00
snowleo e271e60144 Merge branch 'refs/heads/master' into release 2011-11-17 15:34:27 +01:00
snowleo 16be86953f Merge branch 'refs/heads/master' into release 2011-11-15 22:52:42 +01:00
KHobbits 1f527cdb9e Merge branch 'essmaster' into essrelease 2011-11-08 05:17:42 +00:00
snowleo 11e8240c5c Merge branch 'refs/heads/master' into release
Conflicts:
	EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
2011-10-22 11:55:01 +02:00
KHobbits 4aecc034c2 Fixing typo in release build. 2011-10-11 22:51:30 +01:00
KHobbits a111a07bca Merge branch 'essmaster' into essrelease 2011-10-11 20:06:23 +01:00
KHobbits eb71097546 Merge remote branch 'remotes/ess/master' into essrelease 2011-10-11 17:52:56 +01:00
KHobbits c7fcb72d6c Merge remote branch 'remotes/ess/master' into essrelease 2011-10-10 17:21:48 +01:00
snowleo 04af8ef329 Merge branch 'master' into release 2011-10-10 00:30:47 +02:00
snowleo 4cdf803ab7 Merge branch 'master' into release 2011-10-09 23:52:15 +02:00
snowleo 4595c15bee Merge branch 'master' into release 2011-10-09 17:54:59 +02:00
snowleo 1e3d2fbfd2 Merge branch 'master' into release 2011-10-08 19:43:07 +02:00
snowleo 57c25bf151 Merge branch 'master' into release 2011-10-04 23:07:30 +02:00
snowleo ae030b227a Merge branch 'master' into release 2011-10-04 22:20:10 +02:00
snowleo 4f85751694 Merge branch 'master' into release 2011-10-04 21:34:28 +02:00
KHobbits 6b0d0daa2e Merge branch 'essmaster' into essrelease 2011-10-04 14:40:12 +01:00
KHobbits 401498a4f7 Merge branch 'essmaster' into essrelease 2011-10-04 09:51:51 +01:00
KHobbits 8bb50189bc Merge remote branch 'remotes/ess/master' into essrelease 2011-09-29 00:43:42 +01:00
KHobbits eb665a059a Merge branch 'essmaster' into essrelease 2011-09-29 00:40:16 +01:00
KHobbits 3dc29be083 Merge branch 'essmaster' into essrelease 2011-09-27 02:01:52 +01:00
KHobbits 82e5447526 Merge branch 'essmaster' into essrelease 2011-09-26 23:06:02 +01:00
KHobbits 066f3fd726 Merge branch 'essmaster' into essrelease 2011-09-22 15:29:47 +01:00
snowleo f0acf733a5 Merge branch 'master' into release 2011-09-22 10:47:58 +02:00
snowleo 96c4dd2ab9 Merge branch 'master' into release 2011-09-05 14:15:07 +02:00
snowleo df3b9a7ef9 Merge branch 'master' into release 2011-09-04 20:47:46 +02:00
snowleo 70a3a5919e Merge branch 'master' into release 2011-09-02 00:05:05 +02:00
snowleo 688d37ee60 Merge branch 'master' into release 2011-09-01 16:35:47 +02:00
snowleo 3dcf8bc8fc Merge branch 'master' into release 2011-08-30 09:46:49 +02:00
snowleo 7039d613ee Merge branch 'master' into release 2011-08-29 20:43:49 +02:00
snowleo 256c963370 Merge branch 'master' into release 2011-08-21 21:44:58 +02:00
snowleo 7b8c2a4575 Merge branch 'master' into release 2011-08-21 20:22:28 +02:00
snowleo 7f1ba0d6ae Merge branch 'master' into release 2011-08-19 02:32:56 +02:00
snowleo 7e5b79aa14 Merge branch 'master' into release 2011-08-19 02:10:36 +02:00
snowleo 086343ee48 Merge branch 'master' into release 2011-08-19 01:06:52 +02:00
snowleo a1ad512a80 Merge branch 'master' into release 2011-08-19 00:42:26 +02:00
snowleo 9bb2ef9cbe Merge branch 'master' into release 2011-07-27 01:04:37 +02:00
snowleo 832910d480 Merge branch 'master' into release 2011-07-23 22:34:43 +02: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 5613975314 Merge branch 'master' into release 2011-07-23 03:11:14 +02:00
snowleo 662d30ae45 Merge branch 'master' into release 2011-07-23 03:07:38 +02:00
snowleo 57bee443b1 Merge branch 'master' into release 2011-07-23 02:39:37 +02:00
snowleo 621618e41f Merge branch 'master' into release 2011-07-21 02:58:39 +02:00
snowleo 6ccb60813a Merge branch 'master' into release 2011-07-21 02:52:25 +02:00
snowleo b34119901e Merge branch 'master' into release 2011-07-21 02:29:45 +02:00
snowleo b317aef8c9 Merge branch 'master' into release 2011-07-21 00:31:39 +02:00
snowleo fdbc6fa94f Merge branch 'master' into release 2011-07-20 23:18:34 +02:00
snowleo 0ffe24903a Merge branch 'master' into release 2011-07-20 23:09:40 +02:00
snowleo e550a7cc44 Merge branch 'master' into release 2011-07-20 22:37:43 +02:00
snowleo 82165a2af6 Merge branch 'master' into release 2011-07-20 22:22:02 +02:00
snowleo 63a4fe32c1 Merge branch 'master' into release 2011-07-20 18:40:04 +02:00
snowleo 1c44a25a4a Merge branch 'master' into release 2011-07-20 12:13:24 +02:00
snowleo cf21ecee2e Merge branch 'master' into release 2011-07-19 12:09:48 +02:00
snowleo 5467e502a5 Merge branch 'master' into release 2011-07-19 11:42:18 +02:00
snowleo 6af9ec266b Merge branch 'master' into release 2011-07-19 01:52:44 +02:00
snowleo faa7e0e7a9 Merge branch 'master' into release 2011-07-19 00:47:14 +02:00
snowleo aa3606007a Merge branch 'master' into release 2011-07-19 00:42:10 +02:00
snowleo db5974970d Merge branch 'master' into release 2011-07-18 20:55:31 +02:00
snowleo ba2539db67 Merge branch 'master' into release 2011-07-18 02:30:16 +02:00
snowleo 21d0661d79 Merge branch 'master' into release 2011-07-18 01:49:45 +02:00
snowleo 9f3eb461a9 Merge branch 'master' into release 2011-07-16 17:04:46 +02:00
snowleo 34b0deba29 Merge branch 'master' into release 2011-07-16 16:53:13 +02:00
snowleo d9a93d8dff Merge branch 'master' into release 2011-07-16 14:04:49 +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 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 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 e5eb1ca0cb More names for pistons (items.csv)
Fix for /unlimited and pistons
2011-07-01 10:52:59 +02:00
snowleo ea2649db5e Updated items.csv 2011-06-30 19:16:50 +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
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 e652ed2981 Copy&Paste is bad. 2011-06-26 02:00:57 +02:00
snowleo 28db891aa5 Fix for Register inside Essentials 2011-06-26 01:43:59 +02:00
snowleo b63ae9b771 SEVERE error messages for other plugins, that try to manually enable Essentials, FakePermissions or GroupManager 2011-06-26 01:43:19 +02:00
snowleo 27c84ceaac Remove the restriction of EssEcoApi to not use iConomy or BOSE 2011-06-25 15:35:47 +02:00
snowleo d67ccd03ca Merge branch 'bukkitupdate' into release 2011-06-25 14:27:30 +02:00
snowleo 96b0f27c51 Fix for Craftbukkit Bug 912 2011-06-12 02:59:34 +02:00
155 changed files with 5180 additions and 1509 deletions

No files matched your search

@@ -61,6 +61,12 @@ public class Backup implements Runnable
{
return;
}
if ("save-all".equalsIgnoreCase(command)) {
final CommandSender cs = server.getConsoleSender();
server.dispatchCommand(cs, "save-all");
active = false;
return;
}
LOGGER.log(Level.INFO, _("backupStarted"));
final CommandSender cs = server.getConsoleSender();
server.dispatchCommand(cs, "save-all");
@@ -24,6 +24,9 @@ import com.earth2me.essentials.commands.EssentialsCommand;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.commands.NoChargeException;
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
import com.earth2me.essentials.metrics.Metrics;
import com.earth2me.essentials.metrics.MetricsListener;
import com.earth2me.essentials.metrics.MetricsStarter;
import com.earth2me.essentials.perm.PermissionsHandler;
import com.earth2me.essentials.register.payment.Methods;
import com.earth2me.essentials.signs.SignBlockListener;
@@ -32,10 +35,8 @@ import com.earth2me.essentials.signs.SignPlayerListener;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -45,7 +46,6 @@ import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
@@ -66,7 +66,7 @@ import org.yaml.snakeyaml.error.YAMLException;
public class Essentials extends JavaPlugin implements IEssentials
{
public static final int BUKKIT_VERSION = 1952;
public static final int BUKKIT_VERSION = 2122;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
@@ -82,6 +82,7 @@ public class Essentials extends JavaPlugin implements IEssentials
private transient UserMap userMap;
private transient ExecuteTimer execTimer;
private transient I18n i18n;
private transient Metrics metrics;
@Override
public ISettings getSettings()
@@ -124,19 +125,22 @@ public class Essentials extends JavaPlugin implements IEssentials
for (Plugin plugin : pm.getPlugins())
{
if (plugin.getDescription().getName().startsWith("Essentials")
&& !plugin.getDescription().getVersion().equals(this.getDescription().getVersion()))
&& !plugin.getDescription().getVersion().equals(this.getDescription().getVersion())
&& !plugin.getDescription().getName().equals("EssentialsAntiCheat"))
{
LOGGER.log(Level.WARNING, _("versionMismatch", plugin.getDescription().getName()));
}
}
final Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-R[0-9]+-(?:[0-9]+-g[0-9a-f]+-)?b([0-9]+)jnks.*").matcher(getServer().getVersion());
final Matcher versionMatch = Pattern.compile("git-Bukkit-(?:(?:[0-9]+)\\.)+[0-9]+-R[\\.0-9]+-(?:[0-9]+-g[0-9a-f]+-)?b([0-9]+)jnks.*").matcher(getServer().getVersion());
if (versionMatch.matches())
{
final int versionNumber = Integer.parseInt(versionMatch.group(4));
if (versionNumber < BUKKIT_VERSION)
final int versionNumber = Integer.parseInt(versionMatch.group(1));
if (versionNumber < BUKKIT_VERSION && versionNumber > 100)
{
LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *");
LOGGER.log(Level.SEVERE, _("notRecommendedBukkit"));
LOGGER.log(Level.SEVERE, _("requiredBukkit", Integer.toString(BUKKIT_VERSION)));
LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *");
this.setEnabled(false);
return;
}
@@ -223,7 +227,7 @@ public class Essentials extends JavaPlugin implements IEssentials
final EssentialsEntityListener entityListener = new EssentialsEntityListener(this);
pm.registerEvents(entityListener, this);
final EssentialsWorldListener worldListener = new EssentialsWorldListener(this);
pm.registerEvents(worldListener, this);
@@ -237,6 +241,18 @@ public class Essentials extends JavaPlugin implements IEssentials
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
Economy.setEss(this);
execTimer.mark("RegListeners");
final MetricsStarter metricsStarter = new MetricsStarter(this);
if (metricsStarter.getStart() != null && metricsStarter.getStart() == true)
{
getScheduler().scheduleAsyncDelayedTask(this, metricsStarter, 1);
}
else if (metricsStarter.getStart() != null && metricsStarter.getStart() == false)
{
final MetricsListener metricsListener = new MetricsListener(this, metricsStarter);
pm.registerEvents(metricsListener, this);
}
final String timeroutput = execTimer.end();
if (getSettings().isDebug())
{
@@ -435,6 +451,16 @@ public class Essentials extends JavaPlugin implements IEssentials
return backup;
}
public Metrics getMetrics()
{
return metrics;
}
public void setMetrics(Metrics metrics)
{
this.metrics = metrics;
}
@Override
public User getUser(final Object base)
{
@@ -599,15 +625,16 @@ public class Essentials extends JavaPlugin implements IEssentials
{
return i18n;
}
private static class EssentialsWorldListener implements Listener, Runnable {
private static class EssentialsWorldListener implements Listener, Runnable
{
private transient final IEssentials ess;
public EssentialsWorldListener(final IEssentials ess)
{
this.ess = ess;
}
@EventHandler(priority = EventPriority.LOW)
public void onWorldLoad(final WorldLoadEvent event)
@@ -616,7 +643,8 @@ public class Essentials extends JavaPlugin implements IEssentials
ess.getWarps().reloadConfig();
for (IConf iConf : ((Essentials)ess).confList)
{
if (iConf instanceof IEssentialsModule) {
if (iConf instanceof IEssentialsModule)
{
iConf.reloadConfig();
}
}
@@ -629,7 +657,8 @@ public class Essentials extends JavaPlugin implements IEssentials
ess.getWarps().reloadConfig();
for (IConf iConf : ((Essentials)ess).confList)
{
if (iConf instanceof IEssentialsModule) {
if (iConf instanceof IEssentialsModule)
{
iConf.reloadConfig();
}
}
@@ -17,13 +17,9 @@ public class EssentialsBlockListener implements Listener
this.ess = ess;
}
@EventHandler(priority = EventPriority.LOWEST)
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockPlace(final BlockPlaceEvent event)
{
if (event.isCancelled())
{
return;
}
final User user = ess.getUser(event.getPlayer());
// Do not rely on getItemInHand();
// http://leaky.bukkit.org/issues/663
@@ -32,7 +28,7 @@ public class EssentialsBlockListener implements Listener
{
return;
}
boolean unlimitedForUser = user.hasUnlimited(is);
final boolean unlimitedForUser = user.hasUnlimited(is);
if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL)
{
ess.scheduleSyncDelayedTask(
@@ -1,7 +1,14 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.google.common.io.Files;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CoderResult;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@@ -24,6 +31,7 @@ public class EssentialsConf extends YamlConfiguration
private transient File configFile;
private transient String templateName = null;
private transient Class<?> resourceClass = EssentialsConf.class;
private static final Charset UTF8 = Charset.forName("UTF-8");
public EssentialsConf(final File configFile)
{
@@ -104,15 +112,48 @@ public class EssentialsConf extends YamlConfiguration
try
{
super.load(configFile);
}
catch (FileNotFoundException ex)
{
LOGGER.log(Level.SEVERE, null, ex);
final FileInputStream inputStream = new FileInputStream(configFile);
try
{
final FileChannel channel = inputStream.getChannel();
final ByteBuffer buffer = ByteBuffer.allocate((int)configFile.length());
channel.read(buffer);
buffer.rewind();
final CharBuffer data = CharBuffer.allocate((int)configFile.length());
CharsetDecoder decoder = UTF8.newDecoder();
CoderResult result = decoder.decode(buffer, data, true);
if (result.isError())
{
buffer.rewind();
data.clear();
LOGGER.log(Level.INFO, "File " + configFile.getAbsolutePath().toString() + " is not utf-8 encoded, trying " + Charset.defaultCharset().displayName());
decoder = Charset.defaultCharset().newDecoder();
result = decoder.decode(buffer, data, true);
if (result.isError())
{
throw new InvalidConfigurationException("Invalid Characters in file " + configFile.getAbsolutePath().toString());
}
else
{
decoder.flush(data);
}
}
else
{
decoder.flush(data);
}
final int end = data.position();
data.rewind();
super.loadFromString(data.subSequence(0, end).toString());
}
finally
{
inputStream.close();
}
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, null, ex);
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
}
catch (InvalidConfigurationException ex)
{
@@ -301,27 +342,55 @@ public class EssentialsConf extends YamlConfiguration
return def;
}
}
public void save() {
public void save()
{
try
{
save(configFile);
}
catch (IOException ex)
{
LOGGER.log(Level.SEVERE, null, ex);
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
}
}
public Object getProperty(String path) {
@Override
public void save(final File file) throws IOException
{
if (file == null)
{
throw new IllegalArgumentException("File cannot be null");
}
Files.createParentDirs(file);
final String data = saveToString();
final OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), UTF8);
try
{
writer.write(data);
}
finally
{
writer.close();
}
}
public Object getProperty(String path)
{
return get(path);
}
public void setProperty(String path, Object object) {
public void setProperty(String path, Object object)
{
set(path, object);
}
public void removeProperty(String path) {
public void removeProperty(String path)
{
set(path, null);
}
}
@@ -24,48 +24,50 @@ public class EssentialsEntityListener implements Listener
}
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageEvent event)
public void onEntityDamage(final EntityDamageByEntityEvent event)
{
if (event instanceof EntityDamageByEntityEvent)
final Entity eAttack = event.getDamager();
final Entity eDefend = event.getEntity();
if (eDefend instanceof Player && eAttack instanceof Player)
{
EntityDamageByEntityEvent edEvent = (EntityDamageByEntityEvent)event;
Entity eAttack = edEvent.getDamager();
Entity eDefend = edEvent.getEntity();
if (eDefend instanceof Player && eAttack instanceof Player)
final User defender = ess.getUser(eDefend);
final User attacker = ess.getUser(eAttack);
if (attacker.hasInvulnerabilityAfterTeleport() || defender.hasInvulnerabilityAfterTeleport()) {
event.setCancelled(true);
}
attacker.updateActivity(true);
final List<String> commandList = attacker.getPowertool(attacker.getItemInHand());
if (commandList != null && !commandList.isEmpty())
{
User defender = ess.getUser(eDefend);
User attacker = ess.getUser(eAttack);
attacker.updateActivity(true);
ItemStack is = attacker.getItemInHand();
List<String> commandList = attacker.getPowertool(is);
if (commandList != null && !commandList.isEmpty())
for (String command : commandList)
{
for (String command : commandList)
if (command != null && !command.isEmpty())
{
if (command != null && !command.isEmpty())
{
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
event.setCancelled(true);
return;
}
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
event.setCancelled(true);
return;
}
}
}
if (eDefend instanceof Animals && eAttack instanceof Player)
}
else if (eDefend instanceof Animals && eAttack instanceof Player)
{
final User player = ess.getUser(eAttack);
final ItemStack hand = player.getItemInHand();
if (hand != null && hand.getType() == Material.MILK_BUCKET)
{
User player = ess.getUser(eAttack);
ItemStack hand = player.getItemInHand();
if (hand != null && hand.getType() == Material.MILK_BUCKET)
{
((Animals)eDefend).setAge(-24000);
hand.setType(Material.BUCKET);
player.setItemInHand(hand);
player.updateInventory();
event.setCancelled(true);
}
((Animals)eDefend).setAge(-24000);
hand.setType(Material.BUCKET);
player.setItemInHand(hand);
player.updateInventory();
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityDamage(final EntityDamageEvent event)
{
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{
final Player player = (Player)event.getEntity();
@@ -75,8 +77,8 @@ public class EssentialsEntityListener implements Listener
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityCombust(EntityCombustEvent event)
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityCombust(final EntityCombustEvent event)
{
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{
@@ -85,26 +87,22 @@ public class EssentialsEntityListener implements Listener
}
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDeath(final EntityDeathEvent event)
public void onPlayerDeathEvent(final PlayerDeathEvent event)
{
if (event instanceof PlayerDeathEvent)
final User user = ess.getUser(event.getEntity());
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
{
final PlayerDeathEvent pdevent = (PlayerDeathEvent)event;
final User user = ess.getUser(pdevent.getEntity());
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
{
user.setLastLocation();
user.sendMessage(_("backAfterDeath"));
}
if (!ess.getSettings().areDeathMessagesEnabled())
{
pdevent.setDeathMessage("");
}
user.setLastLocation();
user.sendMessage(_("backAfterDeath"));
}
if (!ess.getSettings().areDeathMessagesEnabled())
{
event.setDeathMessage("");
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onFoodLevelChange(FoodLevelChangeEvent event)
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onFoodLevelChange(final FoodLevelChangeEvent event)
{
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{
@@ -112,8 +110,8 @@ public class EssentialsEntityListener implements Listener
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityRegainHealth(EntityRegainHealthEvent event)
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityRegainHealth(final EntityRegainHealthEvent event)
{
if (event.getRegainReason() == RegainReason.SATIATED && event.getEntity() instanceof Player
&& ess.getUser(event.getEntity()).isAfk() && ess.getSettings().getFreezeAfkPlayers())
@@ -19,7 +19,9 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@@ -43,10 +45,7 @@ public class EssentialsPlayerListener implements Listener
{
final User user = ess.getUser(event.getPlayer());
updateCompass(user);
if (ess.getSettings().changeDisplayName())
{
user.setDisplayNick();
}
user.setDisplayNick();
}
@EventHandler(priority = EventPriority.LOWEST)
@@ -69,19 +68,19 @@ public class EssentialsPlayerListener implements Listener
}
}
user.updateActivity(true);
if (ess.getSettings().changeDisplayName())
{
user.setDisplayNick();
}
user.setDisplayNick();
}
@EventHandler(priority = EventPriority.HIGH)
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerMove(final PlayerMoveEvent event)
{
if (event.isCancelled())
if (event.getFrom().getBlockX() == event.getTo().getBlockX()
&& event.getFrom().getBlockZ() == event.getTo().getBlockZ()
&& event.getFrom().getBlockY() == event.getTo().getBlockY())
{
return;
}
final User user = ess.getUser(event.getPlayer());
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers())
@@ -117,11 +116,6 @@ public class EssentialsPlayerListener implements Listener
{
user.toggleGodModeEnabled();
}
if (user.getSavedInventory() != null)
{
user.getInventory().setContents(user.getSavedInventory());
user.setSavedInventory(null);
}
user.updateActivity(false);
user.dispose();
}
@@ -132,12 +126,11 @@ public class EssentialsPlayerListener implements Listener
ess.getBackup().onPlayerJoin();
final User user = ess.getUser(event.getPlayer());
if (ess.getSettings().changeDisplayName())
{
user.setDisplayNick();
}
user.setLastLoginAddress(user.getAddress().getAddress().getHostAddress());
user.setDisplayNick();
user.setLastLogin(System.currentTimeMillis());
user.updateActivity(false);
updateCompass(user);
if (user.isAuthorized("essentials.sleepingignored"))
{
user.setSleepingIgnored(true);
@@ -182,34 +175,40 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerLogin(final PlayerLoginEvent event)
{
if (event.getResult() != Result.ALLOWED && event.getResult() != Result.KICK_FULL && event.getResult() != Result.KICK_BANNED)
switch (event.getResult())
{
case ALLOWED:
case KICK_FULL:
case KICK_BANNED:
break;
default:
return;
}
User user = ess.getUser(event.getPlayer());
user.setNPC(false);
if (user.isNPC())
{
user.setNPC(false);
}
final long currentTime = System.currentTimeMillis();
final boolean banExpired = user.checkBanTimeout(currentTime);
user.checkMuteTimeout(currentTime);
user.checkJailTimeout(currentTime);
if (banExpired == false && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
if (!banExpired && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
{
final String banReason = user.getBanReason();
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : _("defaultBanReason"));
return;
}
if (server.getOnlinePlayers().length >= server.getMaxPlayers() && !user.isAuthorized("essentials.joinfullserver"))
if (event.getResult() == Result.KICK_FULL && !user.isAuthorized("essentials.joinfullserver"))
{
event.disallow(Result.KICK_FULL, _("serverFull"));
return;
}
event.allow();
user.setLastLogin(System.currentTimeMillis());
updateCompass(user);
}
private void updateCompass(final User user)
@@ -225,29 +224,20 @@ public class EssentialsPlayerListener implements Listener
}
}
@EventHandler(priority = EventPriority.HIGH)
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerTeleport(final PlayerTeleportEvent event)
{
if (event.isCancelled())
{
return;
}
//TODO: Don't fetch user unless one of these features are enabled.
final User user = ess.getUser(event.getPlayer());
//There is TeleportCause.COMMMAND but plugins have to actively pass the cause in on their teleports.
if ((event.getCause() == TeleportCause.PLUGIN || event.getCause() == TeleportCause.COMMAND) && ess.getSettings().registerBackInListener())
{
user.setLastLocation();
}
if (ess.getSettings().changeDisplayName())
{
user.setDisplayNick();
}
updateCompass(user);
user.enableInvulnerabilityAfterTeleport();
}
@EventHandler(priority = EventPriority.HIGH)
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerEggThrow(final PlayerEggThrowEvent event)
{
final User user = ess.getUser(event.getPlayer());
@@ -259,7 +249,7 @@ public class EssentialsPlayerListener implements Listener
}
}
@EventHandler(priority = EventPriority.HIGH)
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
{
final User user = ess.getUser(event.getPlayer());
@@ -277,58 +267,9 @@ public class EssentialsPlayerListener implements Listener
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerAnimation(final PlayerAnimationEvent event)
{
final User user = ess.getUser(event.getPlayer());
user.updateActivity(true);
if (event.getAnimationType() == PlayerAnimationType.ARM_SWING
&& user.hasPowerTools() && user.arePowerToolsEnabled())
{
usePowertools(user);
}
}
private void usePowertools(final User user)
{
final ItemStack is = user.getItemInHand();
int id;
if (is == null || (id = is.getTypeId()) == 0)
{
return;
}
final List<String> commandList = user.getPowertool(id);
if (commandList == null || commandList.isEmpty())
{
return;
}
// We need to loop through each command and execute
for (String command : commandList)
{
if (command.matches(".*\\{player\\}.*"))
{
//user.sendMessage("Click a player to use this command");
continue;
}
else if (command.startsWith("c:"))
{
user.chat(command.substring(2));
}
else
{
user.getServer().dispatchCommand(user.getBase(), command);
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
{
if (event.isCancelled())
{
return;
}
final User user = ess.getUser(event.getPlayer());
final String cmd = event.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "").toLowerCase(Locale.ENGLISH);
final List<String> commands = Arrays.asList("msg", "r", "mail", "m", "t", "emsg", "tell", "er", "reply", "ereply", "email");
@@ -336,7 +277,7 @@ public class EssentialsPlayerListener implements Listener
{
for (Player player : ess.getServer().getOnlinePlayers())
{
User spyer = ess.getUser(player);
final User spyer = ess.getUser(player);
if (spyer.isSocialSpyEnabled() && !user.equals(spyer))
{
player.sendMessage(user.getDisplayName() + " : " + event.getMessage());
@@ -352,9 +293,12 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
{
final User user = ess.getUser(event.getPlayer());
user.setDisplayNick();
updateCompass(user);
if (ess.getSettings().getNoGodWorlds().contains(event.getPlayer().getLocation().getWorld().getName()))
{
User user = ess.getUser(event.getPlayer());
if (user.isGodModeEnabledRaw())
{
user.sendMessage(_("noGodWorldWarning"));
@@ -362,28 +306,82 @@ public class EssentialsPlayerListener implements Listener
}
}
@EventHandler(priority = EventPriority.MONITOR)
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerInteract(final PlayerInteractEvent event)
{
if (event.isCancelled())
final User user = ess.getUser(event.getPlayer());
user.updateActivity(true);
switch (event.getAction())
{
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
return;
}
if (ess.getSettings().getUpdateBedAtDaytime() && event.getClickedBlock().getType() == Material.BED_BLOCK)
{
event.getPlayer().setBedSpawnLocation(event.getClickedBlock().getLocation());
case RIGHT_CLICK_BLOCK:
if (event.isCancelled())
{
return;
}
if (event.getClickedBlock().getType() == Material.BED_BLOCK && ess.getSettings().getUpdateBedAtDaytime())
{
event.getPlayer().setBedSpawnLocation(event.getClickedBlock().getLocation());
}
break;
case LEFT_CLICK_BLOCK:
case LEFT_CLICK_AIR:
if (user.hasPowerTools() && user.arePowerToolsEnabled() && usePowertools(user, event.getItem()))
{
event.setCancelled(true);
}
break;
default:
break;
}
}
@EventHandler(priority = EventPriority.LOW)
public void onPlayerPickupItem(PlayerPickupItemEvent event)
private boolean usePowertools(final User user, final ItemStack is)
{
if (event.isCancelled() || !ess.getSettings().getDisableItemPickupWhileAfk())
int id;
if (is == null || (id = is.getTypeId()) == 0)
{
return false;
}
final List<String> commandList = user.getPowertool(id);
if (commandList == null || commandList.isEmpty())
{
return false;
}
boolean used = false;
// We need to loop through each command and execute
for (final String command : commandList)
{
if (command.matches(".*\\{player\\}.*"))
{
//user.sendMessage("Click a player to use this command");
continue;
}
else if (command.startsWith("c:"))
{
used = true;
user.chat(command.substring(2));
}
else
{
used = true;
ess.scheduleSyncDelayedTask(
new Runnable()
{
@Override
public void run()
{
user.getServer().dispatchCommand(user.getBase(), command);
}
});
}
}
return used;
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerPickupItem(final PlayerPickupItemEvent event)
{
if (!ess.getSettings().getDisableItemPickupWhileAfk())
{
return;
}
@@ -393,4 +391,27 @@ public class EssentialsPlayerListener implements Listener
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onInventoryClickEvent(final InventoryClickEvent event)
{
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
{
final User user = ess.getUser(event.getWhoClicked());
if (user.isInvSee() && !user.isAuthorized("essentials.invsee.modify"))
{
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onInventoryCloseEvent(final InventoryCloseEvent event)
{
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
{
final User user = ess.getUser(event.getPlayer());
user.setInvSee(false);
}
}
}
@@ -48,6 +48,7 @@ public class EssentialsTimer implements Runnable
}
user.checkMuteTimeout(currentTime);
user.checkJailTimeout(currentTime);
user.resetInvulnerabilityAfterTeleport();
}
}
}
@@ -271,18 +271,18 @@ public class EssentialsUpgrade
if (config.hasProperty("powertools"))
{
@SuppressWarnings("unchecked")
final Map<Integer, Object> powertools = (Map<Integer, Object>)config.getProperty("powertools");
final Map<String, Object> powertools = config.getConfigurationSection("powertools").getValues(false);
if (powertools == null)
{
continue;
}
for (Map.Entry<Integer, Object> entry : powertools.entrySet())
for (Map.Entry<String, Object> entry : powertools.entrySet())
{
if (entry.getValue() instanceof String)
{
List<String> temp = new ArrayList<String>();
temp.add((String)entry.getValue());
((Map<Integer, Object>)powertools).put(entry.getKey(), temp);
((Map<String, Object>)powertools).put(entry.getKey(), temp);
}
}
config.save();
@@ -730,7 +730,7 @@ public class EssentialsUpgrade
doneFile.setProperty("updateSpawnsToNewSpawnsConfig", true);
doneFile.save();
}
private void updateJailsToNewJailsConfig()
{
if (doneFile.getBoolean("updateJailsToNewJailsConfig", false))
@@ -778,6 +778,17 @@ public class EssentialsUpgrade
doneFile.save();
}
private void warnMetrics()
{
if (doneFile.getBoolean("warnMetrics", false))
{
return;
}
ess.getSettings().setMetricsEnabled(false);
doneFile.setProperty("warnMetrics", true);
doneFile.save();
}
public void beforeSettings()
{
if (!ess.getDataFolder().exists())
@@ -800,5 +811,6 @@ public class EssentialsUpgrade
deleteOldItemsCsv();
updateSpawnsToNewSpawnsConfig();
updateJailsToNewJailsConfig();
warnMetrics();
}
}
@@ -114,6 +114,7 @@ public class I18n implements II18n
{
currentLocale = new Locale(parts[0], parts[1], parts[2]);
}
ResourceBundle.clearCache();
Logger.getLogger("Minecraft").log(Level.INFO, String.format("Using locale %s", currentLocale.toString()));
customBundle = ResourceBundle.getBundle(MESSAGES, currentLocale, new FileResClassLoader(I18n.class.getClassLoader(), ess));
localeBundle = ResourceBundle.getBundle(MESSAGES, currentLocale);
@@ -1,6 +1,7 @@
package com.earth2me.essentials;
import com.earth2me.essentials.api.IJails;
import com.earth2me.essentials.metrics.Metrics;
import com.earth2me.essentials.perm.PermissionsHandler;
import com.earth2me.essentials.register.payment.Methods;
import org.bukkit.World;
@@ -9,6 +10,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitScheduler;
/**
* @deprecated This will be moved to the api package soon
*/
@@ -64,4 +66,9 @@ public interface IEssentials extends Plugin
ItemDb getItemDb();
UserMap getUserMap();
Metrics getMetrics();
void setMetrics(Metrics metrics);
}
@@ -8,6 +8,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.EventPriority;
@@ -19,6 +20,8 @@ public interface ISettings extends IConf
boolean getAnnounceNewPlayers();
String getNewPlayerKit();
String getBackupCommand();
long getBackupInterval();
@@ -39,9 +42,9 @@ public interface ISettings extends IConf
double getHealCooldown();
Object getKit(String name);
Map<String, Object> getKit(String name);
Map<String, Object> getKits();
ConfigurationSection getKits();
String getLocale();
@@ -115,11 +118,17 @@ public interface ISettings extends IConf
double getMaxMoney();
double getMinMoney();
boolean isEcoLogEnabled();
boolean isEcoLogUpdateEnabled();
boolean removeGodOnDisconnect();
boolean changeDisplayName();
boolean changePlayerListName();
boolean isPlayerCommand(String string);
@@ -147,7 +156,7 @@ public interface ISettings extends IConf
boolean getRepairEnchanted();
boolean getIsWorldTeleportPermissions();
boolean isWorldTeleportPermissions();
boolean registerBackInListener();
@@ -156,4 +165,10 @@ public interface ISettings extends IConf
EventPriority getRespawnPriority();
long getTpaAcceptCancellation();
boolean isMetricsEnabled();
void setMetricsEnabled(boolean metricsEnabled);
public long getTeleportInvulnerability();
}
@@ -32,6 +32,8 @@ public interface IUser extends Player
void takeMoney(double value);
void giveMoney(double value);
boolean canAfford(double value);
String getGroup();
@@ -26,16 +26,17 @@ import org.bukkit.plugin.PluginManager;
public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.settings.Jails> implements IJails
{
private static final transient Logger LOGGER = Bukkit.getLogger();
private static transient boolean enabled = false;
public Jails(final IEssentials ess)
{
super(ess, com.earth2me.essentials.settings.Jails.class);
reloadConfig();
registerListeners();
}
private void registerListeners()
{
enabled = true;
final PluginManager pluginManager = ess.getServer().getPluginManager();
final JailBlockListener blockListener = new JailBlockListener();
final JailPlayerListener playerListener = new JailPlayerListener();
@@ -49,6 +50,24 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
return new File(ess.getDataFolder(), "jail.yml");
}
@Override
public void finishRead()
{
if (enabled == false && getCount() > 0)
{
registerListeners();
}
}
@Override
public void finishWrite()
{
if (enabled == false)
{
registerListeners();
}
}
@Override
public Location getJail(final String jailName) throws Exception
{
@@ -115,7 +134,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
acquireReadLock();
try
{
if (!(user.getBase() instanceof OfflinePlayer))
if (user.isOnline())
{
Location loc = getJail(jail);
user.getTeleport().now(loc, false, TeleportCause.COMMAND);
@@ -146,10 +165,23 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
}
@Override
public int getCount()
{
try
{
return getList().size();
}
catch (Exception ex)
{
return 0;
}
}
private class JailBlockListener implements Listener
{
@EventHandler(priority = EventPriority.LOW)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent event)
{
final User user = ess.getUser(event.getPlayer());
@@ -159,7 +191,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
}
@EventHandler(priority = EventPriority.LOW)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockPlace(final BlockPlaceEvent event)
{
final User user = ess.getUser(event.getPlayer());
@@ -169,7 +201,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
}
@EventHandler(priority = EventPriority.LOW)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockDamage(final BlockDamageEvent event)
{
final User user = ess.getUser(event.getPlayer());
@@ -183,7 +215,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
private class JailPlayerListener implements Listener
{
@EventHandler(priority = EventPriority.LOW)
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerInteract(final PlayerInteractEvent event)
{
final User user = ess.getUser(event.getPlayer());
@@ -193,7 +225,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
}
}
@EventHandler(priority = EventPriority.HIGH)
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerRespawn(final PlayerRespawnEvent event)
{
final User user = ess.getUser(event.getPlayer());
@@ -246,7 +278,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
user.sendMessage(_("jailMessage"));
}
@EventHandler(priority = EventPriority.HIGH)
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerJoin(final PlayerJoinEvent event)
{
final User user = ess.getUser(event.getPlayer());
+46 -12
View File
@@ -1,10 +1,13 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import static com.earth2me.essentials.I18n.capitalCase;
import com.earth2me.essentials.commands.NoChargeException;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import java.util.*;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
@@ -15,16 +18,16 @@ public class Kit
{
try
{
final Map<String, Object> kits = ess.getSettings().getKits();
final ConfigurationSection kits = ess.getSettings().getKits();
final StringBuilder list = new StringBuilder();
for (String kiteItem : kits.keySet())
for (String kiteItem : kits.getKeys(false))
{
if (user.isAuthorized("essentials.kit." + kiteItem.toLowerCase(Locale.ENGLISH)))
{
list.append(" ").append(kiteItem);
list.append(" ").append(capitalCase(kiteItem));
}
}
return list.toString();
return list.toString().trim();
}
catch (Exception ex)
{
@@ -59,11 +62,16 @@ public class Kit
}
}
public static List<String> getItems(final User user, final Map<String, Object> els) throws Exception
public static List<String> getItems(final User user, final Map<String, Object> kit) throws Exception
{
if (kit == null)
{
throw new Exception(_("kitError2"));
}
try
{
return (List<String>)els.get("items");
return (List<String>)kit.get("items");
}
catch (Exception e)
{
@@ -79,18 +87,44 @@ public class Kit
boolean spew = false;
for (String d : items)
{
final String[] parts = d.split("[^0-9]+", 3);
final int id = Material.getMaterial(Integer.parseInt(parts[0])).getId();
final int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1;
final short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0;
final String[] parts = d.split(" ");
final String[] item = parts[0].split("[:+',;.]", 2);
final int id = Material.getMaterial(Integer.parseInt(item[0])).getId();
final short data = item.length > 1 ? Short.parseShort(item[1]) : 0;
final int amount = parts.length > 1 ? Integer.parseInt(parts[1]) : 1;
final ItemStack stack = new ItemStack(id, amount, data);
if (parts.length > 2)
{
for (int i = 2; i < parts.length; i++)
{
final String[] split = parts[i].split("[:+',;.]", 2);
if (split.length < 1)
{
continue;
}
final Enchantment enchantment = Enchantments.getByName(split[0]);
int level;
if (split.length > 1)
{
level = Integer.parseInt(split[1]);
}
else
{
level = enchantment.getMaxLevel();
}
stack.addEnchantment(enchantment, level);
}
}
final Map<Integer, ItemStack> overfilled;
if (user.isAuthorized("essentials.oversizedstacks"))
{
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), new ItemStack(id, amount, data));
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
}
else
{
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, new ItemStack(id, amount, data));
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, 0, stack);
}
for (ItemStack itemStack : overfilled.values())
{
+32 -29
View File
@@ -1,6 +1,7 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@@ -9,40 +10,42 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public enum Mob
{
CHICKEN("Chicken", Enemies.FRIENDLY, CreatureType.CHICKEN),
COW("Cow", Enemies.FRIENDLY, CreatureType.COW),
CREEPER("Creeper", Enemies.ENEMY, CreatureType.CREEPER),
GHAST("Ghast", Enemies.ENEMY, CreatureType.GHAST),
GIANT("Giant", Enemies.ENEMY, CreatureType.GIANT),
PIG("Pig", Enemies.FRIENDLY, CreatureType.PIG),
PIGZOMB("PigZombie", Enemies.NEUTRAL, CreatureType.PIG_ZOMBIE),
SHEEP("Sheep", Enemies.FRIENDLY, "", CreatureType.SHEEP),
SKELETON("Skeleton", Enemies.ENEMY, CreatureType.SKELETON),
SLIME("Slime", Enemies.ENEMY, CreatureType.SLIME),
SPIDER("Spider", Enemies.ENEMY, CreatureType.SPIDER),
SQUID("Squid", Enemies.FRIENDLY, CreatureType.SQUID),
ZOMBIE("Zombie", Enemies.ENEMY, CreatureType.ZOMBIE),
WOLF("Wolf", Enemies.NEUTRAL, CreatureType.WOLF),
CAVESPIDER("CaveSpider", Enemies.ENEMY, CreatureType.CAVE_SPIDER),
ENDERMAN("Enderman", Enemies.ENEMY, "", CreatureType.ENDERMAN),
SILVERFISH("Silverfish", Enemies.ENEMY, "", CreatureType.SILVERFISH),
ENDERDRAGON("EnderDragon", Enemies.ENEMY, CreatureType.ENDER_DRAGON),
VILLAGER("Villager", Enemies.FRIENDLY, CreatureType.VILLAGER),
BLAZE("Blaze", Enemies.ENEMY, CreatureType.BLAZE),
MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, CreatureType.MUSHROOM_COW),
MAGMACUBE("MagmaCube", Enemies.ENEMY, CreatureType.MAGMA_CUBE),
SNOWMAN("Snowman", Enemies.FRIENDLY, "", CreatureType.SNOWMAN);
CHICKEN("Chicken", Enemies.FRIENDLY, EntityType.CHICKEN),
COW("Cow", Enemies.FRIENDLY, EntityType.COW),
CREEPER("Creeper", Enemies.ENEMY, EntityType.CREEPER),
GHAST("Ghast", Enemies.ENEMY, EntityType.GHAST),
GIANT("Giant", Enemies.ENEMY, EntityType.GIANT),
PIG("Pig", Enemies.FRIENDLY, EntityType.PIG),
PIGZOMB("PigZombie", Enemies.NEUTRAL, EntityType.PIG_ZOMBIE),
SHEEP("Sheep", Enemies.FRIENDLY, "", EntityType.SHEEP),
SKELETON("Skeleton", Enemies.ENEMY, EntityType.SKELETON),
SLIME("Slime", Enemies.ENEMY, EntityType.SLIME),
SPIDER("Spider", Enemies.ENEMY, EntityType.SPIDER),
SQUID("Squid", Enemies.FRIENDLY, EntityType.SQUID),
ZOMBIE("Zombie", Enemies.ENEMY, EntityType.ZOMBIE),
WOLF("Wolf", Enemies.NEUTRAL, EntityType.WOLF),
CAVESPIDER("CaveSpider", Enemies.ENEMY, EntityType.CAVE_SPIDER),
ENDERMAN("Enderman", Enemies.ENEMY, "", EntityType.ENDERMAN),
SILVERFISH("Silverfish", Enemies.ENEMY, "", EntityType.SILVERFISH),
ENDERDRAGON("EnderDragon", Enemies.ENEMY, EntityType.ENDER_DRAGON),
VILLAGER("Villager", Enemies.FRIENDLY, EntityType.VILLAGER),
BLAZE("Blaze", Enemies.ENEMY, EntityType.BLAZE),
MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, EntityType.MUSHROOM_COW),
MAGMACUBE("MagmaCube", Enemies.ENEMY, EntityType.MAGMA_CUBE),
SNOWMAN("Snowman", Enemies.FRIENDLY, "", EntityType.SNOWMAN),
OCELOT("Ocelot", Enemies.NEUTRAL, EntityType.OCELOT),
IRONGOLEM("IronGolem", Enemies.NEUTRAL, EntityType.IRON_GOLEM);
public static final Logger logger = Logger.getLogger("Minecraft");
private Mob(String n, Enemies en, String s, CreatureType type)
private Mob(String n, Enemies en, String s, EntityType type)
{
this.suffix = s;
this.name = n;
@@ -50,7 +53,7 @@ public enum Mob
this.bukkitType = type;
}
private Mob(String n, Enemies en, CreatureType type)
private Mob(String n, Enemies en, EntityType type)
{
this.name = n;
this.type = en;
@@ -59,7 +62,7 @@ public enum Mob
public String suffix = "s";
final public String name;
final public Enemies type;
final private CreatureType bukkitType;
final private EntityType bukkitType;
private static final Map<String, Mob> hashMap = new HashMap<String, Mob>();
static
@@ -71,7 +74,7 @@ public enum Mob
}
public static Set<String> getMobList() {
return hashMap.keySet();
return Collections.unmodifiableSet(hashMap.keySet());
}
public LivingEntity spawn(final Player player, final Server server, final Location loc) throws MobException
@@ -99,7 +102,7 @@ public enum Mob
final protected String type;
}
public CreatureType getType()
public EntityType getType()
{
return bukkitType;
}
@@ -1,18 +1,23 @@
package com.earth2me.essentials;
import com.earth2me.essentials.craftbukkit.OfflineBedLocation;
import static com.earth2me.essentials.I18n._;
import java.net.InetSocketAddress;
import java.util.*;
import lombok.Delegate;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.conversations.Conversation;
import org.bukkit.conversations.ConversationAbandonedEvent;
import org.bukkit.entity.*;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.InventoryView.Property;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.map.MapView;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
@@ -21,7 +26,6 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
public class OfflinePlayer implements Player
{
private final transient IEssentials ess;
@@ -172,11 +176,6 @@ public class OfflinePlayer implements Player
return false;
}
public boolean isPlayer()
{
return false;
}
@Override
public int getRemainingAir()
{
@@ -901,4 +900,155 @@ public class OfflinePlayer implements Player
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T extends Projectile> T launchProjectile(Class<? extends T> arg0)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public EntityType getType()
{
return EntityType.PLAYER;
}
@Override
public <T> void playEffect(Location lctn, Effect effect, T t)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean setWindowProperty(Property prprt, int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public InventoryView getOpenInventory()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public InventoryView openInventory(Inventory invntr)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public InventoryView openWorkbench(Location lctn, boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public InventoryView openEnchanting(Location lctn, boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void openInventory(InventoryView iv)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void closeInventory()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ItemStack getItemOnCursor()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setItemOnCursor(ItemStack is)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setMetadata(String string, MetadataValue mv)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<MetadataValue> getMetadata(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean hasMetadata(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void removeMetadata(String string, Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isConversing()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void acceptConversationInput(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean beginConversation(Conversation c)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void abandonConversation(Conversation c)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void sendMessage(String[] strings)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isBlocking()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void abandonConversation(Conversation arg0, ConversationAbandonedEvent arg1)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isFlying()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setFlying(boolean arg0)
{
throw new UnsupportedOperationException("Not supported yet.");
}
}
@@ -5,15 +5,15 @@ import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.signs.EssentialsSign;
import com.earth2me.essentials.signs.Signs;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.KeywordReplacer;
import com.earth2me.essentials.textreader.SimpleTextInput;
import com.earth2me.essentials.textreader.SimpleTextPager;
import java.io.File;
import java.text.MessageFormat;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.MemoryConfiguration;
import org.bukkit.event.EventPriority;
import org.bukkit.inventory.ItemStack;
@@ -23,6 +23,7 @@ public class Settings implements ISettings
private final transient EssentialsConf config;
private final static Logger logger = Logger.getLogger("Minecraft");
private final transient IEssentials ess;
private boolean metricsEnabled = true;
public Settings(IEssentials ess)
{
@@ -209,25 +210,45 @@ public class Settings implements ISettings
{
return config.getDouble("heal-cooldown", 0);
}
private ConfigurationSection kits;
@Override
public Object getKit(String name)
public ConfigurationSection _getKits()
{
Map<String, Object> kits = (Map<String, Object>)config.get("kits");
for (Map.Entry<String, Object> entry : kits.entrySet())
if (config.isConfigurationSection("kits"))
{
if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_')))
final ConfigurationSection section = config.getConfigurationSection("kits");
final ConfigurationSection newSection = new MemoryConfiguration();
for (String kitItem : section.getKeys(false))
{
return entry.getValue();
if (section.isConfigurationSection(kitItem))
{
newSection.set(kitItem.toLowerCase(Locale.ENGLISH), section.getConfigurationSection(kitItem));
}
}
return newSection;
}
return null;
}
@Override
public Map<String, Object> getKits()
public ConfigurationSection getKits()
{
return (Map<String, Object>)config.get("kits");
return kits;
}
@Override
public Map<String, Object> getKit(String name)
{
name = name.replace('.', '_').replace('/', '_');
if (config.isConfigurationSection("kits"))
{
final ConfigurationSection kits = getKits();
if (kits.isConfigurationSection(name))
{
return kits.getConfigurationSection(name).getValues(true);
}
}
return null;
}
@Override
@@ -282,7 +303,7 @@ public class Settings implements ISettings
@Override
public boolean areSignsDisabled()
{
return enabledSigns.isEmpty();
return !signsEnabled;
}
@Override
@@ -306,13 +327,13 @@ public class Settings implements ISettings
{
String format = config.getString("chat.group-formats." + (group == null ? "Default" : group),
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
format = Util.replaceColor(format);
format = Util.replaceFormat(format);
format = format.replace("{DISPLAYNAME}", "%1$s");
format = format.replace("{GROUP}", "{0}");
format = format.replace("{MESSAGE}", "%2$s");
format = format.replace("{WORLDNAME}", "{1}");
format = format.replace("{SHORTWORLDNAME}", "{2}");
format = format.replaceAll("\\{(\\D*)\\}", "\\[$1\\]");
format = format.replaceAll("\\{(\\D*?)\\}", "\\[$1\\]");
mFormat = new MessageFormat(format);
chatFormats.put(group, mFormat);
}
@@ -328,7 +349,13 @@ public class Settings implements ISettings
@Override
public IText getAnnounceNewPlayerFormat()
{
return new SimpleTextInput(Util.replaceColor(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")));
return new SimpleTextInput(Util.replaceFormat(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")));
}
@Override
public String getNewPlayerKit()
{
return config.getString("newbies.kit", "");
}
@Override
@@ -354,8 +381,9 @@ public class Settings implements ISettings
{
config.load();
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds"));
enabledSigns = getEnabledSigns();
itemSpawnBl = getItemSpawnBlacklist();
enabledSigns = _getEnabledSigns();
itemSpawnBl = _getItemSpawnBlacklist();
kits = _getKits();
chatFormats.clear();
}
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
@@ -366,7 +394,7 @@ public class Settings implements ISettings
return itemSpawnBl;
}
private List<Integer> getItemSpawnBlacklist()
private List<Integer> _getItemSpawnBlacklist()
{
final List<Integer> epItemSpwn = new ArrayList<Integer>();
if (ess.getItemDb() == null)
@@ -394,6 +422,7 @@ public class Settings implements ISettings
return epItemSpwn;
}
private List<EssentialsSign> enabledSigns = new ArrayList<EssentialsSign>();
private boolean signsEnabled = false;
@Override
public List<EssentialsSign> enabledSigns()
@@ -401,7 +430,7 @@ public class Settings implements ISettings
return enabledSigns;
}
private List<EssentialsSign> getEnabledSigns()
private List<EssentialsSign> _getEnabledSigns()
{
List<EssentialsSign> newSigns = new ArrayList<EssentialsSign>();
@@ -412,6 +441,11 @@ public class Settings implements ISettings
{
continue;
}
if (signName.equals("COLOR") || signName.equals("COLOUR"))
{
signsEnabled = true;
continue;
}
try
{
newSigns.add(Signs.valueOf(signName).getSign());
@@ -419,7 +453,9 @@ public class Settings implements ISettings
catch (Exception ex)
{
logger.log(Level.SEVERE, _("unknownItemInList", signName, "enabledSigns"));
continue;
}
signsEnabled = true;
}
return newSigns;
}
@@ -533,6 +569,22 @@ public class Settings implements ISettings
}
return max;
}
private final static double MINMONEY = -10000000000000.0;
@Override
public double getMinMoney()
{
double min = config.getDouble("min-money", MINMONEY);
if (min > 0)
{
min = -min;
}
if (min < MINMONEY)
{
min = MINMONEY;
}
return min;
}
@Override
public boolean isEcoLogEnabled()
@@ -540,6 +592,12 @@ public class Settings implements ISettings
return config.getBoolean("economy-log-enabled", false);
}
@Override
public boolean isEcoLogUpdateEnabled()
{
return config.getBoolean("economy-log-update-enabled", false);
}
@Override
public boolean removeGodOnDisconnect()
{
@@ -552,6 +610,12 @@ public class Settings implements ISettings
return config.getBoolean("change-displayname", true);
}
@Override
public boolean changePlayerListName()
{
return config.getBoolean("change-playerlist", false);
}
@Override
public boolean useBukkitPermissions()
{
@@ -620,7 +684,7 @@ public class Settings implements ISettings
}
@Override
public boolean getIsWorldTeleportPermissions()
public boolean isWorldTeleportPermissions()
{
return config.getBoolean("world-teleport-permissions", false);
}
@@ -669,4 +733,22 @@ public class Settings implements ISettings
{
return config.getLong("tpa-accept-cancellation", 0);
}
@Override
public boolean isMetricsEnabled()
{
return metricsEnabled;
}
@Override
public void setMetricsEnabled(boolean metricsEnabled)
{
this.metricsEnabled = metricsEnabled;
}
@Override
public long getTeleportInvulnerability()
{
return config.getLong("teleport-invulnerability", 0) * 1000;
}
}
@@ -1,6 +1,5 @@
package com.earth2me.essentials;
import com.earth2me.essentials.craftbukkit.FakeExplosion;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -46,8 +45,12 @@ public class TNTExplodeListener implements Listener, Runnable
{
return;
}
FakeExplosion.createExplosion(event, ess.getServer(), ess.getServer().getOnlinePlayers());
if (event.blockList().size() < 1)
{
return;
}
event.setCancelled(true);
event.getLocation().getWorld().createExplosion(event.getLocation(), 0F);
}
@Override
@@ -56,11 +56,9 @@ public class Trade
public void isAffordableFor(final IUser user) throws ChargeException
{
final double mon = user.getMoney();
if (getMoney() != null
&& mon < getMoney()
&& getMoney() > 0
&& !user.isAuthorized("essentials.eco.loan"))
&& !user.canAfford(getMoney()))
{
throw new ChargeException(_("notEnoughMoney"));
}
@@ -71,12 +69,10 @@ public class Trade
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
}
double money;
if (command != null && !command.isEmpty()
&& !user.isAuthorized("essentials.nocommandcost.all")
&& !user.isAuthorized("essentials.nocommandcost." + command)
&& mon < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
&& 0 < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
&& !user.isAuthorized("essentials.eco.loan"))
&& 0 < (money = getCommandCost(user))
&& !user.canAfford(money))
{
throw new ChargeException(_("notEnoughMoney"));
}
@@ -143,8 +139,7 @@ public class Trade
{
if (getMoney() != null)
{
final double mon = user.getMoney();
if (mon < getMoney() && getMoney() > 0 && !user.isAuthorized("essentials.eco.loan"))
if (!user.canAfford(getMoney()) && getMoney() > 0)
{
throw new ChargeException(_("notEnoughMoney"));
}
@@ -159,13 +154,10 @@ public class Trade
InventoryWorkaround.removeItem(user.getInventory(), true, true, getItemStack());
user.updateInventory();
}
if (command != null && !command.isEmpty()
&& !user.isAuthorized("essentials.nocommandcost.all")
&& !user.isAuthorized("essentials.nocommandcost." + command))
if (command != null)
{
final double mon = user.getMoney();
final double cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
if (mon < cost && cost > 0 && !user.isAuthorized("essentials.eco.loan"))
final double cost = getCommandCost(user);
if (!user.canAfford(cost) && cost > 0)
{
throw new ChargeException(_("notEnoughMoney"));
}
@@ -196,11 +188,24 @@ public class Trade
{
return exp;
}
public Double getCommandCost(final IUser user)
{
double cost = 0d;
if (command != null && !command.isEmpty()
&& !user.isAuthorized("essentials.nocommandcost.all")
&& !user.isAuthorized("essentials.nocommandcost." + command))
{
cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
}
return cost;
}
private static FileWriter fw = null;
public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess)
{
if (!ess.getSettings().isEcoLogEnabled())
if ((loc == null && !ess.getSettings().isEcoLogUpdateEnabled())
|| (loc != null && !ess.getSettings().isEcoLogEnabled()))
{
return;
}
+115 -39
View File
@@ -7,7 +7,6 @@ import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -24,6 +23,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
private transient long lastActivity = System.currentTimeMillis();
private boolean hidden = false;
private transient Location afkPosition = null;
private boolean invSee = false;
private static final Logger logger = Logger.getLogger("Minecraft");
User(final Player base, final IEssentials ess)
@@ -57,6 +57,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
@Override
public boolean isAuthorized(final String node)
{
if (ess.getSettings().isDebug())
{
ess.getLogger().log(Level.INFO, "checking if " + base.getName() + " has " + node);
}
if (base instanceof OfflinePlayer)
{
return false;
@@ -72,7 +76,15 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return false;
}
return ess.getPermissionsHandler().hasPermission(base, node);
try
{
return ess.getPermissionsHandler().hasPermission(base, node);
}
catch (Exception ex)
{
ess.getLogger().log(Level.SEVERE, "Permission System Error: " + ess.getPermissionsHandler().getName() + " returned: " + ex.getMessage());
return false;
}
}
public void healCooldown() throws Exception
@@ -106,10 +118,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return;
}
setMoney(getMoney() + value);
sendMessage(_("addedToAccount", Util.formatCurrency(value, ess)));
sendMessage(_("addedToAccount", Util.displayCurrency(value, ess)));
if (initiator != null)
{
initiator.sendMessage(_("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
initiator.sendMessage(_("addedToOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
}
}
@@ -123,8 +135,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
setMoney(getMoney() - value);
reciever.setMoney(reciever.getMoney() + value);
sendMessage(_("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
reciever.sendMessage(_("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
sendMessage(_("moneySentTo", Util.displayCurrency(value, ess), reciever.getDisplayName()));
reciever.sendMessage(_("moneyRecievedFrom", Util.displayCurrency(value, ess), getDisplayName()));
}
else
{
@@ -145,17 +157,26 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return;
}
setMoney(getMoney() - value);
sendMessage(_("takenFromAccount", Util.formatCurrency(value, ess)));
sendMessage(_("takenFromAccount", Util.displayCurrency(value, ess)));
if (initiator != null)
{
initiator.sendMessage(_("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
initiator.sendMessage(_("takenFromOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
}
}
public boolean canAfford(final double cost)
{
return canAfford(cost, true);
}
public boolean canAfford(final double cost, final boolean permcheck)
{
final double mon = getMoney();
return mon >= cost || isAuthorized("essentials.eco.loan");
if (!permcheck || isAuthorized("essentials.eco.loan"))
{
return (mon - cost) >= ess.getSettings().getMinMoney();
}
return cost <= mon;
}
public void dispose()
@@ -178,7 +199,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
@Override
public int compareTo(final User other)
{
return Util.stripColor(this.getDisplayName()).compareToIgnoreCase(Util.stripColor(other.getDisplayName()));
return Util.stripFormat(this.getDisplayName()).compareToIgnoreCase(Util.stripFormat(other.getDisplayName()));
}
@Override
@@ -236,12 +257,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return teleportRequester;
}
public boolean isTeleportRequestHere()
public boolean isTpRequestHere()
{
return teleportRequestHere;
}
public String getNick(boolean addprefixsuffix)
public String getNick(final boolean addprefixsuffix)
{
final StringBuilder nickname = new StringBuilder();
final String nick = getNickname();
@@ -253,30 +274,34 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
nickname.append(ess.getSettings().getNicknamePrefix()).append(nick);
}
if (isOp())
if (addprefixsuffix && isOp())
{
try
{
nickname.insert(0, ess.getSettings().getOperatorColor().toString());
nickname.append("§f");
final String opPrefix = ess.getSettings().getOperatorColor().toString();
if (opPrefix.length() > 0)
{
nickname.insert(0, opPrefix);
nickname.append("§f");
}
}
catch (Exception e)
{
}
}
if (addprefixsuffix && ess.getSettings().addPrefixSuffix())
{
if (!ess.getSettings().disablePrefix())
{
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§');
nickname.insert(0, prefix);
}
if (!ess.getSettings().disableSuffix())
{
final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§');
nickname.append(suffix);
if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
if (suffix.length() < 2 || suffix.charAt(suffix.length() - 2) != '§')
{
nickname.append("§f");
}
@@ -292,36 +317,42 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
public void setDisplayNick()
{
String name = getNick(true);
setDisplayName(name);
if (name.length() > 16)
if (base.isOnline() && ess.getSettings().changeDisplayName())
{
name = getNick(false);
}
if (name.length() > 16)
{
name = name.substring(0, name.charAt(15) == '§' ? 15 : 16);
}
try
{
setPlayerListName(name);
}
catch (IllegalArgumentException e)
{
logger.log(Level.INFO, "Playerlist for " + name + " was not updated. Use a shorter displayname prefix.");
String name = getNick(true);
setDisplayName(name);
if (name.length() > 16)
{
name = getNick(false);
}
if (name.length() > 16)
{
name = Util.stripFormat(name);
}
if (ess.getSettings().changePlayerListName())
{
try
{
setPlayerListName(name);
}
catch (IllegalArgumentException e)
{
if (ess.getSettings().isDebug())
{
logger.log(Level.INFO, "Playerlist for " + name + " was not updated. Name clashed with another online player.");
}
}
}
}
}
@Override
public String getDisplayName()
{
if (!(base instanceof OfflinePlayer) && ess.getSettings().changeDisplayName())
{
setDisplayNick();
}
return super.getDisplayName() == null ? super.getName() : super.getDisplayName();
}
@Override
public Teleport getTeleport()
{
return teleport;
@@ -379,6 +410,15 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
}
super.setMoney(value);
Trade.log("Update", "Set", "API", getName(), new Trade(value, ess), null, null, null, ess);
}
public void updateMoneyCache(final double value)
{
if (ess.getPaymentMethod().hasMethod() && super.getMoney() != value)
{
super.setMoney(value);
}
}
@Override
@@ -468,6 +508,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
setAfk(false);
if (broadcast && !isHidden())
{
setDisplayNick();
ess.broadcastMessage(this, _("userIsNotAway", getDisplayName()));
}
}
@@ -500,6 +541,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
setAfk(true);
if (!isHidden())
{
setDisplayNick();
ess.broadcastMessage(this, _("userIsAway", getDisplayName()));
}
}
@@ -555,4 +597,38 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
return teleportRequestTime;
}
public boolean isInvSee()
{
return invSee;
}
public void setInvSee(final boolean set)
{
invSee = set;
}
private transient long teleportInvulnerabilityTimestamp = 0;
public void enableInvulnerabilityAfterTeleport()
{
final long time = ess.getSettings().getTeleportInvulnerability();
if (time > 0)
{
teleportInvulnerabilityTimestamp = System.currentTimeMillis() + time;
}
}
public void resetInvulnerabilityAfterTeleport()
{
if (teleportInvulnerabilityTimestamp != 0
&& teleportInvulnerabilityTimestamp < System.currentTimeMillis())
{
teleportInvulnerabilityTimestamp = 0;
}
}
public boolean hasInvulnerabilityAfterTeleport()
{
return teleportInvulnerabilityTimestamp != 0 && teleportInvulnerabilityTimestamp >= System.currentTimeMillis();
}
}
@@ -1,5 +1,6 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import java.io.File;
import java.util.*;
import java.util.logging.Logger;
@@ -41,10 +42,9 @@ public abstract class UserData extends PlayerExtension implements IConf
lastHealTimestamp = _getLastHealTimestamp();
jail = _getJail();
mails = _getMails();
savedInventory = _getSavedInventory();
teleportEnabled = getTeleportEnabled();
ignoredPlayers = getIgnoredPlayers();
godmode = getGodModeEnabled();
godmode = _getGodModeEnabled();
muted = getMuted();
muteTimeout = _getMuteTimeout();
jailed = getJailed();
@@ -58,6 +58,7 @@ public abstract class UserData extends PlayerExtension implements IConf
isNPC = _isNPC();
arePowerToolsEnabled = _arePowerToolsEnabled();
kitTimestamps = _getKitTimestamps();
nickname = _getNickname();
}
private double money;
@@ -94,17 +95,11 @@ public abstract class UserData extends PlayerExtension implements IConf
private Map<String, Object> _getHomes()
{
Object o = config.getProperty("homes");
if (o instanceof Map)
if (config.isConfigurationSection("homes"))
{
return (Map<String, Object>)o;
return config.getConfigurationSection("homes").getValues(false);
}
else
{
return new HashMap<String, Object>();
}
return new HashMap<String, Object>();
}
public Location getHome(String name) throws Exception
@@ -181,8 +176,7 @@ public abstract class UserData extends PlayerExtension implements IConf
}
else
{
//TODO: move this message to messages file
throw new Exception("Home " + name + " doesn't exist");
throw new Exception(_("invalidHome", name));
}
}
@@ -194,14 +188,21 @@ public abstract class UserData extends PlayerExtension implements IConf
}
return false;
}
private String nickname;
public String getNickname()
public String _getNickname()
{
return config.getString("nickname");
}
public String getNickname()
{
return nickname;
}
public void setNickname(String nick)
{
nickname = nick;
config.setProperty("nickname", nick);
config.save();
}
@@ -235,22 +236,15 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("unlimited", unlimited);
config.save();
}
private Map<Integer, Object> powertools;
private Map<String, Object> powertools;
@SuppressWarnings("unchecked")
private Map<Integer, Object> _getPowertools()
private Map<String, Object> _getPowertools()
{
Object o = config.getProperty("powertools");
if (o instanceof Map)
if (config.isConfigurationSection("powertools"))
{
return (Map<Integer, Object>)o;
return config.getConfigurationSection("powertools").getValues(false);
}
else
{
return new HashMap<Integer, Object>();
}
return new HashMap<String, Object>();
}
public void clearAllPowertools()
@@ -262,23 +256,23 @@ public abstract class UserData extends PlayerExtension implements IConf
public List<String> getPowertool(ItemStack stack)
{
return (List<String>)powertools.get(stack.getTypeId());
return (List<String>)powertools.get("" + stack.getTypeId());
}
public List<String> getPowertool(int id)
{
return (List<String>)powertools.get(id);
return (List<String>)powertools.get("" + id);
}
public void setPowertool(ItemStack stack, List<String> commandList)
{
if (commandList == null || commandList.isEmpty())
{
powertools.remove(stack.getTypeId());
powertools.remove("" + stack.getTypeId());
}
else
{
powertools.put(stack.getTypeId(), commandList);
powertools.put("" + stack.getTypeId(), commandList);
}
config.setProperty("powertools", powertools);
config.save();
@@ -411,50 +405,6 @@ public abstract class UserData extends PlayerExtension implements IConf
mails.add(mail);
setMails(mails);
}
private ItemStack[] savedInventory;
public ItemStack[] getSavedInventory()
{
return savedInventory;
}
private ItemStack[] _getSavedInventory()
{
int size = config.getInt("inventory.size", 0);
if (size < 1 || (getInventory() != null && size > getInventory().getSize()))
{
return null;
}
ItemStack[] is = new ItemStack[size];
for (int i = 0; i < size; i++)
{
is[i] = config.getItemStack("inventory." + i);
}
return is;
}
public void setSavedInventory(ItemStack[] is)
{
if (is == null || is.length == 0)
{
savedInventory = null;
config.removeProperty("inventory");
}
else
{
savedInventory = is;
config.setProperty("inventory.size", is.length);
for (int i = 0; i < is.length; i++)
{
if (is[i] == null || is[i].getType() == Material.AIR)
{
continue;
}
config.setProperty("inventory." + i, is[i]);
}
}
config.save();
}
private boolean teleportEnabled;
private boolean getTeleportEnabled()
@@ -528,7 +478,7 @@ public abstract class UserData extends PlayerExtension implements IConf
}
private boolean godmode;
private boolean getGodModeEnabled()
private boolean _getGodModeEnabled()
{
return config.getBoolean("godmode", false);
}
@@ -671,10 +621,16 @@ public abstract class UserData extends PlayerExtension implements IConf
return lastLogin;
}
public void setLastLogin(long time)
private void _setLastLogin(long time)
{
lastLogin = time;
config.setProperty("timestamps.login", time);
}
public void setLastLogin(long time)
{
_setLastLogin(time);
_setLastLoginAddress(base.getAddress().getAddress().getHostAddress());
config.save();
}
private long lastLogout;
@@ -707,11 +663,10 @@ public abstract class UserData extends PlayerExtension implements IConf
return lastLoginAddress;
}
public void setLastLoginAddress(String address)
private void _setLastLoginAddress(String address)
{
lastLoginAddress = address;
config.setProperty("ipAddress", address);
config.save();
}
private boolean afk;
@@ -739,7 +694,6 @@ public abstract class UserData extends PlayerExtension implements IConf
return ret;
}
private boolean newplayer;
private String geolocation;
private String _getGeoLocation()
@@ -831,16 +785,12 @@ public abstract class UserData extends PlayerExtension implements IConf
private Map<String, Object> _getKitTimestamps()
{
final Object map = config.getProperty("timestamps.kits");
if (map instanceof Map)
if (config.isConfigurationSection("timestamps.kits"))
{
return (Map<String, Object>)map;
}
else
{
return new HashMap<String, Object>();
return config.getConfigurationSection("timestamps.kits").getValues(false);
}
return new HashMap<String, Object>();
}
public Long getKitTimestamp(final String name)
+103 -13
View File
@@ -242,6 +242,7 @@ public class Util
AIR_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
AIR_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
AIR_MATERIALS.add(Material.STONE_BUTTON.getId());
AIR_MATERIALS.add(Material.SNOW.getId());
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
@@ -249,8 +250,10 @@ public class Util
AIR_MATERIALS.add(Material.PUMPKIN_STEM.getId());
AIR_MATERIALS.add(Material.MELON_STEM.getId());
AIR_MATERIALS.add(Material.VINE.getId());
AIR_MATERIALS.add(Material.NETHER_WARTS.getId());
AIR_MATERIALS.add(Material.FENCE_GATE.getId());
AIR_MATERIALS.add(Material.WATER_LILY.getId());
AIR_MATERIALS.add(Material.NETHER_FENCE.getId());
AIR_MATERIALS.add(Material.NETHER_WARTS.getId());
for (Integer integer : AIR_MATERIALS)
{
@@ -293,7 +296,7 @@ public class Util
while (isBlockUnsafe(world, x, y, z))
{
y += 1;
if (y >= 127)
if (y >= world.getHighestBlockYAt(x, z))
{
x += 1;
break;
@@ -304,8 +307,8 @@ public class Util
y -= 1;
if (y <= 1)
{
y = 127;
x += 1;
y = world.getHighestBlockYAt(x, z);
if (x - 32 > loc.getBlockX())
{
throw new Exception(_("holeInFloor"));
@@ -422,11 +425,11 @@ public class Util
}
return is;
}
private static DecimalFormat df = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
private static DecimalFormat dFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
public static String formatCurrency(final double value, final IEssentials ess)
public static String formatAsCurrency(final double value)
{
String str = ess.getSettings().getCurrencySymbol() + df.format(value);
String str = dFormat.format(value);
if (str.endsWith(".00"))
{
str = str.substring(0, str.length() - 3);
@@ -434,6 +437,16 @@ public class Util
return str;
}
public static String displayCurrency(final double value, final IEssentials ess)
{
return _("currency", ess.getSettings().getCurrencySymbol(), formatAsCurrency(value));
}
public static String shortCurrency(final double value, final IEssentials ess)
{
return ess.getSettings().getCurrencySymbol() + formatAsCurrency(value);
}
public static double roundDouble(final double d)
{
return Math.round(d * 100.0) / 100.0;
@@ -485,26 +498,103 @@ public class Util
}
return buf.toString();
}
private static transient final Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-FKa-fk]");
private static transient final Pattern EASY_COLOR_PATTERN = Pattern.compile("&([0-9a-fk])");
private static transient final Pattern URL_PATTERN = Pattern.compile("((?:(?:https?)://)?[\\w-_\\.]{2,})\\.([a-z]{2,3}(?:/\\S+)?)");
private static transient final Pattern VANILLA_PATTERN = Pattern.compile("\u00A7+[0-9A-FK-ORa-fk-or]");
private static transient final Pattern REPLACE_PATTERN = Pattern.compile("&([0-9a-fk-or])");
private static transient final Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-Fa-f]");
private static transient final Pattern VANILLA_MAGIC_PATTERN = Pattern.compile("\u00A7+[Kk]");
private static transient final Pattern VANILLA_FORMAT_PATTERN = Pattern.compile("\u00A7+[L-ORl-or]");
private static transient final Pattern REPLACE_COLOR_PATTERN = Pattern.compile("&([0-9a-f])");
private static transient final Pattern REPLACE_MAGIC_PATTERN = Pattern.compile("&(k)");
private static transient final Pattern REPLACE_FORMAT_PATTERN = Pattern.compile("&([l-or])");
public static String stripColor(final String input)
public static String stripFormat(final String input)
{
if (input == null)
{
return null;
}
return VANILLA_COLOR_PATTERN.matcher(input).replaceAll("");
return VANILLA_PATTERN.matcher(input).replaceAll("");
}
public static String replaceColor(final String input)
public static String replaceFormat(final String input)
{
if (input == null)
{
return null;
}
return REPLACE_PATTERN.matcher(input).replaceAll("\u00a7$1");
}
return EASY_COLOR_PATTERN.matcher(input).replaceAll("\u00a7$1");
public static String blockURL(final String input)
{
if (input == null)
{
return null;
}
String text = URL_PATTERN.matcher(input).replaceAll("$1 $2");
while (URL_PATTERN.matcher(text).find())
{
text = URL_PATTERN.matcher(text).replaceAll("$1 $2");
}
return text;
}
public static String formatString(final IUser user, final String permBase, final String input)
{
if (input == null)
{
return null;
}
String message;
if (user.isAuthorized(permBase + ".color"))
{
message = Util.replaceColor(input, REPLACE_COLOR_PATTERN);
}
else
{
message = Util.stripColor(input, VANILLA_COLOR_PATTERN);
}
if (user.isAuthorized(permBase + ".magic"))
{
message = Util.replaceColor(message, REPLACE_MAGIC_PATTERN);
}
else
{
message = Util.stripColor(message, VANILLA_MAGIC_PATTERN);
}
if (user.isAuthorized(permBase + ".format"))
{
message = Util.replaceColor(message, REPLACE_FORMAT_PATTERN);
}
else
{
message = Util.stripColor(message, VANILLA_FORMAT_PATTERN);
}
return message;
}
public static String formatMessage(final IUser user, final String permBase, final String input)
{
if (input == null)
{
return null;
}
String message = formatString(user, permBase, input);
if (!user.isAuthorized(permBase + ".url"))
{
message = Util.blockURL(message);
}
return message;
}
private static String stripColor(final String input, final Pattern pattern)
{
return pattern.matcher(input).replaceAll("");
}
private static String replaceColor(final String input, final Pattern pattern)
{
return pattern.matcher(input).replaceAll("\u00a7$1");
}
}
@@ -1,6 +1,7 @@
package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.commands.WarpNotFoundException;
import java.io.File;
import java.util.*;
import java.util.logging.Level;
@@ -48,7 +49,7 @@ public class Warps implements IConf
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp));
if (conf == null)
{
throw new Exception(_("warpNotExist"));
throw new WarpNotFoundException();
}
return conf.getLocation(null, server);
}
@@ -115,6 +115,10 @@ public final class Economy
{
throw new UserDoesNotExistException(name);
}
if (balance < ess.getSettings().getMinMoney())
{
throw new NoLoanPermittedException();
}
if (balance < 0.0 && !user.isAuthorized("essentials.eco.loan"))
{
throw new NoLoanPermittedException();
@@ -245,7 +249,7 @@ public final class Economy
{
throw new RuntimeException(noCallBeforeLoad);
}
return Util.formatCurrency(amount, ess);
return Util.displayCurrency(amount, ess);
}
/**
@@ -10,6 +10,8 @@ public interface IJails extends IReload
Collection<String> getList() throws Exception;
int getCount();
void removeJail(String jail) throws Exception;
void sendToJail(com.earth2me.essentials.IUser user, String jail) throws Exception;
@@ -31,6 +31,7 @@ public class Commandafk extends EssentialsCommand
private void toggleAfk(User user)
{
user.setDisplayNick();
if (!user.toggleAfk())
{
//user.sendMessage(_("markedAsNotAway"));
@@ -17,8 +17,11 @@ public class Commandantioch extends EssentialsCommand
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
ess.broadcastMessage(user, "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
ess.broadcastMessage(user, "who being naughty in My sight, shall snuff it.");
if (args.length > 0)
{
ess.broadcastMessage(user, "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
ess.broadcastMessage(user, "who being naughty in My sight, shall snuff it.");
}
final Location loc = Util.getTarget(user);
loc.getWorld().spawn(loc, TNTPrimed.class);
@@ -19,7 +19,12 @@ public class Commandbackup extends EssentialsCommand
final Backup backup = ess.getBackup();
if (backup == null)
{
throw new Exception();
throw new Exception(_("backupDisabled"));
}
final String command = ess.getSettings().getBackupCommand();
if (command == null || "".equals(command) || "save-all".equalsIgnoreCase(command))
{
throw new Exception(_("backupDisabled"));
}
backup.run();
sender.sendMessage(_("backupStarted"));
@@ -21,7 +21,7 @@ public class Commandbalance extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
sender.sendMessage(_("balance", Util.formatCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
sender.sendMessage(_("balance", Util.displayCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
}
@Override
@@ -32,6 +32,6 @@ public class Commandbalance extends EssentialsCommand
|| user.isAuthorized("essentials.balance.other"))
? user
: getPlayer(server, args, 0, true)).getMoney();
user.sendMessage(_("balance", Util.formatCurrency(bal, ess)));
user.sendMessage(_("balance", Util.displayCurrency(bal, ess)));
}
}
@@ -105,14 +105,18 @@ public class Commandbalancetop extends EssentialsCommand
{
if (force || cacheage <= System.currentTimeMillis() - CACHETIME)
{
cache.getLines().clear();
cache.getLines().clear();
final Map<String, Double> balances = new HashMap<String, Double>();
double totalMoney = 0d;
for (String u : ess.getUserMap().getAllUniqueUsers())
{
final User user = ess.getUserMap().getUser(u);
if (user != null)
{
balances.put(user.getDisplayName(), user.getMoney());
final double userMoney = user.getMoney();
user.updateMoneyCache(userMoney);
totalMoney += userMoney;
balances.put(user.getDisplayName(), userMoney);
}
}
@@ -125,10 +129,12 @@ public class Commandbalancetop extends EssentialsCommand
return -entry1.getValue().compareTo(entry2.getValue());
}
});
cache.getLines().add(_("serverTotal", Util.displayCurrency(totalMoney, ess)));
int pos = 1;
for (Map.Entry<String, Double> entry : sortedEntries)
{
cache.getLines().add(pos + ". " + entry.getKey() + ", " + Util.formatCurrency(entry.getValue(), ess));
cache.getLines().add(pos + ". " + entry.getKey() + ", " + Util.displayCurrency(entry.getValue(), ess));
pos++;
}
cacheage = System.currentTimeMillis();
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -24,7 +23,7 @@ public class Commandban extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final User user = getPlayer(server, args, 0, true);
if (user.getBase() instanceof OfflinePlayer)
if (!user.isOnline())
{
if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
@@ -27,6 +27,10 @@ public class Commandbigtree extends EssentialsCommand
{
tree = TreeType.BIG_TREE;
}
else if (args.length > 0 && args[0].equalsIgnoreCase("jungle"))
{
tree = TreeType.JUNGLE;
}
else
{
throw new NotEnoughArgumentsException();
@@ -1,10 +1,14 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
public class Commandbreak extends EssentialsCommand
@@ -29,8 +33,10 @@ public class Commandbreak extends EssentialsCommand
}
if (block.getType() == Material.BEDROCK && !user.isAuthorized("essentials.break.bedrock"))
{
throw new Exception("You are not allowed to destroy bedrock."); //TODO: Translation
throw new Exception(_("noBreakBedrock"));
}
//final List<ItemStack> list = (List<ItemStack>)block.getDrops();
//final BlockBreakEvent event = new BlockBreakEvent(block, user.getBase(), list);
final BlockBreakEvent event = new BlockBreakEvent(block, user.getBase());
server.getPluginManager().callEvent(event);
if (event.isCancelled())
@@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import java.util.Locale;
import org.bukkit.Server;
@@ -33,7 +34,31 @@ public class Commandeco extends EssentialsCommand
throw new NotEnoughArgumentsException(ex);
}
if (args[1].contentEquals("*"))
if (args[1].contentEquals("**"))
{
for (String sUser : ess.getUserMap().getAllUniqueUsers())
{
final User player = ess.getUser(sUser);
switch (cmd)
{
case GIVE:
player.giveMoney(amount);
break;
case TAKE:
if (player.canAfford(amount, false))
{
player.takeMoney(amount);
}
break;
case RESET:
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
break;
}
}
}
else if (args[1].contentEquals("*"))
{
for (Player onlinePlayer : server.getOnlinePlayers())
{
@@ -45,6 +70,10 @@ public class Commandeco extends EssentialsCommand
break;
case TAKE:
if (!player.canAfford(amount, false))
{
throw new Exception(_("notEnoughMoney"));
}
player.takeMoney(amount);
break;
@@ -64,6 +93,10 @@ public class Commandeco extends EssentialsCommand
break;
case TAKE:
if (!player.canAfford(amount, false))
{
throw new Exception(_("notEnoughMoney"));
}
player.takeMoney(amount, sender);
break;
@@ -2,13 +2,18 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.metrics.Metrics;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
@@ -35,6 +40,14 @@ public class Commandessentials extends EssentialsCommand
{
run_nya(server, sender, commandLabel, args);
}
else if (args[0].equalsIgnoreCase("moo"))
{
run_moo(server, sender, commandLabel, args);
}
else if (args[0].equalsIgnoreCase("opt-out"))
{
run_optout(server, sender, commandLabel, args);
}
else {
run_reload(server, sender, commandLabel, args);
}
@@ -112,7 +125,7 @@ public class Commandessentials extends EssentialsCommand
if (loc.getBlock().getTypeId() == 0)
{
noteBlocks.put(player, loc.getBlock());
loc.getBlock().setType(Material.NOTE_BLOCK);
player.sendBlockChange(loc, Material.NOTE_BLOCK, (byte)0);
}
}
taskid = ess.scheduleSyncRepeatingTask(new Runnable()
@@ -144,7 +157,6 @@ public class Commandessentials extends EssentialsCommand
}
}
}, 20, 2);
return;
}
private void stopTune()
@@ -159,4 +171,31 @@ public class Commandessentials extends EssentialsCommand
}
noteBlocks.clear();
}
private void run_moo(final Server server, final CommandSender sender, final String command, final String args[])
{
if(sender instanceof ConsoleCommandSender)
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | ||", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } );
else
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | | |", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } );
}
private void run_optout(final Server server, final CommandSender sender, final String command, final String args[])
{
final Metrics metrics = ess.getMetrics();
try
{
sender.sendMessage("Essentials collects simple metrics to highlight which features to concentrate work on in the future.");
if (metrics.isOptOut()) {
metrics.enable();
} else {
metrics.disable();
}
sender.sendMessage("Anonymous Metrics are now: " + (metrics.isOptOut() ? "disabled" : "enabled"));
}
catch (IOException ex)
{
sender.sendMessage("Unable to modify 'plugins/PluginMetrics/config.yml': " + ex.getMessage());
}
}
}
@@ -0,0 +1,63 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import java.util.Locale;
import org.bukkit.GameMode;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandfly extends EssentialsCommand
{
public Commandfly()
{
super("fly");
}
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
flyOtherPlayers(server, sender, args[0]);
}
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length > 0 && !args[0].trim().isEmpty() && user.isAuthorized("essentials.fly.others"))
{
flyOtherPlayers(server, user, args[0]);
return;
}
user.setAllowFlight(!user.getAllowFlight());
if (!user.getAllowFlight())
{
user.setFlying(false);
}
user.sendMessage(_("flyMode", _(user.getAllowFlight() ? "enabled" : "disabled"), user.getDisplayName()));
}
private void flyOtherPlayers(final Server server, final CommandSender sender, final String name)
{
for (Player matchPlayer : server.matchPlayer(name))
{
final User player = ess.getUser(matchPlayer);
if (player.isHidden())
{
continue;
}
player.setAllowFlight(!player.getAllowFlight());
if (!player.getAllowFlight())
{
player.setFlying(false);
}
sender.sendMessage(_("flyMode", _(player.getAllowFlight() ? "enabled" : "disabled"), player.getDisplayName()));
}
}
}
@@ -12,21 +12,23 @@ public class Commandgetpos extends EssentialsCommand
{
super("getpos");
}
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length > 0 && user.isAuthorized("essentials.getpos.others"))
{
final User otherUser = getPlayer(server, args, 0);
outputPosition(user, otherUser.getLocation(), user.getLocation());
}
else
{
outputPosition(user, user.getLocation(), null);
if (!otherUser.isHidden() || user.isAuthorized("essentials.list.hidden"))
{
outputPosition(user, otherUser.getLocation(), user.getLocation());
return;
}
}
outputPosition(user, user.getLocation(), null);
}
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
@@ -37,7 +39,7 @@ public class Commandgetpos extends EssentialsCommand
final User user = getPlayer(server, args, 0);
outputPosition(sender, user.getLocation(), null);
}
//TODO: Translate
private void outputPosition(final CommandSender sender, final Location coords, final Location distance)
{
@@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import com.earth2me.essentials.User;
import java.util.Locale;
@@ -19,7 +20,6 @@ public class Commandgive extends EssentialsCommand
super("give");
}
//TODO: move these messages to message file
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
@@ -39,7 +39,7 @@ public class Commandgive extends EssentialsCommand
: (!ess.getUser(sender).isAuthorized("essentials.itemspawn.exempt")
&& !ess.getUser(sender).canSpawnItem(stack.getTypeId()))))
{
throw new Exception(ChatColor.RED + "You are not allowed to spawn the item " + itemname);
throw new Exception(_("cantSpawnItem", itemname));
}
final User giveTo = getPlayer(server, args, 0);
@@ -82,9 +82,10 @@ public class Commandgive extends EssentialsCommand
if (stack.getType() == Material.AIR)
{
throw new Exception(ChatColor.RED + "You can't give air.");
throw new Exception(_("cantSpawnItem", "Air"));
}
//TODO: TL this.
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
if (giveTo.isAuthorized("essentials.oversizedstacks"))
@@ -4,6 +4,7 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.textreader.*;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -21,6 +22,7 @@ public class Commandhelp extends EssentialsCommand
IText output;
String pageStr = args.length > 0 ? args[0] : null;
String chapterPageStr = args.length > 1 ? args[1] : null;
String command = commandLabel;
final IText input = new TextInput(user, "help", false, ess);
if (input.getLines().isEmpty())
@@ -31,7 +33,12 @@ public class Commandhelp extends EssentialsCommand
}
else
{
output = new HelpInput(user, pageStr, ess);
if (pageStr.length() > 26)
{
pageStr = pageStr.substring(0, 25);
}
output = new HelpInput(user, pageStr.toLowerCase(Locale.ENGLISH), ess);
command = command.concat(" ").concat(pageStr);
pageStr = chapterPageStr;
}
chapterPageStr = null;
@@ -41,7 +48,7 @@ public class Commandhelp extends EssentialsCommand
output = new KeywordReplacer(input, user, ess);
}
final TextPager pager = new TextPager(output);
pager.showPage(pageStr, chapterPageStr, commandLabel, user);
pager.showPage(pageStr, chapterPageStr, command, user);
}
@Override
@@ -22,8 +22,8 @@ public class Commandhelpop extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
final String message = _("helpOp", user.getDisplayName(), Util.stripColor(getFinalArg(args, 0)));
user.setDisplayNick();
final String message = _("helpOp", user.getDisplayName(), Util.stripFormat(getFinalArg(args, 0)));
logger.log(Level.INFO, message);
for (Player onlinePlayer : server.getOnlinePlayers())
{
@@ -17,41 +17,12 @@ public class Commandinvsee extends EssentialsCommand
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1 && user.getSavedInventory() == null)
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
User invUser = user;
if (args.length == 1)
{
invUser = getPlayer(server, args, 0);
}
if (invUser == user && user.getSavedInventory() != null)
{
invUser.getInventory().setContents(user.getSavedInventory());
user.setSavedInventory(null);
user.sendMessage(_("invRestored"));
throw new NoChargeException();
}
if (user.getSavedInventory() == null)
{
user.setSavedInventory(user.getInventory().getContents());
}
ItemStack[] invUserStack = invUser.getInventory().getContents();
final int userStackLength = user.getInventory().getContents().length;
if (invUserStack.length < userStackLength)
{
invUserStack = Arrays.copyOf(invUserStack, userStackLength);
}
if (invUserStack.length > userStackLength)
{
throw new Exception(_("invBigger"));
}
user.getInventory().setContents(invUserStack);
user.sendMessage(_("invSee", invUser.getDisplayName()));
user.sendMessage(_("invSeeHelp"));
throw new NoChargeException();
final User invUser = getPlayer(server, args, 0);
user.setInvSee(true);
user.openInventory(invUser.getInventory());
}
}
@@ -125,7 +125,7 @@ public class Commandkillall extends EssentialsCommand
{
if (entity instanceof Animals || entity instanceof NPC || entity instanceof Snowman || entity instanceof WaterMob)
{
EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST);
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
ess.getServer().getPluginManager().callEvent(event);
entity.remove();
numKills++;
@@ -135,7 +135,7 @@ public class Commandkillall extends EssentialsCommand
{
if (entity instanceof Monster || entity instanceof ComplexLivingEntity || entity instanceof Flying || entity instanceof Slime)
{
EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST);
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
ess.getServer().getPluginManager().callEvent(event);
entity.remove();
numKills++;
@@ -143,14 +143,14 @@ public class Commandkillall extends EssentialsCommand
}
else if (all)
{
EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST);
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
ess.getServer().getPluginManager().callEvent(event);
entity.remove();
numKills++;
}
else if (entityClass != null && entityClass.isAssignableFrom(entity.getClass()))
{
EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST);
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
ess.getServer().getPluginManager().callEvent(event);
entity.remove();
numKills++;
@@ -32,22 +32,22 @@ public class Commandkit extends EssentialsCommand
else
{
final String kitName = args[0].toLowerCase(Locale.ENGLISH);
final Object kit = ess.getSettings().getKit(kitName);
final Map<String, Object> kit = ess.getSettings().getKit(kitName);
if (!user.isAuthorized("essentials.kit." + kitName))
{
throw new Exception(_("noKitPermission", "essentials.kit." + kitName));
}
final Map<String, Object> els = (Map<String, Object>)kit;
final List<String> items = Kit.getItems(user, els);
Kit.checkTime(user, kitName, els);
final List<String> items = Kit.getItems(user, kit);
Kit.checkTime(user, kitName, kit);
final Trade charge = new Trade("kit-" + kitName, ess);
charge.isAffordableFor(user);
Kit.expandItems(ess, user, items);
charge.charge(user);
user.sendMessage(_("kitGive", kitName));
@@ -0,0 +1,44 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Mob;
import com.earth2me.essentials.User;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.entity.Ocelot;
public class Commandkittycannon extends EssentialsCommand
{
private static Random random = new Random();
public Commandkittycannon()
{
super("kittycannon");
}
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
final Mob cat = Mob.OCELOT;
final Ocelot ocelot = (Ocelot)cat.spawn(user, server, user.getEyeLocation());
if (ocelot == null)
{
return;
}
final int i = random.nextInt(Ocelot.Type.values().length);
ocelot.setCatType(Ocelot.Type.values()[i]);
ocelot.setTamed(true);
ocelot.setVelocity(user.getEyeLocation().getDirection().multiply(2));
ess.scheduleSyncDelayedTask(new Runnable()
{
@Override
public void run()
{
final Location loc = ocelot.getLocation();
ocelot.remove();
loc.getWorld().createExplosion(loc, 0F);
}
}, 20);
}
}
@@ -24,7 +24,7 @@ public class Commandlightning extends EssentialsCommand
{
user = ess.getUser(((Player)sender));
}
if (args.length < 1 & user != null)
if ((args.length < 1 || !user.isAuthorized("essentials.lightning.others")) & user != null)
{
user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation());
return;
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.*;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -43,8 +44,10 @@ public class Commandlist extends EssentialsCommand
if (showhidden && playerHidden > 0)
{
online = _("listAmountHidden", server.getOnlinePlayers().length - playerHidden, playerHidden, server.getMaxPlayers());
} else {
online = _("listAmount",server.getOnlinePlayers().length - playerHidden, server.getMaxPlayers());
}
else
{
online = _("listAmount", server.getOnlinePlayers().length - playerHidden, server.getMaxPlayers());
}
sender.sendMessage(online);
@@ -72,7 +75,7 @@ public class Commandlist extends EssentialsCommand
for (String group : groups)
{
final StringBuilder groupString = new StringBuilder();
groupString.append(group).append(": ");
groupString.append(_("listGroupTag", Util.replaceFormat(group)));
final List<User> users = sort.get(group);
Collections.sort(users);
boolean first = true;
@@ -94,6 +97,7 @@ public class Commandlist extends EssentialsCommand
{
groupString.append(_("listHiddenTag"));
}
user.setDisplayNick();
groupString.append(user.getDisplayName());
groupString.append("§f");
}
@@ -135,6 +139,7 @@ public class Commandlist extends EssentialsCommand
{
onlineUsers.append(_("listHiddenTag"));
}
user.setDisplayNick();
onlineUsers.append(user.getDisplayName());
onlineUsers.append("§f");
}
@@ -59,7 +59,7 @@ public class Commandmail extends EssentialsCommand
}
if (!u.isIgnoredPlayer(user.getName()))
{
final String mail = Util.sanitizeString(Util.stripColor(getFinalArg(args, 2)));
final String mail = Util.sanitizeString(Util.stripFormat(getFinalArg(args, 2)));
u.addMail(user.getName() + ": " + mail);
}
user.sendMessage(_("mailSent"));
@@ -71,7 +71,7 @@ public class Commandmail extends EssentialsCommand
{
throw new Exception(_("noPerm", "essentials.mail.sendall"));
}
ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripColor(getFinalArg(args, 1))));
ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripFormat(getFinalArg(args, 1))));
user.sendMessage(_("mailSent"));
return;
}
@@ -27,15 +27,9 @@ public class Commandme extends EssentialsCommand
}
String message = getFinalArg(args, 0);
if (user.isAuthorized("essentials.chat.color"))
{
message = Util.replaceColor(message);
}
else {
message = Util.stripColor(message);
}
message = Util.formatMessage(user, "essentials.chat", message);
user.setDisplayNick();
ess.broadcastMessage(user, _("action", user.getDisplayName(), message));
}
}
@@ -34,18 +34,11 @@ public class Commandmsg extends EssentialsCommand
{
throw new Exception(_("voiceSilenced"));
}
if (user.isAuthorized("essentials.msg.color"))
{
message = Util.replaceColor(message);
}
else
{
message = Util.stripColor(message);
}
message = Util.formatMessage(user, "essentials.msg", message);
}
else
{
message = Util.replaceColor(message);
message = Util.replaceFormat(message);
}
final String translatedMe = _("me");
@@ -64,11 +64,13 @@ public class Commandnick extends EssentialsCommand
private String formatNickname(final User user, final String nick)
{
if (user == null || user.isAuthorized("essentials.nick.color"))
if (user == null)
{
return nick.replace('&', '\u00a7').replaceAll("\u00a7+k", "");
} else {
return Util.stripColor(nick);
return Util.replaceFormat(nick);
}
else
{
return Util.formatString(user, "essentials.nick", nick);
}
}
@@ -51,7 +51,7 @@ public class Commandnuke extends EssentialsCommand
{
for (int z = -10; z <= 10; z += 5)
{
final Location tntloc = new Location(world, loc.getBlockX() + x, 127, loc.getBlockZ() + z);
final Location tntloc = new Location(world, loc.getBlockX() + x, world.getHighestBlockYAt(loc) + 64, loc.getBlockZ() + z);
final TNTPrimed tnt = world.spawn(tntloc, TNTPrimed.class);
}
}
@@ -23,7 +23,7 @@ public class Commandping extends EssentialsCommand
}
else
{
sender.sendMessage(Util.replaceColor(getFinalArg(args, 0)));
sender.sendMessage(Util.replaceFormat(getFinalArg(args, 0)));
}
}
}
@@ -32,20 +32,13 @@ public class Commandr extends EssentialsCommand
if (sender instanceof Player)
{
User user = ess.getUser(sender);
if (user.isAuthorized("essentials.msg.color"))
{
message = Util.replaceColor(message);
}
else
{
message = Util.stripColor(message);
}
message = Util.formatMessage(user, "essentials.msg", message);
replyTo = user;
senderName = user.getDisplayName();
}
else
{
message = Util.replaceColor(message);
message = Util.replaceFormat(message);
replyTo = Console.getConsoleReplyTo();
senderName = Console.NAME;
}
@@ -31,9 +31,10 @@ public class Commandrealname extends EssentialsCommand
{
continue;
}
final String displayName = Util.stripColor(u.getDisplayName()).toLowerCase(Locale.ENGLISH);
u.setDisplayNick();
final String displayName = Util.stripFormat(u.getDisplayName()).toLowerCase(Locale.ENGLISH);
if (!whois.equals(displayName)
&& !displayName.equals(Util.stripColor(ess.getSettings().getNicknamePrefix()) + whois)
&& !displayName.equals(Util.stripFormat(ess.getSettings().getNicknamePrefix()) + whois)
&& !whois.equalsIgnoreCase(u.getName()))
{
continue;
@@ -16,6 +16,17 @@ public class Commandseen extends EssentialsCommand
@Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
seen(server, sender, args, true);
}
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
seen(server, user, args, user.isAuthorized("essentials.seen.banreason"));
}
protected void seen(final Server server, final CommandSender sender, final String[] args, final boolean show) throws Exception
{
if (args.length < 1)
{
@@ -23,20 +34,22 @@ public class Commandseen extends EssentialsCommand
}
try
{
User u = getPlayer(server, args, 0);
sender.sendMessage(_("seenOnline", u.getDisplayName(), Util.formatDateDiff(u.getLastLogin())));
User player = getPlayer(server, args, 0);
player.setDisplayNick();
sender.sendMessage(_("seenOnline", player.getDisplayName(), Util.formatDateDiff(player.getLastLogin())));
}
catch (NoSuchFieldException e)
{
User u = ess.getOfflineUser(args[0]);
if (u == null)
User player = ess.getOfflineUser(args[0]);
if (player == null)
{
throw new Exception(_("playerNotFound"));
}
sender.sendMessage(_("seenOffline", u.getDisplayName(), Util.formatDateDiff(u.getLastLogout())));
if (u.isBanned())
player.setDisplayNick();
sender.sendMessage(_("seenOffline", player.getDisplayName(), Util.formatDateDiff(player.getLastLogout())));
if (player.isBanned())
{
sender.sendMessage(_("whoisBanned", _("true")));
sender.sendMessage(_("whoisBanned", show ? player.getBanReason() : _("true")));
}
}
}
@@ -160,8 +160,8 @@ public class Commandsell extends EssentialsCommand
user.updateInventory();
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess);
user.giveMoney(worth * amount);
user.sendMessage(_("itemSold", Util.formatCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.formatCurrency(worth, ess)));
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess)));
user.sendMessage(_("itemSold", Util.displayCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth, ess)));
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth * amount, ess), amount, Util.displayCurrency(worth, ess)));
}
}
@@ -2,6 +2,8 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.Warps;
import org.bukkit.Location;
import org.bukkit.Server;
@@ -26,7 +28,25 @@ public class Commandsetwarp extends EssentialsCommand
}
final Location loc = user.getLocation();
ess.getWarps().setWarp(args[0], loc);
final Warps warps = ess.getWarps();
Location warpLoc = null;
try
{
warpLoc = warps.getWarp(args[0]);
}
catch (Exception ex)
{
}
if (warpLoc == null || user.isAuthorized("essentials.warp.overwrite." + Util.sanitizeFileName(args[0])))
{
warps.setWarp(args[0], loc);
}
else
{
throw new Exception(_("warpOverwrite"));
}
user.sendMessage(_("warpSet", args[0]));
}
}
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.inventory.ItemStack;
@@ -15,6 +16,32 @@ public class Commandsetworth extends EssentialsCommand
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
ItemStack stack;
String price;
if (args.length == 1)
{
stack = user.getInventory().getItemInHand();
price = args[0];
}
else
{
stack = ess.getItemDb().get(args[0]);
price = args[1];
}
ess.getWorth().setPrice(stack, Double.parseDouble(price));
user.sendMessage(_("worthSet"));
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
@@ -23,6 +50,6 @@ public class Commandsetworth extends EssentialsCommand
ItemStack stack = ess.getItemDb().get(args[0]);
ess.getWorth().setPrice(stack, Double.parseDouble(args[1]));
user.sendMessage(_("worthSet"));
sender.sendMessage(_("worthSet"));
}
}
@@ -1,15 +1,13 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.*;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Mob;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.entity.EntityType;
public class Commandspawner extends EssentialsCommand
@@ -33,34 +31,34 @@ public class Commandspawner extends EssentialsCommand
throw new Exception(_("mobSpawnTarget"));
}
String name = args[0];
Mob mob = null;
mob = Mob.fromName(name);
if (mob == null)
{
throw new Exception(_("invalidMob"));
}
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
{
throw new Exception(_("disabledToSpawnMob"));
}
if (!user.isAuthorized("essentials.spawner." + mob.name.toLowerCase(Locale.ENGLISH)))
{
throw new Exception(_("noPermToSpawnMob"));
}
final Trade charge = new Trade("spawner-" + mob.name.toLowerCase(Locale.ENGLISH), ess);
charge.isAffordableFor(user);
try
{
String name = args[0];
Mob mob = null;
mob = Mob.fromName(name);
if (mob == null)
{
user.sendMessage(_("invalidMob"));
return;
}
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
{
throw new Exception(_("unableToSpawnMob"));
}
if (!user.isAuthorized("essentials.spawner." + mob.name.toLowerCase(Locale.ENGLISH)))
{
throw new Exception(_("unableToSpawnMob"));
}
final Trade charge = new Trade("spawner-" + mob.name.toLowerCase(Locale.ENGLISH), ess);
charge.isAffordableFor(user);
((CreatureSpawner)target.getBlock().getState()).setCreatureType(mob.getType());
charge.charge(user);
user.sendMessage(_("setSpawner", mob.name));
((CreatureSpawner)target.getBlock().getState()).setSpawnedType(mob.getType());
}
catch (Throwable ex)
{
throw new Exception(_("mobSpawnError"), ex);
}
charge.charge(user);
user.sendMessage(_("setSpawner", mob.name));
}
}
@@ -5,14 +5,14 @@ import com.earth2me.essentials.Mob;
import com.earth2me.essentials.Mob.MobException;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Locale;
import java.util.Random;
import java.util.Set;
import java.util.*;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.entity.*;
import org.bukkit.entity.Villager.Profession;
import org.bukkit.material.Colorable;
public class Commandspawnmob extends EssentialsCommand
@@ -27,12 +27,13 @@ public class Commandspawnmob extends EssentialsCommand
{
if (args.length < 1)
{
Set<String> availableList = Mob.getMobList();
for (String mob : availableList)
final Set<String> mobList = Mob.getMobList();
final Set<String> availableList = new HashSet<String>();
for (String mob : mobList)
{
if (!user.isAuthorized("essentials.spawnmob." + mob.toLowerCase()))
if (user.isAuthorized("essentials.spawnmob." + mob.toLowerCase()))
{
availableList.remove(mob);
availableList.add(mob);
}
}
if (availableList.isEmpty())
@@ -176,7 +177,7 @@ public class Commandspawnmob extends EssentialsCommand
changeMobData(mobMount.getType(), spawnedMount, mountData, user);
}
}
user.sendMessage(args[1] + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned"));
user.sendMessage(mobCount + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned"));
}
catch (MobException e1)
{
@@ -197,9 +198,11 @@ public class Commandspawnmob extends EssentialsCommand
}
}
private void changeMobData(final CreatureType type, final Entity spawned, final String data, final User user) throws Exception
private void changeMobData(final EntityType type, final Entity spawned, String data, final User user) throws Exception
{
if (type == CreatureType.SLIME || type == CreatureType.MAGMA_CUBE)
data = data.toLowerCase(Locale.ENGLISH);
if (spawned instanceof Slime)
{
try
{
@@ -210,35 +213,24 @@ public class Commandspawnmob extends EssentialsCommand
throw new Exception(_("slimeMalformedSize"), e);
}
}
if ((type == CreatureType.SHEEP
|| type == CreatureType.COW
|| type == CreatureType.MUSHROOM_COW
|| type == CreatureType.CHICKEN
|| type == CreatureType.PIG
|| type == CreatureType.WOLF)
&& data.equalsIgnoreCase("baby"))
if (spawned instanceof Ageable && data.contains("baby"))
{
((Animals)spawned).setAge(-24000);
((Ageable)spawned).setBaby();
return;
}
if (type == CreatureType.SHEEP)
if (spawned instanceof Colorable)
{
if (data.toLowerCase(Locale.ENGLISH).contains("baby"))
{
((Sheep)spawned).setAge(-24000);
}
final String color = data.toUpperCase(Locale.ENGLISH).replace("BABY", "");
try
{
if (color.equalsIgnoreCase("random"))
if (color.equals("RANDOM"))
{
Random rand = new Random();
((Sheep)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
final Random rand = new Random();
((Colorable)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
}
else
{
((Sheep)spawned).setColor(DyeColor.valueOf(color));
((Colorable)spawned).setColor(DyeColor.valueOf(color));
}
}
catch (Exception e)
@@ -246,30 +238,45 @@ public class Commandspawnmob extends EssentialsCommand
throw new Exception(_("sheepMalformedColor"), e);
}
}
if (type == CreatureType.WOLF
&& data.toLowerCase(Locale.ENGLISH).startsWith("tamed"))
if (spawned instanceof Tameable && data.contains("tamed"))
{
final Wolf wolf = ((Wolf)spawned);
wolf.setTamed(true);
wolf.setOwner(user);
wolf.setSitting(true);
if (data.equalsIgnoreCase("tamedbaby"))
{
((Animals)spawned).setAge(-24000);
}
final Tameable tameable = ((Tameable)spawned);
tameable.setTamed(true);
tameable.setOwner(user.getBase());
}
if (type == CreatureType.WOLF
&& data.toLowerCase(Locale.ENGLISH).startsWith("angry"))
if (type == EntityType.WOLF
&& data.contains("angry"))
{
((Wolf)spawned).setAngry(true);
if (data.equalsIgnoreCase("angrybaby"))
{
((Animals)spawned).setAge(-24000);
}
}
if (type == CreatureType.CREEPER && data.equalsIgnoreCase("powered"))
if (type == EntityType.CREEPER && data.contains("powered"))
{
((Creeper)spawned).setPowered(true);
}
if (type == EntityType.OCELOT)
{
if (data.contains("siamese"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.SIAMESE_CAT);
}
else if (data.contains("red"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.RED_CAT);
}
else if (data.contains("black"))
{
((Ocelot)spawned).setCatType(Ocelot.Type.BLACK_CAT);
}
}
if (type == EntityType.VILLAGER)
{
for (Profession prof : Villager.Profession.values())
{
if (data.contains(prof.toString().toLowerCase(Locale.ENGLISH)))
{
((Villager)spawned).setProfession(prof);
}
}
}
}
}
@@ -1,6 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
@@ -29,14 +31,12 @@ public class Commandsudo extends EssentialsCommand
System.arraycopy(args, 2, arguments, 0, args.length - 2);
}
//TODO: Translate this.
if (user.isAuthorized("essentials.sudo.exempt"))
{
throw new Exception("You cannot sudo this user");
throw new Exception(_("sudoExempt"));
}
//TODO: Translate this.
sender.sendMessage("Forcing " + user.getDisplayName() + " to run: /" + command + " " + arguments);
sender.sendMessage(_("sudoRun", user.getDisplayName(), command, getFinalArg(arguments, 0)));
final PluginCommand execCommand = ess.getServer().getPluginCommand(command);
if (execCommand != null)
@@ -16,11 +16,12 @@ public class Commandsuicide extends EssentialsCommand
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
EntityDamageEvent ede = new EntityDamageEvent(user, EntityDamageEvent.DamageCause.SUICIDE, 1000);
EntityDamageEvent ede = new EntityDamageEvent(user.getBase(), EntityDamageEvent.DamageCause.SUICIDE, 1000);
server.getPluginManager().callEvent(ede);
user.damage(1000);
user.setHealth(0);
user.sendMessage(_("suicideMessage"));
user.setDisplayNick();
ess.broadcastMessage(user,_("suicideSuccess", user.getDisplayName()));
}
}
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@@ -25,7 +24,7 @@ public class Commandtempban extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
final User user = getPlayer(server, args, 0, true);
if (user.getBase() instanceof OfflinePlayer)
if (!user.isOnline())
{
if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.tempban.offline"))
@@ -1,7 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
@@ -28,7 +27,7 @@ public class Commandtogglejail extends EssentialsCommand
if (args.length >= 2 && !player.isJailed())
{
if (player.getBase() instanceof OfflinePlayer)
if (!player.isOnline())
{
if (sender instanceof Player
&& !ess.getUser(sender).isAuthorized("essentials.togglejail.offline"))
@@ -45,7 +44,7 @@ public class Commandtogglejail extends EssentialsCommand
return;
}
}
if (!(player.getBase() instanceof OfflinePlayer))
if (player.isOnline())
{
ess.getJails().sendToJail(player, args[1]);
}
@@ -96,7 +95,7 @@ public class Commandtogglejail extends EssentialsCommand
player.setJailTimeout(0);
player.sendMessage(_("jailReleasedPlayerNotify"));
player.setJail(null);
if (!(player.getBase() instanceof OfflinePlayer))
if (player.isOnline())
{
player.getTeleport().back();
}
@@ -30,6 +30,11 @@ public class Commandtp extends EssentialsCommand
{
throw new Exception(_("teleportDisabled", player.getDisplayName()));
}
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + player.getWorld().getName()))
{
throw new Exception(_("noPerm", "essentials.world." + player.getWorld().getName()));
}
user.sendMessage(_("teleporting"));
final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
@@ -37,14 +42,26 @@ public class Commandtp extends EssentialsCommand
throw new NoChargeException();
default:
if (!user.isAuthorized("essentials.tpohere"))
if (!user.isAuthorized("essentials.tp.others"))
{
//TODO: Translate this
throw new Exception("You need access to /tpohere to teleport other players.");
throw new Exception(_("noPerm", "essentials.tp.others"));
}
user.sendMessage(_("teleporting"));
final User target = getPlayer(server, args, 0);
final User toPlayer = getPlayer(server, args, 1);
if (!target.isTeleportEnabled())
{
throw new Exception(_("teleportDisabled", target.getDisplayName()));
}
if (!toPlayer.isTeleportEnabled())
{
throw new Exception(_("teleportDisabled", toPlayer.getDisplayName()));
}
if (target.getWorld() != toPlayer.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + toPlayer.getWorld().getName()))
{
throw new Exception(_("noPerm", "essentials.world." + toPlayer.getWorld().getName()));
}
target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND);
target.sendMessage(_("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
break;
@@ -25,6 +25,11 @@ public class Commandtpa extends EssentialsCommand
{
throw new Exception(_("teleportDisabled", player.getDisplayName()));
}
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + player.getWorld().getName()))
{
throw new Exception(_("noPerm", "essentials.world." + player.getWorld().getName()));
}
if (!player.isIgnoredPlayer(user.getName()))
{
player.requestTeleport(user, false);
@@ -45,6 +45,11 @@ public class Commandtpaall extends EssentialsCommand
{
continue;
}
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + user.getWorld().getName()))
{
continue;
}
try
{
player.requestTeleport(user, true);
@@ -1,7 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import org.bukkit.Server;
@@ -20,15 +19,26 @@ public class Commandtpaccept extends EssentialsCommand
{
final User target = user.getTeleportRequest();
if (target == null
|| target.getBase() instanceof OfflinePlayer
|| (user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpahere"))
|| (!user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpa") && !target.isAuthorized("essentials.tpaall"))
)
if (target == null || !target.isOnline())
{
throw new Exception(_("noPendingRequest"));
}
if (user.isTpRequestHere() && ((!target.isAuthorized("essentials.tpahere") && !target.isAuthorized("essentials.tpaall"))
|| (user.getWorld() != target.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + user.getWorld().getName()))))
{
throw new Exception(_("noPendingRequest"));
}
if (!user.isTpRequestHere() && (!target.isAuthorized("essentials.tpa")
|| (user.getWorld() != target.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + target.getWorld().getName()))))
{
throw new Exception(_("noPendingRequest"));
}
if (args.length > 0 && !target.getName().contains(args[0]))
{
throw new Exception(_("noPendingRequest"));
@@ -42,7 +52,7 @@ public class Commandtpaccept extends EssentialsCommand
}
final Trade charge = new Trade(this.getName(), ess);
if (user.isTeleportRequestHere())
if (user.isTpRequestHere())
{
charge.isAffordableFor(user);
}
@@ -53,7 +63,7 @@ public class Commandtpaccept extends EssentialsCommand
user.sendMessage(_("requestAccepted"));
target.sendMessage(_("requestAcceptedFrom", user.getDisplayName()));
if (user.isTeleportRequestHere())
if (user.isTpRequestHere())
{
user.getTeleport().teleport(target, charge, TeleportCause.COMMAND);
}
@@ -25,6 +25,11 @@ public class Commandtpahere extends EssentialsCommand
{
throw new Exception(_("teleportDisabled", player.getDisplayName()));
}
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + user.getWorld().getName()))
{
throw new Exception(_("noPerm", "essentials.world." + user.getWorld().getName()));
}
player.requestTeleport(user, true);
player.sendMessage(_("teleportHereRequest", user.getDisplayName()));
player.sendMessage(_("typeTpaccept"));
@@ -42,6 +42,11 @@ public class Commandtpall extends EssentialsCommand
{
continue;
}
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + user.getWorld().getName()))
{
continue;
}
try
{
player.getTeleport().now(user, false, TeleportCause.COMMAND);
@@ -22,6 +22,11 @@ public class Commandtphere extends EssentialsCommand
{
throw new Exception(_("teleportDisabled", player.getDisplayName()));
}
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + user.getWorld().getName()))
{
throw new Exception(_("noPerm", "essentials.world." + user.getWorld().getName()));
}
player.getTeleport().teleport(user, new Trade(this.getName(), ess), TeleportCause.COMMAND);
user.sendMessage(_("teleporting"));
player.sendMessage(_("teleporting"));
@@ -1,7 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@@ -17,28 +16,50 @@ public class Commandtpo extends EssentialsCommand
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
switch (args.length)
{
case 0:
throw new NotEnoughArgumentsException();
}
//Just basically the old tp command
final User player = getPlayer(server, args, 0, true);
// Check if user is offline
if (player.getBase() instanceof OfflinePlayer)
{
throw new NoSuchFieldException(_("playerNotFound"));
}
// Verify permission
if (!player.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
{
user.getTeleport().now(player, false, TeleportCause.COMMAND);
case 1:
final User player = getPlayer(server, args, 0, true);
if (!player.isOnline() || (player.isHidden() && !user.isAuthorized("essentials.teleport.hidden")))
{
throw new NoSuchFieldException(_("playerNotFound"));
}
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + player.getWorld().getName()))
{
throw new Exception(_("noPerm", "essentials.world." + player.getWorld().getName()));
}
user.sendMessage(_("teleporting"));
}
else
{
throw new NoSuchFieldException(_("playerNotFound"));
user.getTeleport().now(player, false, TeleportCause.COMMAND);
break;
default:
if (!user.isAuthorized("essentials.tp.others"))
{
throw new Exception(_("noPerm", "essentials.tp.others"));
}
user.sendMessage(_("teleporting"));
final User target = getPlayer(server, args, 0, true);
final User toPlayer = getPlayer(server, args, 1, true);
if (!target.isOnline() || !toPlayer.isOnline()
|| ((target.isHidden() || toPlayer.isHidden()) && !user.isAuthorized("essentials.teleport.hidden")))
{
throw new NoSuchFieldException(_("playerNotFound"));
}
if (target.getWorld() != toPlayer.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + toPlayer.getWorld().getName()))
{
throw new Exception(_("noPerm", "essentials.world." + toPlayer.getWorld().getName()));
}
target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND);
target.sendMessage(_("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
break;
}
}
}
@@ -1,7 +1,6 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@@ -26,11 +25,17 @@ public class Commandtpohere extends EssentialsCommand
final User player = getPlayer(server, args, 0, true);
// Check if user is offline
if (player.getBase() instanceof OfflinePlayer)
if (!player.isOnline())
{
throw new NoSuchFieldException(_("playerNotFound"));
}
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions()
&& !user.isAuthorized("essentials.world." + user.getWorld().getName()))
{
throw new Exception(_("noPerm", "essentials.world." + user.getWorld().getName()));
}
// Verify permission
if (!player.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
{
@@ -43,6 +43,18 @@ public class Commandtree extends EssentialsCommand
{
tree = TreeType.BROWN_MUSHROOM;
}
else if (args[0].equalsIgnoreCase("jungle"))
{
tree = TreeType.SMALL_JUNGLE;
}
else if (args[0].equalsIgnoreCase("junglebush"))
{
tree = TreeType.JUNGLE_BUSH;
}
else if (args[0].equalsIgnoreCase("swamp"))
{
tree = TreeType.SWAMP;
}
else
{
throw new NotEnoughArgumentsException();
@@ -115,7 +115,10 @@ public class Commandwarp extends EssentialsCommand
private void warpUser(final User owner, final User user, final String name) throws Exception
{
final Trade charge = new Trade("warp-" + name.toLowerCase(Locale.ENGLISH).replace('_', '-'), ess);
final Trade chargeWarp = new Trade("warp-" + name.toLowerCase(Locale.ENGLISH).replace('_', '-'), ess);
final Trade chargeCmd = new Trade(this.getName(), ess);
final double fullCharge = chargeWarp.getCommandCost(user) + chargeCmd.getCommandCost(user);
final Trade charge = new Trade(fullCharge, ess);
charge.isAffordableFor(owner);
if (ess.getSettings().getPerWarpPermission() && !owner.isAuthorized("essentials.warp." + name))
{
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import com.earth2me.essentials.craftbukkit.SetExpFix;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -36,7 +37,7 @@ public class Commandwhois extends EssentialsCommand
showhidden = true;
}
final String whois = args[0].toLowerCase(Locale.ENGLISH);
final int prefixLength = Util.stripColor(ess.getSettings().getNicknamePrefix()).length();
final int prefixLength = Util.stripFormat(ess.getSettings().getNicknamePrefix()).length();
for (Player onlinePlayer : server.getOnlinePlayers())
{
final User user = ess.getUser(onlinePlayer);
@@ -44,7 +45,7 @@ public class Commandwhois extends EssentialsCommand
{
continue;
}
final String nickName = Util.stripColor(user.getNickname());
final String nickName = Util.stripFormat(user.getNickname());
if (!whois.equalsIgnoreCase(nickName)
&& !whois.substring(prefixLength).equalsIgnoreCase(nickName)
&& !whois.equalsIgnoreCase(user.getName()))
@@ -52,16 +53,23 @@ public class Commandwhois extends EssentialsCommand
continue;
}
sender.sendMessage("");
user.setDisplayNick();
sender.sendMessage(_("whoisIs", user.getDisplayName(), user.getName()));
sender.sendMessage(_("whoisHealth", user.getHealth()));
sender.sendMessage(_("whoisExp", SetExpFix.getTotalExperience(user), user.getLevel()));
sender.sendMessage(_("whoisOP", (user.isOp() ? _("true") : _("false"))));
sender.sendMessage(_("whoisGod", (user.isGodModeEnabled() ? _("true") : _("false"))));
sender.sendMessage(_("whoisGamemode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH))));
sender.sendMessage(_("whoisLocation", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));
if (!ess.getSettings().isEcoDisabled())
{
sender.sendMessage(_("whoisMoney", Util.formatCurrency(user.getMoney(), ess)));
sender.sendMessage(_("whoisMoney", Util.displayCurrency(user.getMoney(), ess)));
}
sender.sendMessage(_("whoisJail", (user.isJailed()
? user.getJailTimeout() > 0
? Util.formatDateDiff(user.getJailTimeout())
: _("true")
: _("false"))));
sender.sendMessage(user.isAfk()
? _("whoisStatusAway")
: _("whoisStatusAvailable"));
@@ -54,13 +54,9 @@ public class Commandworld extends EssentialsCommand
}
}
if (ess.getSettings().getIsWorldTeleportPermissions())
if (ess.getSettings().isWorldTeleportPermissions() && !user.isAuthorized("essentials.world." + world.getName()))
{
if (!user.isAuthorized("essentials.world." + world.getName()))
{
user.sendMessage(_("invalidWorld")); //TODO: Make a "world teleport denied" translation
throw new NoChargeException();
}
throw new Exception(_("noPerm", "essentials.world." + world.getName()));
}
double factor;
@@ -51,14 +51,14 @@ public class Commandworth extends EssentialsCommand
? _("worthMeta",
iStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""),
iStack.getDurability(),
Util.formatCurrency(worth * amount, ess),
Util.displayCurrency(worth * amount, ess),
amount,
Util.formatCurrency(worth, ess))
Util.displayCurrency(worth, ess))
: _("worth",
iStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""),
Util.formatCurrency(worth * amount, ess),
Util.displayCurrency(worth * amount, ess),
amount,
Util.formatCurrency(worth, ess)));
Util.displayCurrency(worth, ess)));
}
@Override
@@ -95,14 +95,14 @@ public class Commandworth extends EssentialsCommand
? _("worthMeta",
iStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""),
iStack.getDurability(),
Util.formatCurrency(worth * amount, ess),
Util.displayCurrency(worth * amount, ess),
amount,
Util.formatCurrency(worth, ess))
Util.displayCurrency(worth, ess))
: _("worth",
iStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""),
Util.formatCurrency(worth * amount, ess),
Util.displayCurrency(worth * amount, ess),
amount,
Util.formatCurrency(worth, ess)));
Util.displayCurrency(worth, ess)));
}
}
@@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.IEssentialsModule;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import java.util.List;
@@ -31,7 +30,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand
{
this.ess = ess;
}
@Override
public void setEssentialsModule(final IEssentialsModule module)
{
@@ -62,7 +61,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand
final User user = ess.getUser(args[pos]);
if (user != null)
{
if (!getOffline && (user.getBase() instanceof OfflinePlayer || user.isHidden()))
if (!getOffline && (!user.isOnline() || user.isHidden()))
{
throw new NoSuchFieldException(_("playerNotFound"));
}
@@ -0,0 +1,16 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
public class WarpNotFoundException extends Exception
{
public WarpNotFoundException()
{
super(_("warpNotExist"));
}
public WarpNotFoundException(String message)
{
super(message);
}
}
@@ -1,51 +0,0 @@
package com.earth2me.essentials.craftbukkit;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.server.ChunkPosition;
import net.minecraft.server.Packet60Explosion;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityExplodeEvent;
public class FakeExplosion
{
public static void createExplosion(final EntityExplodeEvent event, final Server server, final Player[] players)
{
try
{
final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
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)server).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0F, set));
}
catch (Throwable ex)
{
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
}
}
}
@@ -1,8 +1,13 @@
package com.earth2me.essentials.craftbukkit;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import org.bukkit.Material;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
@@ -187,4 +192,52 @@ public class FakeInventory implements Inventory
items[i] = null;
}
}
@Override
public List<HumanEntity> getViewers()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getTitle()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public InventoryType getType()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public InventoryHolder getHolder()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ListIterator<ItemStack> iterator()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getMaxStackSize()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setMaxStackSize(int size)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ListIterator<ItemStack> iterator(int index)
{
throw new UnsupportedOperationException("Not supported yet.");
}
}
@@ -12,6 +12,7 @@ import org.bukkit.entity.*;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector;
@@ -584,4 +585,52 @@ public class FakeWorld implements World
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public LivingEntity spawnCreature(Location arg0, EntityType arg1)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> void playEffect(Location lctn, Effect effect, T t)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> void playEffect(Location lctn, Effect effect, T t, int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setMetadata(String string, MetadataValue mv)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<MetadataValue> getMetadata(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean hasMetadata(String string)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void removeMetadata(String string, Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setBiome(int arg0, int arg1, Biome arg2)
{
throw new UnsupportedOperationException("Not supported yet.");
}
}
@@ -15,12 +15,12 @@ public final class InventoryWorkaround
{
}
public static int first(final Inventory inventory, final ItemStack item, final boolean forceDurability, final boolean forceAmount, final boolean forceEnchantments)
public static int first(final Inventory inventory, final ItemStack item, final boolean enforceDurability, final boolean enforceAmount, final boolean enforceEnchantments)
{
return next(inventory, item, 0, forceDurability, forceAmount, forceEnchantments);
return next(inventory, item, 0, enforceDurability, enforceAmount, enforceEnchantments);
}
public static int next(final Inventory cinventory, final ItemStack item, final int start, final boolean forceDurability, final boolean forceAmount, final boolean forceEnchantments)
public static int next(final Inventory cinventory, final ItemStack item, final int start, final boolean enforceDurability, final boolean enforceAmount, final boolean enforceEnchantments)
{
final ItemStack[] inventory = cinventory.getContents();
for (int i = start; i < inventory.length; i++)
@@ -30,7 +30,7 @@ public final class InventoryWorkaround
{
continue;
}
if (item.getTypeId() == cItem.getTypeId() && (!forceAmount || item.getAmount() == cItem.getAmount()) && (!forceDurability || cItem.getDurability() == item.getDurability()) && (!forceEnchantments || cItem.getEnchantments().equals(item.getEnchantments())))
if (item.getTypeId() == cItem.getTypeId() && (!enforceAmount || item.getAmount() == cItem.getAmount()) && (!enforceDurability || cItem.getDurability() == item.getDurability()) && (!enforceEnchantments || cItem.getEnchantments().equals(item.getEnchantments())))
{
return i;
}
@@ -38,12 +38,12 @@ public final class InventoryWorkaround
return -1;
}
public static int firstPartial(final Inventory cinventory, final ItemStack item, final boolean forceDurability)
public static int firstPartial(final Inventory cinventory, final ItemStack item, final boolean enforceDurability)
{
return firstPartial(cinventory, item, forceDurability, item.getType().getMaxStackSize());
return firstPartial(cinventory, item, enforceDurability, item.getType().getMaxStackSize());
}
public static int firstPartial(final Inventory cinventory, final ItemStack item, final boolean forceDurability, final int maxAmount)
public static int firstPartial(final Inventory cinventory, final ItemStack item, final boolean enforceDurability, final int maxAmount)
{
if (item == null)
{
@@ -57,7 +57,7 @@ public final class InventoryWorkaround
{
continue;
}
if (item.getTypeId() == cItem.getTypeId() && cItem.getAmount() < maxAmount && (!forceDurability || cItem.getDurability() == item.getDurability()) && cItem.getEnchantments().equals(item.getEnchantments()))
if (item.getTypeId() == cItem.getTypeId() && cItem.getAmount() < maxAmount && (!enforceDurability || cItem.getDurability() == item.getDurability()) && cItem.getEnchantments().equals(item.getEnchantments()))
{
return i;
}
@@ -65,12 +65,12 @@ public final class InventoryWorkaround
return -1;
}
public static boolean addAllItems(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
public static boolean addAllItems(final Inventory cinventory, final boolean enforceDurability, final ItemStack... items)
{
final Inventory fake = new FakeInventory(cinventory.getContents());
if (addItem(fake, forceDurability, items).isEmpty())
if (addItem(fake, enforceDurability, items).isEmpty())
{
addItem(cinventory, forceDurability, items);
addItem(cinventory, enforceDurability, items);
return true;
}
else
@@ -84,7 +84,7 @@ public final class InventoryWorkaround
return addItem(cinventory, forceDurability, 0, items);
}
public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean forceDurability, final int oversizedStacks, final ItemStack... items)
public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean enforceDurability, final int oversizedStacks, final ItemStack... items)
{
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
@@ -109,7 +109,7 @@ public final class InventoryWorkaround
combined[j] = items[i].clone();
break;
}
if (combined[j].getTypeId() == items[i].getTypeId() && (!forceDurability || combined[j].getDurability() == items[i].getDurability()) && combined[j].getEnchantments().equals(items[i].getEnchantments()))
if (combined[j].getTypeId() == items[i].getTypeId() && (!enforceDurability || combined[j].getDurability() == items[i].getDurability()) && combined[j].getEnchantments().equals(items[i].getEnchantments()))
{
combined[j].setAmount(combined[j].getAmount() + items[i].getAmount());
break;
@@ -130,7 +130,7 @@ public final class InventoryWorkaround
{
// Do we already have a stack of it?
final int maxAmount = oversizedStacks > item.getType().getMaxStackSize() ? oversizedStacks : item.getType().getMaxStackSize();
final int firstPartial = firstPartial(cinventory, item, forceDurability, maxAmount);
final int firstPartial = firstPartial(cinventory, item, enforceDurability, maxAmount);
// Drat! no partial stack
if (firstPartial == -1)
@@ -186,7 +186,7 @@ public final class InventoryWorkaround
return leftover;
}
public static Map<Integer, ItemStack> removeItem(final Inventory cinventory, final boolean forceDurability, final boolean forceEnchantments, final ItemStack... items)
public static Map<Integer, ItemStack> removeItem(final Inventory cinventory, final boolean enforceDurability, final boolean enforceEnchantments, final ItemStack... items)
{
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
@@ -211,7 +211,7 @@ public final class InventoryWorkaround
}
// get first Item, ignore the amount
final int first = first(cinventory, item, forceDurability, false, forceEnchantments);
final int first = first(cinventory, item, enforceDurability, false, enforceEnchantments);
// Drat! we don't have this type in the inventory
if (first == -1)
@@ -244,7 +244,7 @@ public final class InventoryWorkaround
return leftover;
}
public static boolean containsItem(final Inventory cinventory, final boolean forceDurability, final boolean forceEnchantments, final ItemStack... items)
public static boolean containsItem(final Inventory cinventory, final boolean enforceDurability, final boolean enforceEnchantments, final ItemStack... items)
{
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
@@ -266,7 +266,7 @@ public final class InventoryWorkaround
combined[j] = items[i].clone();
break;
}
if (combined[j].getTypeId() == items[i].getTypeId() && (!forceDurability || combined[j].getDurability() == items[i].getDurability()) && (!forceEnchantments || combined[j].getEnchantments().equals(items[i].getEnchantments())))
if (combined[j].getTypeId() == items[i].getTypeId() && (!enforceDurability || combined[j].getDurability() == items[i].getDurability()) && (!enforceEnchantments || combined[j].getEnchantments().equals(items[i].getEnchantments())))
{
combined[j].setAmount(combined[j].getAmount() + items[i].getAmount());
break;
@@ -292,7 +292,7 @@ public final class InventoryWorkaround
break;
}
final int slot = next(cinventory, item, position, forceDurability, false, forceEnchantments);
final int slot = next(cinventory, item, position, enforceDurability, false, enforceEnchantments);
// Drat! we don't have this type in the inventory
if (slot == -1)
@@ -5,6 +5,8 @@ import org.bukkit.entity.Player;
public class SetExpFix
{
//This method is used to update both the recorded total experience and displayed total experience.
//We reset both types to prevent issues.
public static void setTotalExperience(final Player player, final int exp)
{
if (exp < 0)
@@ -14,6 +16,9 @@ public class SetExpFix
player.setExp(0);
player.setLevel(0);
player.setTotalExperience(0);
//This following code is technically redundant now, as bukkit now calulcates levels more or less correctly
//At larger numbers however... player.getExp(3000), only seems to give 2999, putting the below calculations off.
int amount = exp;
while (amount > 0)
{
@@ -44,6 +49,8 @@ public class SetExpFix
return 7 + (level * 7 >> 1);
}
//This method is required because the bukkit player.getTotalExperience() method, shows exp that has been 'spent'.
//Without this people would be able to use exp and then still sell it.
public static int getTotalExperience(final Player player)
{
int exp = (int) (getExpToLevel(player) * player.getExp());
@@ -1,46 +0,0 @@
package com.earth2me.essentials.craftbukkit;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.IInventory;
import net.minecraft.server.PlayerInventory;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class ShowInventory
{
public static void showEmptyInventory(final Player player)
{
try
{
final EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle();
final CraftInventoryPlayer inv = new CraftInventoryPlayer(new PlayerInventory(((CraftPlayer)player).getHandle()));
inv.clear();
entityPlayer.a((IInventory)inv.getInventory());
}
catch (Throwable ex)
{
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
}
}
public static void showFilledInventory(final Player player, final ItemStack stack)
{
try
{
final EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle();
final CraftInventoryPlayer inv = new CraftInventoryPlayer(new PlayerInventory(((CraftPlayer)player).getHandle()));
inv.clear();
InventoryWorkaround.addItem(inv, true, stack);
entityPlayer.a((IInventory)inv.getInventory());
}
catch (Throwable ex)
{
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
}
}
}
@@ -0,0 +1,625 @@
package com.earth2me.essentials.metrics;
/*
* Copyright 2011 Tyler Blair. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
* disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and contributors and
* should not be interpreted as representing official policies, either expressed or implied, of anybody else.
*/
import java.io.*;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.*;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
/**
* <p> The metrics class obtains data about a plugin and submits statistics about it to the metrics backend. </p> <p>
* Public methods provided by this class: </p>
* <code>
* Graph createGraph(String name); <br/>
* void addCustomData(Metrics.Plotter plotter); <br/>
* void start(); <br/>
* </code>
*/
public class Metrics
{
/**
* The current revision number
*/
private final static int REVISION = 5;
/**
* The base url of the metrics domain
*/
private static final String BASE_URL = "http://metrics.essentials3.net";
/**
* The url used to report a server's status
*/
private static final String REPORT_URL = "/report/%s";
/**
* The file where guid and opt out is stored in
*/
private static final String CONFIG_FILE = "plugins/PluginMetrics/config.yml";
/**
* The separator to use for custom data. This MUST NOT change unless you are hosting your own version of metrics and
* want to change it.
*/
private static final String CUSTOM_DATA_SEPARATOR = "~~";
/**
* Interval of time to ping (in minutes)
*/
private static final int PING_INTERVAL = 10;
/**
* The plugin this metrics submits for
*/
private final Plugin plugin;
/**
* All of the custom graphs to submit to metrics
*/
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
/**
* The default graph, used for addCustomData when you don't want a specific graph
*/
private final Graph defaultGraph = new Graph("Default");
/**
* The plugin configuration file
*/
private final YamlConfiguration configuration;
/**
* The plugin configuration file
*/
private final File configurationFile;
/**
* Unique server id
*/
private final String guid;
/**
* Lock for synchronization
*/
private final Object optOutLock = new Object();
/**
* Id of the scheduled task
*/
private volatile int taskId = -1;
public Metrics(final Plugin plugin) throws IOException
{
if (plugin == null)
{
throw new IllegalArgumentException("Plugin cannot be null");
}
this.plugin = plugin;
// load the config
configurationFile = new File(CONFIG_FILE);
configuration = YamlConfiguration.loadConfiguration(configurationFile);
// add some defaults
configuration.addDefault("opt-out", false);
configuration.addDefault("guid", UUID.randomUUID().toString());
// Do we need to create the file?
if (configuration.get("guid", null) == null)
{
configuration.options().header("http://metrics.griefcraft.com").copyDefaults(true);
configuration.save(configurationFile);
}
// Load the guid then
guid = configuration.getString("guid");
}
/**
* Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics
* website. Plotters can be added to the graph object returned.
*
* @param name
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
*/
public Graph createGraph(final String name)
{
if (name == null)
{
throw new IllegalArgumentException("Graph name cannot be null");
}
// Construct the graph object
final Graph graph = new Graph(name);
// Now we can add our graph
graphs.add(graph);
// and return back
return graph;
}
/**
* Adds a custom data plotter to the default graph
*
* @param plotter
*/
public void addCustomData(final Plotter plotter)
{
if (plotter == null)
{
throw new IllegalArgumentException("Plotter cannot be null");
}
// Add the plotter to the graph o/
defaultGraph.addPlotter(plotter);
// Ensure the default graph is included in the submitted graphs
graphs.add(defaultGraph);
}
/**
* Start measuring statistics. This will immediately create an async repeating task as the plugin and send the
* initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200
* ticks.
*/
public void start()
{
synchronized (optOutLock)
{
// Did we opt out?
if (isOptOut())
{
return;
}
// Begin hitting the server with glorious data
taskId = plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable()
{
private boolean firstPost = true;
public void run()
{
try
{
// This has to be synchronized or it can collide with the disable method.
synchronized (optOutLock)
{
// Disable Task, if it is running and the server owner decided to opt-out
if (isOptOut() && taskId > 0)
{
plugin.getServer().getScheduler().cancelTask(taskId);
taskId = -1;
}
}
// We use the inverse of firstPost because if it is the first time we are posting,
// it is not a interval ping, so it evaluates to FALSE
// Each time thereafter it will evaluate to TRUE, i.e PING!
postPlugin(!firstPost);
// After the first post we set firstPost to false
// Each post thereafter will be a ping
firstPost = false;
}
catch (IOException e)
{
Bukkit.getLogger().log(Level.INFO, "[Metrics] {0}", e.getMessage());
}
}
}, 0, PING_INTERVAL * 1200);
}
}
/**
* Has the server owner denied plugin metrics?
*
* @return
*/
public boolean isOptOut()
{
synchronized (optOutLock)
{
try
{
// Reload the metrics file
configuration.load(CONFIG_FILE);
}
catch (IOException ex)
{
Bukkit.getLogger().log(Level.INFO, "[Metrics] {0}", ex.getMessage());
return true;
}
catch (InvalidConfigurationException ex)
{
Bukkit.getLogger().log(Level.INFO, "[Metrics] {0}", ex.getMessage());
return true;
}
return configuration.getBoolean("opt-out", false);
}
}
/**
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
*
* @throws IOException
*/
public void enable() throws IOException
{
// This has to be synchronized or it can collide with the check in the task.
synchronized (optOutLock)
{
// Check if the server owner has already set opt-out, if not, set it.
if (isOptOut())
{
configuration.set("opt-out", false);
configuration.save(configurationFile);
}
// Enable Task, if it is not running
if (taskId < 0)
{
start();
}
}
}
/**
* Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
*
* @throws IOException
*/
public void disable() throws IOException
{
// This has to be synchronized or it can collide with the check in the task.
synchronized (optOutLock)
{
// Check if the server owner has already set opt-out, if not, set it.
if (!isOptOut())
{
configuration.set("opt-out", true);
final File file = new File(CONFIG_FILE);
configuration.save(file);
}
// Disable Task, if it is running
if (taskId >= 0)
{
this.plugin.getServer().getScheduler().cancelTask(taskId);
taskId = -1;
}
}
}
/**
* Generic method that posts a plugin to the metrics website
*/
private void postPlugin(final boolean isPing) throws IOException
{
// The plugin's description file containg all of the plugin data such as name, version, author, etc
final PluginDescriptionFile description = plugin.getDescription();
// Construct the post data
final StringBuilder data = new StringBuilder();
data.append(encode("guid")).append('=').append(encode(guid));
encodeDataPair(data, "version", description.getVersion());
encodeDataPair(data, "server", Bukkit.getVersion());
encodeDataPair(data, "players", Integer.toString(Bukkit.getServer().getOnlinePlayers().length));
encodeDataPair(data, "revision", String.valueOf(REVISION));
// If we're pinging, append it
if (isPing)
{
encodeDataPair(data, "ping", "true");
}
// Acquire a lock on the graphs, which lets us make the assumption we also lock everything
// inside of the graph (e.g plotters)
synchronized (graphs)
{
final Iterator<Graph> iter = graphs.iterator();
while (iter.hasNext())
{
final Graph graph = iter.next();
// Because we have a lock on the graphs set already, it is reasonable to assume
// that our lock transcends down to the individual plotters in the graphs also.
// Because our methods are private, no one but us can reasonably access this list
// without reflection so this is a safe assumption without adding more code.
for (Plotter plotter : graph.getPlotters())
{
// The key name to send to the metrics server
// The format is C-GRAPHNAME-PLOTTERNAME where separator - is defined at the top
// Legacy (R4) submitters use the format Custom%s, or CustomPLOTTERNAME
final String key = String.format("C%s%s%s%s", CUSTOM_DATA_SEPARATOR, graph.getName(), CUSTOM_DATA_SEPARATOR, plotter.getColumnName());
// The value to send, which for the foreseeable future is just the string
// value of plotter.getValue()
final String value = Integer.toString(plotter.getValue());
// Add it to the http post data :)
encodeDataPair(data, key, value);
}
}
}
// Create the url
final URL url = new URL(BASE_URL + String.format(REPORT_URL, description.getName()));
// Connect to the website
URLConnection connection;
// Mineshafter creates a socks proxy, so we can safely bypass it
// It does not reroute POST requests so we need to go around it
if (isMineshafterPresent())
{
connection = url.openConnection(Proxy.NO_PROXY);
}
else
{
connection = url.openConnection();
}
connection.setDoOutput(true);
// Write the data
final OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
writer.write(data.toString());
writer.flush();
// Now read the response
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
final String response = reader.readLine();
// close resources
writer.close();
reader.close();
if (response == null || response.startsWith("ERR"))
{
throw new IOException(response); //Throw the exception
}
else
{
// Is this the first update this hour?
if (response.contains("OK This is your first update this hour"))
{
synchronized (graphs)
{
final Iterator<Graph> iter = graphs.iterator();
while (iter.hasNext())
{
final Graph graph = iter.next();
for (Plotter plotter : graph.getPlotters())
{
plotter.reset();
}
}
}
}
}
//if (response.startsWith("OK")) - We should get "OK" followed by an optional description if everything goes right
}
/**
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
*
* @return
*/
private boolean isMineshafterPresent()
{
try
{
Class.forName("mineshafter.MineServer");
return true;
}
catch (Exception e)
{
return false;
}
}
/**
* <p>Encode a key/value data pair to be used in a HTTP post request. This INCLUDES a & so the first key/value pair
* MUST be included manually, e.g:</p>
* <code>
* StringBuffer data = new StringBuffer();
* data.append(encode("guid")).append('=').append(encode(guid));
* encodeDataPair(data, "version", description.getVersion());
* </code>
*
* @param buffer
* @param key
* @param value
* @return
*/
private static void encodeDataPair(final StringBuilder buffer, final String key, final String value) throws UnsupportedEncodingException
{
buffer.append('&').append(encode(key)).append('=').append(encode(value));
}
/**
* Encode text as UTF-8
*
* @param text
* @return
*/
private static String encode(final String text) throws UnsupportedEncodingException
{
return URLEncoder.encode(text, "UTF-8");
}
/**
* Represents a custom graph on the website
*/
public static class Graph
{
/**
* The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is
* rejected
*/
private final String name;
/**
* The set of plotters that are contained within this graph
*/
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
private Graph(final String name)
{
this.name = name;
}
/**
* Gets the graph's name
*
* @return
*/
public String getName()
{
return name;
}
/**
* Add a plotter to the graph, which will be used to plot entries
*
* @param plotter
*/
public void addPlotter(final Plotter plotter)
{
plotters.add(plotter);
}
/**
* Remove a plotter from the graph
*
* @param plotter
*/
public void removePlotter(final Plotter plotter)
{
plotters.remove(plotter);
}
/**
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
*
* @return
*/
public Set<Plotter> getPlotters()
{
return Collections.unmodifiableSet(plotters);
}
@Override
public int hashCode()
{
return name.hashCode();
}
@Override
public boolean equals(final Object object)
{
if (!(object instanceof Graph))
{
return false;
}
final Graph graph = (Graph)object;
return graph.name.equals(name);
}
}
/**
* Interface used to collect custom data for a plugin
*/
public static abstract class Plotter
{
/**
* The plot's name
*/
private final String name;
/**
* Construct a plotter with the default plot name
*/
public Plotter()
{
this("Default");
}
/**
* Construct a plotter with a specific plot name
*
* @param name
*/
public Plotter(final String name)
{
this.name = name;
}
/**
* Get the current value for the plotted point
*
* @return
*/
public abstract int getValue();
/**
* Get the column name for the plotted point
*
* @return the plotted point's column name
*/
public String getColumnName()
{
return name;
}
/**
* Called after the website graphs have been updated
*/
public void reset()
{
}
@Override
public int hashCode()
{
return getColumnName().hashCode() + getValue();
}
@Override
public boolean equals(final Object object)
{
if (!(object instanceof Plotter))
{
return false;
}
final Plotter plotter = (Plotter)object;
return plotter.name.equals(name) && plotter.getValue() == getValue();
}
}
}
@@ -0,0 +1,40 @@
package com.earth2me.essentials.metrics;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import java.util.logging.Level;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class MetricsListener implements Listener
{
private final transient Server server;
private final transient IEssentials ess;
private final transient MetricsStarter starter;
public MetricsListener(final IEssentials parent, final MetricsStarter starter)
{
this.ess = parent;
this.server = parent.getServer();
this.starter = starter;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(final PlayerJoinEvent event)
{
final User player = ess.getUser(event.getPlayer());
if (ess.getSettings().isMetricsEnabled() == false && (player.isAuthorized("essentials.essentials") || player.isAuthorized("bukkit.broadcast.admin")))
{
player.sendMessage("PluginMetrics collects minimal statistic data, starting in about 5 minutes.");
player.sendMessage("To opt out, run /essentials opt-out");
ess.getLogger().log(Level.INFO, "[Metrics] Admin join - Starting 5 minute opt-out period.");
ess.getSettings().setMetricsEnabled(true);
ess.getScheduler().scheduleAsyncDelayedTask(ess, starter, 5 * 1200);
}
}
}
@@ -0,0 +1,203 @@
package com.earth2me.essentials.metrics;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.metrics.Metrics.Graph;
import com.earth2me.essentials.metrics.Metrics.Plotter;
import com.earth2me.essentials.register.payment.Method;
import java.util.Locale;
import java.util.logging.Level;
public class MetricsStarter implements Runnable
{
private final IEssentials ess;
private transient Boolean start;
private enum Modules
{
Essentials,
EssentialsAntiCheat,
EssentialsChat,
EssentialsSpawn,
EssentialsProtect,
EssentialsGeoIP,
EssentialsXMPP
};
public MetricsStarter(final IEssentials plugin)
{
ess = plugin;
try
{
final Metrics metrics = new Metrics(ess);
ess.setMetrics(metrics);
if (!metrics.isOptOut())
{
if (ess.getSettings().isMetricsEnabled())
{
start = true;
}
else
{
ess.getLogger().info("This plugin collects minimal statistic data and sends it to http://metrics.essentials3.net.");
ess.getLogger().info("You can opt out by running /essentials opt-out");
ess.getLogger().info("This will start 5 minutes after the first admin/op joins.");
start = false;
}
return;
}
}
catch (Exception ex)
{
metricsError(ex);
}
}
@Override
public void run()
{
try
{
final Metrics metrics = ess.getMetrics();
final Graph moduleGraph = metrics.createGraph("Modules Used");
for (Modules module : Modules.values())
{
final String moduleName = module.toString();
if (ess.getServer().getPluginManager().isPluginEnabled(moduleName))
{
moduleGraph.addPlotter(new SimplePlotter(moduleName));
}
}
final Graph localeGraph = metrics.createGraph("Locale");
localeGraph.addPlotter(new SimplePlotter(ess.getI18n().getCurrentLocale().getDisplayLanguage(Locale.ENGLISH)));
final Graph featureGraph = metrics.createGraph("Features");
featureGraph.addPlotter(new Plotter("Unique Accounts")
{
@Override
public int getValue()
{
return ess.getUserMap().getUniqueUsers();
}
});
featureGraph.addPlotter(new Plotter("Jails")
{
@Override
public int getValue()
{
return ess.getJails().getCount();
}
});
featureGraph.addPlotter(new Plotter("Kits")
{
@Override
public int getValue()
{
return ess.getSettings().getKits().getKeys(false).size();
}
});
featureGraph.addPlotter(new Plotter("Warps")
{
@Override
public int getValue()
{
return ess.getWarps().getWarpNames().size();
}
});
final Graph enabledGraph = metrics.createGraph("EnabledFeatures");
enabledGraph.addPlotter(new SimplePlotter("Total"));
final String BKcommand = ess.getSettings().getBackupCommand();
if (BKcommand != null && !"".equals(BKcommand))
{
enabledGraph.addPlotter(new SimplePlotter("Backup"));
}
if (ess.getJails().getCount() > 0)
{
enabledGraph.addPlotter(new SimplePlotter("Jails"));
}
if (ess.getSettings().getKits().getKeys(false).size() > 0)
{
enabledGraph.addPlotter(new SimplePlotter("Kits"));
}
if (ess.getWarps().getWarpNames().size() > 0)
{
enabledGraph.addPlotter(new SimplePlotter("Warps"));
}
if (!ess.getSettings().areSignsDisabled())
{
enabledGraph.addPlotter(new SimplePlotter("Signs"));
}
if (ess.getSettings().getAutoAfk() > 0)
{
enabledGraph.addPlotter(new SimplePlotter("AutoAFK"));
}
if (ess.getSettings().changeDisplayName())
{
enabledGraph.addPlotter(new SimplePlotter("DisplayName"));
}
if (ess.getSettings().getChatRadius() >= 1)
{
enabledGraph.addPlotter(new SimplePlotter("LocalChat"));
}
final Graph depGraph = metrics.createGraph("Dependencies");
final Method method = ess.getPaymentMethod().getMethod();
if (method != null)
{
String version = method.getVersion();
final int dashPosition = version.indexOf('-');
if (dashPosition > 0)
{
version = version.substring(0, dashPosition);
}
depGraph.addPlotter(new SimplePlotter(method.getName() + " " + version));
}
depGraph.addPlotter(new SimplePlotter(ess.getPermissionsHandler().getName()));
metrics.start();
}
catch (Exception ex)
{
metricsError(ex);
}
}
public void metricsError(final Exception ex)
{
if (ess.getSettings().isDebug())
{
ess.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage(), ex);
}
else
{
ess.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
}
}
public Boolean getStart()
{
return start;
}
private class SimplePlotter extends Plotter
{
public SimplePlotter(final String name)
{
super(name);
}
@Override
public int getValue()
{
return 1;
}
}
}
@@ -3,6 +3,7 @@ package com.earth2me.essentials.perm;
import java.util.Arrays;
import java.util.List;
import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.dataholder.worlds.WorldsHolder;
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@@ -20,7 +21,7 @@ public class GroupManagerHandler implements IPermissionsHandler
@Override
public String getGroup(final Player base)
{
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
final AnjoPermissionsHandler handler = getHandler(base);
if (handler == null)
{
return null;
@@ -31,7 +32,7 @@ public class GroupManagerHandler implements IPermissionsHandler
@Override
public List<String> getGroups(final Player base)
{
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
final AnjoPermissionsHandler handler = getHandler(base);
if (handler == null)
{
return null;
@@ -42,7 +43,7 @@ public class GroupManagerHandler implements IPermissionsHandler
@Override
public boolean canBuild(final Player base, final String group)
{
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
final AnjoPermissionsHandler handler = getHandler(base);
if (handler == null)
{
return false;
@@ -53,7 +54,7 @@ public class GroupManagerHandler implements IPermissionsHandler
@Override
public boolean inGroup(final Player base, final String group)
{
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
AnjoPermissionsHandler handler = getHandler(base);
if (handler == null)
{
return false;
@@ -64,7 +65,7 @@ public class GroupManagerHandler implements IPermissionsHandler
@Override
public boolean hasPermission(final Player base, final String node)
{
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
AnjoPermissionsHandler handler = getHandler(base);
if (handler == null)
{
return false;
@@ -75,7 +76,7 @@ public class GroupManagerHandler implements IPermissionsHandler
@Override
public String getPrefix(final Player base)
{
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
AnjoPermissionsHandler handler = getHandler(base);
if (handler == null)
{
return null;
@@ -86,11 +87,21 @@ public class GroupManagerHandler implements IPermissionsHandler
@Override
public String getSuffix(final Player base)
{
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
AnjoPermissionsHandler handler = getHandler(base);
if (handler == null)
{
return null;
}
return handler.getUserSuffix(base.getName());
}
private AnjoPermissionsHandler getHandler(final Player base)
{
final WorldsHolder holder = groupManager.getWorldsHolder();
if (holder == null)
{
return null;
}
return holder.getWorldPermissions(base);
}
}
@@ -210,4 +210,9 @@ public class PermissionsHandler implements IPermissionsHandler
{
this.useSuperperms = useSuperperms;
}
public String getName()
{
return handler.getClass().getSimpleName().replace("Handler", "");
}
}
@@ -266,7 +266,7 @@ public class EssentialsSign
final Double money = trade.getMoney();
if (money != null)
{
sign.setLine(index, Util.formatCurrency(money, ess));
sign.setLine(index, Util.shortCurrency(money, ess));
}
}
@@ -3,6 +3,7 @@ package com.earth2me.essentials.signs;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
public class SignBalance extends EssentialsSign
@@ -15,7 +16,7 @@ public class SignBalance extends EssentialsSign
@Override
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
{
player.sendMessage(_("balance", player.getMoney()));
player.sendMessage(_("balance", Util.displayCurrency(player.getMoney(), ess)));
return true;
}
}
@@ -2,6 +2,7 @@ package com.earth2me.essentials.signs;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Material;
@@ -83,13 +84,12 @@ public class SignBlockListener implements Listener
return;
}
User user = ess.getUser(event.getPlayer());
if (user.isAuthorized("essentials.signs.color"))
for (int i = 0; i < 4; i++)
{
for (int i = 0; i < 4; i++)
{
event.setLine(i, event.getLine(i).replaceAll("&([0-9a-f])", "§$1"));
}
event.setLine(i, Util.formatString(user, "essentials.signs", event.getLine(i)));
}
for (Signs signs : Signs.values())
{
final EssentialsSign sign = signs.getSign();
@@ -2,7 +2,6 @@ package com.earth2me.essentials.signs;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.ShowInventory;
public class SignDisposal extends EssentialsSign
@@ -15,7 +14,7 @@ public class SignDisposal extends EssentialsSign
@Override
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess)
{
ShowInventory.showEmptyInventory(player.getBase());
player.getBase().openInventory(ess.getServer().createInventory(player, 36));
return true;
}
}
@@ -4,8 +4,10 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.ShowInventory;
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@@ -32,8 +34,12 @@ public class SignFree extends EssentialsSign
throw new SignException(_("cantSpawnItem", "Air"));
}
item.setAmount(item.getType().getMaxStackSize() * 9 * 4);
ShowInventory.showFilledInventory(player.getBase(), item);
item.setAmount(item.getType().getMaxStackSize());
Inventory invent = ess.getServer().createInventory(player, 36);
for (int i = 0; i < 36; i++) {
invent.addItem(item);
}
player.openInventory(invent);
Trade.log("Sign", "Free", "Interact", username, null, username, new Trade(item, ess), sign.getBlock().getLocation(), ess);
return true;
}
@@ -17,7 +17,7 @@ public class SignKit extends EssentialsSign
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
{
validateTrade(sign, 3, ess);
final String kitName = sign.getLine(1).toLowerCase(Locale.ENGLISH);
if (kitName.isEmpty())
@@ -56,10 +56,10 @@ public class SignKit extends EssentialsSign
charge.isAffordableFor(player);
try
{
final Object kit = ess.getSettings().getKit(kitName);
final Map<String, Object> els = (Map<String, Object>)kit;
final List<String> items = Kit.getItems(player, els);
Kit.expandItems(ess, player, items);
final Map<String, Object> kit = ess.getSettings().getKit(kitName);
Kit.checkTime(player, kitName, kit);
final List<String> items = Kit.getItems(player, kit);
Kit.expandItems(ess, player, items);
charge.charge(player);
}
catch (Exception ex)
@@ -147,7 +147,7 @@ public class SignProtection extends EssentialsSign
{
return SignProtectionState.OWNER;
}
if (Util.stripColor(sign.getLine(3)).equalsIgnoreCase(username))
if (Util.stripFormat(sign.getLine(3)).equalsIgnoreCase(username))
{
return SignProtectionState.OWNER;
}
@@ -135,11 +135,11 @@ public class SignTrade extends EssentialsSign
final Double money = getMoney(split[0]);
if (money != null)
{
if (Util.formatCurrency(money, ess).length() * 2 > 15)
if (Util.shortCurrency(money, ess).length() * 2 > 15)
{
throw new SignException("Line can be too long!");
}
sign.setLine(index, Util.formatCurrency(money, ess) + ":0");
sign.setLine(index, Util.shortCurrency(money, ess) + ":0");
return;
}
}
@@ -155,7 +155,7 @@ public class SignTrade extends EssentialsSign
{
throw new SignException(_("moreThanZero"));
}
sign.setLine(index, Util.formatCurrency(money, ess) + ":" + Util.formatCurrency(amount, ess).substring(1));
sign.setLine(index, Util.shortCurrency(money, ess) + ":" + Util.shortCurrency(amount, ess).substring(1));
return;
}
}
@@ -313,7 +313,7 @@ public class SignTrade extends EssentialsSign
final Double amount = getDouble(split[1]);
if (money != null && amount != null)
{
final String newline = Util.formatCurrency(money, ess) + ":" + Util.formatCurrency(amount + value, ess).substring(1);
final String newline = Util.shortCurrency(money, ess) + ":" + Util.shortCurrency(amount + value, ess).substring(1);
if (newline.length() > 15)
{
throw new SignException("This sign is full: Line too long!");
@@ -19,6 +19,7 @@ public enum Signs
TRADE(new SignTrade()),
WARP(new SignWarp()),
WEATHER(new SignWeather());
private final EssentialsSign sign;
private Signs(final EssentialsSign sign)
Loaded 100 of 155 files, more files were not shown because too many files have changed in this diff. Show more