Compare commits

..
498 Commits
Author SHA1 Message Date
Eric Stokes d473ac3f78 Bump API to v7 for 2.1 release 2011-10-18 20:48:23 -06:00
Eric Stokes 093e01d865 Change priority to Low, so MV can fix portal locations 2011-10-18 18:13:22 -06:00
Eric Stokes 2d7626684f Fix initial configs not loading properly 2011-10-18 16:45:55 -06:00
Eric Stokes 698671c700 Fix spawn not loading from config. Closes #195 2011-10-17 20:51:51 -06:00
Eric Stokes 0d06fb8a0d Reload the config after save for the initial creation 2011-10-17 19:09:22 -06:00
Eric Stokes 6e6c40bd3b Cannon destinations are basically exact destinations, don't perform the safety check. 2011-10-17 18:06:16 -06:00
Eric Stokes 4067d0cd28 Detect bad worlds and tell the user to use chunkster 2011-10-16 13:59:13 -06:00
Eric Stokes 5b19404c13 Clean up some comments. 2011-10-16 13:53:23 -06:00
Eric Stokes e6f81b01d6 Move the enforce access flag to canEnterWorld so other plugins don't have to check it also, Add "mv conf show" 2011-10-16 13:38:05 -06:00
Eric Stokes 25d9231d30 Check all parent perms if the player's normal perm wasn't found. Closes #174
I consider this a workaround. At the moment, when we add a node AND
recalc the permissions, until the perms plugin reloads, when MV asks
the API if a player has a perm, it reports that they do NOT. For the
moment, we're going to check all of this node's parents to see if the
user has those. It stops when if finds a true or there are no more
parents.
2011-10-16 11:06:40 -06:00
Eric Stokes 3284670153 Fix Difficulty and GameMode not reloading properly. Closes #190 2011-10-16 10:14:02 -06:00
Eric Stokes ea920c1252 Merge branch 'master' of github.com:Multiverse/Multiverse-Core 2011-10-16 09:56:47 -06:00
Eric Stokes 987e2eff51 Reorder the loading of fakepvp so it doesn't override regular pvp. 2011-10-16 09:41:47 -06:00
main() 67c165ff25 Fixed #191 (WorldManager.deleteWorld()). 2011-10-16 17:36:18 +02:00
main() e7aa563352 Revert "Fix startup error on Windows."
This reverts commit 01bed7cc4b.
Because that commit CAUSED a startup error instead of fixing one.
2011-10-16 15:29:09 +02:00
Eric Stokes 56926dc14c State when a perm has been found in debug, Fix The TeleportCommand not obeying enforce access 2011-10-16 02:06:18 -06:00
Eric Stokes 2d0eb7e7bb If enforceaccess == false, show all players all worlds (unless they're hidden) also for mv who 2011-10-16 00:38:49 -06:00
Eric Stokes 54e7bc454a If enforceaccess == false, show all players all worlds (unless they're hidden) 2011-10-16 00:34:40 -06:00
Eric Stokes 01bed7cc4b Fix startup error on Windows.
Psh who uses Windows anyways :P
2011-10-16 00:01:09 -06:00
main() 5d11e27eb0 Fixed javadoc of the WorldManager. 2011-10-15 17:24:12 +02:00
Rigby fbc5c6f0d2 Removed Doxygen stuff as it is no longer required.
Added the ability to generate a Source JAR and pass to Artifactory.
2011-10-15 15:33:03 +01:00
fernferret b867df7315 Add main-- to the authors 2011-10-14 15:12:44 -04:00
fernferret a8068a5669 Protocol Bump to v6 2011-10-13 21:39:17 -04:00
fernferret ab17064006 Route all teleports through the SafeTTeleporter
There are still some access caveats. When you request that a player be
tp'd to you, there's currently not a good way to tell the teleport
event that… So we either get full control of all plugins and limited
control to override it, or unlimited control to override and no access
to other plugins' access to teleport players to potentially restricted
locations…

This will break the latest other Plugin builds.
2011-10-13 21:38:44 -04:00
fernferret d3c1538083 Fix config.yml overwriting worlds.yml, Fix invalid spawn locations 2011-10-13 16:37:53 -04:00
fernferret b2ef10a699 Revamp config to simpler 2.4 format 2011-10-12 21:50:03 -04:00
fernferret fba3f71238 Fix invalid values in /mv config, Closes #178 2011-10-12 17:04:21 -04:00
fernferret af3dcf049d Remove outdated values from config.yml, Fix Configs and reloading, Closes #186 2011-10-12 16:50:04 -04:00
fernferret a30222bec7 Show whether or not gamemode is being enforced, Fix enum Config Property 2011-10-11 22:51:30 -04:00
fernferret 86af11b662 Fixes for hidden worlds displaying as null 2011-10-11 21:57:35 -04:00
fernferret 750adcf376 Fix color checking, fix price reporting failure on successful set 2011-10-11 17:01:56 -04:00
fernferret c200d43f51 Bunch of NPE fixes 2011-10-11 16:45:47 -04:00
fernferret f4093cbe51 Implement new config items 2011-10-10 21:37:58 -04:00
fernferret 4366b16a74 Start using the new config 2011-10-10 20:40:31 -04:00
fernferret cfdd1ac38c Remove naming conflict with bukkit 2011-10-10 20:12:22 -04:00
fernferret 3e10f18079 Add a bunch of examples, add loadworld to the plugin.yml 2011-10-10 13:02:29 -06:00
fernferret c7c73e7094 Implement Check Command 2011-10-10 12:28:02 -06:00
fernferret c7e5816b2e Add better debug for world access 2011-10-10 11:57:45 -06:00
fernferret 50a89b7b1a Update Config.yml, implement enforceaccess
Cache enforceaccess and enforcegamemodes, as both of these get accessed
a lot.
2011-10-10 11:49:53 -06:00
fernferret 1aad872333 Start adding the Config Command 2011-10-10 11:31:22 -06:00
fernferret 73b42b5430 Merge branch 'master' of https://github.com/Multiverse/Multiverse-Core 2011-10-10 09:36:36 -06:00
fernferret e93fec45ac Much needed code reformat 2011-10-10 09:34:04 -06:00
Eric Stokes 23933c4706 Correct some javadoc 2011-10-10 07:50:03 -06:00
Eric Stokes 9e14daac1f Implement getMvWorld 2011-10-09 21:03:05 -06:00
Eric Stokes aa079b2920 Add Colored string to the alias, remove Double, use double 2011-10-09 20:26:23 -06:00
Eric Stokes bac24e1c97 Use the MultiverseWorld instead of MVWorld 2011-10-09 20:10:59 -06:00
Eric Stokes c72f602045 Fix MVINFO NPE, Fix NPE on startup with addWorld, Remove deprecated methods 2011-10-09 18:25:42 -06:00
Eric Stokes c22a8a9d18 Implement new world creation methods 2011-10-09 18:11:36 -06:00
Eric Stokes 2759d75125 Finalize API v5 2011-10-09 16:36:05 -06:00
Eric Stokes 980381194b Continue updating API. Fix squids not being monitored, Closes #181 2011-10-09 15:38:18 -06:00
Eric Stokes 8370a72776 Add hunger API, bump protocol to 5 2011-10-09 11:48:09 -06:00
Eric Stokes e0f9344d20 Merge branch 'master' of github.com:Multiverse/Multiverse-Core 2011-10-09 11:43:13 -06:00
Eric Stokes 3fde98049f Add a bunch more to the API 2011-10-09 11:31:50 -06:00
main() 40c04a1f4e Made removePlayersFromWorld() visible from the API and moved the javadoc 2011-10-09 19:27:40 +02:00
Eric Stokes 5386aadbb7 Add new api items for hiding worlds, Move the severe perms error to a level 2 log 2011-10-09 08:51:29 -06:00
Eric Stokes 5e0903086e Display API version, fix difficulty enums missing 2011-10-08 14:59:47 -06:00
Eric Stokes ff47610424 Bump protocol to 4 2011-10-08 14:29:44 -06:00
Eric Stokes 84e178d12e Bump API to version 3 2011-10-08 12:38:54 -06:00
Eric Stokes f2a263f86c Merge WorldManager Changes to keep the API happy 2011-10-08 12:38:23 -06:00
Eric Stokes 3c750104a5 rename some methods in the WorldManagerAPI 2011-10-08 12:36:57 -06:00
main() f69c85e6b0 Added loadWorld(String name) to the WorldManager and made it accessible with a command
Added some "'" around log-messages
2011-10-08 12:28:27 -06:00
Eric Stokes 6e4de79bfb Add WorldManager API, API is now level 2 2011-10-08 11:57:50 -06:00
Eric Stokes 2d112edee5 Start writing the Core API 2011-10-08 11:42:35 -06:00
Eric Stokes 4a634e8418 Final backwards compatability checks 2011-10-08 10:57:48 -06:00
Eric Stokes e31f2c79ac Fix breakages with SignPortals 2011-10-08 10:14:52 -06:00
Eric Stokes cc3889b166 Increment v to 2.1, start adding dummy files 2011-10-08 08:22:19 -06:00
Eric Stokes 7bbdac9012 Move a bunch of classes into utils 2011-10-07 18:47:39 -06:00
Eric Stokes d04a42ee92 Move utils package inside multiversecore 2011-10-07 18:26:40 -06:00
Eric Stokes fa80b66ac2 Pull changes from master 2011-10-07 18:22:54 -06:00
Eric Stokes ae19604eab Add difficulty to the info command 2011-10-03 19:59:29 -06:00
Eric Stokes 6e7daf4e85 And this is why we need unit tests... 2011-10-03 19:40:21 -06:00
Eric Stokes 86d3628b1c Actually save the difficulty 2011-10-03 19:24:38 -06:00
Rigby 9be14a2a0c You just can't get the right staff these days... 2011-10-04 01:28:42 +01:00
Eric Stokes 091c5a9621 Move GameMode check to onPlayerChangeWorld, fix difficulty case settings 2011-10-03 17:43:57 -06:00
Eric Stokes c566ead9ef Add multiworld difficulty 2011-10-02 21:18:25 -06:00
Eric Stokes d97bbfb1b1 Fixed Hunger/Food setting Closes #119 2011-09-28 19:56:41 -06:00
Eric Stokes ea6e94d99d Fix Signportals not going anywhere 2011-09-28 19:34:00 -06:00
Eric Stokes f0ae8cbb8e Ensure that the world players are going to is not null 2011-09-28 17:02:21 -06:00
Eric Stokes 1a6e93f0df Add aditional checks for onPlayerPortal 2011-09-28 16:28:09 -06:00
Eric Stokes 8fe128ec0f Add more api items 2011-09-26 20:21:39 -06:00
Eric Stokes f3cd433e80 Remove ALL perms3 refs 2011-09-25 12:11:42 -06:00
Eric Stokes 0964f461eb Remove Permissions 3 support 2011-09-25 12:02:28 -06:00
Eric Stokes fa409ac4f5 Remove fakePvp from the API 2011-09-25 11:05:48 -06:00
Eric Stokes 3753256611 Move destinations to their own package 2011-09-25 10:46:07 -06:00
Eric Stokes b378b0cf79 Update World API's comments to reflect new API changes 2011-09-25 10:43:22 -06:00
Eric Stokes e5646bbbfd Remove silly nullable reference 2011-09-25 10:41:43 -06:00
Eric Stokes 66538ccd02 Moved API around, added more docs 2011-09-25 10:40:23 -06:00
Eric Stokes d63c043368 New code format 2011-09-25 09:14:17 -06:00
Eric Stokes 65dce752d4 Don't set the hunger, only cancel the events 2011-09-22 19:47:14 -06:00
Eric Stokes 268b272f4d Implement Hunger. Untested 2011-09-21 22:15:16 -06:00
Eric Stokes eb0b83c507 Add getHunger api. No implementation yet 2011-09-21 19:26:02 -06:00
Eric Stokes f009ad6dd6 Merge branch 'master' into development 2011-09-21 17:50:16 -06:00
Eric Stokes 6b543a793a Add BedDestination 2011-09-21 17:45:10 -06:00
Rigby 05de5055ab Lets try this. 2011-09-21 19:16:25 +01:00
Rigby 688ea7a1d3 Merge branch 'master' of github.com:Herocraft/Multiverse-Core 2011-09-21 18:43:18 +01:00
Rigby fc02efd90f Added Doxygen... hopefully we'll have pretty JavaDocs. 2011-09-21 18:42:44 +01:00
Eric Stokes 6039009e3f Merge branch 'master' into development 2011-09-18 13:53:36 -06:00
Eric Stokes a9cb378eab Fixed the from worlds being the to worlds. 2011-09-18 13:51:28 -06:00
Eric Stokes fcfa45717c Fix Change Gamemode with NetherPortals, Fix NetherPortals allowing you entry to worlds you shouldn't be able to access. 2011-09-18 13:22:48 -06:00
Eric Stokes 9333f70add Working on messaging 2011-09-18 13:04:37 -06:00
Eric Stokes 30704338e6 Require spawn permission if you're using mvtp to go back to spawn (Thanks Verrier!) 2011-09-18 12:31:41 -06:00
Eric Stokes 17a519f961 Add the teleport permissions to the teleport command... oops 2011-09-18 11:45:06 -06:00
Eric Stokes 74aba9d6e8 Refactor so a Teleporter can be a CommandSender 2011-09-18 10:03:59 -06:00
Eric Stokes 43fcbc9af9 Add new messaging stuff 2011-09-18 09:48:46 -06:00
Eric Stokes fa3e0d6186 Check for console, Closes #118 2011-09-18 09:48:23 -06:00
Eric Stokes 20ce518d33 Added Copyright notice and remove trailing whitespace. 2011-09-17 12:59:37 -06:00
Eric Stokes f9481db5a6 Document WorldManager.java 2011-09-17 12:55:28 -06:00
Eric Stokes 1b42a25ccb Only set the velocity if a player did successfully teleport. Issue #72 2011-09-17 11:12:02 -06:00
Eric Stokes e3edcb88df Remove JDK 6 dependency 2011-09-17 10:05:01 -06:00
Eric Stokes bef22ba534 Add Per-Destination perms, Closes #61 2011-09-17 09:59:38 -06:00
Eric Stokes 10d6a7e1dc Add Documentation to MVDestination 2011-09-17 08:27:10 -06:00
Eric Stokes b39098a592 Move Mode to page 1: Closes #111, Fix nether imports not defaulting to 8: Closes #103. 2011-09-17 07:35:39 -06:00
Eric Stokes a2c6dad243 Remove my silly printlines 2011-09-16 19:18:36 -06:00
Eric Stokes b76da91013 Merge branch 'master' of github.com:Herocraft/Multiverse-Core 2011-09-16 18:35:22 -06:00
Eric Stokes e7f97a8ae7 Add new debugging 2011-09-16 18:35:17 -06:00
Rigby e792c338aa Fern's FAULT. 2011-09-16 11:19:52 +01:00
Rigby 133810550f Allow the per world Game Modes to not be enforced. 2011-09-16 10:11:30 +01:00
Eric Stokes 97168043ff Fix && should be ||, Allow Creative mode, Set all players in a world to a specific mode when it's changed 2011-09-14 20:06:03 -06:00
Tim Ekl 40c4ce0a37 Merge branch 'master' into gamemodes 2011-09-14 19:11:47 -04:00
Eric Stokes 318564ccf2 Add new CH and CH checks 2011-09-13 20:13:27 -06:00
Eric Stokes 9c1a9769b2 Update to new AllPay version 2011-09-13 19:54:06 -06:00
Eric Stokes 89ea09fba2 Minor changes
Update CommandHandler
Fix typo in Debug
Version now posts as a Multiverse user
2011-09-11 17:37:32 -06:00
Rigby 9384f96549 Getting ready for 1.8 GameModes.
This setup will allow different worlds to be setup under different gamemodes, it handles per player modes during teleportation to and from Worlds.
2011-09-09 12:25:21 +01:00
Rigby 69b143ada6 Believe this should be a set :). 2011-09-09 12:16:54 +01:00
Jeff Wardian a97b6f80d2 Fixed ArrayIndexOutofBounds on translateTempSpawn() 2011-09-02 16:26:36 -07:00
Eric Stokes ad47ce7d1b Add Bed Respawns back in! Thanks @Vaht 2011-09-01 19:18:56 -06:00
Eric Stokes d09d340e0f Fix "There are players in <Java Object>" 2011-08-31 21:05:53 -06:00
Eric Stokes 751ed5a8e8 Check for null creature types. Closes #83 2011-08-29 17:03:59 -06:00
Eric Stokes a0667d49b8 Fix our Custom PTA not obeying useSafeTeleporter 2011-08-25 19:42:52 -06:00
Eric Stokes 8c45d0b76a Exact destinations now don't use the safeTeleport check. Add API hook to allow this to be configurable per destination. 2011-08-25 19:31:46 -06:00
Eric Stokes 319567eb67 Fix the console spewing many many errors. Sorry. 2011-08-24 20:01:50 -06:00
Eric Stokes 7a38806134 Remove Additional Private Deprecations, Must keep methods until Portals 2.1 is out. 2011-08-24 19:05:20 -06:00
Eric Stokes b6755a1047 Return the Permission if it was created, or the old one if it existed. 2011-08-24 18:49:13 -06:00
Eric Stokes 69360a49ec Move World Functions to a new WorldManager. 2011-08-24 17:25:30 -06:00
Eric Stokes 3876c0f47f Remove prints. 2011-08-24 16:38:08 -06:00
Eric Stokes 5fe8f76c34 Add MVTeleportEvent back in. 2011-08-23 16:48:11 -06:00
Eric Stokes e556261e84 Small changes to BlockSafety for MVPortals, Remove hard spout dependency for real this time. Thanks @lithium3141 2011-08-22 19:53:00 -06:00
Eric Stokes 8d09c19988 Add the MVTravelAgent to Core since NetherPortals, Portals _and_ SignPortals use it. 2011-08-22 17:58:54 -06:00
Eric Stokes 4fd0150945 Add ability to query all generator plugins via /mv generators 2011-08-21 16:57:17 -06:00
Eric Stokes f96f3151f9 Allow you to set debug in the config. 2011-08-21 14:30:12 -06:00
Eric Stokes 047e0d8001 Remove hard Spout dependency. Sorry. Thanks Fetch! 2011-08-21 12:10:18 -06:00
Eric Stokes 5f88247810 More fixes to the new World Destinations that support pitch and yaw. 2011-08-21 11:38:01 -06:00
Eric Stokes d12725ca0e Deprecate 2 location methods in favor of using MVDestination instead of Location to preserver velocity. 2011-08-21 10:32:07 -06:00
Eric Stokes dc9f2fc360 Use DisplayName in mvwho Closes #62 2011-08-21 08:36:43 -06:00
Eric Stokes 2c865aa0ff Allow our own spawns to be more accurate, including decimal precision on XYZ and Pitch/Yaw.
We still set the spawn in the bukkit worlds to the inaccurate setting.
No migrator is included for this change, just do /mvss in game.
2011-08-21 08:34:07 -06:00
Eric Stokes f11f3dd88e Allow us to add permissions safely via the Permissions object. 2011-08-20 22:50:06 -06:00
Eric Stokes c503849107 Exposed getSafeLocation 2011-08-20 16:36:39 -06:00
Eric Stokes ce8b042919 Merge branch 'master' into development 2011-08-20 09:16:14 -06:00
Eric Stokes 92a762e5e4 Add MV Debug, Attempted fix for Portal teleportation fail, Water and Doors are now safe materials 2011-08-20 09:07:40 -06:00
Eric Stokes eb4f9700bc Made World Access by default OP. However, opfallback is still set to true by default 2011-08-19 16:48:55 -06:00
Eric Stokes 49e3a42550 Give an easy way of using cannons without portals
Behold: /mvtp cannon-2
2011-08-17 16:49:24 -06:00
Eric Stokes 1ab56096f8 Increment AllPay to 1.0.3 2011-08-16 18:32:05 -06:00
Eric Stokes afc388637f Update AllPay, Hopefully fix the BOSEcon bug 2011-08-16 18:02:43 -06:00
Eric Stokes 93fab486ff Add iCo 6 Support, update to AllPay 1.0.1 2011-08-15 20:53:16 -06:00
Eric Stokes e36210b99a Add spout tests 2011-08-13 14:58:43 -06:00
Eric Stokes f6299c60a0 Fix scale named scaling (thanks krinsdeath) 2011-08-11 18:28:45 -06:00
Eric Stokes 06bc0dea02 Fix not being able to set world scaling. (Thanks krinsdeath) Add pitch to mvcoord, add missing variables to mvinfo 2011-08-11 18:20:35 -06:00
Eric Stokes 11ce604938 Fix NPE when a world was not known by MV Thanks Rockstar04! 2011-08-10 19:35:48 -06:00
Eric Stokes 7ef564799e Actually fixed cannons this time... 2011-08-09 19:23:28 -06:00
Eric Stokes 62f15bb101 Sync the mobs when we clear a list. 2011-08-09 18:41:27 -06:00
Eric Stokes e551b7184d Cannon Refactor, Info fixes, Permissions clarification 2011-08-09 18:13:28 -06:00
Eric Stokes 06830f4e98 Fix Cannons, Closes #53 2011-08-09 17:41:35 -06:00
Eric Stokes c629fe72e4 Yes. Cannons. In Multiverse2. What now. 2011-08-08 22:02:56 -06:00
Eric Stokes 04779cb8ba Fix worlds being reported as deleted. Closes #52 2011-08-08 18:17:55 -06:00
Eric Stokes 1abcb187e6 Removed lightning from what we're watching 2011-08-07 21:06:50 -06:00
Eric Stokes ff89bda57e Add ability to disable weather per world. 2011-08-07 21:03:36 -06:00
Eric Stokes 9b9bbb4091 Fix MvInfo's respawn world 2011-08-07 16:42:50 -06:00
Eric Stokes 818756d45b Fix PlayerDestination 2011-08-07 09:40:22 -06:00
Eric Stokes 23ea0e0c37 Add new PlayerDestination, this build should be treated as unstable 2011-08-07 08:29:23 -06:00
Eric Stokes c9f8b06f34 Update CH 2011-08-06 14:02:14 -06:00
Eric Stokes f06c553055 Fix Animals info actually being monsters info in /mvi 2011-08-05 22:35:55 -06:00
Rigby 6e1cff5d26 Basic implementation of the spawn in memory setting. 2011-08-05 05:12:07 +01:00
Rigby 01b016f002 Prevent multiple configuration saves in the constructor, perform a single save at the end and then consequent saves when settings are changed. 2011-08-05 05:10:21 +01:00
Eric Stokes f81a9d15c0 Remove Spam, Add auto-pastebin code, Minor bugfixes. 2011-08-04 20:26:25 -06:00
Eric Stokes dd388d0d9f Fix world teleports. Whoops. 2011-08-03 20:24:44 -06:00
Eric Stokes 5e7d58a1dd Apparently GH for Mac doesn't handle deletes right yet... 2011-08-03 18:59:52 -06:00
Eric Stokes 1cc47ff1ba Fix "Blah, Blah" in delete command, abs class Dest -> interface MVDest, restrict teleports based on MVDest.getPermissionString. 2011-08-03 18:59:21 -06:00
Eric Stokes 1671a8163d Remove spam on delete. 2011-08-03 18:19:50 -06:00
Eric Stokes 9d2cc9a839 Fix license, Update CH, Fix mvdelete 2011-08-03 18:15:21 -06:00
Eric Stokes 34a0ab2e67 Add some examples to create, upgrade CH 2011-08-02 19:13:23 -06:00
Eric Stokes 4a478d159b Made the mvm commands prettier/more informative. 2011-08-01 20:53:06 -06:00
Eric Stokes dbdc6d91d2 Added search to help command! Thanks @AkiTensai! 2011-08-01 19:51:57 -06:00
Eric Stokes b9e9a65022 Upgrade CH 2011-07-31 21:58:53 -06:00
Eric Stokes ae7000b3ad Curse you Config.save() 2011-07-31 20:52:14 -06:00
Eric Stokes 6c061f1116 Add Version Event, Add MVPlugin Interface. 2011-07-31 19:18:59 -06:00
Eric Stokes 1e9a826999 Finalize the mv info command 2011-07-31 18:24:09 -06:00
Eric Stokes 1a938c8ce8 Command fixes. 2011-07-31 17:29:14 -06:00
Eric Stokes c5108c3463 Upgrade command Handler, start implementing mvinfo 2011-07-31 17:11:59 -06:00
Eric Stokes 9acc46f9d1 Cleaned up MVINFO Closes #47 2011-07-31 08:45:10 -06:00
Eric Stokes de9209b270 Remove debug, Add warning if users have spawn-monsters set to false. 2011-07-31 07:41:09 -06:00
Eric Stokes 3ccc08b9e5 Tune the teleport methods. 2011-07-30 21:28:59 -06:00
Eric Stokes c78e11bf52 Add new vehicle checks 2011-07-30 21:12:16 -06:00
Eric Stokes fbcadd9b21 Merge branch 'master' of github.com:Herocraft/Multiverse-Core 2011-07-30 19:09:36 -06:00
Eric Stokes 9d9a091e7a core work from lith 2011-07-30 19:09:30 -06:00
Tim Ekl 9fbccfded3 Update submodule & POM file 2011-07-30 15:42:31 -06:00
Eric Stokes 0c3a3732be Added fancy formatting to force teleport. 2011-07-30 09:27:18 -06:00
Eric Stokes addd95443a Add second chance to teleports 2011-07-30 09:17:23 -06:00
Eric Stokes a43e033a84 Fix opfallback not playing nicely with new bukkit perms. 2011-07-30 09:02:20 -06:00
Eric Stokes e5e908800d Add spaces to commands. 2011-07-30 00:53:55 -06:00
Eric Stokes 48f51e8a3a Fix Price not being able to be set. Closes #45 2011-07-29 23:17:17 -06:00
Eric Stokes dd129f2776 Fix MVWho Closes #44 2011-07-29 22:29:09 -06:00
Eric Stokes 37914bc4d1 Add LoggablePlugin interface, so we can log without knowing the plugin! 2011-07-29 18:42:17 -06:00
Eric Stokes e888738f0d This shoudld be gone 2011-07-29 18:20:26 -06:00
Eric Stokes f07be132f8 Move Listeners 2011-07-29 18:09:48 -06:00
Eric Stokes 48f9226d27 Refactoring on the ConfigMigrator 2011-07-29 16:57:38 -06:00
Eric Stokes cd7ad37887 Add New ConfigMigrator Style 2011-07-29 16:35:27 -06:00
Eric Stokes dca9a01c25 Fix my misspellings... 2011-07-29 15:54:32 -06:00
Eric Stokes f06642a7ce Add Config Migrate, clean up some logs. 2011-07-29 15:52:43 -06:00
Eric Stokes 0f10451269 Upgrade AllPay. Fix free recognition 2011-07-28 19:12:38 -06:00
Eric Stokes 0d4d344165 Fix WorldDest orientation not being saved. Fixed Permission oopsie. 2011-07-28 18:39:47 -06:00
Eric Stokes dac95eceba Add more currency stuff, lots of cleanup. 2011-07-28 16:14:15 -06:00
Eric Stokes 9e1484408c Add charge for entering worlds, add exemptions 2011-07-27 18:12:58 -06:00
Eric Stokes c81dcb227c Remove BlockSafety Spam, remove useless class. 2011-07-27 16:48:27 -06:00
Eric Stokes ad3643758d upgrade CH 2011-07-26 20:52:35 -06:00
Eric Stokes 0a8b77a99c Updated CH version 2011-07-26 20:45:43 -06:00
Eric Stokes 3eb10dc251 Getting new dependencies working, DO NOT USE THIS BUILD 2011-07-26 19:35:00 -06:00
Eric Stokes 524fe82784 adding new payment stuff 2011-07-26 19:13:25 -06:00
Eric Stokes 970e06042a Finall fix permissions issues 2011-07-26 18:47:33 -06:00
Eric Stokes 70e4bad62b Fix spawn permissions, upgrade CH 2011-07-26 16:58:20 -06:00
Eric Stokes 811aa811bb Yea it's not really a teleport event... 2011-07-26 16:34:22 -06:00
Eric Stokes 52f8476907 Fire off an event when we reload configs, so all plugins can too! 2011-07-26 16:06:00 -06:00
Eric Stokes 4c4fd08dc8 Allow World Destinations to have a direction. 2011-07-26 15:39:44 -06:00
Eric Stokes f9db8ef7f9 Fix getSafeLocation(L) only returning unsafe locations… Silly booleans... 2011-07-25 21:15:47 -06:00
Eric Stokes 6e88301351 Refactored the Teleportation Method. Finally Closes #1 :D 2011-07-25 19:16:00 -06:00
Eric Stokes ecbdff428c Compatibility for vehicles and directions 2011-07-24 17:43:30 -06:00
Eric Stokes 2897d23d4b Fix NSEW
(ha you thought I said NSFW)
2011-07-24 17:20:02 -06:00
Eric Stokes 320a8dfebf Fixed the Remove command having the wrong command. 2011-07-24 16:32:50 -06:00
Eric Stokes d9530061ff Compatibility changes for Portals directions. 2011-07-24 16:30:56 -06:00
Eric Stokes 61e917a60f Test Push. Do not use this build! 2011-07-24 12:10:39 -06:00
Eric Stokes 23158a0707 Compatibility with new Dest Types. 2011-07-23 16:56:19 -06:00
Eric Stokes de3e4ec1cb Now CH supports unordered commands. Yay! (Thanks Rigby) 2011-07-23 07:57:05 -06:00
Eric Stokes 9bf993ef12 Destination fixes. 2011-07-23 07:21:40 -06:00
Eric Stokes 45c76d8faa Remove old Dest References 2011-07-22 23:34:10 -06:00
Eric Stokes e0ebfdb806 Temp Fix for help command params 2011-07-22 23:27:57 -06:00
Eric Stokes 0bbb66737e Fix World Dest Bugs, add Exact Dest type. 2011-07-22 23:19:31 -06:00
Eric Stokes 6ae22cf752 Allow No identifier 2011-07-22 21:44:02 -06:00
Eric Stokes 83aa79deed Add new destination arch. This will break all plugins. 2011-07-22 20:57:56 -06:00
Eric Stokes 0532564431 Forgot the world... 2011-07-21 17:31:39 -06:00
Eric Stokes 04accbfded Add exact destination 2011-07-21 17:27:33 -06:00
Eric Stokes 2c47a414eb Add the multivers.core.tp.* node, decided to leave multiverse.core.tp They both do the same thing 2011-07-21 14:16:24 -06:00
Eric Stokes 1a16636c7a Refactor, Now we safely move players from a world to be unlaoded, unload actually unloads from memory 2011-07-21 14:07:57 -06:00
Eric Stokes a3e27da978 Add multiverse.* and all other recursive perms 2011-07-20 21:44:43 -06:00
Eric Stokes e374a97257 No slash for you! 2011-07-20 18:52:55 -06:00
Rigby 39d0f897b3 Bloody hypens 2011-07-20 16:23:09 +01:00
Rigby 02df3c478c Update .gitignore 2011-07-20 15:49:11 +01:00
Rigby ab1c1be9b1 Swap to Maven -- Hopefully 2011-07-20 15:48:46 +01:00
Eric Stokes c678750c90 Fixed the Version command.
Bad case of the copy pastes...
2011-07-19 17:21:44 -06:00
Eric Stokes 9eff255f47 Add new version cmd, lots of cleanup 2011-07-19 16:51:39 -06:00
Eric Stokes f09bcac644 Check for the MVWorld before doing a Coord - Thanks for the bug report JonDatz! 2011-07-17 19:15:33 -06:00
Eric Stokes e446c99f9e Remove deprecated methods, update all perms to default to OP, except help 2011-07-17 17:13:33 -06:00
Eric Stokes bdefb38f3c I'm sorry Kainzo. Now Core does NOT use PLAYER_MOVE. 2011-07-17 15:45:17 -06:00
Eric Stokes 5aa91c67f5 upgrade CH 2011-07-17 13:40:35 -06:00
Eric Stokes 2d48cda537 Final updates to work with Bukkit Permissions. Yes. MV2 works with the built in Bukkit Permissions system NOW!
The other plugins, however, do not :P Yet.
2011-07-17 13:37:49 -06:00
Eric Stokes 3c4135236d Commit because i've changed just about everything... Doubt this one works. 2011-07-17 13:06:21 -06:00
Eric Stokes bf51adaa3e Node based permissions 2011-07-17 11:01:44 -06:00
Eric Stokes 96fa18eab3 Cleaning up the Commands 2011-07-17 09:12:12 -06:00
Eric Stokes fc7db31b0d Add Exact type 2011-07-16 22:01:01 -06:00
Eric Stokes c9c58c93e6 MVPortals Compatibility changes 2011-07-16 20:19:37 -06:00
Eric Stokes 099bd9dbb6 Add prettier "MV does not know about this" method. Now it will be consistent. 2011-07-16 15:22:23 -06:00
Eric Stokes 8792d3b4c3 Merge branch 'master' of github.com:Herocraft/Multiverse-Core 2011-07-16 14:43:31 -06:00
Eric Stokes 7754f470c7 Merge pull request #40 from AkiTensai/Aki_ModifyCopy
Fixed grammer in command descriptions.
2011-07-16 13:40:27 -07:00
Aki Tensai 0cd86d7212 /mvspawn's description altered 2011-07-16 14:36:00 -06:00
Eric Stokes 2b4ab07417 Bits of cleanup. 2011-07-16 14:11:14 -06:00
Aki Tensai 2a7504c044 Attempting to get my local to get rid of old files. 2011-07-16 14:06:45 -06:00
Aki Tensai 6a6d1a2a10 Altered punctuation on several command's descriptions. Teleport's description altered to state it sends the provided player, or self if no player specified. 2011-07-16 13:59:32 -06:00
Eric Stokes d6f046a4fc Why do letters have to have a cAsE? 2011-07-16 13:31:16 -06:00
Aki Tensai 935f987a4d Merge remote-tracking branch 'upstream/master' into HEAD
Conflicts:
	src/com/onarandombox/MultiverseCore/command/commands/CreateCommand.java
	src/com/onarandombox/MultiverseCore/command/commands/HelpCommand.java
	src/com/onarandombox/MultiverseCore/command/commands/ModifyAddCommand.java
	src/com/onarandombox/MultiverseCore/command/commands/ModifyClearCommand.java
	src/com/onarandombox/MultiverseCore/command/commands/ModifyRemoveCommand.java
	src/com/onarandombox/MultiverseCore/command/commands/ModifySetCommand.java
	src/com/onarandombox/MultiverseCore/command/commands/SpawnCommand.java
	src/com/onarandombox/MultiverseCore/command/commands/WhoCommand.java
	src/com/onarandombox/MultiverseCore/commands/EnvironmentCommand.java
	src/com/onarandombox/MultiverseCore/commands/ImportCommand.java
	src/com/onarandombox/MultiverseCore/commands/ListCommand.java
2011-07-16 13:28:20 -06:00
Eric Stokes c25205f61c Really? Really? Why didn't you catch this before... *sigh* 2011-07-16 12:54:16 -06:00
Eric Stokes 1d87be12e9 Fixed big oopsie in the Migrator - Thanks go out to MV2 tester Kane_Hart for this one! 2011-07-16 12:48:58 -06:00
Eric Stokes eaeb980aeb Changes to Destination, Added more error checking for ConfigMigrator 2011-07-16 11:58:33 -06:00
Eric Stokes 1a8c46581c Fix concurrent modification. Why would I ever have done that... 2011-07-16 08:43:55 -06:00
Eric Stokes a87756480a Add another layer of spawn traials, This is needed for generators such as Cleanroom. This also removes a NPE. 2011-07-16 08:09:56 -06:00
Eric Stokes 952a0be4a8 Pull changes that fix MVDelete 2011-07-16 07:41:26 -06:00
Eric Stokes b2f75c52a6 Remove copying file, the licsense should suffice 2011-07-16 06:45:44 -06:00
Eric Stokes beace36110 Removed spam. 2011-07-15 17:03:00 -06:00
Eric Stokes 48e86a8153 Finalized new respawn functionality 2011-07-15 16:59:32 -06:00
Eric Stokes 3c5a93be3b Remove super long package, convert to shorter. 2011-07-15 14:22:22 -06:00
Eric Stokes b7fd8f970b Remove the editwhite/blacklist garbage. 2011-07-15 14:18:22 -06:00
Rigby 8c8a0b713a Output the world for a more descriptive response. 2011-07-14 03:35:15 +01:00
Rigby 00449e9206 Some more formatting. 2011-07-14 03:31:44 +01:00
Rigby 0925c37eb4 Removed the console spam and instead alert the sender at the end. 2011-07-14 03:30:54 +01:00
Eric Stokes ab56f9ed4d Add version to config.yml 2011-07-13 18:30:07 -06:00
Eric Stokes 55c77f48e0 I am a bad person 2011-07-13 18:27:25 -06:00
Eric Stokes 64a7a1ad8b Add config.yml to the migrator 2011-07-13 18:24:09 -06:00
Eric Stokes c6a16d00ce Add ConfigMigrator 2011-07-13 18:13:12 -06:00
Rigby fa07867f64 Now you can have an equal share of blame =D, 10/90 split seem reasonable to you? 2011-07-13 12:11:02 +01:00
Rigby 1d9b94294b Alterred the respawn functionality to hopefully be more customiseable. 2011-07-13 12:10:25 +01:00
Rigby 889dbf2986 Once in a blue moon I need to make it look like I actually do some work on this project... 2011-07-13 11:37:52 +01:00
Rigby 78d2d242f2 Support for the new UUID Duplicate checks, createWorld can now return null if the world was a duplicate of an already loaded world. 2011-07-13 11:32:40 +01:00
Eric Stokes 3856d6777c Add new configMigrator class, update allpay 2011-07-12 21:13:56 -06:00
Eric Stokes 6d61e7e419 Fix command descriptions, upgrade CH 2011-07-12 18:44:57 -06:00
Eric Stokes 3ea2f42e7f Many fixes to aliases. Add newer CH version 2011-07-11 21:02:34 -06:00
Eric Stokes ac66c2f3bb Sync with the Wiki 2011-07-10 20:36:10 -06:00
Eric Stokes 77a25ad8e6 Added a bunch more short commands 2011-07-10 16:08:24 -06:00
Eric Stokes e059a565c7 Add more finely grained permissions for MVTP 2011-07-10 15:32:35 -06:00
Eric Stokes 91802f0e55 Move the filtering of commands out of the Handler 2011-07-10 14:23:44 -06:00
Eric Stokes 8e92496fb9 Revert "Permissions is Silly"
This reverts commit d9cca0f822.
2011-07-10 14:02:39 -06:00
Eric Stokes d9cca0f822 Permissions is Silly
Where Silly = Stupid
2011-07-10 13:42:13 -06:00
Eric Stokes 0edd3f80e0 Oh silly booleans... 2011-07-10 13:19:38 -06:00
Eric Stokes 8a0301f162 What's this? MV2 Supports multi-world bed respawns now? It sure does! 2011-07-10 12:06:14 -06:00
Eric Stokes c54a746c2f Minor Fixes to some commands 2011-07-10 08:40:06 -06:00
Eric Stokes b6d718a0ba Fix fakePVP 2011-07-09 22:15:36 -06:00
Eric Stokes 54573889af Add 'fakepvp' config, currently untested... 2011-07-09 22:00:07 -06:00
Eric Stokes 1c3d3b0807 Add a freshly baked BSD help command 2011-07-09 21:50:25 -06:00
Eric Stokes 6be11c01ee Remove deprecated method 2011-07-09 21:00:01 -06:00
Eric Stokes f9114996e2 increment CH version 2011-07-09 20:21:50 -06:00
Eric Stokes 8adf06f247 Implement permissions 2011-07-09 20:21:22 -06:00
Eric Stokes a8999ee5a1 Made MVPermissions implement PermissionsInterface, Increment CommandHandler 2011-07-09 20:10:43 -06:00
Eric Stokes 5da92705bb Increment commandhandler 2011-07-09 20:05:14 -06:00
Eric Stokes 5b30e7214e Implement new CommandHandler 2011-07-09 19:59:06 -06:00
Eric Stokes 83bb61a5ee update CommandHandler Again 2011-07-09 18:35:01 -06:00
Eric Stokes 71a63d10d6 Update commandhandler version 2011-07-09 18:32:33 -06:00
Eric Stokes aa96821df1 working on delete 2011-07-09 18:28:35 -06:00
Eric Stokes 20eb65fd59 Upade CommandHandler 2011-07-09 18:19:46 -06:00
Eric Stokes a4b74d172b More progress 2011-07-09 18:13:56 -06:00
Eric Stokes 9c924b04a0 ConfirmCommand has been refitted with the new hooks. 2011-07-09 18:06:42 -06:00
Eric Stokes f1c94bf851 Started implementing the new CommandHandler 2011-07-09 18:00:30 -06:00
Eric Stokes 4d39f2ec56 Removed Licensed CommandManager Code
We want no part in CC NoDeriv Code.
2011-07-09 17:42:32 -06:00
Eric Stokes 949e70b81c Remove code I don't want anymore. 2011-07-09 16:57:04 -06:00
Eric Stokes 6ccb52bc3e Change to BSD from CC 2011-07-09 08:34:18 -06:00
Eric Stokes 2985167936 Fixed Spacing, fixed Modify commands 2011-07-09 08:33:18 -06:00
Eric Stokes fc9aa456da Rewritten commandManager 2011-07-09 07:52:20 -06:00
Aki Tensai fda6b31f06 Consistant punctuation on descriptions of commands.
/mvspawn's description altered
Testing my ability to commit changes on GitHub.
2011-07-09 02:13:02 -06:00
Eric Stokes 8f56347572 Fixed ordering causing some commands to be read over MVModify 2011-07-07 21:32:21 -06:00
Eric Stokes 0187a600b3 Still working on these multi staged modify commands 2011-07-07 21:27:12 -06:00
Eric Stokes 55b873ddea Update more allpay libraries 2011-07-06 19:24:50 -06:00
Eric Stokes f3c67390ce Update AllPay 2011-07-06 19:11:51 -06:00
Eric Stokes 3b32e334d7 Add allpay submodule 2011-07-06 18:42:18 -06:00
Eric Stokes f86f753563 Fix telling people they can't go to a world, then taking them there anyways. #whoops 2011-07-06 18:17:41 -06:00
Eric Stokes 8ecfebe480 Decouple iConomy and Permissions from Core. Closes #32 2011-07-06 18:10:36 -06:00
Eric Stokes 79fba462b9 Add Message to ops and those who can create, Closes #25. Bullet proofed a few more methods. 2011-06-30 22:07:17 -06:00
Eric Stokes c43362bb5e Add default and none respawn styles 2011-06-30 21:07:48 -06:00
Eric Stokes 81315ba7a4 Add MVRespawnEvent 2011-06-30 20:42:32 -06:00
Eric Stokes 60d456900d This was missing from the last commit. 2011-06-30 18:41:08 -06:00
Eric Stokes 72fc006795 Allow disableautoheal 2011-06-30 18:40:57 -06:00
Eric Stokes 1024506f8c Remove unrequired imports. 2011-06-30 18:11:37 -06:00
Eric Stokes 406e31f5c5 Moved the flag extractor to the CommandManager 2011-06-30 18:09:30 -06:00
Eric Stokes f7ded5f129 Now you can say /mvpurge pig rather than /mvpurge PIG 2011-06-30 17:45:49 -06:00
Rigby 6858c878d3 Don't prevent plugins from spawning creatures. 2011-06-30 20:45:04 +01:00
Rigby 2ff10d0882 1.5 Compatibility 2011-06-30 20:44:46 +01:00
Eric Stokes dad4547c21 More code cleanup, remove bogus method in MVPlayerListener 2011-06-30 07:30:55 -06:00
Eric Stokes f7bdffa365 Fix Colors not saving correctly. Closes #26 2011-06-29 22:15:16 -06:00
Eric Stokes 04346f0efc Removed a bunch of Multiverse Spam 2011-06-29 21:47:36 -06:00
Eric Stokes 4f7c2d507a Fix Monster/Animals Spawning 2011-06-29 21:43:37 -06:00
Eric Stokes 535dcded34 Animals exceptions are working. Time to refactor. seriously. 2011-06-29 19:21:07 -06:00
Eric Stokes 69c23980e1 Wow. what was I thinking... 2011-06-28 21:31:50 -06:00
Eric Stokes 57941719ad Heh, switched my booleans... 2011-06-28 21:27:50 -06:00
Eric Stokes ed5dfd08ae Still a few bugs with Purge 2011-06-28 21:22:28 -06:00
Eric Stokes ce3e203bc1 Think I've finished the Purge Command. It's untested. o.O 2011-06-28 20:02:40 -06:00
Eric Stokes 3124a5c678 Put your commits in the air like you just don't care!
But seriously, working on MVPurge
2011-06-28 19:11:12 -06:00
Eric Stokes 7271e5cfb8 Started Purge Cmd. Moved Queued cmds to CmdMgr 2011-06-28 17:53:26 -06:00
Eric Stokes b37799354b Remove autoloading of worlds, Part of issue #25 2011-06-28 07:34:13 -06:00
Eric Stokes eceeb72b59 Environments no longer default to Normal, Closes #24 2011-06-27 21:26:49 -06:00
Eric Stokes ea45d2675e Add opfallback to config; Permissions cleanup 2011-06-26 20:56:10 -06:00
Eric Stokes 46ed043104 Add Colors to chat, update default config 2011-06-26 20:24:44 -06:00
Eric Stokes 84b726b636 Add colors to Who command. Fix not being able to use black 2011-06-26 19:58:37 -06:00
Eric Stokes a62d341d8f Add colors to world aliases
Now World aliases take priority over world folder names. Bit of cleanup
2011-06-26 19:50:40 -06:00
Eric Stokes 1a31fca6a7 Remove old breaking method 2011-06-26 18:26:57 -06:00
Eric Stokes bd7d5265a5 Temp debug lines. They'll go away. 2011-06-26 18:17:20 -06:00
Eric Stokes 252e15d48e Fix NPE when teleporting someone from console 2011-06-26 16:41:34 -06:00
Eric Stokes 4effff9145 Allow players to mvtp other players
Added permissions node: multiverse.world.tp.other/self
2011-06-26 16:25:53 -06:00
Eric Stokes 0885ba3089 Cleanup and Add 2nd permissions node to mvspawn 2011-06-26 15:58:23 -06:00
Eric Stokes 532e2c2f75 It was the ultimate refactor... of ultimate destiny.
Now requires use of getters and setters for MVWorld things.
2011-06-26 14:56:59 -06:00
Eric Stokes d4729653a1 Fix monsters and animals settings 2011-06-26 13:26:19 -06:00
Eric Stokes f33e93e077 MVModify is working now. Yay.
Still need to purge animals/mobs when the var is set.
2011-06-26 12:27:03 -06:00
Eric Stokes 28276daa81 More MVWorld Refactors
although the modify command got a lot messier...
2011-06-26 11:57:45 -06:00
Eric Stokes 04c6024616 More refactoring on MVWorld 2011-06-26 11:38:36 -06:00
Eric Stokes 0a88c086f4 Moving stuff into their gitters and setters
Pun intended.
2011-06-26 11:04:47 -06:00
Eric Stokes 028b910e9a Refactor MVWorld 2011-06-26 11:00:52 -06:00
Eric Stokes cedc097efa Remove libs, updated the update script
So we're not dependent on other people's failing websites (iConomy *cough* *cough*)
2011-06-26 10:51:51 -06:00
Eric Stokes 358dab345a Made CustomGenerators up to spec 2011-06-26 10:45:02 -06:00
Eric Stokes ca8a017d32 Fix worlds not being saved correctly. 2011-06-26 10:01:40 -06:00
Eric Stokes 4edecaaf6f Remove MVCommandHandler, we're finally free of it! 2011-06-26 09:31:00 -06:00
Eric Stokes be8ff3ad6d Fix null environments for worlds 2011-06-26 09:16:26 -06:00
Eric Stokes 19da230723 More work on mvmodify; Better integration with Custom gens 2011-06-26 08:55:24 -06:00
Eric Stokes b2bcb941c3 Made 'worlds' private and added accessor methods. 2011-06-25 17:15:46 -06:00
Eric Stokes 53345c2f42 Lots of Cleanup
Fixed a bunch of missing this.'s, unused imports, etc.
2011-06-25 15:43:46 -06:00
Eric Stokes dc2a8309bc Add Minecraft behavior to multiple worlds
If a world has NO exceptions, and has monsters/animals turned off, we should not even try and spawn them, or at least tell Bukkit to do this.
2011-06-25 14:32:37 -06:00
Eric Stokes 63a2fc0f1f Add Custom world types to MVWho and MVEnv 2011-06-24 21:43:05 -06:00
Eric Stokes 09b6d72881 Plugins can register with MV as a custom world type now! 2011-06-24 19:48:04 -06:00
Eric Stokes a2bef29bc2 Starting to support custom generators 2011-06-24 18:47:31 -06:00
Eric Stokes e24dc7f83a Add Crippled info command, update compatability with 920 2011-06-23 06:57:47 -06:00
Eric Stokes 086c96bf9b Update CB 2011-06-20 21:38:47 -06:00
Eric Stokes 9632414429 Disallow negative or 0 scaling 2011-06-20 20:22:50 -06:00
Eric Stokes 5a60df3f5a Rename Compression -> Scaling 2011-06-20 19:51:58 -06:00
Eric Stokes 98e1af0f66 Add fancy permissions (/mv) 2011-06-19 17:07:03 -06:00
Eric Stokes 82429ee7de Add true permissions support 2011-06-19 16:58:28 -06:00
Eric Stokes 665dccbcc5 Additional comments to logger 2011-06-19 09:55:21 -06:00
Eric Stokes 6af3964699 Small bits of clean up and commenting 2011-06-18 21:00:54 -06:00
Eric Stokes eab4067c7d Fix White/Blacklisting
Add more permissions support
2011-06-18 20:57:24 -06:00
Eric Stokes cdc858a1e3 Add ability to add dangerous commands, users must now confirm mvdelete 2011-06-18 16:29:22 -06:00
Eric Stokes 69bffd87c7 More print cleanup 2011-06-18 14:59:20 -06:00
Eric Stokes 20c3b516cc Fix seed not being added
Remove test methods
Bits of refactoring
2011-06-18 14:53:51 -06:00
Eric Stokes c668bdb4f5 Forgot to add environment to the worlds config! 2011-06-18 14:44:50 -06:00
Eric Stokes 6afd8dfdfb Add mvdelete, mvremove and mvunload 2011-06-18 14:26:30 -06:00
Eric Stokes 8e41d2ea4b Normal worlds now featuring Nether skyboxes... 2011-06-04 17:37:33 -04:00
Eric Stokes 7ff5c518f4 Cleanup the EntityListener a bit
Save worlds when they are initialized
Add Some test data for the list types since they don't show up
Working on the respawn issue still...
2011-06-04 17:01:43 -04:00
Eric Stokes 1971b8fc4e Import MVSpawn, close #11 2011-06-03 23:30:37 -04:00
Eric Stokes 7c595bd58b MVImport works, close #10 2011-06-03 22:25:26 -04:00
Eric Stokes 5233ab17c6 AutoLoad Default Worlds, close #13 2011-06-03 19:40:54 -04:00
Eric Stokes babc3a8d76 Lots of code cleanup 2011-06-03 16:44:15 -04:00
Eric Stokes 5223bef9d0 Cleanup CreateCommand, almost looks pretty now. 2011-06-03 15:40:50 -04:00
Eric Stokes 3651972901 Fix help not showing for invalid commands 2011-06-03 15:34:39 -04:00
Eric Stokes 8cb421b27a Working on issue #10 2011-06-03 14:43:31 -04:00
Eric Stokes 04a76b1eb2 Remove junk print code, cleanup parseAllQuotedStrings a bit 2011-06-03 14:25:20 -04:00
Eric Stokes 1f3a325bc9 Verify worlds and portals at the time of Destination creation 2011-06-03 14:17:28 -04:00
Eric Stokes 7061c7a9c2 Fix SKYLAND should be SKYLANDS, whoops 2011-06-03 10:31:02 -04:00
Eric Stokes 33b846cf22 Remove extra semicolon
Closes #4
2011-06-03 10:25:20 -04:00
Eric Stokes 4556b0d4c6 Teleports work with spaces, still needs refactor before merge 2011-06-02 21:43:01 -04:00
Eric Stokes 80fd19c0f8 Supports CommandManager level string combining
Now when someone enters a command surrounded in quotes, it gets combined and passed as an arg with spaces! Woot.
2011-06-02 20:58:03 -04:00
Eric Stokes a5a3618439 Creation of spaced worlds works, so do seeds. Now refactor hardcore. 2011-06-02 19:59:57 -04:00
Eric Stokes 3a6d401a72 Should allow spaces, needs testing 2011-06-02 16:43:22 -04:00
Eric Stokes 00b7af5c84 Starting on the create command 2011-06-02 15:38:41 -04:00
Eric Stokes f2b9b95dc9 Remove old MVCoord 2011-06-02 15:31:12 -04:00
Eric Stokes 2ea45c8219 Ported SetSpawn.
Extraced common in game only command error message
2011-06-02 10:58:15 -04:00
Eric Stokes 5c144f31c2 Multi-World travel now possible, not perfected at all 2011-06-02 10:41:24 -04:00
Eric Stokes 599bbcd16c Made DestinationType enum public 2011-06-02 10:10:20 -04:00
Eric Stokes 116b661b84 Move MVTP and MVList to proper command style
Add Destination which allows easier parsing of World/Portals. This currently has NO regex check, but it can be added here for easy control over portal/world naming conventions
2011-06-02 09:45:42 -04:00
Eric Stokes 2a991a3e7d Update for iConomy 5 2011-06-02 08:40:31 -04:00
Eric Stokes 45ca828107 Remove libs from repo, add other folders to .gitignore 2011-06-01 20:14:39 -04:00
Rigby db64804e27 WIP! Just doing this to test the GitBot... AGAIN 2011-05-02 03:51:02 +01:00
Rigby fae3d33a6c Remove NULL from the seedStr default. Also some debug output for outputting the seed of a world. Ready to implement getSeed(); 2011-04-05 22:26:38 +01:00
Rigby 20c14daf49 ReadMe + Copying 2011-04-01 19:21:14 +01:00
Rigby a9103d1ba9 Updated to b602
Minor Changes - Removed Static from some variables etc.
Added Custom seed to Worlds.
2011-04-01 01:38:17 +01:00
Rigby 85b219282e DebugLog + Messaging (Forgot these :)) 2011-03-31 16:07:03 +01:00
Rigby 93aae71375 CleanUp + Format 2011-03-31 16:06:48 +01:00
Rigby 3659e41098 Renamed from "MultiVerse-Core" to "Multiverse-Core" ./slaps Kainzo 2011-03-31 16:04:54 +01:00
Rigby 4fb9098485 Tidying up code to make it look like I'm actually doing something... 2011-03-31 03:29:29 +01:00
Rigby 6fdd00724f Sorry IRC Bot :( 2011-03-30 17:37:55 +01:00
petteyg 33afc8a3ca Stuff 2011-03-28 09:56:50 -05:00
petteyg 7241720677 Stuff 2011-03-28 09:52:20 -05:00
Rigby 9c3fbe54ce Updating to a new Bukkit build... everything broke :'( 2011-03-27 21:47:57 +01:00
Rigby 09c540453f If you're happy and you know it - make it easier to read. (Boredom) 2011-03-18 11:52:00 +00:00
Rigby 84d7fc0260 Silly formatting 2011-03-18 00:56:11 +00:00
Rigby bd589a6b9a Quick fixes to the purge command. 2011-03-18 00:55:58 +00:00
Rigby 6de723705f Alterations to the getAuthors function...
Set Permissions to null onDisable.
2011-03-18 00:55:10 +00:00
Rigby 3220dd0587 CleanUp - Remove debug line. 2011-03-14 23:44:55 +00:00
Rigby ec980248f8 Fixed up the Permissions link. 2011-03-14 23:44:20 +00:00
Rigby 178b15926f Started work on Permissions/isOP() support. 2011-03-14 22:55:36 +00:00
Rigby b8ee4c7f53 Ditching GM and weird API... No one has specifically requested GM
support anyways, wonder why...
2011-03-14 22:54:50 +00:00
Rigby f73d5dbcf1 GroupManager is going to be the death of me... this was a bad idea to
support it.
2011-03-14 22:13:58 +00:00
Rigby 097985f24a Output Authors correctly to the Console. 2011-03-14 21:33:57 +00:00
Rigby 924d027618 Helps if I do it right the first time. 2011-03-14 21:33:34 +00:00
Rigby fda6801f51 Author change 2011-03-14 21:21:12 +00:00
Rigby 2055055bbb CleanUp, need to sort out SafeTeleportation more... 2011-03-14 21:06:56 +00:00
Rigby 3b79634352 onLoad = decent... Needless spam in console due to lack of the
function within a plugin which doesn't utilize onLoad() = not so fun
2011-03-14 21:03:38 +00:00
Rigby a4aae6d47f Quick alteration to allow us not to send a response. 2011-03-14 12:16:41 +00:00
Rigby 7f690ae7d8 Basic PurgeWorld command, needs working on more for Permissions and
target worlds etc. Currently "/mvpurge CREATURETYPE" and "/mvpurge *"
work perfectly.
2011-03-14 12:14:27 +00:00
Rigby 37b2ad7e1d PurgeWorlds class, purges a given world of the given entities. 2011-03-14 12:12:32 +00:00
Rigby f579b36d65 GM Lib 2011-03-14 11:20:23 +00:00
Rigby 121f6f500d Added basic 'has()' permission. 2011-03-14 11:20:15 +00:00
Rigby 1dcaa0045f Added listener for GroupManager and also looking out for the Plugins
disabling themselves, if so we act accordingly.
2011-03-14 11:19:55 +00:00
Rigby ab0f78787a Lets try throwing GroupManager into the mix... Will see how this
performs.
2011-03-14 11:19:31 +00:00
Rigby 6a6f97ecd4 Keep the playerSessions updated with the players last location so the
portals can act accordingly.
2011-03-14 01:57:53 +00:00
Rigby 0d64b59851 Start of the MV Permissions Handler... centralise all Permission
checks and fall back to isOP().
2011-03-14 01:57:10 +00:00
Rigby 30e9b991b7 PluginListener for Permissions and iConomy. 2011-03-14 01:56:33 +00:00
Rigby a9aa346659 CleanUp + Permissions and iConomy checks & support. 2011-03-14 01:56:05 +00:00
Rigby f70f09880e Permissions Lib 2011-03-12 23:22:27 +00:00
Rigby 4763e04c90 UpdateChecker class, runs on a seperate thread and every 30 minutes it
checks for an update for the plugin.
2011-03-12 23:22:19 +00:00
Rigby aadb3b574e CleanUp + Moving permission checks over to its own class to tidy
things up and to handle it better.
2011-03-12 23:21:38 +00:00
Simon Rigby 3c054e4a95 Check Default node exists, if not write it. Saves erroring etc.
I'm sure theres an easier/better way to do this but this will do for
now.
2011-03-12 18:51:13 +00:00
Simon Rigby a288015bf0 Changing version and testing IRC. 2011-03-12 18:47:46 +00:00
Simon Rigby 26ee10b163 Added Slime check to the Entity... more as a precaution till I'm sure
it exists within Monster etc...
2011-03-11 17:14:52 +00:00
Simon Rigby 4e8d8626a7 Added findPortal -- Find a nearby portal around the destination...
Changed how a Destination is found and dealt with and changed how the
player is teleported. (Need to fix the safe teleportation code...
rather check X&Z before Y... Currently it prefers higher coordinates
over a block right infront of the destination.
2011-03-11 11:12:52 +00:00
Simon Rigby 0d85557362 Basic changes and Notes.
Including latest Lib Files as well.
2011-03-11 11:11:23 +00:00
Simon Rigby 724e05d73b Basic Spawn & setSpawn Commands. 2011-03-11 11:10:25 +00:00
Simon Rigby b110c51062 Change to CreatureType 2011-03-11 11:09:38 +00:00
Rigby b687b62a15 MVReload command. 2011-03-09 16:02:39 +00:00
Rigby 7f6e9e567e Ye... sort later 2011-03-09 14:50:57 +00:00
Rigby 195e8dc863 herp derp 2011-03-09 12:44:43 +00:00
Simon Rigby 438aa472d6 Fixed up the safe teleporting, now checks Y Properly and no longer
prioritises a higher coordinate over lower.
2011-03-09 08:11:35 +00:00
Simon Rigby 764b050baa Refactoring... Cleaning Up... Adding some Commands... Fixing up some
mistakes etc etc etc.
2011-03-07 09:14:02 +00:00
Simon Rigby bdf3d70bbf sigh... 2011-03-05 23:40:39 +00:00
Simon Rigby 63ea3c961b Added response messages and updated the teleport section... Needed to
add 0.5 to prevent half block teleports and then the player dieing.
2011-03-05 23:30:33 +00:00
Simon Rigby 130c51c366 Hopefully Fixed an NPE... 2011-03-05 00:32:39 +00:00
Simon Rigby 4053937019 Hopefully fixed Ghasts & PigZombies spawning regardless of setting.
Implemented PVP Setting & EnableHealth setting.
World Compressiong = 0 forces you to Spawn now.
2011-03-04 22:22:02 +00:00
Protected e4718d38d4 Portal targetting, compression 2011-03-04 12:12:41 +00:00
Simon Rigby 8a52e55cdf Tidy up + purgeWorld() -- Remove any entities in the world... this
needs improving to only remove those necessary. Quick workaround for
now.
2011-03-04 09:06:12 +00:00
Simon Rigby 4ca35d1c6a Added examples to default 'worlds.yml' as well as changing DataFolder
location.
2011-03-02 05:03:56 +00:00
Simon Rigby 466e31c9ee Removed unneeded crap. 2011-03-01 19:17:06 +00:00
Simon Rigby b8560a41c0 hmm :) 2011-03-01 19:09:36 +00:00
Simon Rigby 92e3917a17 Merge branch 'refs/heads/master' of git@github.com:Rigby90/MultiVerse-Core.git 2011-03-01 18:45:21 +00:00
Simon Rigby 441e6d40f8 Fixed the Listeners, stupid mistake on my part :). 2011-03-01 18:43:53 +00:00
Protected 015daf1695 Merge branch 'master' of https://github.com/Rigby90/MultiVerse-Core 2011-03-01 18:07:01 +00:00
Protected 187c6acbb6 Teleporter factory method 2011-03-01 18:05:24 +00:00
Simon Rigby 7da2c84806 Useless spam, quite obvious the default World will be loaded before
the plugin.
2011-03-01 18:03:28 +00:00
Simon Rigby 33603d3605 Fixed 2011-03-01 17:58:48 +00:00
Protected a5df509fdf Here it goes again 2011-03-01 17:49:08 +00:00
Simon Rigby 0efc0c98ff ... 2011-03-01 17:18:49 +00:00
Simon Rigby bee723182a Removed Permissions support for now. 2011-03-01 16:46:50 +00:00
Simon Rigby 7d9060879c Removed teleport from PlayerSession. 2011-03-01 16:10:28 +00:00
Simon Rigby a91991551c Getting there... 2011-03-01 15:47:36 +00:00
Simon Rigby cd1de2b594 Added basics for the Command Handler. 2011-02-27 06:43:39 +00:00
Simon Rigby 23c695b3a2 More basics... Configurations, PlayerSessions, Events etc... 2011-02-26 06:26:13 +00:00
Simon Rigby 3f678fcd36 Some more basics etc... 2011-02-26 05:21:56 +00:00
Simon Rigby 4fd9821c79 The old Lib files.... 2011-02-22 01:06:26 +00:00
Simon Rigby 81b5e33f64 Added onCommand, testing Eclipse with GIT. 2011-02-22 01:01:13 +00:00
Simon Rigby 68107d9df8 Basics 2011-02-22 00:55:37 +00:00
109 changed files with 9840 additions and 739 deletions

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
# Eclipse stuff
/.classpath
/.project
/.settings
# netbeans
/nbproject
# we use maven!
/build.xml
# maven
/target
# vim
.*.sw[a-p]
# various other potential build files
/build
/bin
/dist
/manifest.mf
/world
# Mac filesystem dust
*.DS_Store
# intellij
*.iml
*.ipr
*.iws
.idea/
# Fern's utils
uploadtoserver.sh
+7
View File
@@ -0,0 +1,7 @@
[submodule "lib/allpay"]
path = lib/allpay
url = git://github.com/FernFerret/AllPay.git
[submodule "lib/commandhandler"]
path = lib/commandhandler
url = git://github.com/PneumatiCraft/CommandHandler.git
branch = notrie
+5
View File
@@ -0,0 +1,5 @@
Copyright (c) 2011, The Multiverse Team All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 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. Neither the name of the The Multiverse Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER 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.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

-71
View File
@@ -1,71 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<link href='https://fonts.googleapis.com/css?family=Chivo:900' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen" />
<link rel="stylesheet" type="text/css" href="stylesheets/pygment_trac.css" media="screen" />
<link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print" />
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<title>Multiverse-Core by Multiverse</title>
</head>
<body>
<div id="container">
<div class="inner">
<header>
<h1>Multiverse-core</h1>
<h2>The original Bukkit Multi-World Plugin! </h2>
</header>
<section id="downloads" class="clearfix">
<a href="https://github.com/Multiverse/Multiverse-Core/zipball/master" id="download-zip" class="button"><span>Download .zip</span></a>
<a href="https://github.com/Multiverse/Multiverse-Core/tarball/master" id="download-tar-gz" class="button"><span>Download .tar.gz</span></a>
<a href="https://github.com/Multiverse/Multiverse-Core" id="view-on-github" class="button"><span>View on GitHub</span></a>
</section>
<hr>
<section id="main_content">
<h3>Welcome to GitHub Pages.</h3>
<p>This automatic page generator is the easiest way to create beautiful pages for all of your projects. Author your page content here using GitHub Flavored Markdown, select a template crafted by a designer, and publish. After your page is generated, you can check out the new branch:</p>
<pre><code>$ cd your_repo_root/repo_name
$ git fetch origin
$ git checkout gh-pages
</code></pre>
<p>If you're using the GitHub for Mac, simply sync your repository and you'll see the new branch.</p>
<h3>Designer Templates</h3>
<p>We've crafted some handsome templates for you to use. Go ahead and continue to layouts to browse through them. You can easily go back to edit your page before publishing. After publishing your page, you can revisit the page generator and switch to another theme. Your Page content will be preserved if it remained markdown format.</p>
<h3>Rather Drive Stick?</h3>
<p>If you prefer to not use the automatic generator, push a branch named <code>gh-pages</code> to your repository to create a page manually. In addition to supporting regular HTML content, GitHub Pages support Jekyll, a simple, blog aware static site generator written by our own Tom Preston-Werner. Jekyll makes it easy to create site-wide headers and footers without having to copy them across every page. It also offers intelligent blog support and other advanced templating features.</p>
<h3>Authors and Contributors</h3>
<p>You can <a href="https://github.com/blog/821" class="user-mention">@mention</a> a GitHub username to generate a link to their profile. The resulting <code>&lt;a&gt;</code> element will link to the contributor's GitHub Profile. For example: In 2007, Chris Wanstrath (<a href="https://github.com/defunkt" class="user-mention">@defunkt</a>), PJ Hyett (<a href="https://github.com/pjhyett" class="user-mention">@pjhyett</a>), and Tom Preston-Werner (<a href="https://github.com/mojombo" class="user-mention">@mojombo</a>) founded GitHub.</p>
<h3>Support or Contact</h3>
<p>Having trouble with Pages? Check out the documentation at <a href="http://help.github.com/pages">http://help.github.com/pages</a> or contact <a href="mailto:support@github.com">support@github.com</a> and we’ll help you sort it out.</p>
</section>
<footer>
Multiverse-core is maintained by <a href="https://github.com/Multiverse">Multiverse</a><br>
This page was generated by <a href="http://pages.github.com">GitHub Pages</a>. Tactile theme by <a href="http://twitter.com/jasonlong">Jason Long</a>.
</footer>
</div>
</div>
</body>
</html>
-1
View File
@@ -1 +0,0 @@
console.log('This would be the main JS file.');
Submodule
+1
Submodule lib/allpay added at 18c55a9070.
Submodule lib/commandhandler added at 50ecf6af45.
-1
View File
@@ -1 +0,0 @@
{"tagline":"The original Bukkit Multi-World Plugin! ","body":"### Welcome to GitHub Pages.\r\nThis automatic page generator is the easiest way to create beautiful pages for all of your projects. Author your page content here using GitHub Flavored Markdown, select a template crafted by a designer, and publish. After your page is generated, you can check out the new branch:\r\n\r\n```\r\n$ cd your_repo_root/repo_name\r\n$ git fetch origin\r\n$ git checkout gh-pages\r\n```\r\n\r\nIf you're using the GitHub for Mac, simply sync your repository and you'll see the new branch.\r\n\r\n### Designer Templates\r\nWe've crafted some handsome templates for you to use. Go ahead and continue to layouts to browse through them. You can easily go back to edit your page before publishing. After publishing your page, you can revisit the page generator and switch to another theme. Your Page content will be preserved if it remained markdown format.\r\n\r\n### Rather Drive Stick?\r\nIf you prefer to not use the automatic generator, push a branch named `gh-pages` to your repository to create a page manually. In addition to supporting regular HTML content, GitHub Pages support Jekyll, a simple, blog aware static site generator written by our own Tom Preston-Werner. Jekyll makes it easy to create site-wide headers and footers without having to copy them across every page. It also offers intelligent blog support and other advanced templating features.\r\n\r\n### Authors and Contributors\r\nYou can @mention a GitHub username to generate a link to their profile. The resulting `<a>` element will link to the contributor's GitHub Profile. For example: In 2007, Chris Wanstrath (@defunkt), PJ Hyett (@pjhyett), and Tom Preston-Werner (@mojombo) founded GitHub.\r\n\r\n### Support or Contact\r\nHaving trouble with Pages? Check out the documentation at http://help.github.com/pages or contact support@github.com and we’ll help you sort it out.","note":"Don't delete this file! It's used internally to help with page regeneration.","google":"","name":"Multiverse-core"}
+196
View File
@@ -0,0 +1,196 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.onarandombox.multiversecore</groupId>
<artifactId>Multiverse-Core</artifactId>
<version>2.1</version>
<name>Multiverse-Core</name>
<description>World Management Plugin</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.number>UNKNOWN</project.build.number>
</properties>
<repositories>
<repository>
<id>OnARandomBox</id>
<url>http://repo.onarandombox.com/artifactory/repo</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>doodleproject-repo</id>
<name>DoodleProject Maven 2 Repository</name>
<url>http://doodleproject.sourceforge.net/maven2/release</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<ciManagement>
<system>jenkins</system>
<url>http://ci.onarandombox.com</url>
</ciManagement>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<!-- Compiler -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<!-- Build Helper - Additional Source Folders -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-wsdl-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/lib/allpay/src</source>
<source>${project.basedir}/lib/commandhandler/src</source>
<source>${project.basedir}/lib/commandhandler/lib/ShellParser/src</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.3.8</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>target/classes/plugin.yml</file>
<replacements>
<replacement>
<token>maven-version-number</token>
<value>${project.version}-${project.build.number}</value>
</replacement>
</replacements>
</configuration>
</plugin>
<!-- Jar Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifestEntries>
</manifestEntries>
</archive>
</configuration>
</plugin>
<!-- Maven Source Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Bukkit Dependency -->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- Bukkit Dependency -->
<!-- Start of Spout -->
<dependency>
<groupId>org.getspout</groupId>
<artifactId>spoutapi</artifactId>
<version>dev-SNAPSHOT</version>
</dependency>
<!-- End of Spout -->
<!-- Start of Economy Dependencies -->
<dependency>
<groupId>cosine.boseconomy</groupId>
<artifactId>BOSEconomy</artifactId>
<version>0.6.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>fr.crafter.tickleman.RealShop</groupId>
<artifactId>RealShop</artifactId>
<version>0.63</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.iCo6</groupId>
<artifactId>iConomy</artifactId>
<version>6.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.iConomy</groupId>
<artifactId>iConomy</artifactId>
<version>5.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.nijiko.coelho.iConomy</groupId>
<artifactId>iConomy</artifactId>
<version>4.65</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.earth2me.essentials</groupId>
<artifactId>Essentials</artifactId>
<version>2.4.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.ashtheking.currency</groupId>
<artifactId>MultiCurrency</artifactId>
<version>0.09</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End of Economy Dependencies -->
<!-- Start of JUnit Dependencies -->
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
<!-- End of JUnit Dependencies -->
</dependencies>
</project>
@@ -0,0 +1,17 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore;
/**
* Dummy class to make old MV Plugins not explode.
* If this loads, the user WILL get a severe telling them to update said plugin!
* WILL BE DELETED ON 11/1/11
*/
@Deprecated
public interface LoggablePlugin extends com.onarandombox.MultiverseCore.api.LoggablePlugin {
}
@@ -0,0 +1,20 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore;
/**
* Dummy class to make old MV Plugins not explode.
* If this loads, the user WILL get a severe telling them to update said plugin!
* WILL BE DELETED ON 11/1/11
*/
@Deprecated
public class MVPermissions extends com.onarandombox.MultiverseCore.utils.MVPermissions {
public MVPermissions(MultiverseCore plugin) {
super(plugin);
}
}
@@ -0,0 +1,17 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore;
/**
* Dummy class to make old MV Plugins not explode.
* If this loads, the user WILL get a severe telling them to update said plugin!
* WILL BE DELETED ON 11/1/11
*/
@Deprecated
public interface MVPlugin extends com.onarandombox.MultiverseCore.api.MVPlugin {
}
@@ -0,0 +1,846 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
import com.onarandombox.MultiverseCore.utils.BlockSafety;
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
import org.bukkit.*;
import org.bukkit.World.Environment;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
public class MVWorld implements MultiverseWorld {
private MultiverseCore plugin; // Hold the Plugin Instance.
private FileConfiguration config; // Hold the Configuration File.
private ConfigurationSection worldSection; // Holds the section of the config file for this world.
private World world; // The World Instance.
private Environment environment; // Hold the Environment type EG Environment.NETHER / Environment.NORMAL
private Long seed;
private String name; // The Worlds Name, EG its folder name.
private String alias = ""; // Short Alias for the World, this will be used in Chat Prefixes.
private ChatColor aliasColor; // Color for this world
private boolean allowAnimals; // Does this World allow Animals to Spawn?
private boolean allowMonsters; // Does this World allow Monsters to Spawn?
private boolean keepSpawnInMemory; // Does the World have the spawn loaded all the time?
private boolean pvp; // Does this World allow PVP?
private boolean fakePVP; // Should this world have fakePVP on? (used for PVP zones)
private GameMode gameMode = GameMode.SURVIVAL;
private String respawnWorld; // Contains the name of the World to respawn the player to
private Map<String, List<String>> masterList;
private double scaling; // How stretched/compressed distances are
private double price; // How much does it cost to enter this world
private int currency = -1; // What is the currency
private boolean hunger = true;
private Permission permission;
private Permission exempt;
private boolean canSave = false; // Prevents all the setters from constantly saving to the config when being called from the constructor.
private boolean allowWeather;
private Location spawnLocation;
private boolean isHidden = false;
public MVWorld(World world, FileConfiguration config, MultiverseCore instance, Long seed, String generatorString) {
this.config = config;
this.plugin = instance;
// Set local values that CANNOT be changed by user
this.world = world;
this.name = world.getName();
this.seed = seed;
this.environment = world.getEnvironment();
// Initialize our lists
this.initLists();
worldSection = config.getConfigurationSection("worlds." + this.name);
if (worldSection == null) {
config.createSection("worlds." + this.name);
worldSection = config.getConfigurationSection("worlds." + this.name);
}
// Write these files to the config (once it's saved)
if (generatorString != null) {
worldSection.set("generator", generatorString);
}
if (seed != null) {
worldSection.set("seed", this.seed);
}
worldSection.set("environment", this.environment.toString());
// Set local values that CAN be changed by the user
this.setAlias(worldSection.getString("alias.name", ""));
this.setColor(worldSection.getString("alias.color", ChatColor.WHITE.toString()));
this.setPVPMode(worldSection.getBoolean("pvp", true));
this.setFakePVPMode(worldSection.getBoolean("fakepvp", false));
this.setScaling(worldSection.getDouble("scale", this.getDefaultScale(this.environment)));
this.setRespawnToWorld(worldSection.getString("respawnworld", ""));
this.setEnableWeather(worldSection.getBoolean("allowweather", true));
this.setDifficulty(worldSection.get("difficulty", "EASY"));
this.setAllowAnimalSpawn(worldSection.getBoolean("animals.spawn", true));
this.setAllowMonsterSpawn(worldSection.getBoolean("monsters.spawn", true));
this.setPrice(worldSection.getDouble("entryfee.amount", 0.0));
this.setCurrency(worldSection.getInt("entryfee.currency", -1));
this.setHunger(worldSection.getBoolean("hunger", true));
this.setHidden(worldSection.getBoolean("hidden", false));
this.getMobExceptions();
this.setGameMode(worldSection.get("gamemode", GameMode.SURVIVAL.toString()));
this.setKeepSpawnInMemory(worldSection.getBoolean("keepspawninmemory", true));
this.getWorldBlacklist().addAll(worldSection.getList("worldblacklist", new ArrayList<String>()));
this.translateTempSpawn(worldSection);
this.readSpawnFromConfig(this.getCBWorld());
this.canSave = true;
this.saveConfig();
this.permission = new Permission("multiverse.access." + this.getName(), "Allows access to " + this.getName(), PermissionDefault.OP);
this.exempt = new Permission("multiverse.exempt." + this.getName(), "A player who has this does not pay to enter this world, or use any MV portals in it " + this.getName(), PermissionDefault.OP);
try {
this.plugin.getServer().getPluginManager().addPermission(this.permission);
this.plugin.getServer().getPluginManager().addPermission(this.exempt);
addToUpperLists(this.permission);
} catch (IllegalArgumentException e) {
this.plugin.log(Level.FINER, "Permissions nodes were already added for " + this.name);
}
}
private double getDefaultScale(Environment environment) {
if (environment == Environment.NETHER) {
return 8.0;
}
return 1.0;
}
public void setEnableWeather(boolean weather) {
this.allowWeather = weather;
// Disable any current weather
if (!weather) {
this.getCBWorld().setStorm(false);
this.getCBWorld().setThundering(false);
}
this.worldSection.set("allowweather", weather);
saveConfig();
}
private void addToUpperLists(Permission permission) {
Permission all = this.plugin.getServer().getPluginManager().getPermission("multiverse.*");
Permission allWorlds = this.plugin.getServer().getPluginManager().getPermission("multiverse.access.*");
Permission allExemption = this.plugin.getServer().getPluginManager().getPermission("multiverse.exempt.*");
if (allWorlds == null) {
allWorlds = new Permission("multiverse.access.*");
this.plugin.getServer().getPluginManager().addPermission(allWorlds);
}
allWorlds.getChildren().put(permission.getName(), true);
if (allExemption == null) {
allExemption = new Permission("multiverse.exempt.*");
this.plugin.getServer().getPluginManager().addPermission(allExemption);
}
allExemption.getChildren().put(this.exempt.getName(), true);
if (all == null) {
all = new Permission("multiverse.*");
this.plugin.getServer().getPluginManager().addPermission(all);
}
all.getChildren().put("multiverse.access.*", true);
all.getChildren().put("multiverse.exempt.*", true);
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(all);
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(allWorlds);
}
private void translateTempSpawn(ConfigurationSection section) {
String tempspawn = section.getString("tempspawn", "");
if (tempspawn.length() > 0) {
String[] coordsString = tempspawn.split(":");
if (coordsString.length >= 3) {
int[] coords = new int[3];
try {
for (int i = 0; i < 3; i++) {
coords[i] = Integer.parseInt(coordsString[i]);
}
this.setSpawnLocation(new Location(this.getCBWorld(), coords[0], coords[1], coords[2]));
} catch (NumberFormatException e) {
this.plugin.log(Level.WARNING, "A MV1 spawn value was found, but it could not be migrated. Format Error. Sorry.");
}
} else {
this.plugin.log(Level.WARNING, "A MV1 spawn value was found, but it could not be migrated. Format Error. Sorry.");
}
this.worldSection.set("tempspawn", null);
}
}
public String getColoredWorldString() {
if (this.getColor() == null) {
return this.getAlias() + ChatColor.WHITE;
}
return this.getColor() + this.getAlias() + ChatColor.WHITE;
}
private void getMobExceptions() {
List<String> temp;
temp = this.worldSection.getList("animals.exceptions", new ArrayList<String>());
// Add Animals to the exclusion list
for (String s : temp) {
this.masterList.get("animals").add(s.toUpperCase());
}
temp = this.worldSection.getList("monsters.exceptions", new ArrayList<String>());
// Add Monsters to the exclusion list
for (String s : temp) {
this.masterList.get("monsters").add(s.toUpperCase());
}
}
public World getCBWorld() {
return this.world;
}
private void initLists() {
this.masterList = new HashMap<String, List<String>>();
this.masterList.put("worldblacklist", new ArrayList<String>());
this.masterList.put("animals", new ArrayList<String>());
this.masterList.put("monsters", new ArrayList<String>());
}
@Override
public boolean clearVariable(String property) {
if (this.masterList.keySet().contains(property)) {
this.masterList.get(property).clear();
} else {
return false;
}
this.worldSection.set(property.toLowerCase(), new ArrayList<String>());
this.saveConfig();
return true;
}
@Override
public boolean addToVariable(String property, String value) {
if (this.masterList.keySet().contains(property)) {
if (property.equalsIgnoreCase("animals") || property.equalsIgnoreCase("monsters")) {
this.masterList.get(property).add(value.toUpperCase());
this.worldSection.set(property.toLowerCase() + ".exceptions", this.masterList.get(property));
this.syncMobs();
} else {
this.masterList.get(property).add(value);
this.worldSection.set(property.toLowerCase(), this.masterList.get(property));
}
saveConfig();
return true;
}
return false;
}
@Override
public boolean removeFromVariable(String property, String value) {
if (this.masterList.keySet().contains(property)) {
if (property.equalsIgnoreCase("animals") || property.equalsIgnoreCase("monsters")) {
this.masterList.get(property).remove(value.toUpperCase());
this.worldSection.set("" + property.toLowerCase() + ".exceptions", this.masterList.get(property));
this.syncMobs();
} else {
this.masterList.get(property).remove(value);
this.worldSection.set("" + property.toLowerCase(), this.masterList.get(property));
}
saveConfig();
return true;
}
return false;
}
/** Deprecated, use {@link #addToVariable(String, String)} now. */
@Deprecated
public boolean addToList(String list, String value) {
return this.addToVariable(list, value);
}
// Deprecated, use {@link #removeFromVariable(String, String)} now.
@Deprecated
public boolean removeFromList(String list, String value) {
return this.removeFromVariable(list, value);
}
private void syncMobs() {
if (this.getAnimalList().isEmpty()) {
this.world.setSpawnFlags(this.world.getAllowMonsters(), this.allowAnimals);
} else {
this.world.setSpawnFlags(this.world.getAllowMonsters(), true);
}
if (this.getMonsterList().isEmpty()) {
this.world.setSpawnFlags(this.allowMonsters, this.world.getAllowAnimals());
} else {
this.world.setSpawnFlags(true, this.world.getAllowAnimals());
}
this.plugin.getMVWorldManager().getWorldPurger().purgeWorld(null, this);
}
private boolean setVariable(String name, boolean value) {
if (name.equalsIgnoreCase("pvp")) {
this.setPVPMode(value);
} else if (name.equalsIgnoreCase("animals")) {
this.setAllowAnimalSpawn(value);
} else if (name.equalsIgnoreCase("monsters")) {
this.setAllowMonsterSpawn(value);
} else if (name.equalsIgnoreCase("memory") || name.equalsIgnoreCase("spawnmemory")) {
this.setKeepSpawnInMemory(value);
} else if ((name.equalsIgnoreCase("hunger")) || (name.equalsIgnoreCase("food"))) {
this.setHunger(value);
} else if (name.equalsIgnoreCase("weather") || name.equalsIgnoreCase("storm")) {
this.setEnableWeather(value);
} else if (name.equalsIgnoreCase("hidden")) {
this.setHidden(value);
} else {
return false;
}
return true;
}
@Override
public void setKeepSpawnInMemory(boolean value) {
this.world.setKeepSpawnInMemory(value);
this.keepSpawnInMemory = value;
this.worldSection.set("keepspawninmemory", value);
saveConfig();
}
@Override
public boolean setVariable(String name, String value) {
if (name.equalsIgnoreCase("diff") || name.equalsIgnoreCase("difficulty")) {
return this.setDifficulty(value);
}
if (name.equalsIgnoreCase("alias")) {
this.setAlias(value);
return true;
}
if (name.equalsIgnoreCase("respawn")) {
this.setRespawnToWorld(value);
return true;
}
if (name.equalsIgnoreCase("aliascolor") || name.equalsIgnoreCase("color")) {
return this.setColor(value);
}
if (name.equalsIgnoreCase("currency") || name.equalsIgnoreCase("curr")) {
try {
this.setCurrency(Integer.parseInt(value));
return true;
} catch (Exception e) {
return false;
}
}
if (name.equalsIgnoreCase("price")) {
try {
this.setPrice(Double.parseDouble(value));
return true;
} catch (Exception e) {
return false;
}
}
if (name.equalsIgnoreCase("scale") || name.equalsIgnoreCase("scaling")) {
try {
return this.setScaling(Double.parseDouble(value));
} catch (Exception e) {
return false;
}
}
if (name.equalsIgnoreCase("gamemode") || name.equalsIgnoreCase("mode")) {
try {
return this.setGameMode(GameMode.valueOf(value.toUpperCase()));
} catch (Exception e) {
return false;
}
}
try {
return this.setVariable(name, Boolean.parseBoolean(value));
} catch (Exception e) {
return false;
}
}
@Override
public Environment getEnvironment() {
return this.environment;
}
@Override
public void setEnvironment(Environment environment) {
this.environment = environment;
}
@Override
public Long getSeed() {
return this.seed;
}
@Override
public void setSeed(Long seed) {
this.seed = seed;
}
@Override
public String getName() {
return this.name;
}
@Override
public String getAlias() {
if (this.alias == null || this.alias.length() == 0) {
return this.name;
}
return this.alias;
}
@Override
public void setAlias(String alias) {
this.alias = alias;
this.worldSection.set("alias.name", alias);
saveConfig();
}
@Override
public boolean canAnimalsSpawn() {
return this.allowAnimals;
}
@Override
public void setAllowAnimalSpawn(boolean animals) {
this.allowAnimals = animals;
// If animals are a boolean, then we can turn them on or off on the server
// If there are ANY exceptions, there will be something spawning, so turn them on
this.worldSection.set("animals.spawn", animals);
saveConfig();
this.syncMobs();
}
@Override
public List<String> getAnimalList() {
return this.masterList.get("animals");
}
@Override
public boolean canMonstersSpawn() {
return this.allowMonsters;
}
@Override
public void setAllowMonsterSpawn(boolean monsters) {
this.allowMonsters = monsters;
// If monsters are a boolean, then we can turn them on or off on the server
// If there are ANY exceptions, there will be something spawning, so turn them on
this.worldSection.set("monsters.spawn", monsters);
saveConfig();
this.syncMobs();
}
@Override
public List<String> getMonsterList() {
return this.masterList.get("monsters");
}
@Override
public boolean isPVPEnabled() {
return this.pvp;
}
@Override
public void setPVPMode(boolean pvp) {
if (this.fakePVP) {
this.world.setPVP(true);
} else {
this.world.setPVP(pvp);
}
this.pvp = pvp;
this.worldSection.set("pvp", pvp);
saveConfig();
}
/**
* Gets whether or not this world will display in chat, mvw and mvl regardless if a user has the
* access permissions to go to this world.
*
* @return True if the world will be hidden, false if not.
*/
@Override
public boolean isHidden() {
return this.isHidden;
}
/**
* Sets whether or not this world will display in chat, mvw and mvl regardless if a user has the
* access permissions to go to this world.
*
* @param hidden Set
*/
@Override
public void setHidden(boolean hidden) {
this.isHidden = hidden;
this.worldSection.set("hidden", hidden);
saveConfig();
}
public void setFakePVPMode(Boolean fakePVPMode) {
this.fakePVP = fakePVPMode;
this.worldSection.set("fakepvp", this.fakePVP);
// Now that we've set PVP mode, make sure to go through the normal setting too!
// This method will perform the save for us to eliminate one write.
this.setPVPMode(this.pvp);
}
public List<String> getWorldBlacklist() {
return this.masterList.get("worldblacklist");
}
@Override
public double getScaling() {
return this.scaling;
}
@Override
public boolean setScaling(double scaling) {
boolean success = true;
if (scaling <= 0) {
// Disallow negative or 0 scalings.
scaling = 1.0;
this.plugin.log(Level.WARNING, "Someone tried to set a scale <= 0, defaulting to 1.");
success = false;
}
this.scaling = scaling;
this.worldSection.set("scale", scaling);
saveConfig();
return success;
}
@Override
public boolean setColor(String aliasColor) {
EnglishChatColor color = EnglishChatColor.fromString(aliasColor);
if (color == null) {
return false;
}
this.aliasColor = color.getColor();
this.worldSection.set("alias.color", color.getText());
saveConfig();
return true;
}
public boolean isValidAliasColor(String aliasColor) {
return (EnglishChatColor.fromString(aliasColor) != null);
}
@Override
public ChatColor getColor() {
return this.aliasColor;
}
public boolean clearList(String property) {
if (this.masterList.containsKey(property)) {
this.masterList.get(property).clear();
this.worldSection.set(property.toLowerCase(), this.masterList.get(property));
this.syncMobs();
saveConfig();
return true;
}
return false;
}
public boolean getFakePVP() {
return this.fakePVP;
}
@Override
public World getRespawnToWorld() {
if (this.respawnWorld == null) {
return null;
}
return (this.plugin.getServer().getWorld(this.respawnWorld));
}
@Override
public boolean setRespawnToWorld(String respawnToWorld) {
if (this.plugin.getServer().getWorld(respawnToWorld) != null) {
this.respawnWorld = respawnToWorld;
this.worldSection.set("respawnworld", respawnToWorld);
saveConfig();
return true;
}
return false;
}
@Override
public Permission getAccessPermission() {
return this.permission;
}
@Override
public int getCurrency() {
return this.currency;
}
@Override
public double getPrice() {
return this.price;
}
@Override
public void setCurrency(int currency) {
this.currency = currency;
this.worldSection.set("entryfee.currency", currency);
saveConfig();
}
@Override
public void setPrice(double price) {
this.price = price;
this.worldSection.set("entryfee.amount", price);
saveConfig();
}
/** This method really isn't needed */
@Deprecated
public boolean isExempt(Player p) {
return (this.plugin.getMVPerms().hasPermission(p, this.exempt.getName(), true));
}
@Override
public Permission getExemptPermission() {
return this.exempt;
}
private void saveConfig() {
if (this.canSave) {
try {
this.config.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
} catch (IOException e) {
this.plugin.log(Level.SEVERE, "Could not save worlds.yml. Please check your filesystem permissions.");
}
}
}
@Override
public boolean setGameMode(String gameMode) {
GameMode mode;
try {
mode = GameMode.valueOf(gameMode.toUpperCase());
} catch (Exception e) {
try {
int modeInt = Integer.parseInt(gameMode);
mode = GameMode.getByValue(modeInt);
} catch (Exception e2) {
return false;
}
}
if (mode == null) {
return false;
}
this.setGameMode(mode);
this.worldSection.set("gamemode", mode.toString());
saveConfig();
return true;
}
/**
* FernFerret messed up and now config values could be in either string or Int
*
* @param mode The gamemode as an object.
*
* @return True if the mode was set, false if not.
*/
private boolean setGameMode(Object mode) {
if (mode instanceof Integer) {
return this.setGameMode(GameMode.getByValue((Integer) mode));
}
try {
return this.setGameMode((String) mode);
} catch (ClassCastException e) {
return false;
}
}
private boolean setGameMode(GameMode mode) {
this.gameMode = mode;
this.worldSection.set("gamemode", this.gameMode.toString());
saveConfig();
if (MultiverseCore.EnforceGameModes) {
for (Player p : this.plugin.getServer().getWorld(this.getName()).getPlayers()) {
this.plugin.log(Level.FINER, "Setting " + p.getName() + "'s GameMode to " + this.gameMode.toString());
this.plugin.getPlayerListener().handleGameMode(p, this);
}
}
return true;
}
public GameMode getGameMode() {
return this.gameMode;
}
@Override
public boolean isWeatherEnabled() {
return this.allowWeather;
}
@Override
public boolean isKeepingSpawnInMemory() {
return this.keepSpawnInMemory;
}
@Override
public void setHunger(boolean hunger) {
this.hunger = hunger;
this.worldSection.set("hunger", this.hunger);
saveConfig();
}
@Override
public boolean getHunger() {
return this.hunger;
}
@Override
public void setSpawnLocation(Location l) {
this.getCBWorld().setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
this.worldSection.set("spawn.x", l.getX());
this.worldSection.set("spawn.y", l.getY());
this.worldSection.set("spawn.z", l.getZ());
this.worldSection.set("spawn.pitch", l.getPitch());
this.worldSection.set("spawn.yaw", l.getYaw());
this.getCBWorld().setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
this.spawnLocation = l.clone();
saveConfig();
}
private void readSpawnFromConfig(World w) {
double x = worldSection.getDouble("spawn.x", w.getSpawnLocation().getX());
double y = worldSection.getDouble("spawn.y", w.getSpawnLocation().getY());
double z = worldSection.getDouble("spawn.z", w.getSpawnLocation().getZ());
this.plugin.log(Level.FINE, "Read spawn from config as: " + x + ", " + y + ", " + z);
float pitch = (float) worldSection.getDouble("spawn.pitch", w.getSpawnLocation().getPitch());
float yaw = (float) worldSection.getDouble("spawn.yaw", w.getSpawnLocation().getYaw());
this.setSpawnLocation(new Location(w, x, y, z, yaw, pitch));
SafeTTeleporter teleporter = this.plugin.getTeleporter();
BlockSafety bs = new BlockSafety();
if (!bs.playerCanSpawnHereSafely(this.spawnLocation)) {
this.plugin.log(Level.WARNING, "Spawn location from world.dat file was unsafe. Adjusting...");
Location newSpawn = teleporter.getSafeLocation(this.spawnLocation, 128, 128);
// I think we could also do this, as I think this is what Notch does.
// Not sure how it will work in the nether...
//Location newSpawn = this.spawnLocation.getWorld().getHighestBlockAt(this.spawnLocation).getLocation();
if (newSpawn != null) {
this.plugin.log(Level.INFO, "New Spawn for '" + this.getName() + "' Located at: " + LocationManipulation.locationToString(newSpawn));
this.setSpawnLocation(newSpawn);
} else {
this.plugin.log(Level.SEVERE, "New safe spawn NOT found!!!");
}
}
this.plugin.log(Level.FINEST, "Spawn for '" + this.getName() + "' Located at: " + LocationManipulation.locationToString(this.getSpawnLocation()));
}
@Override
public Location getSpawnLocation() {
return this.spawnLocation;
}
@Override
public Difficulty getDifficulty() {
return this.getCBWorld().getDifficulty();
}
/**
* FernFerret messed up and now config values could be in either string or Int
*
* @param mode The gamemode as an object.
*
* @return True if the mode was set, false if not.
*/
private boolean setDifficulty(Object mode) {
if (mode instanceof Integer) {
return this.setDifficulty(Difficulty.getByValue((Integer) mode));
}
try {
return this.setDifficulty((String) mode);
} catch (ClassCastException e) {
return false;
}
}
@Override
public boolean setDifficulty(String difficulty) {
Difficulty worlddiff;
try {
worlddiff = Difficulty.valueOf(difficulty.toUpperCase());
} catch (Exception e) {
try {
int diff = Integer.parseInt(difficulty);
worlddiff = Difficulty.getByValue(diff);
} catch (Exception e2) {
return false;
}
}
if (worlddiff == null) {
return false;
}
this.setDifficulty(worlddiff);
saveConfig();
return true;
}
private boolean setDifficulty(Difficulty diff) {
this.getCBWorld().setDifficulty(diff);
this.worldSection.set("difficulty", diff.toString());
saveConfig();
return true;
}
// TODO: Implment this, I'm going to bed tonight.
@Override
public boolean getAutoHeal() {
return true;
}
// TODO: Implment this, I'm going to bed tonight.
@Override
public void setAutoHeal(boolean heal) {
}
}
@@ -0,0 +1,629 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore;
import com.fernferret.allpay.AllPay;
import com.fernferret.allpay.GenericBank;
import com.onarandombox.MultiverseCore.api.Core;
import com.onarandombox.MultiverseCore.api.MVPlugin;
import com.onarandombox.MultiverseCore.commands.*;
import com.onarandombox.MultiverseCore.configuration.MVConfigMigrator;
import com.onarandombox.MultiverseCore.configuration.MVCoreConfigMigrator;
import com.onarandombox.MultiverseCore.destination.*;
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
import com.onarandombox.MultiverseCore.utils.*;
import com.onarandombox.MultiverseCore.utils.MVPermissions;
import com.pneumaticraft.commandhandler.CommandHandler;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World.Environment;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
private final static int Protocol = 7;
// Global Multiverse config variable, states whether or not
// Multiverse should stop other plugins from teleporting players
// to worlds.
public static boolean EnforceAccess;
public static boolean EnforceGameModes;
public static boolean PrefixChat;
public static boolean BedRespawn;
@Override
public String dumpVersionInfo(String buffer) {
// I'm kinda cheating on this one, since we call the init event.
return buffer;
}
@Override
public MultiverseCore getCore() {
return this;
}
@Override
public void setCore(MultiverseCore core) {
}
@Override
public int getProtocolVersion() {
return MultiverseCore.Protocol;
}
// Useless stuff to keep us going.
private static final Logger log = Logger.getLogger("Minecraft");
private static DebugLog debugLog;
public static boolean MobsDisabledInDefaultWorld = false;
// Setup our Map for our Commands using the CommandHandler.
private CommandHandler commandHandler;
private final static String tag = "[Multiverse-Core]";
// Multiverse Permissions Handler
private MVPermissions ph;
// Configurations
private FileConfiguration multiverseConfig = null;
private WorldManager worldManager = new WorldManager(this);
// Setup the block/player/entity listener.
private MVPlayerListener playerListener = new MVPlayerListener(this);
private MVEntityListener entityListener = new MVEntityListener(this);
private MVPluginListener pluginListener = new MVPluginListener(this);
private MVWeatherListener weatherListener = new MVWeatherListener(this);
public UpdateChecker updateCheck;
public static int GlobalDebug = 0;
// HashMap to contain information relating to the Players.
private HashMap<String, MVPlayerSession> playerSessions;
private GenericBank bank = null;
private AllPay banker;
protected MVConfigMigrator migrator = new MVCoreConfigMigrator(this);
protected int pluginCount;
private DestinationFactory destFactory;
private SpoutInterface spoutInterface = null;
private double allpayversion = 3;
private double chversion = 1;
private MVMessaging messaging;
@Override
public void onLoad() {
// Create our DataFolder
getDataFolder().mkdirs();
// Setup our Debug Log
debugLog = new DebugLog("Multiverse-Core", getDataFolder() + File.separator + "debug.log");
}
public FileConfiguration getMVConfiguration() {
return this.multiverseConfig;
}
public GenericBank getBank() {
return this.bank;
}
public void onEnable() {
// Perform initial checks for AllPay
if (!this.validateAllpay() || !this.validateCH()) {
this.getServer().getPluginManager().disablePlugin(this);
return;
}
this.banker = new AllPay(this, tag + " ");
// Output a little snippet to show it's enabled.
this.log(Level.INFO, "- Version " + this.getDescription().getVersion() + " (API v" + Protocol + ") Enabled - By " + getAuthors());
this.checkServerProps();
this.registerEvents();
// Setup Permissions, we'll do an initial check for the Permissions plugin then fall back on isOP().
this.ph = new MVPermissions(this);
this.bank = this.banker.loadEconPlugin();
// Setup the command manager
this.commandHandler = new CommandHandler(this, this.ph);
// Call the Function to assign all the Commands to their Class.
this.registerCommands();
// Initialize the Destination factor AFTER the commands
this.initializeDestinationFactory();
this.playerSessions = new HashMap<String, MVPlayerSession>();
// Start the Update Checker
// updateCheck = new UpdateChecker(this.getDescription().getName(), this.getDescription().getVersion());
// Call the Function to load all the Worlds and setup the HashMap
// When called with null, it tries to load ALL
// this function will be called every time a plugin registers a new envtype with MV
// Setup & Load our Configuration files.
loadConfigs();
if (this.multiverseConfig != null) {
this.worldManager.loadWorlds(true);
} else {
this.log(Level.SEVERE, "Your configs were not loaded. Very little will function in Multiverse.");
}
}
private boolean validateAllpay() {
try {
this.banker = new AllPay(this, "Verify");
if (this.banker.getVersion() >= allpayversion) {
return true;
} else {
log.info(tag + " - Version " + this.getDescription().getVersion() + " was NOT ENABLED!!!");
log.info(tag + " A plugin that has loaded before " + this.getDescription().getName() + " has an incompatible version of AllPay!");
log.info(tag + " The Following Plugins MAY out of date!");
log.info(tag + " This plugin needs AllPay v" + allpayversion + " or higher and another plugin has loaded v" + this.banker.getVersion() + "!");
log.info(tag + AllPay.pluginsThatUseUs.toString());
return false;
}
} catch (Throwable t) {
}
log.info(tag + " - Version " + this.getDescription().getVersion() + " was NOT ENABLED!!!");
log.info(tag + " A plugin that has loaded before " + this.getDescription().getName() + " has an incompatible version of AllPay!");
log.info(tag + " Check the logs for [AllPay] - Version ... for PLUGIN NAME to find the culprit! Then Yell at that dev!");
log.info(tag + " Or update that plugin :P");
log.info(tag + " This plugin needs AllPay v" + allpayversion + " or higher!");
return false;
}
private boolean validateCH() {
try {
this.commandHandler = new CommandHandler(this, null);
if (this.commandHandler.getVersion() >= chversion) {
return true;
} else {
log.info(tag + " - Version " + this.getDescription().getVersion() + " was NOT ENABLED!!!");
log.info(tag + " A plugin that has loaded before " + this.getDescription().getName() + " has an incompatible version of CommandHandler (an internal library)!");
log.info(tag + " Please contact this plugin author!!!!!!!");
log.info(tag + " This plugin needs CommandHandler v" + chversion + " or higher and another plugin has loaded v" + this.commandHandler.getVersion() + "!");
return false;
}
} catch (Throwable t) {
}
log.info(tag + " - Version " + this.getDescription().getVersion() + " was NOT ENABLED!!!");
log.info(tag + " A plugin that has loaded before " + this.getDescription().getName() + " has an incompatible version of CommandHandler (an internal library)!");
log.info(tag + " Please contact this plugin author!!!!!!!");
log.info(tag + " This plugin needs CommandHandler v" + chversion + " or higher!");
return false;
}
private void initializeDestinationFactory() {
this.destFactory = new DestinationFactory(this);
this.destFactory.registerDestinationType(WorldDestination.class, "");
this.destFactory.registerDestinationType(WorldDestination.class, "w");
this.destFactory.registerDestinationType(ExactDestination.class, "e");
this.destFactory.registerDestinationType(PlayerDestination.class, "pl");
this.destFactory.registerDestinationType(CannonDestination.class, "ca");
this.destFactory.registerDestinationType(BedDestination.class, "b");
}
/** Function to Register all the Events needed. */
private void registerEvents() {
PluginManager pm = getServer().getPluginManager();
// pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Highest, this); // Low so it acts above any other.
pm.registerEvent(Event.Type.PLAYER_TELEPORT, this.playerListener, Priority.Highest, this); // Cancel Teleports if needed.
pm.registerEvent(Event.Type.PLAYER_JOIN, this.playerListener, Priority.Normal, this); // To create the Player Session
pm.registerEvent(Event.Type.PLAYER_QUIT, this.playerListener, Priority.Normal, this); // To remove Player Sessions
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Priority.Low, this); // Let plugins which specialize in (re)spawning carry more weight.
pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Priority.Normal, this); // To prepend the world name
pm.registerEvent(Event.Type.PLAYER_PORTAL, this.playerListener, Priority.Lowest, this); // To switch gamemode
pm.registerEvent(Event.Type.PLAYER_CHANGED_WORLD, this.playerListener, Priority.Monitor, this); // To switch gamemode
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, this.entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_DAMAGE, this.entityListener, Priority.Normal, this); // To Allow/Disallow fake PVP
pm.registerEvent(Event.Type.CREATURE_SPAWN, this.entityListener, Priority.Normal, this); // To prevent all or certain animals/monsters from spawning.
pm.registerEvent(Event.Type.FOOD_LEVEL_CHANGE, this.entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLUGIN_ENABLE, this.pluginListener, Priority.Monitor, this);
pm.registerEvent(Event.Type.PLUGIN_DISABLE, this.pluginListener, Priority.Monitor, this);
pm.registerEvent(Event.Type.WEATHER_CHANGE, this.weatherListener, Priority.Normal, this);
pm.registerEvent(Event.Type.THUNDER_CHANGE, this.weatherListener, Priority.Normal, this);
}
/** Load the Configuration files OR create the default config files. */
public void loadConfigs() {
// Now grab the Configuration Files.
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
Configuration coreDefaults = YamlConfiguration.loadConfiguration(this.getClass().getResourceAsStream("/defaults/config.yml"));
this.multiverseConfig.setDefaults(coreDefaults);
this.multiverseConfig.options().copyDefaults(true);
this.saveMVConfig();
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
// Setup the Debug option, we'll default to false because this option will not be in the default config.
GlobalDebug = this.multiverseConfig.getInt("debug", 0);
// Lets cache these values due to the fact that they will be accessed many times.
EnforceAccess = this.multiverseConfig.getBoolean("enforceaccess", false);
EnforceGameModes = this.multiverseConfig.getBoolean("enforcegamemodes", true);
PrefixChat = this.multiverseConfig.getBoolean("worldnameprefix", true);
BedRespawn = this.multiverseConfig.getBoolean("bedrespawn", true);
this.messaging = new MVMessaging(this);
this.messaging.setCooldown(this.multiverseConfig.getInt("messagecooldown", 5000));
this.saveMVConfigs();
}
public MVMessaging getMessaging() {
return this.messaging;
}
/** Register Multiverse-Core commands to Command Manager. */
private void registerCommands() {
// Intro Commands
this.commandHandler.registerCommand(new HelpCommand(this));
this.commandHandler.registerCommand(new VersionCommand(this));
this.commandHandler.registerCommand(new ListCommand(this));
this.commandHandler.registerCommand(new InfoCommand(this));
this.commandHandler.registerCommand(new CreateCommand(this));
this.commandHandler.registerCommand(new ImportCommand(this));
this.commandHandler.registerCommand(new ReloadCommand(this));
this.commandHandler.registerCommand(new SetSpawnCommand(this));
this.commandHandler.registerCommand(new CoordCommand(this));
this.commandHandler.registerCommand(new TeleportCommand(this));
this.commandHandler.registerCommand(new WhoCommand(this));
this.commandHandler.registerCommand(new SpawnCommand(this));
// Dangerous Commands
this.commandHandler.registerCommand(new UnloadCommand(this));
this.commandHandler.registerCommand(new LoadCommand(this));
this.commandHandler.registerCommand(new RemoveCommand(this));
this.commandHandler.registerCommand(new DeleteCommand(this));
this.commandHandler.registerCommand(new ConfirmCommand(this));
// Modification commands
this.commandHandler.registerCommand(new ModifyCommand(this));
this.commandHandler.registerCommand(new PurgeCommand(this));
this.commandHandler.registerCommand(new ModifyAddCommand(this));
this.commandHandler.registerCommand(new ModifySetCommand(this));
this.commandHandler.registerCommand(new ModifyRemoveCommand(this));
this.commandHandler.registerCommand(new ModifyClearCommand(this));
this.commandHandler.registerCommand(new ConfigCommand(this));
// Misc Commands
this.commandHandler.registerCommand(new EnvironmentCommand(this));
this.commandHandler.registerCommand(new DebugCommand(this));
this.commandHandler.registerCommand(new GeneratorCommand(this));
this.commandHandler.registerCommand(new CheckCommand(this));
}
/** Deprecated, please use WorldManager.loadWorlds(Boolean forceLoad) now. */
@Deprecated
public void loadWorlds(boolean forceLoad) {
this.worldManager.loadWorlds(true);
}
/**
* Deprecated, please use WorldManager.addWorld(String name, Environment env, String seedString, String generator)
* now.
*/
@Deprecated
public boolean addWorld(String name, Environment env, String seedString, String generator) {
return this.worldManager.addWorld(name, env, seedString, generator);
}
/** Deprecated, please use WorldManager.unloadWorld(String name) now. */
@Deprecated
public boolean removeWorldFromList(String name) {
return this.worldManager.unloadWorld(name);
}
/** Deprecated, please use WorldManager.removeWorldFromConfig(String name) now. */
@Deprecated
public boolean removeWorldFromConfig(String name) {
return this.worldManager.removeWorldFromConfig(name);
}
/** Deprecated please use WorldManager.deleteWorld(String name) now. */
@Deprecated
public Boolean deleteWorld(String name) {
return this.worldManager.deleteWorld(name);
}
/** What happens when the plugin gets disabled... */
public void onDisable() {
debugLog.close();
this.banker = null;
this.bank = null;
log(Level.INFO, "- Disabled");
}
@Override
public MVPlayerSession getPlayerSession(Player player) {
if (this.playerSessions.containsKey(player.getName())) {
return this.playerSessions.get(player.getName());
} else {
this.playerSessions.put(player.getName(), new MVPlayerSession(player, this.multiverseConfig, this));
return this.playerSessions.get(player.getName());
}
}
/**
* Grab and return the Teleport class.
*
* @return
*/
public SafeTTeleporter getTeleporter() {
return new SafeTTeleporter(this);
}
/**
* Grab the Permissions Handler for Multiverse
*
* @return A valid {@link MVPermissions}.
*/
public MVPermissions getMVPerms() {
return this.ph;
}
@Deprecated
public com.onarandombox.MultiverseCore.MVPermissions getPermissions() {
return new com.onarandombox.MultiverseCore.MVPermissions(this);
}
@Deprecated
public PurgeWorlds getWorldPurger() {
return this.worldManager.getWorldPurger();
}
/** onCommand */
@Override
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
if (!this.isEnabled()) {
sender.sendMessage("This plugin is Disabled!");
return true;
}
ArrayList<String> allArgs = new ArrayList<String>(Arrays.asList(args));
allArgs.add(0, command.getName());
return this.commandHandler.locateAndRunCommand(sender, allArgs);
}
/**
* Print messages to the server Log as well as to our DebugLog. 'debugLog' is used to seperate Heroes information
* from the Servers Log Output.
*
* @param level
* @param msg
*/
public void log(Level level, String msg) {
staticLog(level, msg);
}
public static void staticLog(Level level, String msg) {
if (level == Level.FINE && GlobalDebug >= 1) {
staticDebugLog(Level.INFO, msg);
return;
} else if (level == Level.FINER && GlobalDebug >= 2) {
staticDebugLog(Level.INFO, msg);
return;
} else if (level == Level.FINEST && GlobalDebug >= 3) {
staticDebugLog(Level.INFO, msg);
return;
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
log.log(level, tag + " " + msg);
debugLog.log(level, tag + " " + msg);
}
}
/**
* Print messages to the Debug Log, if the servers in Debug Mode then we also wan't to print the messages to the
* standard Server Console.
*
* @param level
* @param msg
*/
public static void staticDebugLog(Level level, String msg) {
log.log(level, "[MVCore-Debug] " + msg);
debugLog.log(level, "[MVCore-Debug] " + msg);
}
/**
* Parse the Authors Array into a readable String with ',' and 'and'.
*
* @return
*/
private String getAuthors() {
String authors = "";
ArrayList<String> auths = this.getDescription().getAuthors();
if (auths.size() == 1) {
return auths.get(0);
}
for (int i = 0; i < auths.size(); i++) {
if (i == this.getDescription().getAuthors().size() - 1) {
authors += " and " + this.getDescription().getAuthors().get(i);
} else {
authors += ", " + this.getDescription().getAuthors().get(i);
}
}
return authors.substring(2);
}
public CommandHandler getCommandHandler() {
return this.commandHandler;
}
public String getTag() {
return MultiverseCore.tag;
}
/**
* This code should get moved somewhere more appropriate, but for now, it's here.
*
* @param env
*
* @return
*/
public Environment getEnvFromString(String env) {
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
if (env.equalsIgnoreCase("HELL") || env.equalsIgnoreCase("NETHER"))
env = "NETHER";
if (env.equalsIgnoreCase("SKYLANDS") || env.equalsIgnoreCase("SKYLAND") || env.equalsIgnoreCase("STARWARS"))
env = "SKYLANDS";
if (env.equalsIgnoreCase("NORMAL") || env.equalsIgnoreCase("WORLD"))
env = "NORMAL";
try {
// If the value wasn't found, maybe it's new, try checking the enum directly.
return Environment.valueOf(env);
} catch (IllegalArgumentException e) {
return null;
}
}
public void showNotMVWorldMessage(CommandSender sender, String worldName) {
sender.sendMessage("Multiverse doesn't know about " + ChatColor.DARK_AQUA + worldName + ChatColor.WHITE + " yet.");
sender.sendMessage("Type " + ChatColor.DARK_AQUA + "/mv import ?" + ChatColor.WHITE + " for help!");
}
public void removePlayerSession(Player player) {
if (this.playerSessions.containsKey(player.getName())) {
this.playerSessions.remove(player.getName());
}
}
/**
* Returns the number of plugins that have specifically hooked into core.
*
* @return
*/
public int getPluginCount() {
return this.pluginCount;
}
/** Increments the number of plugins that have specifically hooked into core. */
public void incrementPluginCount() {
this.pluginCount += 1;
}
/** Decrements the number of plugins that have specifically hooked into core. */
public void decrementPluginCount() {
this.pluginCount -= 1;
}
public AllPay getBanker() {
return this.banker;
}
public void setBank(GenericBank bank) {
this.bank = bank;
}
public DestinationFactory getDestFactory() {
return this.destFactory;
}
@Deprecated
public com.onarandombox.utils.DestinationFactory getDestinationFactory() {
return new com.onarandombox.utils.DestinationFactory(this);
}
/**
* This is a convenience method to allow the QueuedCommand system to call it. You should NEVER call this directly.
*
* @param p Player
* @param l The potentially unsafe location.
*/
public void teleportPlayer(CommandSender teleporter, Player p, Location l) {
// This command is the override, and MUST NOT TELEPORT SAFELY
this.getTeleporter().safelyTeleport(teleporter, p, l, false);
}
private void checkServerProps() {
File serverFolder = new File(this.getDataFolder().getAbsolutePath()).getParentFile().getParentFile();
File serverProperties = new File(serverFolder.getAbsolutePath() + File.separator + "server.properties");
try {
FileInputStream fileStream = new FileInputStream(serverProperties);
DataInputStream in = new DataInputStream(fileStream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String propLine;
while ((propLine = br.readLine()) != null) {
// Print the content on the console
if (propLine.matches(".*spawn-monsters.*") && !propLine.matches(".*spawn-monsters\\s*=\\s*true.*")) {
this.log(Level.SEVERE, "Monster spawning has been DISABLED.");
this.log(Level.SEVERE, "In order to let Multiverse fully control your worlds:");
this.log(Level.SEVERE, "Please set 'spawn-monsters=true' in your server.properties file!");
MultiverseCore.MobsDisabledInDefaultWorld = true;
}
}
} catch (IOException e) {
// This should never happen...
this.log(Level.SEVERE, e.getMessage());
}
}
public void setSpout() {
this.spoutInterface = new SpoutInterface();
this.commandHandler.registerCommand(new SpoutCommand(this));
}
public SpoutInterface getSpout() {
return this.spoutInterface;
}
public WorldManager getMVWorldManager() {
return this.worldManager;
}
@Deprecated
public com.onarandombox.utils.WorldManager getWorldManager() {
return new com.onarandombox.utils.WorldManager(this);
}
public MVPlayerListener getPlayerListener() {
return this.playerListener;
}
public boolean loadMVConfigs() {
return false;
}
public boolean saveMVConfig() {
try {
this.multiverseConfig.save(new File(getDataFolder(), "config.yml"));
return true;
} catch (IOException e) {
this.log(Level.SEVERE, "Could not save Multiverse config.yml config. Please check your file permissions.");
return false;
}
}
public boolean saveWorldConfig() {
return this.worldManager.saveWorldsConfig();
}
public boolean saveMVConfigs() {
return this.saveMVConfig() && this.saveWorldConfig();
}
}
@@ -0,0 +1,101 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.api;
import com.fernferret.allpay.GenericBank;
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
import com.onarandombox.MultiverseCore.utils.*;
import com.pneumaticraft.commandhandler.CommandHandler;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
/**
* Multiverse 2 Core API
* <p/>
* This API contains a bunch of useful things you can get out of Multiverse in general!
*/
public interface Core {
/**
* Gets the Multiverse config file.
*
* @return The Multiverse config file.
*/
public FileConfiguration getMVConfiguration();
/**
* Gets the Banking system that Multiverse-Core has hooked into.
*
* @return A {@link GenericBank} that can be used for payments.
*/
public GenericBank getBank();
/**
* Reloads the Multiverse Configuration files:
* worlds.yml and config.yml.
*/
public void loadConfigs();
/**
* Gets the Multiverse message system. This allows you to send messages
* to users at specified intervals.
*
* @return The loaded {@link MVMessaging}.
*/
public MVMessaging getMessaging();
/**
* Gets the {@link MVPlayerSession} for the given player.
* This will also create a player session if one does not exist
* for a player.
*
* @param player The player's session to grab.
*
* @return The corresponding {@link MVPlayerSession}.
*/
public MVPlayerSession getPlayerSession(Player player);
/**
* Gets the instantiated Safe-T-Teleporter for performing
* safe teleports.
*
* @return A non-null {@link SafeTTeleporter}.
*/
public SafeTTeleporter getTeleporter();
/**
* Multiverse uses an advanced permissions setup, this object
* simplifies getting/setting permissions.
*
* @return A non-null {@link MVPermissions}.
*/
public MVPermissions getMVPerms();
/**
* Multiverse uses {@link CommandHandler} to make adding and using commands
* a piece of cake.
*
* @return A non-null {@link CommandHandler}.
*/
public CommandHandler getCommandHandler();
/**
* Gets the factory class responsible for loading many different destinations
* on demand.
*
* @return A valid {@link DestinationFactory}.
*/
public DestinationFactory getDestFactory();
/**
* Gets the primary class responsible for managing Multiverse Worlds.
*
* @return {@link WorldManager}.
*/
public WorldManager getMVWorldManager();
}
@@ -0,0 +1,17 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.api;
public interface FancyText {
/**
* TODO: Write something useful here.
*
* @return And Here.
*/
public String getFancyText();
}
@@ -0,0 +1,30 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.api;
import org.bukkit.Server;
import java.util.logging.Level;
/** A simple API to require plugins to have a log method. */
public interface LoggablePlugin {
/**
* Logs a message at the specified level.
*
* @param level The severity of the log.
* @param msg The message to log.
*/
public void log(Level level, String msg);
/**
* Gets the server instance that this plugin is attached to.
*
* @return A {@link Server} instance.
*/
public Server getServer();
}
@@ -0,0 +1,143 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.api;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
/**
* A destination API for Multiverse
* Any plugin can add these to MV and when they are, any action that uses them (portals, MVTP, etc.) can use them!
*
* @author fernferret
*/
public interface MVDestination {
/**
* Returns the identifier or prefix that is required for this destination.
* <p/>
* Portals have a prefix of "p" for example and OpenWarp (third party plugin) uses "ow". This is derived from a
* hash and cannot have duplicate values. Read that as your plugin cannot use 'p' because it's already used.
* Please check the wiki when adding a custom destination!
*
* @return The identifier or prefix that is required for this destination.
*/
public String getIdentifier();
/**
* Allows you to determine if a Destination is valid for the type it thinks it is.
* <p/>
* An example of this would be the exact destination. A valid string would be: e:0,0,0 where an invalid one would
* be e:1:2:3. The first string would return true the second would return false. This is simply a convenience
* method
* and does not even NEED to be called, but it's highly recommended if you're teleporting, but it's mainly for
* Multiverse Internal use.
*
* @param plugin The plugin who the type belongs to.
* @param destination The destination string. ex: p:MyPortal:nw
*
* @return True if the destination is valid, false if not.
*/
public boolean isThisType(JavaPlugin plugin, String destination);
/**
* Returns the location a specific entity will spawn at.
* <p/>
* To just retrieve the location as it is stored you can just pass null, but be warned some destinations may return
* null back to you if you do this. It is always safer to pass an actual entity. This is used so things like
* minecarts can be teleported.
* <p/>
* Do not forget to use {@link #getVelocity()} as destinations can use this too!
*
* @param entity The entity to be teleported.
*
* @return The location of the entity.
*/
public Location getLocation(Entity entity);
/**
* Returns the velocity vector for this destination.
* <p/>
* Plugins wishing to fully support MVDestinations MUST implement this.
*
* @return A vector representing the speed/direction the player should travel when arriving
*/
public Vector getVelocity();
/**
* Sets the destination string.
* <p/>
* This should be used when you want to tell this destination object about a change in where it should take people.
* The destination param should be match the result from {@link #getIdentifier()}. A valid example would be that if
* {@link #getIdentifier()} returned "ow" our destination string could be "ow:TownCenter" but could not be
* "p:HomePortal"
*
* @param plugin The plugin who the type belongs to.
* @param destination The destination string. ex: p:MyPortal:nw
*/
public void setDestination(JavaPlugin plugin, String destination);
/**
* Returns true if the destination is valid and players will be taken to it.
* <p/>
* Even if destinations are in the correct format (p:MyPortal) MyPortal may not exist, and therefore this would
* return false.
*
* @return True if the destination is valid; false if not.
*/
public boolean isValid();
/**
* Gives you a general friendly description of the type of destination.
* <p/>
* For example, the PlayerDestination sets this to "Player". You can use this to show where a player will be taken.
*
* @return A friendly string description of the type of destination.
*/
public String getType();
/**
* Gives you a specific name of the destination.
* <p/>
* For example, the PlayerDestination sets this to The Player's Name.
*
* @return A friendly string stating the name of the destination.
*/
public String getName();
/**
* Returns a string that can easily be saved in the config that contains all the details needed to rebuild this
* destination.
* <p/>
* ex: e:0,0,0:50:50
*
* @return The savable config string.
*/
public String toString();
/**
* Returns the permissions string required to go here.
* <p/>
* ex: multiverse.access.world
* <p/>
* NOTE: This is NOT the permission to use the teleport command.
*
* @return the permissions string required to go here.
*/
public String getRequiredPermission();
/**
* Should the Multiverse SafeTeleporter be used?
* <p/>
* If not, MV will blindly take people to the location specified.
*
* @return True if the SafeTeleporter will be used, false if not.
*/
public boolean useSafeTeleporter();
}
@@ -0,0 +1,44 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.MultiverseCore;
public interface MVPlugin extends LoggablePlugin {
/**
* Adds This plugin's version information to the buffer and returns the new string.
*
* @param buffer The string that contains Core and all other MV plugins' versions.
*
* @return A modified buffer that contains this MVPlugin's version information.
*/
public String dumpVersionInfo(String buffer);
/**
* Gets the reference to MultiverseCore.
*
* @return A valid {@link MultiverseCore}.
*/
public MultiverseCore getCore();
/**
* Sets the reference to MultiverseCore.
*
* @param core A valid {@link MultiverseCore}.
*/
public void setCore(MultiverseCore core);
/**
* Allows Multiverse or a plugin to query another Multiverse plugin to see what version its protocol is. This
* number
* should change when something will break the code.
*
* @return The Integer protocol version.
*/
public int getProtocolVersion();
}
@@ -0,0 +1,144 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.generator.ChunkGenerator;
import java.util.Collection;
/**
* Multiverse 2 World Manager API
* <p/>
* This API contains all of the world managing
* functions that your heart desires!
*/
public interface MVWorldManager {
/**
* Add a new World to the Multiverse Setup.
*
* @param name World Name
* @param env Environment Type
* @param seedString The seed in the form of a string.
* If the seed is a Long,
* it will be interpreted as such.
* @param generator The Custom generator plugin to use.
*
* @return True if the world is added, false if not.
*/
public boolean addWorld(String name, Environment env, String seedString, String generator);
/**
* Remove the world from the Multiverse list, from the
* config and deletes the folder
*
* @param name The name of the world to remove
*
* @return True if success, false if failure.
*/
public Boolean deleteWorld(String name);
/**
* Unload a world from Multiverse
*
* @param name Name of the world to unload
*
* @return True if the world was unloaded, false if not.
*/
public boolean unloadWorld(String name);
/**
* Loads the world. Only use this if the world has been
* unloaded with {@link #unloadWorld(String)}.
*
* @param name The name of the world to load
*
* @return True if success, false if failure.
*/
public boolean loadWorld(String name);
/**
* Removes all players from the specified world.
*
* @param name World to remove players from.
*/
public void removePlayersFromWorld(String name);
/**
* Test if a given chunk generator is valid.
*
* @param generator The generator name.
* @param generatorID The generator id.
* @param worldName The worldName to use as the default.
*
* @return A {@link ChunkGenerator} or null
*/
public ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName);
/**
* Returns a list of all the worlds Multiverse knows about.
*
* @return A list of {@link MultiverseWorld}.
*/
public Collection<MultiverseWorld> getMVWorlds();
/**
* Returns a {@link MultiverseWorld} if it exists, and null if it does not.
* This will search name AND alias.
*
* @param name The name or alias of the world to get.
*
* @return A {@link MultiverseWorld} or null.
*/
public MultiverseWorld getMVWorld(String name);
/**
* Returns a {@link MultiverseWorld} if it exists, and null if it does not.
*
* @param world The Bukkit world to check.
*
* @return A {@link MultiverseWorld} or null.
*/
public MultiverseWorld getMVWorld(World world);
/**
* Checks to see if the given name is a valid {@link MultiverseWorld}
*
* @param name The name or alias of the world to check.
*
* @return True if the world exists, false if not.
*/
public boolean isMVWorld(String name);
/**
* Checks to see if the given world is a valid {@link MultiverseWorld}
*
* @param world The Bukkit world to check.
*
* @return True if the world has been loaded into MV2, false if not.
*/
public boolean isMVWorld(World world);
/**
* Load the Worlds & Settings from the configuration file.
*
* @param forceLoad If set to true, this will perform a total
* reset and not just load new worlds.
*/
public void loadWorlds(boolean forceLoad);
/**
* Return the World Purger.
*
* @return A valid {@link PurgeWorlds}.
*/
public PurgeWorlds getWorldPurger();
}
@@ -0,0 +1,441 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.api;
import org.bukkit.*;
import org.bukkit.permissions.Permission;
import java.util.List;
/**
* The API for a Multiverse Handled World.
* <p/>
* Currently INCOMPLETE
*/
public interface MultiverseWorld {
/**
* Returns the Bukkit world object that this world describes.
*
* @return A {@link World}
*/
public World getCBWorld();
/**
* Adds the property to the given value. The property must be a {@link com.onarandombox.MultiverseCore.enums.SetProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.SetProperties} to set.
* @param value A value in string representation, it will be parsed to the correct type.
*
* @return True if the value was set, false if not.
*/
public boolean setVariable(String property, String value);
/**
* Removes all values from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to clear.
*
* @return True if it was cleared, false if not.
*/
public boolean clearVariable(String property);
/**
* Adds a value to the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to add a value to.
* @param value A value in string representation, it will be parsed to the correct type.
*
* @return True if the value was added, false if not.
*/
public boolean addToVariable(String property, String value);
/**
* Removes a value from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to remove a value
* from.
* @param value A value in string representation, it will be parsed to the correct type.
*
* @return True if the value was removed, false if not.
*/
public boolean removeFromVariable(String property, String value);
/**
* Gets the environment of this world.
*
* @return A {@link org.bukkit.World.Environment}.
*/
public World.Environment getEnvironment();
/**
* Sets the environment of a world.
* <p/>
* Note: This will ONLY take effect once the world is unloaded/reloaded.
*
* @param environment A {@link org.bukkit.World.Environment}.
*/
public void setEnvironment(World.Environment environment);
/**
* Gets the world seed of this world.
*
* @return The Long version of the seed.
*/
public Long getSeed();
/**
* Sets the seed of this world.
*
* @param seed A Long that is the seed.
*/
public void setSeed(Long seed);
/**
* Gets the name of this world. This cannot be changed.
*
* @return The name of the world as a String.
*/
public String getName();
/**
* Gets the alias of this world.
* <p/>
* This alias allows users to have a world named "world" but show up in the list as "FernIsland"
*
* @return The alias of the world as a String.
*/
public String getAlias();
/**
* Sets the alias of the world.
*
* @param alias A string that is the new alias.
*/
public void setAlias(String alias);
/**
* Sets the color that this world's name/alias will display as.
*
* @param color A valid color name.
*
* @return True if the color was set, false if not.
*/
public boolean setColor(String color);
/**
* Gets the color that this world's name/alias will display as.
*
* @return The color of this world.
*/
public ChatColor getColor();
/**
* Tells you if someone entered a valid color.
*
* @param color A string that may translate to a color.
*
* @return True if it is a color, false if not.
*/
public boolean isValidAliasColor(String color);
/**
* Returns a very nicely colored string (using Alias and Color if they are set).
*
* @return A nicely colored string.
*/
public String getColoredWorldString();
/**
* Gets whether or not animals are allowed to spawn in this world.
*
* @return True if ANY animal can, false if no animals can spawn.
*/
public boolean canAnimalsSpawn();
/**
* Gets whether or not monsters are allowed to spawn in this world.
*
* @return True if ANY monster can, false if no monsters can spawn.
*/
public boolean canMonstersSpawn();
/**
* Turn pvp on or off. This setting is used to set the world's PVP mode, and thus relies on fakePVP
*
* @param pvpMode True to enable PVP damage, false to disable it.
*/
public void setPVPMode(boolean pvpMode);
/**
* Turn pvp on or off. This setting is used to set the world's PVP mode, and thus relies on fakePVP
*
* @return True if this world has fakepvp on
*/
public boolean getFakePVP();
/**
* Gets whether or not PVP is enabled in this world in some form (fake or not).
*
* @return True if players can take damage from other players.
*/
public boolean isPVPEnabled();
/**
* Gets whether or not this world will display in chat, mvw and mvl regardless if a user has the
* access permissions to go to this world.
*
* @return True if the world will be hidden, false if not.
*/
public boolean isHidden();
/**
* Sets whether or not this world will display in chat, mvw and mvl regardless if a user has the
* access permissions to go to this world.
*
* @param hidden Set
*/
public void setHidden(boolean hidden);
/**
* Sets whether or not there will be weather events in a given world.
* If set to false, Multiverse will disable the weather in the world immediately.
*
* @param enableWeather True if weather events should occur in a world, false if not.
*/
public void setEnableWeather(boolean enableWeather);
/**
* Gets whether weather is enabled in this world.
*
* @return True if weather events will occur, false if not.
*/
public boolean isWeatherEnabled();
/**
* If true, tells Craftbukkit to keep a worlds spawn chunks loaded in memory (default: true)
* If not, CraftBukkit will attempt to free memory when players have not used that world.
* This will not happen immediately.
*
* @param keepSpawnInMemory If true, CraftBukkit will keep the spawn chunks loaded in memory.
*/
public void setKeepSpawnInMemory(boolean keepSpawnInMemory);
/**
* Gets whether or not CraftBukkit is keeping the chunks for this world in memory.
*
* @return True if CraftBukkit is keeping spawn chunks in memory.
*/
public boolean isKeepingSpawnInMemory();
/**
* Sets the difficulty of this world and returns true if success.
* Valid string values are either an integer of difficulty(0-3) or
* the name that resides in the Bukkit enum, ex. PEACEFUL
*
* @param difficulty The difficulty to set the world to as a string.
*
* @return True if success, false if the provided string
* could not be translated to a difficulty.
*/
public boolean setDifficulty(String difficulty);
/**
* Gets the difficulty of this world.
*
* @return The difficulty of this world.
*/
public Difficulty getDifficulty();
/**
* Sets the spawn location for a world.
*
* @param spawnLocation The spawn location for a world.
*/
public void setSpawnLocation(Location spawnLocation);
/**
* Gets the spawn location of this world.
*
* @return The spawn location of this world.
*/
public Location getSpawnLocation();
/**
* Sets whether or not the hunger level of players will go down in a world.
*
* @param hungerEnabled True if hunger will go down, false to keep it at
* the level they entered a world with.
*/
public void setHunger(boolean hungerEnabled);
/**
* Gets whether or not the hunger level of players will go down in a world.
*
* @return True if it will go down, false if it will remain steady.
*/
public boolean getHunger();
/**
* Sets the game mode of this world
*
* @param gameMode A valid game mode string (either
* an int ex. 0 or a string ex. creative).
*
* @return True if the game mode was successfully changed, false if not.
*/
public boolean setGameMode(String gameMode);
/**
* Gets the GameMode of this world.
*
* @return The GameMode of this world.
*/
public GameMode getGameMode();
/**
* Gets the permission required to enter this world.
*
* @return The permission required to be exempt from charges to/from this world.
*/
public Permission getAccessPermission();
/**
* Gets the permission required to be exempt when entering.
*
* @return The permission required to be exempt when entering.
*/
public Permission getExemptPermission();
/**
* Sets the price for entry to this world.
* You can think of this like an amount.
* The type can be set with {@link #setCurrency(int)}
*
* @param price The Amount of money/item to enter the world.
*/
public void setPrice(double price);
/**
* Gets the amount of currency it requires to enter this world.
*
* @return The amount it costs to enter this world.
*/
public double getPrice();
/**
* Sets the type of item that will be required given the price is not 0.
* Use -1 to use an AllPay economy, or any valid itemid
*
* @param item The Type of currency that will be used when users enter this world.
*/
public void setCurrency(int item);
/**
* Gets the Type of currency that will be used when users enter this world.
*
* @return The Type of currency that will be used when users enter this world.
*/
public int getCurrency();
/**
* Sets the world players will respawn in if they die in this one.
* Returns true upon success, false upon failure.
*
* @param respawnWorld The name of a world that exists on the server.
*
* @return True if respawnWorld existed, false if not.
*/
public boolean setRespawnToWorld(String respawnWorld);
/**
* Gets the world players will respawn in if they die in this one.
*
* @return A world that exists on the server.
*/
public World getRespawnToWorld();
/**
* Sets the scale of this world. Really only has an effect if you use
* Multiverse-NetherPortals.
*
* @param scaling A scaling value, cannot be negative or 0.
*/
public boolean setScaling(double scaling);
/**
* Gets the scaling value of this world.Really only has an effect if you use
* Multiverse-NetherPortals.
*
* @return This world's non-negative, non-zero scale.
*/
public double getScaling();
/**
* Gets a list of all the worlds that players CANNOT travel to from this world,
* regardless of their access permissions.
*
* @return A List of world names.
*/
public List<String> getWorldBlacklist();
/**
* Returns a list of animals. This list always negates the {@link #canAnimalsSpawn()} result.
*
* @return A list of animals that will spawn if {@link #canAnimalsSpawn()} is false.
*/
public List<String> getAnimalList();
/**
* Sets whether or not animals can spawn.
* If there are values in {@link #getAnimalList()} and this is false,
* those animals become the exceptions, and will spawn
*
* @param allowAnimalSpawn True to allow spawning of monsters, false to prevent.
*/
public void setAllowAnimalSpawn(boolean allowAnimalSpawn);
/**
* Returns a list of monsters. This list always negates the {@link #canMonstersSpawn()} ()} result.
*
* @return A list of monsters that will spawn if {@link #canMonstersSpawn()} is false.
*/
public List<String> getMonsterList();
/**
* Sets whether or not monsters can spawn.
* If there are values in {@link #getMonsterList()} and this is false,
* those monsters become the exceptions, and will spawn
*
* @param allowMonsterSpawn True to allow spawning of monsters, false to prevent.
*/
public void setAllowMonsterSpawn(boolean allowMonsterSpawn);
/**
* TODO: Write these docs.
*
* @param property
*
* @return
*/
public boolean clearList(String property);
/**
* Sets whether or not a world will autoheal players if the difficulty is on peaceful.
*
* @param heal True if the world will heal.
*/
public void setAutoHeal(boolean heal);
/**
* Gets whether or not a world will autoheal players if the difficulty is on peaceful.
*
* @return True if the world should heal (default), false if not.
*/
public boolean getAutoHeal();
}
@@ -0,0 +1,63 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
import com.onarandombox.MultiverseCore.utils.MVPermissions;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
public class CheckCommand extends MultiverseCommand {
private WorldManager worldManager;
public CheckCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Help you validate your multiverse settings");
this.setCommandUsage("/mv check " + ChatColor.GREEN + "{PLAYER} {DESTINATION}");
this.setArgRange(2, 2);
this.addKey("mv check");
this.addKey("mvcheck");
this.addCommandExample("/mv check " + ChatColor.GREEN + "fernferret " + ChatColor.LIGHT_PURPLE + "w:MyWorld");
this.addCommandExample("/mv check " + ChatColor.GREEN + "Rigby90 " + ChatColor.LIGHT_PURPLE + "p:MyPortal");
this.addCommandExample("/mv check " + ChatColor.GREEN + "lithium3141 " + ChatColor.LIGHT_PURPLE + "ow:WarpName");
this.setPermission("multiverse.core.debug", "Checks to see if a player can go to a destination. Prints debug if false.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player p = this.plugin.getServer().getPlayer(args.get(0));
if (p == null) {
sender.sendMessage("Could not find player " + ChatColor.GREEN + args.get(0));
sender.sendMessage("Are they online?");
return;
}
MVDestination dest = this.plugin.getDestFactory().getDestination(args.get(1));
if (dest instanceof InvalidDestination) {
sender.sendMessage("You asked if '" + args.get(0) + "' could go to " + ChatColor.GREEN + args.get(0) + ChatColor.WHITE + ",");
sender.sendMessage("but I couldn't find a Destination of that name? Did you type it correctly?");
return;
}
MVPermissions perms = this.plugin.getMVPerms();
if (perms.canEnterDestination(p, dest)) {
sender.sendMessage(ChatColor.GREEN + args.get(0) + ChatColor.WHITE + " can travel to " + ChatColor.GREEN + args.get(1));
} else {
sender.sendMessage(ChatColor.AQUA + args.get(0) + ChatColor.RED + " CANNOT travel to " + ChatColor.AQUA + args.get(1));
sender.sendMessage("Please turn debug mode to 3 then watch the console to find out why!");
sender.sendMessage("Use: " + ChatColor.GREEN + "/mv debug 3");
}
}
}
@@ -0,0 +1,93 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.enums.ConfigProperty;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
public class ConfigCommand extends MultiverseCommand {
private MVWorldManager worldManager;
public ConfigCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Configuration");
this.setCommandUsage("/mv config " + ChatColor.GREEN + "{PROPERTY} {VALUE}");
this.setArgRange(1, 2);
this.addKey("mv config");
this.addKey("mvconfig");
this.addKey("mv conf");
this.addKey("mvconf");
this.addCommandExample("All values: " + ConfigProperty.getAllValues());
this.addCommandExample("/mv config show");
this.addCommandExample("/mv config " + ChatColor.GREEN + "debug" + ChatColor.AQUA + " 3");
this.addCommandExample("/mv config " + ChatColor.GREEN + "enforceaccess" + ChatColor.AQUA + " false");
this.addCommandExample("/mv config " + ChatColor.GREEN + "bedrespawn" + ChatColor.AQUA + " true");
this.setPermission("multiverse.core.config", "Allows you to set Global MV Variables.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.size() <= 1) {
String[] allProps = ConfigProperty.getAllValues().split(" ");
String currentvals = "";
for (String prop : allProps) {
currentvals += ChatColor.GREEN;
currentvals += prop;
currentvals += ChatColor.WHITE;
currentvals += " = ";
currentvals += ChatColor.GOLD;
currentvals += this.plugin.getMVConfiguration().get(prop, "NOT SET");
currentvals += ChatColor.WHITE;
currentvals += ", ";
}
sender.sendMessage(currentvals.substring(0, currentvals.length() - 2));
return;
}
if (args.get(0).equalsIgnoreCase("messagecooldown") || args.get(0).equalsIgnoreCase("teleportcooldown") || args.get(0).equalsIgnoreCase("debug")) {
try {
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), Integer.parseInt(args.get(1)));
} catch (NumberFormatException e) {
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be an integer!");
return;
}
} else {
ConfigProperty property = null;
try {
property = ConfigProperty.valueOf(args.get(0).toLowerCase());
} catch (IllegalArgumentException e) {
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " you can't set " + ChatColor.AQUA + args.get(0));
sender.sendMessage(ChatColor.GREEN + "Valid values are:");
sender.sendMessage(ConfigProperty.getAllValues());
return;
}
if (property != null) {
try {
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), Boolean.parseBoolean(args.get(1)));
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be true or false!");
return;
}
}
}
if (this.plugin.saveMVConfigs()) {
sender.sendMessage(ChatColor.GREEN + "SUCCESS!" + ChatColor.WHITE + " Values were updated successfully!");
this.plugin.loadConfigs();
} else {
sender.sendMessage(ChatColor.RED + "FAIL!" + ChatColor.WHITE + " Check your console for details!");
}
}
}
@@ -0,0 +1,36 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
public class ConfirmCommand extends MultiverseCommand {
public ConfirmCommand(MultiverseCore plugin) {
super(plugin);
// Any command that is dangerous should require op
this.setName("Confirms a command that could destroy life, the universe and everything.");
this.setCommandUsage("/mv confirm");
this.setArgRange(0, 0);
this.addKey("mvconfirm");
this.addKey("mv confirm");
this.addCommandExample("/mv confirm");
this.setPermission("multiverse.core.confirm", "If you have not been prompted to use this, it will not do anything.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
this.plugin.getCommandHandler().confirmQueuedCommand(sender);
}
}
@@ -0,0 +1,68 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.text.DecimalFormat;
import java.util.List;
public class CoordCommand extends MultiverseCommand {
private WorldManager worldManager;
public CoordCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Coordinates");
this.setCommandUsage("/mv coord");
this.setArgRange(0, 0);
this.addKey("mv coord");
this.addKey("mvcoord");
this.addKey("mvco");
this.addCommandExample("/mv coord");
this.setPermission("multiverse.core.coord", "Returns detailed information on the Players where abouts.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Check if the command was sent from a Player.
if (sender instanceof Player) {
Player p = (Player) sender;
World world = p.getWorld();
if (!this.worldManager.isMVWorld(world.getName())) {
this.plugin.showNotMVWorldMessage(sender, world.getName());
return;
}
MultiverseWorld mvworld = this.worldManager.getMVWorld(world.getName());
p.sendMessage(ChatColor.AQUA + "--- Location Information ---");
p.sendMessage(ChatColor.AQUA + "World: " + ChatColor.WHITE + world.getName());
p.sendMessage(ChatColor.AQUA + "Alias: " + mvworld.getColoredWorldString());
p.sendMessage(ChatColor.AQUA + "World Scale: " + ChatColor.WHITE + mvworld.getScaling());
DecimalFormat df = new DecimalFormat();
df.setMinimumFractionDigits(0);
df.setMaximumFractionDigits(2);
p.sendMessage(ChatColor.AQUA + "Coordinates: " + ChatColor.WHITE + LocationManipulation.strCoords(p.getLocation()));
p.sendMessage(ChatColor.AQUA + "Direction: " + ChatColor.WHITE + LocationManipulation.getDirection(p.getLocation()));
p.sendMessage(ChatColor.AQUA + "Block: " + ChatColor.WHITE + Material.getMaterial(world.getBlockTypeIdAt(p.getLocation())));
} else {
sender.sendMessage("This command needs to be used from a Player.");
}
}
}
@@ -0,0 +1,71 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import com.pneumaticraft.commandhandler.CommandHandler;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.io.File;
import java.util.List;
public class CreateCommand extends MultiverseCommand {
private WorldManager worldManager;
public CreateCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Create World");
this.setCommandUsage("/mv create" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:ID]]");
this.setArgRange(2, 6);
this.addKey("mvcreate");
this.addKey("mvc");
this.addKey("mv create");
this.setPermission("multiverse.core.create", "Creates a new world and loads it.", PermissionDefault.OP);
this.addCommandExample("/mv create " + ChatColor.GOLD + "world" + ChatColor.GREEN + " normal");
this.addCommandExample("/mv create " + ChatColor.GOLD + "lavaland" + ChatColor.RED + " nether");
this.addCommandExample("/mv create " + ChatColor.GOLD + "starwars" + ChatColor.AQUA + " skylands");
this.addCommandExample("/mv create " + ChatColor.GOLD + "gargamel" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " -s gargamel");
this.addCommandExample("/mv create " + ChatColor.GOLD + "moonworld" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " -g BukkitFullOfMoon");
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.size() % 2 != 0) {
sender.sendMessage("You must preface your SEED with -s OR your GENERATOR with -g. Type /mv for help");
return;
}
String worldName = args.get(0);
String env = args.get(1);
String seed = CommandHandler.getFlag("-s", args);
String generator = CommandHandler.getFlag("-g", args);
if (new File(worldName).exists() || this.worldManager.isMVWorld(worldName)) {
sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
sender.sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
return;
}
Environment environment = this.plugin.getEnvFromString(env);
if (environment == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
EnvironmentCommand.showEnvironments(sender);
return;
}
sender.sendMessage(ChatColor.AQUA + "Starting world creation...");
if (this.worldManager.addWorld(worldName, environment, seed, generator)) {
sender.sendMessage(ChatColor.GREEN + "Complete!");
} else {
sender.sendMessage(ChatColor.RED + "FAILED.");
}
}
}
@@ -0,0 +1,61 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
import java.util.logging.Level;
public class DebugCommand extends MultiverseCommand {
public DebugCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Turn Debug on/off?");
this.setCommandUsage("/mv debug" + ChatColor.GOLD + " [1|2|3|off]");
this.setArgRange(0, 1);
this.addKey("mv debug");
this.addKey("mv d");
this.addKey("mvdebug");
this.addCommandExample("/mv debug " + ChatColor.GOLD + "2");
this.setPermission("multiverse.core.debug", "Spams the console a bunch.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.size() == 1) {
if (args.get(0).equalsIgnoreCase("off")) {
MultiverseCore.GlobalDebug = 0;
} else {
try {
int debugLevel = Integer.parseInt(args.get(0));
if (debugLevel > 3 || debugLevel < 0) {
throw new NumberFormatException();
}
MultiverseCore.GlobalDebug = debugLevel;
} catch (NumberFormatException e) {
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE + " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
}
}
}
this.displayDebugMode(sender);
}
private void displayDebugMode(CommandSender sender) {
if (MultiverseCore.GlobalDebug == 0) {
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
} else {
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + MultiverseCore.GlobalDebug);
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED");
}
}
}
@@ -0,0 +1,37 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
public class DeleteCommand extends MultiverseCommand {
public DeleteCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Delete World");
this.setCommandUsage("/mv delete" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvdelete");
this.addKey("mv delete");
this.addCommandExample("/mv create " + ChatColor.GOLD + "MyWorld");
this.setPermission("multiverse.core.delete", "Deletes a world on your server. " + ChatColor.RED + "PERMANENTLY.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Class<?> paramTypes[] = {String.class};
List<Object> objectArgs = new ArrayList<Object>(args);
this.plugin.getCommandHandler().queueCommand(sender, "mvdelete", "deleteWorld", objectArgs, paramTypes, ChatColor.GREEN + "World Deleted!", ChatColor.RED + "World could NOT be deleted!");
}
}
@@ -0,0 +1,43 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
public class EnvironmentCommand extends MultiverseCommand {
public EnvironmentCommand(MultiverseCore plugin) {
super(plugin);
this.setName("List Environments");
this.setCommandUsage("/mv env");
this.setArgRange(0, 0);
this.addKey("mvenv");
this.addKey("mv env");
this.addKey("mv environment");
this.addKey("mv environments");
this.addCommandExample("/mv env");
this.setPermission("multiverse.core.list.environments", "Lists valid known environments.", PermissionDefault.OP);
}
public static void showEnvironments(CommandSender sender) {
sender.sendMessage(ChatColor.YELLOW + "Valid Environments are:");
sender.sendMessage(ChatColor.GREEN + "NORMAL");
sender.sendMessage(ChatColor.RED + "NETHER");
sender.sendMessage(ChatColor.AQUA + "SKYLANDS");
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
EnvironmentCommand.showEnvironments(sender);
}
}
@@ -0,0 +1,62 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.Plugin;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
public class GeneratorCommand extends MultiverseCommand {
public GeneratorCommand(MultiverseCore plugin) {
super(plugin);
this.setName("World Information");
this.setCommandUsage("/mv generators");
this.setArgRange(0, 0);
this.addKey("mv generators");
this.addKey("mvgenerators");
this.addKey("mv gens");
this.addKey("mvgens");
this.addCommandExample("/mv generators");
this.setPermission("multiverse.core.generator", "Returns a list of Loaded Generator Plugins.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
this.plugin.log(Level.INFO, "PLEASE IGNORE the 'Plugin X does not contain any generators' message below!");
Plugin[] plugins = this.plugin.getServer().getPluginManager().getPlugins();
List<String> generators = new ArrayList<String>();
for (Plugin p : plugins) {
if (p.isEnabled() && p.getDefaultWorldGenerator("world", "") != null) {
generators.add(p.getDescription().getName());
}
}
sender.sendMessage(ChatColor.AQUA + "--- Loaded Generator Plugins ---");
String loadedGens = "";
boolean altColor = false;
for (String s : generators) {
if (altColor) {
altColor = false;
loadedGens += ChatColor.YELLOW + s + "";
} else {
altColor = true;
loadedGens += ChatColor.WHITE + s + "";
}
}
if (loadedGens.length() == 0) {
loadedGens = ChatColor.RED + "No Generator Plugins found.";
}
sender.sendMessage(loadedGens);
}
}
@@ -0,0 +1,134 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
// This file is no longer licensed under that silly CC license. I have blanked it out and will start implementaiton of my own in a few days. For now there is no help.
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.pneumaticraft.commandhandler.Command;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
public class HelpCommand extends MultiverseCommand {
private static final int CMDS_PER_PAGE = 7;
public HelpCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Get Help with Multiverse");
this.setCommandUsage("/mv " + ChatColor.GOLD + "[FILTER] [PAGE #]");
this.setArgRange(0, 2);
this.addKey("mv");
this.addKey("mvh");
this.addKey("mvhelp");
this.addKey("mv help");
this.addKey("mvsearch");
this.addKey("mv search");
this.addCommandExample("/mv help ?");
this.setPermission("multiverse.help", "Displays a nice help menu.", PermissionDefault.TRUE);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
sender.sendMessage(ChatColor.AQUA + "====[ Multiverse Help ]====");
int page = 1;
String filter = "";
if (args.size() == 0) {
filter = "";
page = 1;
} else if (args.size() == 1) {
try {
page = Integer.parseInt(args.get(0));
} catch (NumberFormatException ex) {
filter = args.get(0);
page = 1;
}
} else if (args.size() == 2) {
filter = args.get(0);
try {
page = Integer.parseInt(args.get(1));
} catch (NumberFormatException ex) {
page = 1;
}
}
List<Command> availableCommands = new ArrayList<Command>(this.plugin.getCommandHandler().getCommands(sender));
if (filter.length() > 0) {
availableCommands = this.getFilteredCommands(availableCommands, filter);
if (availableCommands.size() == 0) {
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE + "No commands matched your filter: " + ChatColor.AQUA + filter);
return;
}
}
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.AQUA + " Add a '" + ChatColor.DARK_PURPLE + "?" + ChatColor.AQUA + "' after a command to see more about it.");
for (Command c : availableCommands) {
sender.sendMessage(ChatColor.AQUA + c.getCommandUsage());
}
return;
}
int totalPages = (int) Math.ceil(availableCommands.size() / (CMDS_PER_PAGE + 0.0));
if (page > totalPages) {
page = totalPages;
}
sender.sendMessage(ChatColor.AQUA + " Page " + page + " of " + totalPages);
sender.sendMessage(ChatColor.AQUA + " Add a '" + ChatColor.DARK_PURPLE + "?" + ChatColor.AQUA + "' after a command to see more about it.");
this.showPage(page, sender, availableCommands);
}
private List<Command> getFilteredCommands(List<Command> availableCommands, String filter) {
List<Command> filtered = new ArrayList<Command>();
for (Command c : availableCommands) {
if (stitchThisString(c.getKeyStrings()).matches("(?i).*" + filter + ".*")) {
filtered.add(c);
} else if (c.getCommandName().matches("(?i).*" + filter + ".*")) {
filtered.add(c);
} else if (c.getCommandDesc().matches("(?i).*" + filter + ".*")) {
filtered.add(c);
} else if (c.getCommandUsage().matches("(?i).*" + filter + ".*")) {
filtered.add(c);
}
}
return filtered;
}
private String stitchThisString(List<String> list) {
String returnstr = "";
for (String s : list) {
returnstr += s + " ";
}
return returnstr;
}
private void showPage(int page, CommandSender sender, List<Command> cmds) {
int start = (page - 1) * CMDS_PER_PAGE;
int end = start + CMDS_PER_PAGE;
for (int i = start; i < end; i++) {
// For consistancy, print some extra lines if it's a player:
if (i < cmds.size()) {
sender.sendMessage(ChatColor.AQUA + cmds.get(i).getCommandUsage());
} else if (sender instanceof Player) {
sender.sendMessage(" ");
}
}
}
}
@@ -0,0 +1,73 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.io.File;
import java.util.List;
public class ImportCommand extends MultiverseCommand {
private WorldManager worldManager;
public ImportCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Import World");
this.setCommandUsage("/mv import" + ChatColor.GREEN + " {NAME} {ENV} " + ChatColor.GOLD + "[GENERATOR[:ID]]");
this.setArgRange(2, 3);
this.addKey("mvimport");
this.addKey("mvim");
this.addKey("mv import");
this.addCommandExample("/mv import " + ChatColor.GOLD + "gargamel" + ChatColor.GREEN + " normal");
this.addCommandExample("/mv import " + ChatColor.GOLD + "hell_world" + ChatColor.GREEN + " nether");
this.addCommandExample("/mv import " + ChatColor.GOLD + "CleanRoom" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " CleanRoomGenerator");
this.setPermission("multiverse.core.import", "Imports a new world of the specified type.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
String worldName = args.get(0);
if (this.worldManager.isMVWorld(worldName) && new File(worldName).exists()) {
sender.sendMessage(ChatColor.RED + "Multiverse already knows about this world!");
return;
}
String generator = null;
if (args.size() == 3) {
generator = args.get(2);
}
String env = args.get(1);
Environment environment = this.plugin.getEnvFromString(env);
if (environment == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid environment.");
EnvironmentCommand.showEnvironments(sender);
return;
}
if (new File(worldName).exists() && env != null) {
sender.sendMessage(ChatColor.AQUA + "Starting world import...");
this.worldManager.addWorld(worldName, environment, null, generator);
sender.sendMessage(ChatColor.GREEN + "Complete!");
return;
} else if (env == null) {
sender.sendMessage(ChatColor.RED + "FAILED.");
sender.sendMessage("That world type did not exist.");
sender.sendMessage("For a list of available world types, type: /mvenv");
} else {
sender.sendMessage(ChatColor.RED + "FAILED.");
sender.sendMessage("That world folder does not exist...");
}
}
}
@@ -0,0 +1,249 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.FancyText;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.*;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
// Will use when we can compile with JDK 6
//import com.sun.xml.internal.ws.util.StringUtils;
public class InfoCommand extends MultiverseCommand {
private WorldManager worldManager;
public InfoCommand(MultiverseCore plugin) {
super(plugin);
this.setName("World Information");
this.setCommandUsage("/mv info" + ChatColor.GOLD + " [WORLD] [PAGE]");
this.setArgRange(0, 2);
this.addKey("mvinfo");
this.addKey("mvi");
this.addKey("mv info");
this.addCommandExample("/mv info " + ChatColor.GOLD + "1");
this.addCommandExample("/mv info " + ChatColor.GOLD + "3");
this.setPermission("multiverse.core.info", "Returns detailed information on the world.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Check if the command was sent from a Player.
String worldName = "";
int pageNum = 0;
if (args.size() == 0) {
if (sender instanceof Player) {
Player p = (Player) sender;
worldName = p.getWorld().getName();
} else {
sender.sendMessage("You must enter a" + ChatColor.LIGHT_PURPLE + " world" + ChatColor.WHITE + " from the console!");
return;
}
} else if (args.size() == 1) {
if (this.worldManager.getMVWorld(args.get(0)) != null) {
// then we have a world!
worldName = args.get(0);
} else {
if (sender instanceof Player) {
Player p = (Player) sender;
worldName = p.getWorld().getName();
try {
pageNum = Integer.parseInt(args.get(0)) - 1;
} catch (NumberFormatException e) {
pageNum = 0;
}
} else {
sender.sendMessage("You must enter a" + ChatColor.LIGHT_PURPLE + " world" + ChatColor.WHITE + " from the console!");
return;
}
}
} else if (args.size() == 2) {
worldName = args.get(0);
try {
pageNum = Integer.parseInt(args.get(1)) - 1;
} catch (NumberFormatException e) {
pageNum = 0;
}
}
if (this.worldManager.isMVWorld(worldName)) {
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
showPage(pageNum, sender, this.buildEntireCommand(this.worldManager.getMVWorld(worldName), p));
} else if (this.plugin.getServer().getWorld(worldName) != null) {
sender.sendMessage("That world exists, but multiverse does not know about it!");
sender.sendMessage("You can import it with" + ChatColor.AQUA + "/mv import " + ChatColor.GREEN + worldName + ChatColor.LIGHT_PURPLE + "{ENV}");
sender.sendMessage("For available environments type " + ChatColor.GREEN + "/mv env");
}
}
private List<List<FancyText>> buildEntireCommand(MultiverseWorld world, Player p) {
List<FancyText> message = new ArrayList<FancyText>();
List<List<FancyText>> worldInfo = new ArrayList<List<FancyText>>();
// Page 1
FancyColorScheme colors = new FancyColorScheme(ChatColor.AQUA, ChatColor.AQUA, ChatColor.GOLD, ChatColor.WHITE);
message.add(new FancyHeader("General Info", colors));
message.add(new FancyMessage("World Name: ", world.getName(), colors));
message.add(new FancyMessage("World Alias: ", world.getColoredWorldString(), colors));
String enforced = "";
if (!MultiverseCore.EnforceGameModes) {
enforced = ChatColor.RED + " Not Enforced!";
}
message.add(new FancyMessage("Game Mode: ", world.getGameMode() + enforced, colors));
//message.add(new FancyMessage("Game Mode: ", StringUtils.capitalize(world.getGameMode().toString()), colors));
Location spawn = world.getSpawnLocation();
message.add(new FancyMessage("Spawn Location: ", LocationManipulation.strCoords(spawn), colors));
message.add(new FancyMessage("World Scale: ", world.getScaling() + "", colors));
if (world.getPrice() > 0) {
message.add(new FancyMessage("Price to enter this world: ", this.plugin.getBank().getFormattedAmount(p, world.getPrice(), world.getCurrency()), colors));
} else {
message.add(new FancyMessage("Price to enter this world: ", ChatColor.GREEN + "FREE!", colors));
}
if (world.getRespawnToWorld() != null) {
MultiverseWorld respawn = this.worldManager.getMVWorld(world.getRespawnToWorld());
if (respawn != null) {
message.add(new FancyMessage("Players will respawn in: ", respawn.getColoredWorldString(), colors));
} else {
message.add(new FancyMessage("Players will respawn in: ", ChatColor.RED + "!!INVALID!!", colors));
}
}
worldInfo.add(message);
// Page 2
message = new ArrayList<FancyText>();
message.add(new FancyHeader("More World Settings", colors));
message.add(new FancyMessage("Difficulty: ", world.getDifficulty().toString(), colors));
message.add(new FancyMessage("Weather: ", world.isWeatherEnabled() + "", colors));
message.add(new FancyMessage("Players will get hungry: ", world.getHunger() + "", colors));
message.add(new FancyMessage("Keep spawn in memory: ", world.isKeepingSpawnInMemory() + "", colors));
message.add(new FancyHeader("PVP Settings", colors));
message.add(new FancyMessage("Multiverse Setting: ", world.isPVPEnabled() + "", colors));
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getPVP() + "", colors));
message.add(new FancyMessage("Fake PVP Enabled: ", world.getFakePVP() + "", colors));
worldInfo.add(message);
// Page 3
message = new ArrayList<FancyText>();
message.add(new FancyHeader("Monster Settings", colors));
message.add(new FancyMessage("Multiverse Setting: ", world.canMonstersSpawn() + "", colors));
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getAllowMonsters() + "", colors));
if (MultiverseCore.MobsDisabledInDefaultWorld) {
message.add(new FancyMessage(ChatColor.RED + "WARNING: ", "Monsters WILL NOT SPAWN IN THIS WORLD.", colors));
message.add(new FancyMessage(ChatColor.RED + "WARNING: ", "Check your server log for more details.", colors));
}
if (world.getMonsterList().size() > 0) {
if (world.canMonstersSpawn()) {
message.add(new FancyMessage("Monsters that" + ChatColor.RED + " CAN NOT " + ChatColor.GREEN + "spawn: ", toCommaSeperated(world.getMonsterList()), colors));
} else {
message.add(new FancyMessage("Monsters that" + ChatColor.GREEN + " CAN SPAWN: ", toCommaSeperated(world.getMonsterList()), colors));
}
} else {
message.add(new FancyMessage("Monsters that CAN spawn: ", world.canMonstersSpawn() ? "ALL" : "NONE", colors));
}
worldInfo.add(message);
// Page 4
message = new ArrayList<FancyText>();
message.add(new FancyHeader("Animal Settings", colors));
message.add(new FancyMessage("Multiverse Setting: ", world.canAnimalsSpawn() + "", colors));
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getAllowAnimals() + "", colors));
if (world.getMonsterList().size() > 0) {
if (world.canMonstersSpawn()) {
message.add(new FancyMessage("Animals that" + ChatColor.RED + " CAN NOT " + ChatColor.GREEN + "spawn: ", toCommaSeperated(world.getAnimalList()), colors));
} else {
message.add(new FancyMessage("Animals that" + ChatColor.GREEN + " CAN SPAWN: ", toCommaSeperated(world.getAnimalList()), colors));
}
} else {
message.add(new FancyMessage("Animals that CAN spawn: ", world.canAnimalsSpawn() ? "ALL" : "NONE", colors));
}
worldInfo.add(message);
return worldInfo;
}
private String toCommaSeperated(List<String> list) {
if (list == null || list.size() == 0) {
return "";
}
if (list.size() == 1) {
return list.get(0);
}
String result = list.get(0);
for (int i = 1; i < list.size() - 1; i++) {
result += ", " + list.get(i);
}
result += " and " + list.get(list.size() - 1);
return result;
}
protected ChatColor getChatColor(boolean positive) {
return positive ? ChatColor.GREEN : ChatColor.RED;
}
private void showPage(int page, CommandSender sender, List<List<FancyText>> doc) {
page = page < 0 ? 0 : page;
page = page > doc.size() - 1 ? doc.size() - 1 : page;
boolean altColor = false;
boolean appendedPageNum = false;
if (sender instanceof Player) {
List<FancyText> list = doc.get(page);
for (FancyText fancyT : list) {
if (fancyT instanceof FancyMessage) {
FancyMessage text = (FancyMessage) fancyT;
text.setAltColor(altColor);
altColor = !altColor;
sender.sendMessage(text.getFancyText());
} else if (fancyT instanceof FancyHeader) {
FancyHeader text = (FancyHeader) fancyT;
if (!appendedPageNum) {
text.appendText(ChatColor.DARK_PURPLE + " [ Page " + (page + 1) + " of " + doc.size() + " ]");
appendedPageNum = true;
}
sender.sendMessage(text.getFancyText());
altColor = false;
}
}
} else {
for (List<FancyText> list : doc) {
for (FancyText fancyT : list) {
if (fancyT instanceof FancyMessage) {
FancyMessage text = (FancyMessage) fancyT;
text.setAltColor(altColor);
altColor = !altColor;
sender.sendMessage(text.getFancyText());
} else {
FancyText text = fancyT;
if (appendedPageNum) {
sender.sendMessage(" ");
} else {
appendedPageNum = true;
}
sender.sendMessage(text.getFancyText());
altColor = false;
}
}
}
}
}
}
@@ -0,0 +1,73 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
public class ListCommand extends MultiverseCommand {
public ListCommand(MultiverseCore plugin) {
super(plugin);
this.setName("World Listing");
this.setCommandUsage("/mv list");
this.setArgRange(0, 0);
this.addKey("mvlist");
this.addKey("mvl");
this.addKey("mv list");
this.setPermission("multiverse.core.list.worlds", "Displays a listing of all worlds that you can enter.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
String output = ChatColor.LIGHT_PURPLE + "Worlds which you can view:\n";
for (MultiverseWorld world : this.plugin.getMVWorldManager().getMVWorlds()) {
if (p != null && (!this.plugin.getMVPerms().canEnterWorld(p, world))) {
continue;
}
ChatColor color = ChatColor.GOLD;
Environment env = world.getEnvironment();
if (env == Environment.NETHER) {
color = ChatColor.RED;
} else if (env == Environment.NORMAL) {
color = ChatColor.GREEN;
} else if (env == Environment.SKYLANDS) {
color = ChatColor.AQUA;
}
String outputCache = world.getColoredWorldString() + ChatColor.WHITE + " - " + color + world.getEnvironment() + " \n";
if (world.isHidden()) {
// TODO: Add an actual permission for this.
if (p == null || p.isOp()) {
// Prefix hidden worlds with an "[H]"
outputCache = ChatColor.GRAY + "[H]" + outputCache;
output += outputCache;
}
} else {
output += outputCache;
}
}
String[] response = output.split("\n");
for (String msg : response) {
sender.sendMessage(msg);
}
}
}
@@ -0,0 +1,38 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
public class LoadCommand extends MultiverseCommand {
public LoadCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Load World");
this.setCommandUsage("/mv load" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvload");
this.addKey("mv load");
this.addCommandExample("/mv load " + ChatColor.GREEN + "MyUnloadedWorld");
this.setPermission("multiverse.core.load", "Loads a world into Multiverse.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (this.plugin.getMVWorldManager().loadWorld(args.get(0))) {
sender.sendMessage("World Loaded!");
} else {
sender.sendMessage("Error trying to load world!");
}
}
}
@@ -0,0 +1,86 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.enums.Action;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
// This will contain all the properties that support the ADD/REMOVE
// Anything not in here will only support the SET action
public class ModifyAddCommand extends MultiverseCommand {
private WorldManager worldManager;
public ModifyAddCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World (Add a value)");
this.setCommandUsage("/mv modify " + ChatColor.GREEN + "add {VALUE} {PROPERTY}" + ChatColor.GOLD + " [WORLD] ");
this.setArgRange(2, 3);
this.addKey("mvm add");
this.addKey("mvmadd");
this.addKey("mv modify add");
this.addKey("mvmodify add");
this.addCommandExample("/mvm " + ChatColor.GOLD + "add " + ChatColor.GREEN + "sheep " + ChatColor.RED + "animals");
this.addCommandExample("/mvm " + ChatColor.GOLD + "add " + ChatColor.GREEN + "creeper " + ChatColor.RED + "monsters");
this.addCommandExample("/mvm " + ChatColor.GOLD + "add " + ChatColor.GREEN + "MyWorld " + ChatColor.RED + "worldblacklist");
this.setPermission("multiverse.core.modify.add", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// We NEED a world from the command line
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 2 && p == null) {
sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
MultiverseWorld world;
String value = args.get(0);
String property = args.get(1);
if (args.size() == 2) {
world = this.worldManager.getMVWorld(p.getWorld().getName());
} else {
world = this.worldManager.getMVWorld(args.get(2));
}
if (world == null) {
sender.sendMessage("That world does not exist!");
return;
}
if (!ModifyCommand.validateAction(Action.Add, property)) {
sender.sendMessage("Sorry, you can't ADD to " + property);
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
return;
}
if (world.addToVariable(property, value)) {
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + value + ChatColor.WHITE + " was " + ChatColor.GREEN + "added to " + ChatColor.GREEN + property);
} else {
sender.sendMessage(value + " could not be added to " + property);
}
}
}
@@ -0,0 +1,82 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.enums.Action;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
public class ModifyClearCommand extends MultiverseCommand {
private WorldManager worldManager;
public ModifyClearCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World (Clear a property)");
this.setCommandUsage("/mv modify" + ChatColor.GREEN + " clear {PROPERTY}" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(1, 2);
this.addKey("mvm clear");
this.addKey("mvmclear");
this.addKey("mv modify clear");
this.addKey("mvmodify clear");
this.addCommandExample("/mvm " + ChatColor.GOLD + "clear " + ChatColor.RED + "animals");
this.addCommandExample("/mvm " + ChatColor.GOLD + "clear " + ChatColor.RED + "monsters");
this.addCommandExample("/mvm " + ChatColor.GOLD + "clear " + ChatColor.RED + "worldblacklist");
this.setPermission("multiverse.core.modify.clear", "Removes all values from a property. This will work on properties that contain lists.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// We NEED a world from the command line
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 1 && p == null) {
sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
MultiverseWorld world;
String property = args.get(0);
if (args.size() == 1) {
world = this.worldManager.getMVWorld(p.getWorld().getName());
} else {
world = this.worldManager.getMVWorld(args.get(1));
}
if (world == null) {
sender.sendMessage("That world does not exist!");
return;
}
if (!ModifyCommand.validateAction(Action.Clear, property)) {
sender.sendMessage("Sorry, you can't use CLEAR with " + property);
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/cgB2B");
return;
}
if (world.clearList(property)) {
sender.sendMessage(property + " was cleared. It contains 0 values now.");
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + property + ChatColor.WHITE + " was " + ChatColor.GREEN + "CLEARED" + ChatColor.WHITE + ". It contains " + ChatColor.LIGHT_PURPLE + "0" + ChatColor.WHITE + " values now.");
} else {
sender.sendMessage(ChatColor.RED + "Error: " + ChatColor.GOLD + property + ChatColor.WHITE + " was " + ChatColor.GOLD + "NOT" + ChatColor.WHITE + " cleared.");
}
}
}
@@ -0,0 +1,68 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.enums.Action;
import com.onarandombox.MultiverseCore.enums.AddProperties;
import com.onarandombox.MultiverseCore.enums.SetProperties;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ModifyCommand extends MultiverseCommand {
public ModifyCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World");
this.setCommandUsage("/mv modify" + ChatColor.GREEN + " {set|add|remove|clear} ...");
this.setArgRange(2, 3);
this.addKey("mvm");
this.addKey("mvmodify");
this.addKey("mv modify");
Map<String, Boolean> children = new HashMap<String, Boolean>();
children.put("multiverse.core.modify.add", true);
children.put("multiverse.core.modify.modify", true);
children.put("multiverse.core.modify.clear", true);
children.put("multiverse.core.modify.remove", true);
Permission modify = new Permission("multiverse.core.modify", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP, children);
this.setPermission(modify);
}
protected static boolean validateAction(Action action, String property) {
if (action == Action.Set) {
try {
SetProperties.valueOf(property);
return true;
} catch (IllegalArgumentException e) {
return false;
}
} else {
try {
AddProperties.valueOf(property);
return true;
} catch (IllegalArgumentException e) {
return false;
}
}
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// This is just a place holder. The real commands are in:
// ModifyAddCommand
// ModifyRemoveCommand
// ModifySetCommand
// ModifyClearCommand
}
}
@@ -0,0 +1,87 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.enums.Action;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
public class ModifyRemoveCommand extends MultiverseCommand {
private WorldManager worldManager;
public ModifyRemoveCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World (Remove a value)");
this.setCommandUsage("/mv modify" + ChatColor.GREEN + " remove {PROPERTY} {VALUE}" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(2, 3);
this.addKey("mvm remove");
this.addKey("mvmremove");
this.addKey("mv modify remove");
this.addKey("mvmodify remove");
this.addKey("mvm delete");
this.addKey("mvmdelete");
this.addKey("mv modify delete");
this.addKey("mvmodify delete");
this.addCommandExample("/mvm " + ChatColor.GOLD + "remove " + ChatColor.GREEN + "sheep " + ChatColor.RED + "animals");
this.addCommandExample("/mvm " + ChatColor.GOLD + "remove " + ChatColor.GREEN + "creeper " + ChatColor.RED + "monsters");
this.addCommandExample("/mvm " + ChatColor.GOLD + "remove " + ChatColor.GREEN + "MyWorld " + ChatColor.RED + "worldblacklist");
this.setPermission("multiverse.core.modify.remove", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// We NEED a world from the command line
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 2 && p == null) {
sender.sendMessage(ChatColor.RED + "From the console, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
MultiverseWorld world;
String value = args.get(0);
String property = args.get(1);
if (args.size() == 2) {
world = this.worldManager.getMVWorld(p.getWorld().getName());
} else {
world = this.worldManager.getMVWorld(args.get(2));
}
if (world == null) {
sender.sendMessage("That world does not exist!");
return;
}
if (!ModifyCommand.validateAction(Action.Remove, property)) {
sender.sendMessage("Sorry, you can't REMOVE anything from" + property);
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
return;
}
if (world.removeFromVariable(property, value)) {
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + value + ChatColor.WHITE + " was " + ChatColor.RED + "removed from " + ChatColor.GREEN + property);
} else {
sender.sendMessage(ChatColor.RED + "There was an error removing " + ChatColor.GRAY + value + ChatColor.WHITE + " from " + ChatColor.GOLD + property);
}
}
}
@@ -0,0 +1,109 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.enums.Action;
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
public class ModifySetCommand extends MultiverseCommand {
private WorldManager worldManager;
public ModifySetCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Modify a World (Set a value)");
this.setCommandUsage("/mv modify" + ChatColor.GREEN + " set {PROPERTY} {VALUE}" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(1, 3);
this.addKey("mvm set");
this.addKey("mvmset");
this.addKey("mv modify set");
this.addKey("mvmodify set");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "mode " + ChatColor.RED + "creative");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "animals " + ChatColor.RED + "false");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "monsters " + ChatColor.RED + "false");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "alias " + ChatColor.RED + "MyWorld");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "color " + ChatColor.RED + "green");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "curr " + ChatColor.RED + "3");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "price " + ChatColor.RED + "5");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "scale " + ChatColor.RED + "1.2");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "memory " + ChatColor.RED + "true");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "diff " + ChatColor.RED + "hard");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "hunger " + ChatColor.RED + "false");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "hidden " + ChatColor.RED + "true");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "pvp " + ChatColor.RED + "false");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "spawn");
this.setPermission("multiverse.core.modify.set", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Special case for spawn:
if (args.size() == 1) {
if (args.get(0).equalsIgnoreCase("spawn")) {
SetSpawnCommand c = new SetSpawnCommand(this.plugin);
c.setWorldSpawn(sender);
} else {
sender.sendMessage("Spawn is the only param with no" + ChatColor.GREEN + " VALUE");
sender.sendMessage("Type " + ChatColor.GREEN + "/mv modify ?" + ChatColor.WHITE + " For help.");
}
return;
}
// We NEED a world from the command line
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 2 && p == null) {
sender.sendMessage("From the command line, WORLD is required.");
sender.sendMessage(this.getCommandDesc());
sender.sendMessage(this.getCommandUsage());
sender.sendMessage("Nothing changed.");
return;
}
MultiverseWorld world;
String value = args.get(1);
String property = args.get(0);
if (args.size() == 2) {
world = this.worldManager.getMVWorld(p.getWorld().getName());
} else {
world = this.worldManager.getMVWorld(args.get(2));
}
if (world == null) {
sender.sendMessage("That world does not exist!");
return;
}
if (!ModifyCommand.validateAction(Action.Set, property)) {
sender.sendMessage("Sorry, you can't SET " + property);
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/l54PH");
return;
}
if ((property.equalsIgnoreCase("aliascolor") || property.equalsIgnoreCase("color")) && !world.isValidAliasColor(value)) {
sender.sendMessage(value + " is not a valid color. Please pick one of the following:");
sender.sendMessage(EnglishChatColor.getAllColors());
} else if (world.setVariable(property, value)) {
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + property + ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
} else {
sender.sendMessage(ChatColor.RED + "There was an error setting " + ChatColor.GRAY + property);
}
}
}
@@ -0,0 +1,28 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.pneumaticraft.commandhandler.Command;
import org.bukkit.command.CommandSender;
import java.util.List;
public abstract class MultiverseCommand extends Command {
protected MultiverseCore plugin;
public MultiverseCommand(MultiverseCore plugin) {
super(plugin);
this.plugin = plugin;
}
@Override
public abstract void runCommand(CommandSender sender, List<String> args);
}
@@ -0,0 +1,92 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class PurgeCommand extends MultiverseCommand {
private WorldManager worldManager;
public PurgeCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Purge World of Creatures");
this.setCommandUsage("/mv purge" + ChatColor.GOLD + " [WORLD|all] " + ChatColor.GREEN + "{all|animals|monsters|MOBNAME}");
this.setArgRange(1, 2);
this.addKey("mvpurge");
this.addKey("mv purge");
this.addCommandExample("/mv purge " + ChatColor.GREEN + "all");
this.addCommandExample("/mv purge " + ChatColor.GOLD + "all " + ChatColor.GREEN + "all");
this.addCommandExample("/mv purge " + ChatColor.GREEN + "monsters");
this.addCommandExample("/mv purge " + ChatColor.GOLD + "all " + ChatColor.GREEN + "animals");
this.addCommandExample("/mv purge " + ChatColor.GOLD + "MyWorld " + ChatColor.GREEN + "squid");
this.addCommandExample("/mv purge " + ChatColor.GOLD + "MyWorld_nether " + ChatColor.GREEN + "ghast");
this.setPermission("multiverse.core.purge", "Removed the specified type of mob from the specified world.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (args.size() == 1 && p == null) {
sender.sendMessage("This command requires a WORLD when being run from the console!");
sender.sendMessage(this.getCommandUsage());
return;
}
String worldName = null;
String deathName = null;
if (args.size() == 1) {
worldName = p.getWorld().getName();
deathName = args.get(0);
} else {
worldName = args.get(0);
deathName = args.get(1);
}
if (!worldName.equalsIgnoreCase("all") && !this.worldManager.isMVWorld(worldName)) {
((MultiverseCore) this.plugin).showNotMVWorldMessage(sender, worldName);
sender.sendMessage("It cannot be purged.");
return;
}
List<MultiverseWorld> worldsToRemoveEntitiesFrom = new ArrayList<MultiverseWorld>();
// Handle all case any user who names a world "all" should know better...
if (worldName.equalsIgnoreCase("all")) {
worldsToRemoveEntitiesFrom.addAll(this.worldManager.getMVWorlds());
} else {
worldsToRemoveEntitiesFrom.add(this.worldManager.getMVWorld(worldName));
}
PurgeWorlds purger = this.worldManager.getWorldPurger();
ArrayList<String> thingsToKill = new ArrayList<String>();
if (deathName.equalsIgnoreCase("all") || deathName.equalsIgnoreCase("animals") || deathName.equalsIgnoreCase("monsters")) {
thingsToKill.add(deathName.toUpperCase());
} else {
Collections.addAll(thingsToKill, deathName.toUpperCase().split(","));
}
for (MultiverseWorld w : worldsToRemoveEntitiesFrom) {
purger.purgeWorld(sender, w, thingsToKill, false, false);
}
return;
}
}
@@ -0,0 +1,52 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
public class ReloadCommand extends MultiverseCommand {
public ReloadCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Reload Configs");
this.setCommandUsage("/mv reload");
this.setArgRange(0, 0);
this.addKey("mvreload");
this.addKey("mv reload");
this.addCommandExample("/mv reload");
this.setPermission("multiverse.core.reload", "Reloads worlds.yml and config.yml.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
sender.sendMessage(ChatColor.GOLD + "Reloading all Multiverse Plugin configs...");
this.plugin.loadConfigs();
this.plugin.getMVWorldManager().loadWorlds(true);
List<String> configsLoaded = new ArrayList<String>();
configsLoaded.add("Multiverse-Core - config.yml");
configsLoaded.add("Multiverse-Core - worlds.yml");
// Create the event
MVConfigReloadEvent configReload = new MVConfigReloadEvent(configsLoaded);
// Fire it off
this.plugin.getServer().getPluginManager().callEvent(configReload);
for (String s : configReload.getAllConfigsLoaded()) {
sender.sendMessage(s);
}
sender.sendMessage(ChatColor.GREEN + "Reload Complete!");
}
}
@@ -0,0 +1,38 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
public class RemoveCommand extends MultiverseCommand {
public RemoveCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Remove World");
this.setCommandUsage("/mv remove" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvremove");
this.addKey("mv remove");
this.addCommandExample("/mv remove " + ChatColor.GREEN + "MyWorld");
this.setPermission("multiverse.core.remove", "Unloads a world from Multiverse and removes it from worlds.yml, this does NOT DELETE the world folder.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (this.plugin.getMVWorldManager().removeWorldFromConfig(args.get(0))) {
sender.sendMessage("World removed from config!");
} else {
sender.sendMessage("Error trying to remove world from config!");
}
}
}
@@ -0,0 +1,60 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
public class SetSpawnCommand extends MultiverseCommand {
public SetSpawnCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Set World Spawn");
this.setCommandUsage("/mv setspawn");
this.setArgRange(0, 0);
this.addKey("mvsetspawn");
this.addKey("mvss");
this.addKey("mv set spawn");
this.addKey("mv setspawn");
this.addKey("mvset spawn");
this.addCommandExample("/mv set spawn");
this.setPermission("multiverse.core.spawn.set", "Sets the spawn for the current world.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
setWorldSpawn(sender);
}
protected void setWorldSpawn(CommandSender sender) {
if (sender instanceof Player) {
Player p = (Player) sender;
Location l = p.getLocation();
World w = p.getWorld();
MultiverseWorld foundWorld = this.plugin.getMVWorldManager().getMVWorld(w.getName());
if (foundWorld != null) {
foundWorld.setSpawnLocation(p.getLocation());
sender.sendMessage("Spawn was set to: " + LocationManipulation.strCoords(p.getLocation()));
} else {
w.setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
sender.sendMessage("Multiverse does not know about this world, only X,Y and Z set. Please import it to set the spawn fully (Pitch/Yaws).");
}
} else {
sender.sendMessage("You cannot use this command from the console.");
}
}
}
@@ -0,0 +1,39 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
public class SleepCommand extends MultiverseCommand {
public SleepCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Go to Sleep");
this.setCommandUsage("/mv sleep");
this.setArgRange(0, 0);
this.addKey("mv sleep");
this.setPermission("multiverse.core.sleep", "Takes you the latest bed you've slept in (Currently BROKEN).", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
if (p == null) {
return;
}
}
}
@@ -0,0 +1,86 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
public class SpawnCommand extends MultiverseCommand {
public SpawnCommand(MultiverseCore plugin) {
super(plugin);
Permission otherPerm = new Permission("multiverse.core.spawn.other", "Teleports another player to the spawn of the world they are in.", PermissionDefault.OP);
this.setName("Spawn");
this.setCommandUsage("/mv spawn" + ChatColor.GOLD + " [PLAYER]");
this.setArgRange(0, 1);
this.addKey("mvspawn");
this.addKey("mv spawn");
this.addKey("mvs");
this.setPermission("multiverse.core.spawn.self", "Teleports you to the Spawn Point of the world you are in.", PermissionDefault.OP);
this.addAdditonalPermission(otherPerm);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
// If a persons name was passed in, you must be A. the console, or B have permissions
if (args.size() == 1) {
if (player != null && !this.plugin.getMVPerms().hasPermission(player, "multiverse.core.spawn.other", true)) {
sender.sendMessage("You don't have permission to teleport another player to spawn. (multiverse.core.spawn.other)");
return;
}
Player target = this.plugin.getServer().getPlayer(args.get(0));
if (target != null) {
target.sendMessage("Teleporting to this world's spawn...");
spawnAccurately(target);
if (player != null) {
target.sendMessage("You were teleported by: " + ChatColor.YELLOW + player.getName());
} else {
target.sendMessage("You were teleported by: " + ChatColor.LIGHT_PURPLE + "the console");
}
} else {
sender.sendMessage(args.get(0) + " is not logged on right now!");
}
} else {
if (player != null && !this.plugin.getMVPerms().hasPermission(player, "multiverse.core.spawn.self", true)) {
sender.sendMessage("You don't have permission to teleport yourself to spawn. (multiverse.core.spawn.self)");
return;
}
if (player != null) {
player.sendMessage("Teleporting to this world's spawn...");
spawnAccurately(player);
} else {
sender.sendMessage("From the console, you must provide a PLAYER.");
}
}
}
private void spawnAccurately(Player player) {
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(player.getWorld().getName());
Location spawnLocation;
if (world != null) {
spawnLocation = world.getSpawnLocation();
} else {
spawnLocation = player.getWorld().getSpawnLocation();
}
this.plugin.getTeleporter().safelyTeleport(player, player, spawnLocation, false);
}
}
@@ -0,0 +1,59 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import org.getspout.spoutapi.gui.GenericButton;
import org.getspout.spoutapi.gui.GenericPopup;
import org.getspout.spoutapi.gui.PopupScreen;
import org.getspout.spoutapi.player.SpoutPlayer;
import java.util.List;
public class SpoutCommand extends MultiverseCommand {
public SpoutCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Edit World with Spout");
this.setCommandUsage("/mv spout");
this.setArgRange(0, 0);
this.addKey("mv spout");
this.setPermission("multiverse.core.spout", "Edit a world with spout.", PermissionDefault.OP);
this.addCommandExample("/mv spout");
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command must be run as a player!");
return;
}
if (plugin.getSpout() == null) {
sender.sendMessage(ChatColor.RED + "You need spout installed on this server to use it with Multiverse!");
return;
}
SpoutPlayer p = (SpoutPlayer) sender;
if (!p.isSpoutCraftEnabled()) {
sender.sendMessage(ChatColor.RED + p.getName() + "You need to be using the Spoutcraft client to run this command!");
return;
}
PopupScreen pop = new GenericPopup();
GenericButton button = new GenericButton("Fish");
button.setX(50);
button.setY(50);
button.setWidth(100);
button.setHeight(40);
pop.attachWidget(this.plugin, button);
sender.sendMessage(ChatColor.GREEN + "YAY!");
p.getMainScreen().attachPopupScreen(pop);
}
}
@@ -0,0 +1,182 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
import com.onarandombox.MultiverseCore.destination.WorldDestination;
import com.onarandombox.MultiverseCore.event.MVTeleportEvent;
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import com.onarandombox.MultiverseCore.utils.MVMessaging;
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
public class TeleportCommand extends MultiverseCommand {
private SafeTTeleporter playerTeleporter;
public TeleportCommand(MultiverseCore plugin) {
super(plugin);
Permission menu = new Permission("multiverse.teleport.*", "Allows you to display the teleport menu.", PermissionDefault.OP);
this.setName("Teleport");
this.setCommandUsage("/mv tp " + ChatColor.GOLD + "[PLAYER]" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 2);
this.addKey("mvtp");
this.addKey("mv tp");
this.playerTeleporter = new SafeTTeleporter(this.plugin);
this.setPermission(menu);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Check if the command was sent from a Player.
CommandSender teleporter = sender;
Player teleportee = null;
if (sender instanceof Player) {
teleporter = (Player) sender;
}
String destinationName;
if (args.size() == 2) {
teleportee = this.plugin.getServer().getPlayer(args.get(0));
if (teleportee == null) {
sender.sendMessage("Sorry, I couldn't find player: " + args.get(0));
return;
}
destinationName = args.get(1);
} else {
destinationName = args.get(0);
if (!(sender instanceof Player)) {
sender.sendMessage("From the console, you must specify a player to teleport");
return;
}
teleportee = (Player) sender;
}
// Special case for cannons:
if (destinationName.matches("(?i)cannon-[\\d]+(\\.[\\d]+)?")) {
String[] cannonSpeed = destinationName.split("-");
try {
double speed = Double.parseDouble(cannonSpeed[1]);
destinationName = "ca:" + teleportee.getWorld().getName() + ":" + teleportee.getLocation().getX() + "," + teleportee.getLocation().getY() + "," + teleportee.getLocation().getZ() + ":" + teleportee.getLocation().getPitch() + ":" + teleportee.getLocation().getYaw() + ":" + speed;
} catch (Exception e) {
destinationName = "i:invalid";
}
}
DestinationFactory df = this.plugin.getDestFactory();
MVDestination d = df.getDestination(destinationName);
MVTeleportEvent teleportEvent = new MVTeleportEvent(d, teleportee, teleporter, true);
this.plugin.getServer().getPluginManager().callEvent(teleportEvent);
if (teleportEvent.isCancelled()) {
this.plugin.log(Level.FINE, "Someone else cancelled the MVTeleport Event!!!");
return;
}
if (d != null && d instanceof InvalidDestination) {
sender.sendMessage("Multiverse does not know how to take you to: " + ChatColor.RED + destinationName);
return;
}
if (!this.checkSendPermissions(teleporter, teleportee, d)) {
return;
}
if (MultiverseCore.EnforceAccess && teleporter != null && !this.plugin.getMVPerms().canEnterDestination(teleporter, d)) {
if (teleportee.equals(teleporter)) {
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
} else {
teleporter.sendMessage("Doesn't look like you're allowed to send " + ChatColor.GOLD + teleportee.getName() + ChatColor.WHITE + " to " + ChatColor.RED + "there...");
}
return;
} else if (teleporter != null && !this.plugin.getMVPerms().canTravelFromLocation(teleporter, d.getLocation(teleportee))) {
if (teleportee.equals(teleporter)) {
teleporter.sendMessage("DOH! Doesn't look like you can get to " + ChatColor.RED + "THERE from " + ChatColor.GREEN + ((Player) teleporter).getWorld().getName());
} else {
teleporter.sendMessage("DOH! Doesn't look like " + ChatColor.GREEN + ((Player) teleporter).getWorld().getName() + " can get to " + ChatColor.RED + "THERE from where they are...");
}
return;
}
// Special check to verify if players are tryint to teleport to the same
// WORLDDestination as the world they're in, that they ALSO have multiverse.core.spawn.self
if (d instanceof WorldDestination) {
World w = d.getLocation(teleportee).getWorld();
if (teleportee.getWorld().equals(w)) {
if (teleporter.equals(teleportee)) {
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.self", true)) {
teleporter.sendMessage("Sorry you don't have permission to go to the world spawn!");
teleporter.sendMessage(ChatColor.RED + " (multiverse.core.spawn.self)");
return;
}
} else {
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.other", true)) {
teleporter.sendMessage("Sorry you don't have permission to send " + teleportee.getDisplayName() + "to the world spawn!");
teleporter.sendMessage(ChatColor.RED + " (multiverse.core.spawn.other)");
return;
}
}
}
}
if (d.getLocation(teleportee) == null) {
teleporter.sendMessage("Sorry Boss, I tried everything, but just couldn't teleport ya there!");
return;
}
if (!this.playerTeleporter.safelyTeleport(teleporter, teleportee, d)) {
this.plugin.log(Level.FINE, "Could not teleport " + teleportee.getName() + " to " + LocationManipulation.strCoordsRaw(d.getLocation(teleportee)));
this.plugin.log(Level.FINE, "Queueing Command");
Class<?> paramTypes[] = {CommandSender.class, Player.class, Location.class};
List<Object> items = new ArrayList<Object>();
items.add(teleporter);
items.add(teleportee);
items.add(d.getLocation(teleportee));
String player = "you";
if (!teleportee.equals(teleporter)) {
player = teleportee.getName();
}
String message = ChatColor.GREEN + "Multiverse" + ChatColor.WHITE + " did not teleport " + ChatColor.AQUA + player + ChatColor.WHITE + " to " + ChatColor.DARK_AQUA + d.getName() + ChatColor.WHITE + " because it was unsafe.";
this.plugin.getCommandHandler().queueCommand(sender, "mvteleport", "teleportPlayer", items, paramTypes, message, "Would you like to try anyway?", "", "", 15);
} else {
// Player was teleported successfully (or the tp event was fired I should say);
}
}
private boolean checkSendPermissions(CommandSender teleporter, Player teleportee, MVDestination destination) {
MVMessaging message = this.plugin.getMessaging();
if (teleporter.equals(teleportee)) {
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.teleport.self." + destination.getIdentifier(), true)) {
message.sendMessages(teleporter, new String[]{"You don't have permission to teleport yourself to a " + ChatColor.GREEN + destination.getType() + " Destination.", ChatColor.RED + " (multiverse.teleport.self." + destination.getIdentifier() + ")"});
return false;
}
} else {
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.teleport.other." + destination.getIdentifier(), true)) {
message.sendMessages(teleporter, new String[]{"You don't have permission to teleport another player to a " + ChatColor.GREEN + destination.getType() + " Destination.", ChatColor.RED + " (multiverse.teleport.other." + destination.getIdentifier() + ")"});
return false;
}
}
return true;
}
}
@@ -0,0 +1,37 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
public class UnloadCommand extends MultiverseCommand {
public UnloadCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Unload World");
this.setCommandUsage("/mv unload" + ChatColor.GREEN + " {WORLD}");
this.setArgRange(1, 1);
this.addKey("mvunload");
this.addKey("mv unload");
this.setPermission("multiverse.core.unload", "Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (this.plugin.getMVWorldManager().unloadWorld(args.get(0))) {
sender.sendMessage("World Unloaded!");
} else {
sender.sendMessage("Error trying to unload world!");
}
}
}
@@ -0,0 +1,115 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.event.MVVersionRequestEvent;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
public class VersionCommand extends MultiverseCommand {
public VersionCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Multiverse Version");
this.setCommandUsage("/mv version " + ChatColor.GOLD + "-p");
this.setArgRange(0, 1);
this.addKey("mv version");
this.addKey("mvv");
this.addKey("mvversion");
this.setPermission("multiverse.core.version", "Dumps version info to the console, optionally to pastebin.com with a -p.", PermissionDefault.TRUE);
}
private String pasteBinBuffer = "";
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Check if the command was sent from a Player.
if (sender instanceof Player) {
sender.sendMessage("Version info dumped to console. Please check your server logs.");
}
logAndAddToPasteBinBuffer("Multiverse-Core Version: " + this.plugin.getDescription().getVersion());
logAndAddToPasteBinBuffer("Bukkit Version: " + this.plugin.getServer().getVersion());
logAndAddToPasteBinBuffer("Loaded Worlds: " + this.plugin.getMVWorldManager().getMVWorlds().size());
logAndAddToPasteBinBuffer("Multiverse Plugins Loaded: " + this.plugin.getPluginCount());
logAndAddToPasteBinBuffer("Economy being used: " + this.plugin.getBank().getEconUsed());
logAndAddToPasteBinBuffer("Permissions Plugin: " + this.plugin.getMVPerms().getType());
logAndAddToPasteBinBuffer("Dumping Config Values: (version " + this.plugin.getMVConfiguration().getString("version", "NOT SET") + ")");
logAndAddToPasteBinBuffer("messagecooldown: " + "Not yet IMPLEMENTED");
logAndAddToPasteBinBuffer("teleportcooldown: " + "Not yet IMPLEMENTED");
logAndAddToPasteBinBuffer("worldnameprefix: " + MultiverseCore.PrefixChat);
logAndAddToPasteBinBuffer("enforceaccess: " + MultiverseCore.EnforceAccess);
logAndAddToPasteBinBuffer("enforcegamemodes: " + MultiverseCore.EnforceGameModes);
logAndAddToPasteBinBuffer("bedrespawn: " + MultiverseCore.BedRespawn);
logAndAddToPasteBinBuffer("debug: " + MultiverseCore.GlobalDebug);
logAndAddToPasteBinBuffer("Special Code: FRN002");
MVVersionRequestEvent versionEvent = new MVVersionRequestEvent(pasteBinBuffer);
this.plugin.getServer().getPluginManager().callEvent(versionEvent);
pasteBinBuffer = versionEvent.getPasteBinBuffer();
if (args.size() == 1 && args.get(0).equalsIgnoreCase("-p")) {
String pasteBinUrl = postToPasteBin();
sender.sendMessage("Version info dumped here: " + ChatColor.GREEN + pasteBinUrl);
this.plugin.log(Level.INFO, "Version info dumped here: " + pasteBinUrl);
}
}
private void logAndAddToPasteBinBuffer(String string) {
this.pasteBinBuffer += "[Multiverse-Core] " + string + "\n";
this.plugin.log(Level.INFO, string);
}
private String postToPasteBin() {
try {
String data = URLEncoder.encode("api_dev_key", "UTF-8") + "=" + URLEncoder.encode("d61d68d31e8e0392b59b50b277411c71", "UTF-8");
data += "&" + URLEncoder.encode("api_option", "UTF-8") + "=" + URLEncoder.encode("paste", "UTF-8");
data += "&" + URLEncoder.encode("api_paste_code", "UTF-8") + "=" + URLEncoder.encode(this.pasteBinBuffer, "UTF-8");
data += "&" + URLEncoder.encode("api_paste_private", "UTF-8") + "=" + URLEncoder.encode("1", "UTF-8");
data += "&" + URLEncoder.encode("api_paste_format", "UTF-8") + "=" + URLEncoder.encode("yaml", "UTF-8");
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
data += "&" + URLEncoder.encode("api_paste_name", "UTF-8") + "=" + URLEncoder.encode("Multiverse 2 Dump " + dateFormat.format(date), "UTF-8");
data += "&" + URLEncoder.encode("api_user_key", "UTF-8") + "=" + URLEncoder.encode("c052ac52d2b0db88d36cc32ca462d151", "UTF-8");
URL url = new URL("http://pastebin.com/api/api_post.php");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
String pasteBinUrl = "";
while ((line = rd.readLine()) != null) {
pasteBinUrl = line;
}
wr.close();
rd.close();
return pasteBinUrl;
} catch (Exception e) {
System.out.print(e);
return "Error Posting to pastebin.com";
}
}
}
@@ -0,0 +1,101 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
public class WhoCommand extends MultiverseCommand {
private WorldManager worldManager;
public WhoCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Who?");
this.setCommandUsage("/mv who" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(0, 1);
this.addKey("mv who");
this.addKey("mvw");
this.addKey("mvwho");
this.setPermission("multiverse.core.list.who", "States who is in what world.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// If this command was sent from a Player then we need to check Permissions
Player p = null;
// By default, show all from the console
boolean showAll = true;
if (sender instanceof Player) {
p = (Player) sender;
showAll = false;
}
List<MultiverseWorld> worlds = new ArrayList<MultiverseWorld>();
if (args.size() > 0) {
MultiverseWorld world = this.worldManager.getMVWorld(args.get(0));
if (args.get(0).equalsIgnoreCase("--all") || args.get(0).equalsIgnoreCase("-a")) {
showAll = true;
worlds = new ArrayList<MultiverseWorld>(this.worldManager.getMVWorlds());
} else if (world != null) {
if (!world.isHidden()) {
worlds.add(world);
}
} else {
sender.sendMessage(ChatColor.RED + "World does not exist");
return;
}
} else {
worlds = new ArrayList<MultiverseWorld>(this.worldManager.getMVWorlds());
}
if (worlds.size() == 0) {
sender.sendMessage("Multiverse does not know about any of your worlds :(");
} else if (worlds.size() == 1) {
sender.sendMessage(ChatColor.AQUA + "--- Players in" + worlds.get(0).getColoredWorldString() + ChatColor.AQUA + " ---");
} else {
sender.sendMessage(ChatColor.AQUA + "--- There are players in ---");
}
for (MultiverseWorld world : worlds) {
if (!(this.worldManager.isMVWorld(world.getName()))) {
continue;
}
if (p != null && (!this.plugin.getMVPerms().canEnterWorld(p, world))) {
continue;
}
List<Player> players = world.getCBWorld().getPlayers();
String result = "";
if (players.size() <= 0 && !showAll) {
continue;
}
if (players.size() <= 0) {
result = "Empty";
} else {
for (Player player : players) {
result += player.getDisplayName() + " ";
}
}
sender.sendMessage(world.getColoredWorldString() + ChatColor.WHITE + " - " + result);
}
}
}
@@ -0,0 +1,61 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.configuration;
import com.onarandombox.MultiverseCore.api.LoggablePlugin;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.config.Configuration;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
public abstract class MVConfigMigrator {
public List<String> createdDefaults = new ArrayList<String>();
public abstract boolean migrate(String name, File folder);
protected final void migrateListItem(Configuration newConfig, Configuration oldConfig, String key, String oldProperty, String newProperty) {
List<String> list = Arrays.asList(oldConfig.getString("worlds." + key + oldProperty).split(","));
if (list.size() > 0) {
if (list.get(0).length() == 0) {
list = new ArrayList<String>();
}
}
newConfig.setProperty("worlds." + key + newProperty, list);
}
protected final File detectMultiverseFolders(File folder, LoggablePlugin mvPlugin) {
File oldFolder = null;
mvPlugin.log(Level.INFO, "Starting Multiverse Configuration Migrator(MVCM)!");
// They still have MV 1 installed! Good!
if (mvPlugin.getServer().getPluginManager().getPlugin("MultiVerse") != null) {
mvPlugin.log(Level.INFO, "Found MultiVerse 1. Starting Config Migration...");
Plugin plugin = mvPlugin.getServer().getPluginManager().getPlugin("MultiVerse");
oldFolder = plugin.getDataFolder();
} else {
// They didn't have MV 1 enabled... let's try and find the folder...
File[] folders = folder.getParentFile().listFiles();
List<File> folderList = Arrays.asList(folders);
for (File f : folderList) {
if (f.getName().equalsIgnoreCase("MultiVerse")) {
mvPlugin.log(Level.INFO, "Found the MultiVerse 1 config folder. Starting Config Migration...");
oldFolder = f;
}
}
if (oldFolder == null) {
mvPlugin.log(Level.INFO, "Did not find the MV1 Folder. If you did not have MultiVerse 1 installed and this is the FIRST time you're running MV2, this message is GOOD. ");
mvPlugin.log(Level.INFO, "If you did, your configs were **NOT** migrated! Go Here: INSERTURLFORHELP");
return null;
}
}
return oldFolder;
}
}
@@ -0,0 +1,82 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.configuration;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.util.config.Configuration;
import java.io.File;
import java.util.List;
import java.util.logging.Level;
public class MVCoreConfigMigrator extends MVConfigMigrator {
private MultiverseCore core;
public MVCoreConfigMigrator(MultiverseCore core) {
this.core = core;
}
public boolean migrate(String name, File folder) {
File oldFolder = this.detectMultiverseFolders(folder, core);
if (name.equalsIgnoreCase("worlds.yml")) {
return this.migrateWorlds(name, oldFolder, folder);
}
if (name.equalsIgnoreCase("config.yml")) {
return this.migrateMainConfig(name, oldFolder, folder);
}
return true;
}
private boolean migrateWorlds(String name, File oldFolder, File newFolder) {
Configuration newConfig = new Configuration(new File(newFolder, "worlds.yml"));
this.core.log(Level.INFO, "Trying to migrate worlds.yml...");
Configuration oldConfig = new Configuration(new File(oldFolder, "Worlds.yml"));
oldConfig.load();
List<String> keys = oldConfig.getKeys("worlds");
if (keys == null) {
this.core.log(Level.SEVERE, "Migration FAILURE!");
return false;
}
for (String key : keys) {
newConfig.setProperty("worlds." + key + ".animals.spawn", oldConfig.getProperty("worlds." + key + ".animals"));
newConfig.setProperty("worlds." + key + ".monsters.spawn", oldConfig.getProperty("worlds." + key + ".mobs"));
newConfig.setProperty("worlds." + key + ".pvp", oldConfig.getProperty("worlds." + key + ".pvp"));
newConfig.setProperty("worlds." + key + ".alias.name", oldConfig.getProperty("worlds." + key + ".alias"));
newConfig.setProperty("worlds." + key + ".tempspawn", oldConfig.getProperty("worlds." + key + ".spawn"));
newConfig.setProperty("worlds." + key + ".entryfee.amount", oldConfig.getProperty("worlds." + key + ".price"));
newConfig.setProperty("worlds." + key + ".entryfee.currency", -1);
newConfig.setProperty("worlds." + key + ".environment", oldConfig.getProperty("worlds." + key + ".environment"));
// Have to convert CSLs to arrays
migrateListItem(newConfig, oldConfig, key, ".blockBlacklist", ".blockblacklist");
migrateListItem(newConfig, oldConfig, key, ".worldBlacklist", ".worldblacklist");
}
newConfig.save();
this.core.log(Level.INFO, "Migration SUCCESS!");
return true;
}
private boolean migrateMainConfig(String name, File oldFolder, File newFolder) {
Configuration newConfig = new Configuration(new File(newFolder, "config.yml"));
this.core.log(Level.INFO, "Migrating config.yml...");
Configuration oldConfig = new Configuration(new File(oldFolder, "MultiVerse.yml"));
oldConfig.load();
newConfig.setProperty("worldnameprefix", oldConfig.getProperty("prefix"));
newConfig.setProperty("messagecooldown", oldConfig.getProperty("alertcooldown"));
// Default values:
newConfig.setProperty("opfallback", true);
newConfig.setProperty("disableautoheal", false);
newConfig.setProperty("fakepvp", false);
newConfig.setProperty("bedrespawn", true);
newConfig.setProperty("version", 2.2);
newConfig.save();
return true;
}
}
@@ -0,0 +1,91 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.destination;
import com.onarandombox.MultiverseCore.api.MVDestination;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
/**
* Multiverse 2
*
* @author fernferret
*/
public class BedDestination implements MVDestination {
private boolean isValid;
private Location knownBedLoc;
@Override
public String getIdentifier() {
return "b";
}
@Override
public boolean isThisType(JavaPlugin plugin, String destination) {
String[] split = destination.split(":");
this.isValid = split.length >= 1 && split.length <= 2 && split[0].equals(this.getIdentifier());
return this.isValid;
}
@Override
public Location getLocation(Entity entity) {
if (entity instanceof Player) {
this.knownBedLoc = ((Player) entity).getBedSpawnLocation();
return this.knownBedLoc;
}
return null;
}
@Override
public Vector getVelocity() {
return new Vector();
}
@Override
public void setDestination(JavaPlugin plugin, String destination) {
// Not needed.
}
@Override
public boolean isValid() {
return this.isValid;
}
@Override
public String getType() {
return "Bed";
}
@Override
public String getName() {
return "Bed";
}
@Override
public String getRequiredPermission() {
if (knownBedLoc != null) {
return "multiverse.access." + knownBedLoc.getWorld().getName();
}
return "";
}
@Override
public boolean useSafeTeleporter() {
// Bukkit should have already checked this.
return false;
}
@Override
public String toString() {
return "b:playerbed";
}
}
@@ -0,0 +1,182 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.destination;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import java.util.Arrays;
import java.util.List;
public class CannonDestination implements MVDestination {
private final String coordRegex = "(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*)";
private boolean isValid;
private Location location;
private double speed;
public Vector getVelocity() {
double pitchRadians = Math.toRadians(location.getPitch());
double yawRadians = Math.toRadians(location.getYaw());
double x = Math.sin(yawRadians) * speed * -1;
double y = Math.sin(pitchRadians) * speed * -1;
double z = Math.cos(yawRadians) * speed;
// Account for the angle they were pointed, and take away velocity
x = Math.cos(pitchRadians) * x;
z = Math.cos(pitchRadians) * z;
return new Vector(x, y, z);
}
@Override
public String getIdentifier() {
return "ca";
}
@Override
public boolean isThisType(JavaPlugin plugin, String destination) {
if (!(plugin instanceof MultiverseCore)) {
return false;
}
List<String> parsed = Arrays.asList(destination.split(":"));
// NEED ca:world:x,y,z:pitch:yaw:speed
// so basically 6
if (parsed.size() != 6) {
return false;
}
// If it's not an Cannon type
if (!parsed.get(0).equalsIgnoreCase("ca")) {
return false;
}
// If it's not a MV world
if (!((MultiverseCore) plugin).getMVWorldManager().isMVWorld(parsed.get(1))) {
return false;
}
// Verify X,Y,Z are numbers
if (!parsed.get(2).matches(coordRegex)) {
return false;
}
try {
Float.parseFloat(parsed.get(3));
Float.parseFloat(parsed.get(4));
Float.parseFloat(parsed.get(5));
} catch (NumberFormatException e) {
return false;
}
return true;
}
@Override
public Location getLocation(Entity e) {
return this.location;
}
@Override
public boolean isValid() {
return this.isValid;
}
@Override
public void setDestination(JavaPlugin plugin, String destination) {
if (!(plugin instanceof MultiverseCore)) {
return;
}
List<String> parsed = Arrays.asList(destination.split(":"));
// Need at least: e:world:x,y,z
// OR e:world:x,y,z:pitch:yaw
// so basically 3 or 5
if (parsed.size() != 6) {
this.isValid = false;
return;
}
if (!parsed.get(0).equalsIgnoreCase(this.getIdentifier())) {
this.isValid = false;
return;
}
if (!((MultiverseCore) plugin).getMVWorldManager().isMVWorld(parsed.get(1))) {
this.isValid = false;
return;
}
this.location = new Location(((MultiverseCore) plugin).getMVWorldManager().getMVWorld(parsed.get(1)).getCBWorld(), 0, 0, 0);
if (!parsed.get(2).matches(this.coordRegex)) {
this.isValid = false;
return;
}
double[] coords = new double[3];
String[] coordString = parsed.get(2).split(",");
for (int i = 0; i < 3; i++) {
try {
coords[i] = Double.parseDouble(coordString[i]);
} catch (NumberFormatException e) {
this.isValid = false;
return;
}
}
this.location.setX(coords[0]);
this.location.setY(coords[1]);
this.location.setZ(coords[2]);
try {
this.location.setPitch(Float.parseFloat(parsed.get(3)));
this.location.setYaw(Float.parseFloat(parsed.get(4)));
this.speed = Math.abs(Float.parseFloat(parsed.get(5)));
} catch (NumberFormatException e) {
this.isValid = false;
return;
}
this.isValid = true;
}
@Override
public String getType() {
return "Cannon!";
}
@Override
public String getName() {
return "Cannon (" + this.location.getX() + ", " + this.location.getY() + ", " + this.location.getZ() + ":" +
this.location.getPitch() + ":" + this.location.getYaw() + ":" + this.speed + ")";
}
public void setDestination(Location location, double speed) {
if (location != null) {
this.location = location;
this.speed = Math.abs(speed);
this.isValid = true;
}
this.isValid = false;
}
@Override
public String toString() {
if (isValid) {
return "ca:" + location.getWorld().getName() + ":" + location.getX() + "," + location.getY() + "," + location.getZ() + ":" + location.getPitch() + ":" + location.getYaw() + ":" + this.speed;
}
return "i:Invalid Destination";
}
@Override
public String getRequiredPermission() {
return "multiverse.access." + this.location.getWorld().getName();
}
@Override
public boolean useSafeTeleporter() {
return false;
}
}
@@ -0,0 +1,95 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.destination;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.commands.TeleportCommand;
import com.onarandombox.MultiverseCore.utils.PermissionTools;
import com.pneumaticraft.commandhandler.Command;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** A factory class that will create destinations from specific strings. */
public class DestinationFactory {
private MultiverseCore plugin;
private Map<String, Class<? extends MVDestination>> destList;
private Command teleportCommand;
public DestinationFactory(MultiverseCore plugin) {
this.plugin = plugin;
this.destList = new HashMap<String, Class<? extends MVDestination>>();
List<Command> cmds = this.plugin.getCommandHandler().getAllCommands();
for (Command c : cmds) {
if (c instanceof TeleportCommand) {
this.teleportCommand = c;
}
}
}
/**
* Gets a new destination from a string.
* Returns a new InvalidDestination if the string could not be parsed.
*
* @param destination The destination in string format.
*
* @return A non-null MVDestination
*/
public MVDestination getDestination(String destination) {
String idenChar = "";
if (destination.split(":").length > 1) {
idenChar = destination.split(":")[0];
}
if (this.destList.containsKey(idenChar)) {
Class<? extends MVDestination> myClass = this.destList.get(idenChar);
try {
MVDestination mydest = myClass.newInstance();
if (!mydest.isThisType((MultiverseCore) this.plugin, destination)) {
return new InvalidDestination();
}
mydest.setDestination(this.plugin, destination);
return mydest;
} catch (InstantiationException e) {
} catch (IllegalAccessException e) {
}
}
return new InvalidDestination();
}
public boolean registerDestinationType(Class<? extends MVDestination> c, String identifier) {
if (this.destList.containsKey(identifier)) {
return false;
}
this.destList.put(identifier, c);
// Special case for world defaults:
if (identifier.equals("")) {
identifier = "w";
}
Permission self = this.plugin.getServer().getPluginManager().getPermission("multiverse.teleport.self." + identifier);
Permission other = this.plugin.getServer().getPluginManager().getPermission("multiverse.teleport.other." + identifier);
PermissionTools pt = new PermissionTools(this.plugin);
if (self == null) {
self = new Permission("multiverse.teleport.self." + identifier, "Permission to teleport yourself for the " + identifier + " destination.", PermissionDefault.OP);
this.plugin.getServer().getPluginManager().addPermission(self);
pt.addToParentPerms("multiverse.teleport.self." + identifier);
}
if (other == null) {
other = new Permission("multiverse.teleport.other." + identifier, "Permission to teleport others for the " + identifier + " destination.", PermissionDefault.OP);
this.plugin.getServer().getPluginManager().addPermission(other);
pt.addToParentPerms("multiverse.teleport.other." + identifier);
}
this.teleportCommand.addAdditonalPermission(self);
this.teleportCommand.addAdditonalPermission(other);
return true;
}
}
@@ -0,0 +1,178 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.destination;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import java.util.Arrays;
import java.util.List;
public class ExactDestination implements MVDestination {
private final String coordRegex = "(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*)";
private boolean isValid;
private Location location;
@Override
public String getIdentifier() {
return "e";
}
public Vector getVelocity() {
return new Vector(0, 0, 0);
}
@Override
public boolean isThisType(JavaPlugin plugin, String destination) {
if (!(plugin instanceof MultiverseCore)) {
return false;
}
List<String> parsed = Arrays.asList(destination.split(":"));
// Need at least: e:world:x,y,z
// OR e:world:x,y,z:pitch:yaw
// so basically 3 or 5
if (!(parsed.size() == 3 || parsed.size() == 5)) {
return false;
}
// If it's not an Exact type
if (!parsed.get(0).equalsIgnoreCase("e")) {
return false;
}
// If it's not a MV world
if (!((MultiverseCore) plugin).getMVWorldManager().isMVWorld(parsed.get(1))) {
return false;
}
if (!parsed.get(2).matches(coordRegex)) {
return false;
}
// This is 1 now, because we've removed 2
if (parsed.size() == 3) {
return true;
}
try {
Float.parseFloat(parsed.get(3));
Float.parseFloat(parsed.get(4));
} catch (NumberFormatException e) {
return false;
}
return true;
}
@Override
public Location getLocation(Entity e) {
return this.location;
}
@Override
public boolean isValid() {
return this.isValid;
}
@Override
public void setDestination(JavaPlugin plugin, String destination) {
if (!(plugin instanceof MultiverseCore)) {
return;
}
List<String> parsed = Arrays.asList(destination.split(":"));
// Need at least: e:world:x,y,z
// OR e:world:x,y,z:pitch:yaw
// so basically 3 or 5
if (!(parsed.size() == 3 || parsed.size() == 5)) {
this.isValid = false;
return;
}
if (!parsed.get(0).equalsIgnoreCase(this.getIdentifier())) {
this.isValid = false;
return;
}
if (!((MultiverseCore) plugin).getMVWorldManager().isMVWorld(parsed.get(1))) {
this.isValid = false;
return;
}
this.location = new Location(((MultiverseCore) plugin).getMVWorldManager().getMVWorld(parsed.get(1)).getCBWorld(), 0, 0, 0);
if (!parsed.get(2).matches(this.coordRegex)) {
this.isValid = false;
return;
}
double[] coords = new double[3];
String[] coordString = parsed.get(2).split(",");
for (int i = 0; i < 3; i++) {
try {
coords[i] = Double.parseDouble(coordString[i]);
} catch (NumberFormatException e) {
this.isValid = false;
return;
}
}
this.location.setX(coords[0]);
this.location.setY(coords[1]);
this.location.setZ(coords[2]);
if (parsed.size() == 3) {
this.isValid = true;
return;
}
try {
this.location.setPitch(Float.parseFloat(parsed.get(3)));
this.location.setYaw(Float.parseFloat(parsed.get(4)));
} catch (NumberFormatException e) {
this.isValid = false;
return;
}
this.isValid = true;
}
@Override
public String getType() {
return "Exact";
}
@Override
public String getName() {
return "Exact (" + this.location.getX() + ", " + this.location.getY() + ", " + this.location.getZ() + ":" + location.getPitch() + ":" + location.getYaw() + ")";
}
public void setDestination(Location location) {
if (location != null) {
this.location = location;
this.isValid = true;
}
this.isValid = false;
}
@Override
public String toString() {
if (isValid) {
return "e:" + location.getWorld().getName() + ":" + location.getX() + "," + location.getY() + "," + location.getZ() + ":" + location.getPitch() + ":" + location.getYaw();
}
return "i:Invalid Destination";
}
@Override
public String getRequiredPermission() {
return "multiverse.access." + this.location.getWorld().getName();
}
@Override
public boolean useSafeTeleporter() {
// This is an EXACT destination, don't safely teleport here.
return false;
}
}
@@ -0,0 +1,73 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.destination;
import com.onarandombox.MultiverseCore.api.MVDestination;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
public class InvalidDestination implements MVDestination {
@Override
public String getIdentifier() {
return "i";
}
@Override
public boolean isThisType(JavaPlugin plugin, String destination) {
return false;
}
@Override
public Location getLocation(Entity e) {
return null;
}
@Override
public boolean isValid() {
return false;
}
@Override
public void setDestination(JavaPlugin plugin, String destination) {
// Nothing needed, it's invalid.
}
@Override
public String getType() {
return ChatColor.RED + "Invalid Destination";
}
@Override
public String getName() {
return ChatColor.RED + "Invalid Destination";
}
@Override
public String toString() {
return "i:Invalid Destination";
}
@Override
public String getRequiredPermission() {
return null;
}
public Vector getVelocity() {
return new Vector(0, 0, 0);
}
@Override
public boolean useSafeTeleporter() {
return false;
}
}
@@ -0,0 +1,103 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.destination;
import com.onarandombox.MultiverseCore.api.MVDestination;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
public class PlayerDestination implements MVDestination {
String player;
private boolean isValid;
private JavaPlugin plugin;
@Override
public String getIdentifier() {
return "pl";
}
@Override
public boolean isThisType(JavaPlugin plugin, String destination) {
String[] items = destination.split(":");
if (items.length != 2) {
return false;
}
if (!items[0].equalsIgnoreCase("pl")) {
return false;
}
return true;
}
@Override
public Location getLocation(Entity e) {
Player p = plugin.getServer().getPlayer(this.player);
Player plLoc = null;
if (e instanceof Player) {
plLoc = (Player) e;
} else if (e.getPassenger() instanceof Player) {
plLoc = (Player) e.getPassenger();
}
if (p != null && plLoc != null && !plLoc.getName().equalsIgnoreCase(p.getName())) {
return p.getLocation();
}
return null;
}
@Override
public boolean isValid() {
return this.isValid;
}
@Override
public void setDestination(JavaPlugin plugin, String destination) {
String[] items = destination.split(":");
if (items.length != 2) {
this.isValid = false;
}
if (!items[0].equalsIgnoreCase("pl")) {
this.isValid = false;
}
this.isValid = true;
this.player = items[1];
this.plugin = plugin;
}
@Override
public String getType() {
return "Player";
}
@Override
public String getName() {
return this.player;
}
@Override
public String toString() {
return "pl:" + this.player;
}
@Override
public String getRequiredPermission() {
return "";
}
public Vector getVelocity() {
return new Vector(0, 0, 0);
}
@Override
public boolean useSafeTeleporter() {
return true;
}
}
@@ -0,0 +1,134 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.destination;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
public class WorldDestination implements MVDestination {
private boolean isValid;
private MultiverseWorld world;
float yaw = -1;
String direction = "";
@Override
public String getIdentifier() {
return "w";
}
@Override
public boolean isThisType(JavaPlugin plugin, String destination) {
String[] items = destination.split(":");
if (items.length > 3) {
return false;
}
if (items.length == 1 && ((MultiverseCore) plugin).getMVWorldManager().isMVWorld(items[0])) {
// This case is: world
return true;
}
if (items.length == 2 && ((MultiverseCore) plugin).getMVWorldManager().isMVWorld(items[0])) {
// This case is: world:n
return true;
} else if (items[0].equalsIgnoreCase("w") && ((MultiverseCore) plugin).getMVWorldManager().isMVWorld(items[1])) {
// This case is: w:world
// and w:world:ne
return true;
}
return false;
}
@Override
public Location getLocation(Entity e) {
Location spawnLoc = getAcurateSpawnLocation(e, this.world);
if (this.yaw >= 0) {
// Only modify the yaw if its set.
spawnLoc.setYaw(this.yaw);
}
return spawnLoc;
}
private Location getAcurateSpawnLocation(Entity e, MultiverseWorld world) {
if (world != null) {
return world.getSpawnLocation();
} else {
return e.getWorld().getSpawnLocation().add(.5, 0, .5);
}
}
@Override
public boolean isValid() {
return this.isValid;
}
@Override
public void setDestination(JavaPlugin plugin, String destination) {
String[] items = destination.split(":");
if (items.length > 3) {
isValid = false;
return;
}
if (items.length == 1 && ((MultiverseCore) plugin).getMVWorldManager().isMVWorld(items[0])) {
isValid = true;
this.world = ((MultiverseCore) plugin).getMVWorldManager().getMVWorld(items[0]);
return;
}
if (items.length == 2 && ((MultiverseCore) plugin).getMVWorldManager().isMVWorld(items[0])) {
this.world = ((MultiverseCore) plugin).getMVWorldManager().getMVWorld(items[0]);
this.yaw = LocationManipulation.getYaw(items[1]);
return;
}
if (items[0].equalsIgnoreCase("w") && ((MultiverseCore) plugin).getMVWorldManager().isMVWorld(items[1])) {
this.world = ((MultiverseCore) plugin).getMVWorldManager().getMVWorld(items[1]);
isValid = true;
if (items.length == 3) {
this.yaw = LocationManipulation.getYaw(items[2]);
}
}
}
@Override
public String getType() {
return "World";
}
@Override
public String getName() {
return this.world.getColoredWorldString();
}
@Override
public String toString() {
if (direction.length() > 0 && yaw >= 0) {
return this.world.getCBWorld().getName() + ":" + this.direction;
}
return this.world.getCBWorld().getName();
}
@Override
public String getRequiredPermission() {
// TODO: Potenitally replace spaces wiht tabs for friendlier yaml.
// this.world.getName().replace(" ","_");
return "multiverse.access." + this.world.getName();
}
public Vector getVelocity() {
return new Vector(0, 0, 0);
}
@Override
public boolean useSafeTeleporter() {
return true;
}
}
@@ -0,0 +1,17 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.enums;
/**
* Multiverse 2
*
* @author fernferret
*/
public enum Action {
Set, Add, Remove, Clear
}
@@ -0,0 +1,17 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.enums;
/**
* Multiverse 2
*
* @author fernferret
*/
public enum AddProperties {
worldblacklist, animals, monsters
}
@@ -0,0 +1,23 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.enums;
/** Multiverse 2 */
public enum ConfigProperty {
messagecooldown, teleportcooldown, worldnameprefix, bedrespawn, enforcegamemodes, enforceaccess, debug;
public static String getAllValues() {
String buffer = "";
for (ConfigProperty c : ConfigProperty.values()) {
// All values will NOT Contain spaces.
buffer += c.toString() + " ";
}
return buffer;
}
}
@@ -0,0 +1,68 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.enums;
import org.bukkit.ChatColor;
/**
* Multiverse 2
*
* @author fernferret
*/
public enum EnglishChatColor {
AQUA("AQUA", ChatColor.AQUA),
BLACK("BLACK", ChatColor.BLACK),
BLUE("BLUE", ChatColor.BLUE),
DARKAQUA("DARKAQUA", ChatColor.DARK_AQUA),
DARKBLUE("DARKBLUE", ChatColor.DARK_BLUE),
DARKGRAY("DARKGRAY", ChatColor.DARK_GRAY),
DARKGREEN("DARKGREEN", ChatColor.DARK_GREEN),
DARKPURPLE("DARKPURPLE", ChatColor.DARK_PURPLE),
DARKRED("DARKRED", ChatColor.DARK_RED),
GOLD("GOLD", ChatColor.GOLD),
GRAY("GRAY", ChatColor.GRAY),
GREEN("GREEN", ChatColor.GREEN),
LIGHTPURPLE("LIGHTPURPLE", ChatColor.LIGHT_PURPLE),
RED("RED", ChatColor.RED),
YELLOW("YELLOW", ChatColor.YELLOW),
WHITE("WHITE", ChatColor.WHITE);
private ChatColor color;
private String text;
EnglishChatColor(String name, ChatColor color) {
this.color = color;
this.text = name;
}
public String getText() {
return this.text;
}
public ChatColor getColor() {
return this.color;
}
public static String getAllColors() {
String buffer = "";
for (EnglishChatColor c : EnglishChatColor.values()) {
buffer += c.getColor() + c.getText() + " ";
}
return buffer;
}
public static EnglishChatColor fromString(String text) {
if (text != null) {
for (EnglishChatColor c : EnglishChatColor.values()) {
if (text.equalsIgnoreCase(c.text)) {
return c;
}
}
}
return null;
}
}
@@ -0,0 +1,19 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.enums;
/**
* Multiverse 2
*
* @author fernferret
*/ // Color == Aliascolor
public enum SetProperties {
alias, animals, monsters, pvp, scaling, aliascolor, color, respawn,
currency, curr, price, scale, spawnmemory, memory, weather, storm,
gamemode, mode, hunger, difficulty, diff, hidden, spawn
}
@@ -0,0 +1,30 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.event;
import org.bukkit.event.Event;
import java.util.List;
public class MVConfigMigrateEvent extends Event {
private static final long serialVersionUID = 3647950355746345397L;
private List<String> configsLoaded;
public MVConfigMigrateEvent(List<String> configsLoaded) {
super("MVConfigMigrate");
this.configsLoaded = configsLoaded;
}
public void addConfig(String config) {
this.configsLoaded.add(config);
}
public List<String> getAllConfigsLoaded() {
return this.configsLoaded;
}
}
@@ -0,0 +1,30 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.event;
import org.bukkit.event.Event;
import java.util.List;
public class MVConfigReloadEvent extends Event {
private static final long serialVersionUID = 3647950355746345397L;
private List<String> configsLoaded;
public MVConfigReloadEvent(List<String> configsLoaded) {
super("MVConfigReload");
this.configsLoaded = configsLoaded;
}
public void addConfig(String config) {
this.configsLoaded.add(config);
}
public List<String> getAllConfigsLoaded() {
return this.configsLoaded;
}
}
@@ -0,0 +1,43 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.event;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
public class MVRespawnEvent extends Event {
private static final long serialVersionUID = -2991894063331856687L;
private Player player;
private Location location;
private String respawnMethod;
public MVRespawnEvent(Location spawningAt, Player p, String respawnMethod) {
super("MVRespawn");
this.player = p;
this.location = spawningAt;
this.respawnMethod = respawnMethod;
}
public Player getPlayer() {
return this.player;
}
public String getRespawnMethod() {
return this.respawnMethod;
}
public Location getPlayersRespawnLocation() {
return this.location;
}
public void setRespawnLocation(Location l) {
this.location = l;
}
}
@@ -0,0 +1,82 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.event;
import com.onarandombox.MultiverseCore.api.MVDestination;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
/**
* Event that gets called when a player use the /mvtp command
*
* @author fernferret
*/
public class MVTeleportEvent extends Event implements Cancellable {
private Player teleportee;
private CommandSender teleporter;
private MVDestination dest;
private boolean useSafeTeleport;
private boolean isCancelled;
public MVTeleportEvent(MVDestination dest, Player teleportee, CommandSender teleporter, boolean safeTeleport) {
super("SafeTTeleporter");
this.teleportee = teleportee;
this.teleporter = teleporter;
this.dest = dest;
this.useSafeTeleport = safeTeleport;
}
/**
* Returns the player who will be teleported by this event.
*
* @return The player who will be teleported by this event.
*/
public Player getTeleportee() {
return this.teleportee;
}
/**
* Returns the location the player was before the teleport.
*
* @return The location the player was before the teleport.
*/
public Location getFrom() {
return this.teleportee.getLocation();
}
/**
* Returns the player who requested the Teleport
*
* @return
*/
public CommandSender getTeleporter() {
return this.teleporter;
}
/**
* Returns the destination that the player will spawn at.
*
* @return The destination the player will spawn at.
*/
public MVDestination getDestination() {
return this.dest;
}
@Override
public boolean isCancelled() {
return this.isCancelled;
}
@Override
public void setCancelled(boolean cancel) {
this.isCancelled = cancel;
}
}
@@ -0,0 +1,28 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.event;
import org.bukkit.event.Event;
public class MVVersionRequestEvent extends Event {
private String pasteBinBuffer;
public MVVersionRequestEvent(String pasteBinBuffer) {
super("MVVersion");
this.pasteBinBuffer = pasteBinBuffer;
}
public String getPasteBinBuffer() {
return this.pasteBinBuffer;
}
public void setPasteBinBuffer(String buffer) {
this.pasteBinBuffer = buffer;
}
}
@@ -0,0 +1,172 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.listeners;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.entity.*;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import java.util.List;
import java.util.logging.Level;
//import org.bukkit.event.entity.ExplosionPrimedEvent;
public class MVEntityListener extends EntityListener {
private MultiverseCore plugin;
private WorldManager worldManager;
public MVEntityListener(MultiverseCore plugin) {
this.plugin = plugin;
this.worldManager = plugin.getMVWorldManager();
}
@Override
public void onFoodLevelChange(FoodLevelChangeEvent event) {
if (event.isCancelled()) {
return;
}
if (event.getEntity() instanceof Player) {
Player p = (Player) event.getEntity();
MultiverseWorld w = this.plugin.getMVWorldManager().getMVWorld(p.getWorld().getName());
if (w != null && !w.getHunger()) {
// If the world has hunger set to false, do not let the level go down
if (event.getFoodLevel() < ((Player) event.getEntity()).getFoodLevel()) {
event.setCancelled(true);
}
}
}
}
/**
* Event - When a Entity is Damaged, we first sort out whether it is of importance to us, such as EntityVSEntity or
* EntityVSProjectile. Then we grab the attacked and defender and check if its a player. Then deal with the PVP
* Aspect.
*/
@Override
public void onEntityDamage(EntityDamageEvent event) {
if (event.isCancelled()) {
return;
}
Entity attacker;
Entity defender;
if (event instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
attacker = sub.getDamager();
defender = sub.getEntity();
} else {
return;
}
if (attacker == null || defender == null) {
return;
}
if (defender instanceof Player) {
Player player = (Player) defender;
World w = player.getWorld();
if (!this.worldManager.isMVWorld(w.getName())) {
// if the world is not handled, we don't care
return;
}
MultiverseWorld world = this.worldManager.getMVWorld(w.getName());
if (attacker instanceof Player) {
if (!world.isPVPEnabled() && world.getFakePVP()) {
((Player) attacker).sendMessage(ChatColor.RED + "PVP is disabled in this World.");
event.setCancelled(true);
}
}
}
}
@Override
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
if (event.isCancelled()) {
return;
}
RegainReason reason = event.getRegainReason();
MultiverseWorld world = this.worldManager.getMVWorld(event.getEntity().getLocation().getWorld());
if (world != null && reason == RegainReason.REGEN && !world.getAutoHeal()) {
event.setCancelled(true);
}
}
/** Handle Animal/Monster Spawn settings, seems like a more concrete method than using CraftBukkit. */
@Override
public void onCreatureSpawn(CreatureSpawnEvent event) {
// Check to see if the Creature is spawned by a plugin, we don't want to prevent this behaviour.
if (event.getSpawnReason() == SpawnReason.CUSTOM) {
return;
}
World world = event.getEntity().getWorld();
if (event.isCancelled())
return;
// Check if it's a world which we are meant to be managing.
if (!(this.worldManager.isMVWorld(world.getName())))
return;
CreatureType creature = event.getCreatureType();
MultiverseWorld mvworld = this.worldManager.getMVWorld(world.getName());
/**
* Handle people with non-standard animals: ie a patched craftbukkit.
*/
if (creature == null) {
this.plugin.log(Level.FINER, "Found a null typed creature.");
return;
}
/**
* Animal Handling
*/
if (event.getEntity() instanceof Animals || event.getEntity() instanceof Squid) {
event.setCancelled(this.shouldWeKillThisCreature(mvworld.getAnimalList(), mvworld.canAnimalsSpawn(), creature.toString().toUpperCase()));
}
/**
* Monster Handling
*/
if (event.getEntity() instanceof Monster || event.getEntity() instanceof Ghast || event.getEntity() instanceof Slime) {
event.setCancelled(this.shouldWeKillThisCreature(mvworld.getMonsterList(), mvworld.canMonstersSpawn(), creature.toString().toUpperCase()));
}
}
private boolean shouldWeKillThisCreature(List<String> creatureList, boolean allowCreatureSpawning, String creature) {
if (creatureList.isEmpty() && allowCreatureSpawning) {
// 1. There are no exceptions and animals are allowed. Save it.
return false;
} else if (creatureList.isEmpty()) {
// 2. There are no exceptions and animals are NOT allowed. Kill it.
return true;
} else if (creatureList.contains(creature) && allowCreatureSpawning) {
// 3. There ARE exceptions and animals ARE allowed. Kill it.
return true;
} else if (!creatureList.contains(creature.toUpperCase()) && allowCreatureSpawning) {
// 4. There ARE exceptions and animals ARE NOT allowed. SAVE it.
return false;
} else if (creatureList.contains(creature.toUpperCase()) && !allowCreatureSpawning) {
// 5. No animals are allowed to be spawned, BUT this one can stay...
return false;
} else if (!creatureList.contains(creature.toUpperCase()) && !allowCreatureSpawning) {
// 6. Animals are NOT allowed to spawn, and this creature is not in the save list... KILL IT
return true;
}
// This code should NEVER execute. I just left the verbose conditions in right now.
return false;
}
}
@@ -0,0 +1,257 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.listeners;
import com.fernferret.allpay.GenericBank;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.event.player.*;
import java.util.logging.Level;
public class MVPlayerListener extends PlayerListener {
MultiverseCore plugin;
SafeTTeleporter mvteleporter;
WorldManager worldManager;
public MVPlayerListener(MultiverseCore plugin) {
this.plugin = plugin;
worldManager = plugin.getMVWorldManager();
}
@Override
public void onPlayerChat(PlayerChatEvent event) {
if (event.isCancelled()) {
return;
}
// Check whether the Server is set to prefix the chat with the World name.
// If not we do nothing, if so we need to check if the World has an Alias.
if (MultiverseCore.PrefixChat) {
String world = event.getPlayer().getWorld().getName();
String prefix = "";
// If we're not a MV world, don't do anything
if (!this.worldManager.isMVWorld(world)) {
return;
}
MultiverseWorld mvworld = this.worldManager.getMVWorld(world);
if (mvworld.isHidden()) {
return;
}
prefix = mvworld.getColoredWorldString();
String format = event.getFormat();
event.setFormat("[" + prefix + "]" + format);
}
}
@Override
public void onPlayerRespawn(PlayerRespawnEvent event) {
World world = event.getPlayer().getWorld();
// If it's not a World MV manages we stop.
if (!this.worldManager.isMVWorld(world.getName())) {
return;
}
if (MultiverseCore.BedRespawn) {
this.plugin.log(Level.FINE, "Spawning " + event.getPlayer().getName() + " at their bed");
return;
}
// Get the MultiverseWorld
MultiverseWorld mvWorld = this.worldManager.getMVWorld(world.getName());
// Get the instance of the World the player should respawn at.
MultiverseWorld respawnWorld = null;
if (this.worldManager.isMVWorld(mvWorld.getRespawnToWorld())) {
respawnWorld = this.worldManager.getMVWorld(mvWorld.getRespawnToWorld());
}
// If it's null then it either means the World doesn't exist or the value is blank, so we don't handle it.
// NOW: We'll always handle it to get more accurate spawns
if (respawnWorld != null) {
world = respawnWorld.getCBWorld();
}
// World has been set to the appropriate world
Location respawnLocation = getMostAccurateRespawnLocation(world);
MVRespawnEvent respawnEvent = new MVRespawnEvent(respawnLocation, event.getPlayer(), "compatability");
this.plugin.getServer().getPluginManager().callEvent(respawnEvent);
event.setRespawnLocation(respawnEvent.getPlayersRespawnLocation());
}
private Location getMostAccurateRespawnLocation(World w) {
MultiverseWorld mvw = this.worldManager.getMVWorld(w.getName());
if (mvw != null) {
return mvw.getSpawnLocation();
}
return w.getSpawnLocation();
}
@Override
public void onPlayerJoin(PlayerJoinEvent event) {
if (this.worldManager.getMVWorlds().size() == 0 && this.plugin.getMVPerms().hasPermission(event.getPlayer(), "multiverse.core.import", true)) {
event.getPlayer().sendMessage("You don't have any worlds imported into Multiverse!");
event.getPlayer().sendMessage("You can import your current worlds with " + ChatColor.AQUA + "/mvimport");
event.getPlayer().sendMessage("or you can create new ones with " + ChatColor.GOLD + "/mvcreate");
event.getPlayer().sendMessage("If you just wanna see all of the Multiverse Help, type: " + ChatColor.GREEN + "/mv");
}
// Handle the Players GameMode setting for the new world.
if (MultiverseCore.EnforceGameModes) {
this.handleGameMode(event.getPlayer(), event.getPlayer().getWorld());
}
}
@Override
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
// Handle the Players GameMode setting for the new world.
if (MultiverseCore.EnforceGameModes) {
this.handleGameMode(event.getPlayer(), event.getPlayer().getWorld());
}
}
@Override
public void onPlayerQuit(PlayerQuitEvent event) {
this.plugin.removePlayerSession(event.getPlayer());
}
@Override
public void onPlayerTeleport(PlayerTeleportEvent event) {
if (event.isCancelled()) {
return;
}
MultiverseWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) {
// The player is Teleporting to the same world.
this.plugin.log(Level.FINER, "Player '" + event.getPlayer().getName() + "' is teleporting to the same world.");
return;
}
if (MultiverseCore.EnforceAccess) {
event.setCancelled(!playerCanGoFromTo(fromWorld, toWorld, event.getPlayer()));
if (event.isCancelled()) {
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName() + "' was DENIED ACCESS to '" + event.getTo().getWorld().getName() +
"' because they don't have: multiverse.access." + event.getTo().getWorld().getName());
}
} else {
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName() + "' was allowed to go to '" + event.getTo().getWorld().getName() + "' because enforceaccess is off.");
}
}
@Override
public void onPlayerPortal(PlayerPortalEvent event) {
// If the player was actually outside of the portal, adjust the from location
if (event.getFrom().getWorld().getBlockAt(event.getFrom()).getType() != Material.PORTAL) {
event.setFrom(SafeTTeleporter.findPortalBlockNextTo(event.getFrom()));
}
if (event.isCancelled() || event.getTo() == null || event.getFrom() == null) {
return;
}
MultiverseWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) {
// The player is Portaling to the same world.
this.plugin.log(Level.FINER, "Player '" + event.getPlayer().getName() + "' is portaling to the same world.");
return;
}
if (MultiverseCore.EnforceAccess) {
event.setCancelled(!playerCanGoFromTo(fromWorld, toWorld, event.getPlayer()));
if (event.isCancelled()) {
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName() + "' was DENIED ACCESS to '" + event.getTo().getWorld().getName() +
"' because they don't have: multiverse.access." + event.getTo().getWorld().getName());
}
} else {
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName() + "' was allowed to go to '" + event.getTo().getWorld().getName() + "' because enforceaccess is off.");
}
}
/**
* Checks to see if player can go to a world given their current status.
* <p/>
* The return is a little backwards, and will return a value safe for event.setCancelled.
*
* @param fromWorld The MultiverseWorld they are in.
* @param toWorld The MultiverseWorld they want to go to.
* @param player The player that wants to travel.
*
* @return True if they can't go to the world, False if they can.
*/
private boolean playerCanGoFromTo(MultiverseWorld fromWorld, MultiverseWorld toWorld, Player player) {
if (toWorld != null) {
if (!this.plugin.getMVPerms().canEnterWorld(player, toWorld)) {
player.sendMessage("You don't have access to go here...");
return false;
}
} else {
//TODO: Determine if this value is false because a world didn't exist
// or if it was because a world wasn't imported.
return true;
}
if (fromWorld != null) {
if (fromWorld.getWorldBlacklist().contains(toWorld.getName())) {
player.sendMessage("You don't have access to go to " + toWorld.getColoredWorldString() + " from " + fromWorld.getColoredWorldString());
return false;
}
}
// Only check payments if it's a different world:
if (!toWorld.equals(fromWorld)) {
// If the player does not have to pay, return now.
if (this.plugin.getMVPerms().hasPermission(player, toWorld.getExemptPermission().getName(), true)) {
return true;
}
GenericBank bank = plugin.getBank();
if (!bank.hasEnough(player, toWorld.getPrice(), toWorld.getCurrency(), "You need " + bank.getFormattedAmount(player, toWorld.getPrice(), toWorld.getCurrency()) + " to enter " + toWorld.getColoredWorldString())) {
return false;
} else {
bank.pay(player, toWorld.getPrice(), toWorld.getCurrency());
}
}
return true;
}
// FOLLOWING 2 Methods and Private class handle Per Player GameModes.
private void handleGameMode(Player player, World world) {
MultiverseWorld mvWorld = this.worldManager.getMVWorld(world.getName());
if (mvWorld != null) {
this.handleGameMode(player, mvWorld);
}
}
public void handleGameMode(Player player, MultiverseWorld world) {
// We perform this task one tick later to MAKE SURE that the player actually reaches the
// destination world, otherwise we'd be changing the player mode if they havent moved anywhere.
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new HandleGameMode(player, world), 1L);
}
/** The following private class is used to handle player game mode changes within a scheduler. */
private class HandleGameMode implements Runnable {
private Player player;
private MultiverseWorld world;
private HandleGameMode(Player player, MultiverseWorld world) {
this.player = player;
this.world = world;
}
@Override
public void run() {
// Check that the player is in the new world and they haven't been teleported elsewhere or the event cancelled.
if (player.getWorld().getName().equals(world.getCBWorld().getName())) {
player.setGameMode(world.getGameMode());
}
}
}
}
@@ -0,0 +1,60 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.listeners;
import com.fernferret.allpay.AllPay;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import java.util.Arrays;
import java.util.logging.Level;
public class MVPluginListener extends ServerListener {
MultiverseCore plugin;
public MVPluginListener(MultiverseCore plugin) {
this.plugin = plugin;
}
/** Keep an eye out for Plugins which we can utilize. */
@Override
public void onPluginEnable(PluginEnableEvent event) {
if (event.getPlugin() instanceof com.onarandombox.MultiverseCore.MVPlugin) {
this.plugin.log(Level.SEVERE, "Your version of '" + event.getPlugin() + "' is OUT OF DATE.");
this.plugin.log(Level.SEVERE, "Please grab the latest version from:");
this.plugin.log(Level.SEVERE, "http://bukkit.onarandombox.com/?dir=" + event.getPlugin().getDescription().getName().toLowerCase());
this.plugin.log(Level.SEVERE, "I'm going to disable " + event.getPlugin().getDescription().getName() + " now.");
this.plugin.log(Level.SEVERE, "IF YOU DO NOT UPDATE, YOUR SERVER WILL **NOT** FUNCTION PROPERLY!!!");
this.plugin.getServer().getPluginManager().disablePlugin(event.getPlugin());
}
// Let AllPay handle all econ plugin loadings, only go for econ plugins we support
if (Arrays.asList(AllPay.validEconPlugins).contains(event.getPlugin().getDescription().getName())) {
this.plugin.setBank(this.plugin.getBanker().loadEconPlugin());
}
if (event.getPlugin().getDescription().getName().equals("MultiVerse")) {
if (event.getPlugin().isEnabled()) {
this.plugin.getServer().getPluginManager().disablePlugin(event.getPlugin());
this.plugin.log(Level.WARNING, "I just disabled the old version of Multiverse for you. You should remove the JAR now, your configs have been migrated.");
}
}
if (event.getPlugin().getDescription().getName().equals("Spout")) {
this.plugin.setSpout();
this.plugin.log(Level.INFO, "Spout integration enabled.");
}
}
/** We'll check if any of the plugins we rely on decide to Disable themselves. */
@Override
public void onPluginDisable(PluginDisableEvent event) {
// TODO: Disable econ when it disables.
}
}
@@ -0,0 +1,42 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.listeners;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.event.weather.ThunderChangeEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.weather.WeatherListener;
public class MVWeatherListener extends WeatherListener {
private MultiverseCore plugin;
public MVWeatherListener(MultiverseCore plugin) {
this.plugin = plugin;
}
@Override
public void onWeatherChange(WeatherChangeEvent event) {
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld().getName());
if (world != null) {
// If it's going to start raining and we have weather disabled
event.setCancelled((event.toWeatherState() && !world.isWeatherEnabled()));
}
}
@Override
public void onThunderChange(ThunderChangeEvent event) {
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld().getName());
if (world != null) {
// If it's going to start raining and we have weather disabled
event.setCancelled((event.toThunderState() && !world.isWeatherEnabled()));
}
}
}
@@ -0,0 +1,228 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Vehicle;
import java.util.logging.Level;
public class BlockSafety {
public BlockSafety() {
// TODO Auto-generated constructor stub
}
/**
* This function checks whether the block at the given coordinates are above air or not.
*
* @param world
* @param x
* @param y
* @param z
*
* @return
*/
public boolean isBlockAboveAir(Location l) {
Location downOne = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
downOne.setY(downOne.getY() - 1);
return (downOne.getBlock().getType() == Material.AIR);
}
public boolean blockIsNotSafe(World world, double x, double y, double z) {
Location l = new Location(world, x, y, z);
return !playerCanSpawnHereSafely(l);
}
public boolean playerCanSpawnHereSafely(World world, double x, double y, double z) {
Location l = new Location(world, x, y, z);
return playerCanSpawnHereSafely(l);
}
/**
* This function checks whether the block at the coordinates given is safe or not by checking for Laval/Fire/Air
* etc. This also ensures there is enough space for a player to spawn!
*
* @param world
* @param x
* @param y
* @param z
*
* @return
*/
public boolean playerCanSpawnHereSafely(Location l) {
Location actual = l.clone();
Location upOne = l.clone();
Location downOne = l.clone();
upOne.setY(upOne.getY() + 1);
downOne.setY(downOne.getY() - 1);
if (this.isSolidBlock(actual.getBlock().getType()) || this.isSolidBlock(upOne.getBlock().getType())) {
MultiverseCore.staticLog(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
MultiverseCore.staticLog(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
return false;
}
if (downOne.getBlock().getType() == Material.LAVA || downOne.getBlock().getType() == Material.STATIONARY_LAVA) {
MultiverseCore.staticLog(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
MultiverseCore.staticLog(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
return false;
}
if (downOne.getBlock().getType() == Material.FIRE) {
MultiverseCore.staticLog(Level.FINER, "There's fire below! (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
return false;
}
if (isBlockAboveAir(actual)) {
MultiverseCore.staticLog(Level.FINER, "Is block above air [" + isBlockAboveAir(actual) + "]");
MultiverseCore.staticLog(Level.FINER, "Has 2 blocks of water below [" + this.hasTwoBlocksofWaterBelow(actual) + "]");
return this.hasTwoBlocksofWaterBelow(actual);
}
return true;
}
/**
* If someone has a better way of this... Please either tell us, or submit a pull request!
*
* @param type
*
* @return
*/
private boolean isSolidBlock(Material type) {
switch (type) {
case AIR:
return false;
case SNOW:
return false;
case TRAP_DOOR:
return false;
case TORCH:
return false;
case YELLOW_FLOWER:
return false;
case RED_ROSE:
return false;
case RED_MUSHROOM:
return false;
case BROWN_MUSHROOM:
return false;
case REDSTONE:
return false;
case REDSTONE_WIRE:
return false;
case RAILS:
return false;
case POWERED_RAIL:
return false;
case REDSTONE_TORCH_ON:
return false;
case REDSTONE_TORCH_OFF:
return false;
case DEAD_BUSH:
return false;
case SAPLING:
return false;
case STONE_BUTTON:
return false;
case LEVER:
return false;
case LONG_GRASS:
return false;
case PORTAL:
return false;
case STONE_PLATE:
return false;
case WOOD_PLATE:
return false;
case SEEDS:
return false;
case SUGAR_CANE_BLOCK:
return false;
case WALL_SIGN:
return false;
case SIGN_POST:
return false;
case WOODEN_DOOR:
return false;
case STATIONARY_WATER:
return false;
case WATER:
return false;
}
return true;
}
public boolean isEntitiyOnTrack(Entity e, Location l) {
Material currentBlock = l.getBlock().getType();
return (currentBlock == Material.POWERED_RAIL || currentBlock == Material.DETECTOR_RAIL || currentBlock == Material.RAILS);
}
public void showDangers(Location l) {
Location actual = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
Location upOne = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
Location downOne = new Location(l.getWorld(), l.getX(), l.getY(), l.getZ());
upOne.setY(upOne.getY() + 1);
downOne.setY(downOne.getY() - 1);
System.out.print("Location Up: " + upOne.getBlock().getType());
System.out.print(" " + upOne);
System.out.print("Location: " + actual.getBlock().getType());
System.out.print(" " + actual);
System.out.print("Location Down: " + downOne.getBlock().getType());
System.out.print(" " + downOne);
}
/**
* Checks recursively below location L for 2 blocks of water
*
* @param l
*
* @return
*/
public boolean hasTwoBlocksofWaterBelow(Location l) {
if (l.getBlockY() < 0) {
return false;
}
Location oneBelow = l.clone();
oneBelow.subtract(0, 1, 0);
if (oneBelow.getBlock().getType() == Material.WATER || oneBelow.getBlock().getType() == Material.STATIONARY_WATER) {
Location twoBelow = oneBelow.clone();
twoBelow.subtract(0, 1, 0);
return (oneBelow.getBlock().getType() == Material.WATER || oneBelow.getBlock().getType() == Material.STATIONARY_WATER);
}
if (oneBelow.getBlock().getType() != Material.AIR) {
return false;
}
return hasTwoBlocksofWaterBelow(oneBelow);
}
public boolean canSpawnCartSafely(Minecart cart) {
if (this.isBlockAboveAir(cart.getLocation())) {
return true;
}
if (this.isEntitiyOnTrack(cart, LocationManipulation.getNextBlock(cart))) {
return true;
}
return false;
}
public boolean canSpawnVehicleSafely(Vehicle vehicle) {
if (this.isBlockAboveAir(vehicle.getLocation())) {
return true;
}
return false;
}
}
@@ -0,0 +1,84 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.logging.*;
public class DebugLog {
private FileHandler fh;
private Logger log;
/**
* Creates a new debug logger.
*
* @param logger The name of the logger.
* @param file The file to log to.
*/
public DebugLog(String logger, String file) {
this.log = Logger.getLogger(logger);
try {
this.fh = new FileHandler(file, true);
this.log.setUseParentHandlers(false);
for (Handler handler : this.log.getHandlers()) {
this.log.removeHandler(handler);
}
this.log.addHandler(this.fh);
this.log.setLevel(Level.ALL);
this.fh.setFormatter(new LogFormatter());
} catch (SecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Log a message at a certain level
*
* @param level
* @param msg
*/
public void log(Level level, String msg) {
this.log.log(level, msg);
}
private class LogFormatter extends Formatter {
private final SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Override
public String format(LogRecord record) {
StringBuilder builder = new StringBuilder();
Throwable ex = record.getThrown();
builder.append(this.date.format(record.getMillis()));
builder.append(" [");
builder.append(record.getLevel().getLocalizedName().toUpperCase());
builder.append("] ");
builder.append(record.getMessage());
builder.append('\n');
if (ex != null) {
StringWriter writer = new StringWriter();
ex.printStackTrace(new PrintWriter(writer));
builder.append(writer);
}
return builder.toString();
}
}
public void close() {
this.fh.close();
}
}
@@ -0,0 +1,44 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import org.bukkit.ChatColor;
public class FancyColorScheme {
private ChatColor headerColor;
private ChatColor mainColor;
private ChatColor altColor;
private ChatColor defContentColor;
public FancyColorScheme(ChatColor header, ChatColor main, ChatColor alt, ChatColor defaultColor) {
this.headerColor = header;
this.mainColor = main;
this.altColor = alt;
this.defContentColor = defaultColor;
}
public ChatColor getHeader() {
return this.headerColor;
}
public ChatColor getMain() {
return this.mainColor;
}
public ChatColor getAlt() {
return this.altColor;
}
public ChatColor getDefault() {
return this.defContentColor;
}
public ChatColor getMain(boolean main) {
return main ? this.getMain() : this.getAlt();
}
}
@@ -0,0 +1,31 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import com.onarandombox.MultiverseCore.api.FancyText;
public class FancyHeader implements FancyText {
private FancyColorScheme colors;
private String text;
public FancyHeader(String text, FancyColorScheme scheme) {
this.colors = scheme;
this.text = text;
}
@Override
public String getFancyText() {
return colors.getHeader() + "--- " + text + colors.getHeader() + " ---";
}
public void appendText(String string) {
this.text += string;
}
}
@@ -0,0 +1,50 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import com.onarandombox.MultiverseCore.api.FancyText;
public class FancyMessage implements FancyText {
private String title;
private String message;
private boolean main = true;
private FancyColorScheme colors;
/**
* Allows easy creation of an alternating colored list
*
* @param title
* @param message
*/
public FancyMessage(String title, String message, FancyColorScheme scheme) {
this.title = title;
this.message = message;
this.colors = scheme;
}
public void setColorMain() {
this.main = true;
}
public void setColorAlt() {
this.main = false;
}
@Override
public String getFancyText() {
return this.colors.getMain(this.main) + this.title + this.colors.getDefault() + message;
}
public void setAltColor(boolean altColor) {
this.main = !altColor;
}
public void setMainColor(boolean mainColor) {
this.main = mainColor;
}
}
@@ -0,0 +1,37 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import java.io.File;
public class FileUtils {
/*
* Delete a folder Courtesy of: lithium3141
*
* @param file The folder to delete
*
* @return true if success
*/
public static boolean deleteFolder(File file) {
if (file.exists()) {
// If the file exists, and it has more than one file in it.
if (file.isDirectory()) {
for (File f : file.listFiles()) {
if (!FileUtils.deleteFolder(f)) {
return false;
}
}
}
file.delete();
return !file.exists();
} else {
return false;
}
}
}
@@ -0,0 +1,227 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Vehicle;
import org.bukkit.util.Vector;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;
public class LocationManipulation {
private static Map<String, Integer> orientationInts = new HashMap<String, Integer>();
static {
orientationInts.put("n", 180);
orientationInts.put("ne", 225);
orientationInts.put("e", 270);
orientationInts.put("se", 315);
orientationInts.put("s", 0);
orientationInts.put("sw", 45);
orientationInts.put("w", 90);
orientationInts.put("nw", 135);
}
/**
* Convert a Location into a Colon separated string to allow us to store it in text.
*
* @param location
*
* @return
*/
public static String locationToString(Location location) {
StringBuilder l = new StringBuilder();
l.append(location.getBlockX() + ":");
l.append(location.getBlockY() + ":");
l.append(location.getBlockZ() + ":");
l.append(location.getYaw() + ":");
l.append(location.getPitch());
return l.toString();
}
/**
* Convert a String to a Location.
*
* @param world
* @param xStr
* @param yStr
* @param zStr
* @param yawStr
* @param pitchStr
*
* @return
*/
public Location stringToLocation(World world, String xStr, String yStr, String zStr, String yawStr, String pitchStr) {
double x = Double.parseDouble(xStr);
double y = Double.parseDouble(yStr);
double z = Double.parseDouble(zStr);
float yaw = Float.valueOf(yawStr).floatValue();
float pitch = Float.valueOf(pitchStr).floatValue();
return new Location(world, x, y, z, yaw, pitch);
}
/**
* Returns a colored string with the coords
*
* @param l
*
* @return
*/
public static String strCoords(Location l) {
String result = "";
DecimalFormat df = new DecimalFormat();
df.setMinimumFractionDigits(0);
df.setMaximumFractionDigits(2);
result += ChatColor.WHITE + "X: " + ChatColor.AQUA + df.format(l.getX()) + " ";
result += ChatColor.WHITE + "Y: " + ChatColor.AQUA + df.format(l.getY()) + " ";
result += ChatColor.WHITE + "Z: " + ChatColor.AQUA + df.format(l.getZ()) + " ";
result += ChatColor.WHITE + "P: " + ChatColor.GOLD + df.format(l.getPitch()) + " ";
result += ChatColor.WHITE + "Y: " + ChatColor.GOLD + df.format(l.getYaw()) + " ";
return result;
}
/**
* Converts a location to a printable readable formatted string including pitch/yaw
*
* @param l
*
* @return
*/
public static String strCoordsRaw(Location l) {
String result = "";
DecimalFormat df = new DecimalFormat();
df.setMinimumFractionDigits(0);
df.setMaximumFractionDigits(2);
result += "X: " + df.format(l.getX()) + " ";
result += "Y: " + df.format(l.getY()) + " ";
result += "Z: " + df.format(l.getZ()) + " ";
result += "P: " + df.format(l.getPitch()) + " ";
result += "Y: " + df.format(l.getYaw()) + " ";
return result;
}
/**
* Return the NESW Direction a Location is facing.
*
* @param location
*
* @return
*/
public static String getDirection(Location location) {
double r = (location.getYaw() % 360) + 180;
// Remember, these numbers are every 45 degrees with a 22.5 offset, to detect boundaries.
String dir;
if (r < 22.5)
dir = "n";
else if (r < 67.5)
dir = "ne";
else if (r < 112.5)
dir = "e";
else if (r < 157.5)
dir = "se";
else if (r < 202.5)
dir = "s";
else if (r < 247.5)
dir = "sw";
else if (r < 292.5)
dir = "w";
else if (r < 337.5)
dir = "nw";
else
dir = "n";
return dir;
}
/**
* Returns the float yaw position for the given cardianl direction
*
* @param orientation
*
* @return
*/
public static float getYaw(String orientation) {
if (orientation == null) {
return 0;
}
if (orientationInts.containsKey(orientation.toLowerCase())) {
return orientationInts.get(orientation.toLowerCase());
}
return 0;
}
/**
* Returns a speed float from a given vector.
*
* @param v
*
* @return
*/
public static float getSpeed(Vector v) {
return (float) Math.sqrt(v.getX() * v.getX() + v.getZ() * v.getZ());
}
// X, Y, Z
// -W/+E,0, -N/+S
/**
* Returns a translated vector from the given direction
*
* @param v
* @param direction
*
* @return
*/
public static Vector getTranslatedVector(Vector v, String direction) {
if (direction == null) {
return v;
}
float speed = getSpeed(v);
float halfSpeed = (float) (speed / 2.0);
// TODO: Mathmatacize this:
if (direction.equalsIgnoreCase("n")) {
return new Vector(0, 0, -1 * speed);
} else if (direction.equalsIgnoreCase("ne")) {
return new Vector(halfSpeed, 0, -1 * halfSpeed);
} else if (direction.equalsIgnoreCase("e")) {
return new Vector(speed, 0, 0);
} else if (direction.equalsIgnoreCase("se")) {
return new Vector(halfSpeed, 0, halfSpeed);
} else if (direction.equalsIgnoreCase("s")) {
return new Vector(0, 0, speed);
} else if (direction.equalsIgnoreCase("sw")) {
return new Vector(-1 * halfSpeed, 0, halfSpeed);
} else if (direction.equalsIgnoreCase("w")) {
return new Vector(-1 * speed, 0, 0);
} else if (direction.equalsIgnoreCase("nw")) {
return new Vector(-1 * halfSpeed, 0, -1 * halfSpeed);
}
return v;
}
/**
* Returns the next Location that an entity is traveling at
*
* @param v
*
* @return
*/
public static Location getNextBlock(Vehicle v) {
Vector vector = v.getVelocity();
Location location = v.getLocation();
int x = vector.getX() < 0 ? vector.getX() == 0 ? 0 : -1 : 1;
int z = vector.getZ() < 0 ? vector.getZ() == 0 ? 0 : -1 : 1;
return location.add(x, 0, z);
}
}
@@ -0,0 +1,96 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* Multiverse 2
*
* @author fernferret
*/
public class MVMessaging {
private MultiverseCore plugin;
private Map<String, Date> sentList;
private int cooldown = 0;
public MVMessaging(MultiverseCore plugin) {
this.plugin = plugin;
this.sentList = new HashMap<String, Date>();
}
public void setCooldown(int milliseconds) {
this.cooldown = milliseconds;
}
/**
* Sends a message to the specified sender if the cooldown has passed.
*
* @param sender The person/console to send the message to.
* @param message The message to send.
* @param ignoreCooldown If true this message will always be sent. Useful for things like menus
*
* @return true if the message was sent, false if not.
*/
public boolean sendMessage(CommandSender sender, String message, boolean ignoreCooldown) {
if (!(sender instanceof Player) || ignoreCooldown) {
sender.sendMessage(message);
return true;
}
if (!this.sentList.containsKey(sender.getName())) {
sender.sendMessage(message);
this.sentList.put(sender.getName(), new Date());
return true;
} else {
if (this.sentList.get(sender.getName()).after(new Date((new Date()).getTime() + this.cooldown))) {
sender.sendMessage(message);
this.sentList.put(sender.getName(), new Date());
return true;
}
}
return false;
}
public boolean sendMessages(CommandSender sender, String[] messages, boolean ignoreCooldown) {
if (!(sender instanceof Player) || ignoreCooldown) {
this.sendMessages(sender, messages);
return true;
}
if (!this.sentList.containsKey(sender.getName())) {
this.sendMessages(sender, messages);
this.sentList.put(sender.getName(), new Date());
return true;
} else {
if (this.sentList.get(sender.getName()).after(new Date((new Date()).getTime() + this.cooldown))) {
this.sendMessages(sender, messages);
this.sentList.put(sender.getName(), new Date());
return true;
}
}
return false;
}
public boolean sendMessage(CommandSender sender, String message) {
return this.sendMessage(sender, message, true);
}
public boolean sendMessages(CommandSender sender, String[] messages) {
boolean success = true;
for (String s : messages) {
success = (!(!this.sendMessage(sender, s, true) && success));
}
return success;
}
}
@@ -0,0 +1,309 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.pneumaticraft.commandhandler.PermissionsInterface;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
import java.util.logging.Level;
public class MVPermissions implements PermissionsInterface {
private MultiverseCore plugin;
private WorldManager worldMgr;
/**
* Constructor FTW
*
* @param plugin Pass along the Core Plugin.
*/
public MVPermissions(MultiverseCore plugin) {
this.plugin = plugin;
this.worldMgr = plugin.getMVWorldManager();
}
/**
* Check if a Player can teleport to the Destination world from there current world.
*
* @param p The player to check.
* @param w
*
* @return
*/
public boolean canTravelFromWorld(Player p, MultiverseWorld w) {
List<String> blackList = w.getWorldBlacklist();
boolean returnValue = true;
for (String s : blackList) {
if (s.equalsIgnoreCase(p.getWorld().getName())) {
returnValue = false;
break;
}
}
return returnValue;
}
public boolean canTravelFromLocation(CommandSender sender, Location location) {
if (!(sender instanceof Player)) {
return true;
}
Player teleporter = (Player) sender;
if (!this.worldMgr.isMVWorld(location.getWorld().getName())) {
return false;
}
return canTravelFromWorld(teleporter, this.worldMgr.getMVWorld(location.getWorld().getName()));
}
/**
* Check if the Player has the permissions to enter this world.
*
* @param p
* @param w
*
* @return
*/
public boolean canEnterWorld(Player p, MultiverseWorld w) {
// If we're not enforcing access, anyone can enter.
if (!MultiverseCore.EnforceAccess) {
return true;
}
return this.hasPermission(p, "multiverse.access." + w.getName(), false);
}
public boolean canEnterLocation(Player p, Location l) {
if (l == null) {
return false;
}
String worldName = l.getWorld().getName();
if (!this.plugin.getMVWorldManager().isMVWorld(worldName)) {
return false;
}
return this.hasPermission(p, "multiverse.access." + worldName, false);
}
/**
* Check to see if a sender can enter a destination.
* The reason this is not a player, is it can be used to simply check permissions
* The console should, for exmaple, always see all worlds
*
* @param sender The CommandSender to check.
* @param d The destination they are requesting.
*
* @return True if that sender can go to that destination
*/
public boolean canEnterDestination(CommandSender sender, MVDestination d) {
if (!(sender instanceof Player)) {
return true;
}
Player p = (Player) sender;
if (d == null || d.getLocation(p) == null) {
return false;
}
String worldName = d.getLocation(p).getWorld().getName();
if (!this.worldMgr.isMVWorld(worldName)) {
return false;
}
if (!canEnterLocation(p, d.getLocation(p))) {
return false;
}
return this.hasPermission(p, d.getRequiredPermission(), false);
}
/**
* Check to see if a player has a permission.
*
* @param sender Who is requesting the permission.
* @param node The permission node in string format; multiverse.core.list.worlds for example.
* @param isOpRequired @Deprecated. This is not used for anything anymore.
*
* @return True if they have that permission or any parent.
*/
public boolean hasPermission(CommandSender sender, String node, boolean isOpRequired) {
if (!(sender instanceof Player)) {
return true;
}
// NO one can access a null permission (mainly used for destinations):w
if (node == null) {
return false;
}
// Everyone can access an empty permission
// Currently used for the PlayerDestination
if (node.equals("")) {
return true;
}
boolean hasPermission = checkActualPermission(sender, node);
// I consider this a workaround. At the moment, when we add a node AND recalc the permissions, until the perms
// plugin reloads, when MV asks the API if a player has a perm, it reports that they do NOT.
// For the moment, we're going to check all of this node's parents to see if the user has those. It stops
// when if finds a true or there are no more parents. --FF
if (!hasPermission) {
hasPermission = this.hasAnyParentPermission(sender, node);
}
return hasPermission;
}
// TODO: Better player checks, most likely not needed, but safer.
private boolean checkActualPermission(CommandSender sender, String node) {
Player player = (Player) sender;
this.plugin.log(Level.FINEST, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]");
boolean hasPermission = sender.hasPermission(node);
if (hasPermission) {
this.plugin.log(Level.FINER, "Player [" + player.getName() + "] HAS PERMISSION [" + node + "]!");
}
return hasPermission;
}
/**
* Checks to see if the sender has any parent perms.
* Stops when it finds one or when there are no more parents.
* This method is recursive.
*
* @param sender Who is asking for the permission.
* @param node The permission node to check (possibly already a parent).
*
* @return True if they have any parent perm, false if none.
*/
private boolean hasAnyParentPermission(CommandSender sender, String node) {
String parentPerm = this.pullOneLevelOff(node);
// Base case
if (parentPerm == null) {
return false;
}
// If they have a parent, they're good
if (this.checkActualPermission(sender, parentPerm + ".*")) {
return true;
}
return hasAnyParentPermission(sender, parentPerm);
}
/**
* Pulls one level off of a yaml style node.
* Given multiverse.core.list.worlds will return multiverse.core.list
*
* @param node The root node to check.
*
* @return The parent of the node
*/
private String pullOneLevelOff(String node) {
if (node == null) {
return null;
}
int index = node.lastIndexOf(".");
if (index > 0) {
return node.substring(0, index);
}
return null;
}
public String getType() {
return "Bukkit Permissions (SuperPerms)";
}
@Override
public boolean hasAnyPermission(CommandSender sender, List<String> nodes, boolean isOpRequired) {
for (String node : nodes) {
if (this.hasPermission(sender, node, isOpRequired)) {
return true;
}
}
return false;
}
@Override
public boolean hasAllPermission(CommandSender sender, List<String> nodes, boolean isOpRequired) {
for (String node : nodes) {
if (!this.hasPermission(sender, node, isOpRequired)) {
return false;
}
}
return true;
}
public Permission addPermission(String string, PermissionDefault defaultValue) {
if (this.plugin.getServer().getPluginManager().getPermission(string) == null) {
Permission permission = new Permission(string, defaultValue);
this.plugin.getServer().getPluginManager().addPermission(permission);
this.addToParentPerms(string);
}
return this.plugin.getServer().getPluginManager().getPermission(string);
}
private void addToParentPerms(String permString) {
String permStringChopped = permString.replace(".*", "");
String[] seperated = permStringChopped.split("\\.");
String parentPermString = getParentPerm(seperated);
if (parentPermString == null) {
addToRootPermission("*", permStringChopped);
addToRootPermission("*.*", permStringChopped);
return;
}
Permission parentPermission = this.plugin.getServer().getPluginManager().getPermission(parentPermString);
// Creat parent and grandparents
if (parentPermission == null) {
parentPermission = new Permission(parentPermString);
this.plugin.getServer().getPluginManager().addPermission(parentPermission);
this.addToParentPerms(parentPermString);
}
// Create actual perm.
Permission actualPermission = this.plugin.getServer().getPluginManager().getPermission(permString);
// Extra check just to make sure the actual one is added
if (actualPermission == null) {
actualPermission = new Permission(permString);
this.plugin.getServer().getPluginManager().addPermission(actualPermission);
}
if (!parentPermission.getChildren().containsKey(permString)) {
parentPermission.getChildren().put(actualPermission.getName(), true);
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(parentPermission);
}
}
private void addToRootPermission(String rootPerm, String permStringChopped) {
Permission rootPermission = this.plugin.getServer().getPluginManager().getPermission(rootPerm);
if (rootPermission == null) {
rootPermission = new Permission(rootPerm);
this.plugin.getServer().getPluginManager().addPermission(rootPermission);
}
rootPermission.getChildren().put(permStringChopped + ".*", true);
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(rootPermission);
}
/**
* If the given permission was 'multiverse.core.tp.self', this would return 'multiverse.core.tp.*'.
*
* @param seperated
*
* @return
*/
private String getParentPerm(String[] seperated) {
if (seperated.length == 1) {
return null;
}
String returnString = "";
for (int i = 0; i < seperated.length - 1; i++) {
returnString += seperated[i] + ".";
}
return returnString + "*";
}
}
@@ -0,0 +1,49 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.configuration.Configuration;
import org.bukkit.entity.Player;
import java.util.Date;
public class MVPlayerSession {
private Player player; // Player holder, may be unnecessary.
private Long teleportLast = 0L; // Timestamp for the Players last Portal Teleportation.
private Long messageLast = 0L; // Timestamp for the Players last Alert Message.
private Configuration config; // Configuration file to find out Cooldown Timers.
public MVPlayerSession(Player player, Configuration config, MultiverseCore multiVerseCore) {
this.player = player;
this.config = config;
// this.bedSpawn = null;
}
/** Update the Teleport time. */
public void teleport() {
this.teleportLast = (new Date()).getTime();
}
/**
* Grab whether the cooldown on Portal use has expired or not.
*
* @return
*/
public boolean getTeleportable() {
Long time = (new Date()).getTime();
if ((time - this.teleportLast) > this.config.getInt("portalcooldown", 5000)) {
return true;
} else {
return false;
}
}
}
@@ -0,0 +1,91 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.destination.CannonDestination;
import org.bukkit.Location;
import org.bukkit.TravelAgent;
import org.bukkit.entity.Player;
import java.util.logging.Level;
public class MVTravelAgent implements TravelAgent {
private MVDestination destination;
private MultiverseCore core;
private Player player;
public MVTravelAgent(MultiverseCore multiverseCore, MVDestination d, Player p) {
this.destination = d;
this.core = multiverseCore;
this.player = p;
}
@Override
public TravelAgent setSearchRadius(int radius) {
return this;
}
@Override
public int getSearchRadius() {
return 0;
}
@Override
public TravelAgent setCreationRadius(int radius) {
return this;
}
@Override
public int getCreationRadius() {
return 0;
}
@Override
public boolean getCanCreatePortal() {
return false;
}
@Override
public void setCanCreatePortal(boolean create) {
}
@Override
public Location findOrCreate(Location location) {
return this.getSafeLocation();
}
@Override
public Location findPortal(Location location) {
return this.getSafeLocation();
}
@Override
public boolean createPortal(Location location) {
return false;
}
private Location getSafeLocation() {
// At this time, these can never use the velocity.
if (this.destination instanceof CannonDestination) {
this.core.log(Level.FINE, "Using Stock TP method. This cannon will have 0 velocity");
}
SafeTTeleporter teleporter = new SafeTTeleporter(this.core);
Location newLoc = this.destination.getLocation(this.player);
if (this.destination.useSafeTeleporter()) {
newLoc = teleporter.getSafeLocation(this.player, this.destination);
}
if (newLoc == null) {
return this.player.getLocation();
}
return newLoc;
}
}
@@ -0,0 +1,79 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.permissions.Permission;
public class PermissionTools {
private MultiverseCore plugin;
public PermissionTools(MultiverseCore plugin) {
this.plugin = plugin;
}
public void addToParentPerms(String permString) {
String permStringChopped = permString.replace(".*", "");
String[] seperated = permStringChopped.split("\\.");
String parentPermString = getParentPerm(seperated);
if (parentPermString == null) {
addToRootPermission("*", permStringChopped);
addToRootPermission("*.*", permStringChopped);
return;
}
Permission parentPermission = this.plugin.getServer().getPluginManager().getPermission(parentPermString);
// Creat parent and grandparents
if (parentPermission == null) {
parentPermission = new Permission(parentPermString);
this.plugin.getServer().getPluginManager().addPermission(parentPermission);
this.addToParentPerms(parentPermString);
}
// Create actual perm.
Permission actualPermission = this.plugin.getServer().getPluginManager().getPermission(permString);
// Extra check just to make sure the actual one is added
if (actualPermission == null) {
actualPermission = new Permission(permString);
this.plugin.getServer().getPluginManager().addPermission(actualPermission);
}
if (!parentPermission.getChildren().containsKey(permString)) {
parentPermission.getChildren().put(actualPermission.getName(), true);
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(parentPermission);
}
}
private void addToRootPermission(String rootPerm, String permStringChopped) {
Permission rootPermission = this.plugin.getServer().getPluginManager().getPermission(rootPerm);
if (rootPermission == null) {
rootPermission = new Permission(rootPerm);
this.plugin.getServer().getPluginManager().addPermission(rootPermission);
}
rootPermission.getChildren().put(permStringChopped + ".*", true);
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(rootPermission);
}
/**
* If the given permission was 'multiverse.core.tp.self', this would return 'multiverse.core.tp.*'.
*
* @param separatedPermissionString The array of a dot separated perm string.
*
* @return The dot separated parent permission string.
*/
private String getParentPerm(String[] separatedPermissionString) {
if (separatedPermissionString.length == 1) {
return null;
}
String returnString = "";
for (int i = 0; i < separatedPermissionString.length - 1; i++) {
returnString += separatedPermissionString[i] + ".";
}
return returnString + "*";
}
}
@@ -0,0 +1,129 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.*;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
public class PurgeWorlds {
MultiverseCore plugin;
public PurgeWorlds(MultiverseCore plugin) {
this.plugin = plugin;
}
/** Synchronizes the given world with it's settings */
public void purgeWorlds(CommandSender sender, List<MultiverseWorld> worlds) {
if (worlds == null || worlds.isEmpty()) {
return;
}
for (MultiverseWorld world : worlds) {
this.purgeWorld(sender, world);
}
}
/**
* Convince method for clearing all the animals that do not belong according to the config.
*
* @param sender
* @param world
*/
public void purgeWorld(CommandSender sender, MultiverseWorld world) {
if (world == null) {
return;
}
ArrayList<String> allMobs = new ArrayList<String>(world.getAnimalList());
allMobs.addAll(world.getMonsterList());
purgeWorld(sender, world, allMobs, !world.canAnimalsSpawn(), !world.canMonstersSpawn());
}
public void purgeWorld(CommandSender sender, MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals, boolean negateMonsters) {
if (mvworld == null) {
return;
}
World world = this.plugin.getServer().getWorld(mvworld.getName());
if (world == null) {
return;
}
int entitiesKilled = 0;
for (Entity e : world.getEntities()) {
// Check against Monsters
if (killMonster(mvworld, e, thingsToKill, negateMonsters)) {
entitiesKilled++;
continue;
}
// Check against Animals
if (this.killCreature(mvworld, e, thingsToKill, negateAnimals)) {
entitiesKilled++;
}
}
if (sender != null) {
sender.sendMessage(entitiesKilled + " entities purged from the world '" + world.getName() + "'");
}
}
private boolean killCreature(MultiverseWorld mvworld, Entity e, List<String> creaturesToKill, boolean negate) {
String entityName = e.toString().replaceAll("Craft", "").toUpperCase();
if (e instanceof Squid || e instanceof Animals) {
if (creaturesToKill.contains(entityName) || creaturesToKill.contains("ALL") || creaturesToKill.contains("ANIMALS")) {
if (!negate) {
e.remove();
return true;
}
} else {
if (negate) {
e.remove();
return true;
}
}
}
return false;
}
/**
* Will kill the monster if it's in the list UNLESS the NEGATE boolean is set, then it will kill it if it's NOT
*
* @param mvworld
* @param e
* @param creaturesToKill
* @param negate
*
* @return
*/
private boolean killMonster(MultiverseWorld mvworld, Entity e, List<String> creaturesToKill, boolean negate) {
String entityName = e.toString().replaceAll("Craft", "").toUpperCase();
if (e instanceof Slime || e instanceof Monster || e instanceof Ghast) {
this.plugin.log(Level.FINER, "Looking at a monster: " + e);
if (creaturesToKill.contains(entityName) || creaturesToKill.contains("ALL") || creaturesToKill.contains("MONSTERS")) {
if (!negate) {
this.plugin.log(Level.FINEST, "Removing a monster: " + e);
e.remove();
return true;
}
} else {
if (negate) {
this.plugin.log(Level.FINEST, "Removing a monster: " + e);
e.remove();
return true;
}
}
}
return false;
}
}
@@ -0,0 +1,327 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.util.Vector;
import java.util.logging.Level;
public class SafeTTeleporter {
MultiverseCore plugin;
BlockSafety bs;
public SafeTTeleporter(MultiverseCore plugin) {
this.plugin = plugin;
this.bs = new BlockSafety();
}
public Location getSafeLocation(Location l) {
return this.getSafeLocation(l, 6, 9);
}
public Location getSafeLocation(Location l, int tolerance, int radius) {
// Check around the player first in a configurable radius:
// TODO: Make this configurable
Location safe = checkAboveAndBelowLocation(l, tolerance, radius);
if (safe != null) {
safe.setX(safe.getBlockX() + .5);
safe.setZ(safe.getBlockZ() + .5);
this.plugin.log(Level.FINE, "Hey! I found one: " + LocationManipulation.strCoordsRaw(safe));
} else {
this.plugin.log(Level.FINE, "Uh oh! No safe place found!");
}
return safe;
}
private Location checkAboveAndBelowLocation(Location l, int tolerance, int radius) {
// Tolerance must be an even number:
if (tolerance % 2 != 0) {
tolerance += 1;
}
// We want half of it, so we can go up and down
tolerance /= 2;
this.plugin.log(Level.FINER, "Given Location of: " + LocationManipulation.strCoordsRaw(l));
this.plugin.log(Level.FINER, "Checking +-" + tolerance + " with a radius of " + radius);
// For now this will just do a straight up block.
Location locToCheck = l.clone();
// Check the main level
Location safe = this.checkAroundLocation(locToCheck, radius);
if (safe != null) {
return safe;
}
// We've already checked zero right above this.
int currentLevel = 1;
while (currentLevel <= tolerance) {
// Check above
locToCheck = l.clone();
locToCheck.add(0, currentLevel, 0);
safe = this.checkAroundLocation(locToCheck, radius);
if (safe != null) {
return safe;
}
// Check below
locToCheck = l.clone();
locToCheck.subtract(0, currentLevel, 0);
safe = this.checkAroundLocation(locToCheck, radius);
if (safe != null) {
return safe;
}
currentLevel++;
}
return null;
}
/**
* For my crappy algorithm, radius MUST be odd
*
* @param l
* @param diameter
*
* @return
*/
private Location checkAroundLocation(Location l, int diameter) {
if (diameter % 2 == 0) {
diameter += 1;
}
Location checkLoc = l.clone();
// Start at 3, the min diameter around a block
int loopcounter = 3;
while (loopcounter <= diameter) {
boolean foundSafeArea = checkAroundSpecificDiameter(checkLoc, loopcounter);
// If a safe area was found:
if (foundSafeArea) {
// Return the checkLoc, it is the safe location.
return checkLoc;
}
// Otherwise, let's reset our location
checkLoc = l.clone();
// And increment the radius
loopcounter += 2;
}
return null;
}
private boolean checkAroundSpecificDiameter(Location checkLoc, int circle) {
// Adjust the circle to get how many blocks to step out.
// A radius of 3 makes the block step 1
// A radius of 5 makes the block step 2
// A radius of 7 makes the block step 3
// ...
int adjustedCircle = ((circle - 1) / 2);
checkLoc.add(adjustedCircle, 0, 0);
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
return true;
}
// Now we go to the right that adjustedCircle many
for (int i = 0; i < adjustedCircle; i++) {
checkLoc.add(0, 0, 1);
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
return true;
}
}
// Then down adjustedCircle *2
for (int i = 0; i < adjustedCircle * 2; i++) {
checkLoc.add(-1, 0, 0);
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
return true;
}
}
// Then left adjustedCircle *2
for (int i = 0; i < adjustedCircle * 2; i++) {
checkLoc.add(0, 0, -1);
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
return true;
}
}
// Then up Then left adjustedCircle *2
for (int i = 0; i < adjustedCircle * 2; i++) {
checkLoc.add(1, 0, 0);
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
return true;
}
}
// Then finish up by doing adjustedCircle - 1
for (int i = 0; i < adjustedCircle - 1; i++) {
checkLoc.add(0, 0, 1);
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
return true;
}
}
return false;
}
/**
* Safely teleport the entity to the MVDestination. This will perform checks to see if the place is safe, and if
* it's not, will adjust the final destination accordingly.
*
* @param teleporter Person who performed the teleport command.
* @param teleportee Entity to teleport
* @param d Destination to teleport them to
*
* @return true for success, false for failure
*/
public boolean safelyTeleport(CommandSender teleporter, Entity teleportee, MVDestination d) {
if (d instanceof InvalidDestination) {
this.plugin.log(Level.FINER, "Entity tried to teleport to an invalid destination");
return false;
}
Location safeLoc = d.getLocation(teleportee);
if (d.useSafeTeleporter()) {
safeLoc = this.getSafeLocation(teleportee, d);
}
if (safeLoc != null) {
if (teleportee.teleport(safeLoc)) {
if (!d.getVelocity().equals(new Vector(0, 0, 0))) {
teleportee.setVelocity(d.getVelocity());
}
return true;
}
}
return false;
}
/**
* Safely teleport the entity to the Location. This may perform checks to
* see if the place is safe, and if
* it's not, will adjust the final destination accordingly.
*
* @param teleporter Person who issued the teleport command.
* @param teleportee Entity to teleport.
* @param location Location to teleport them to.
* @param safely Should the destination be checked for safety before teleport?
*
* @return true for success, false for failure.
*/
public boolean safelyTeleport(CommandSender teleporter, Entity teleportee, Location location, boolean safely) {
if (safely) {
location = this.getSafeLocation(location);
}
if (location != null) {
if (teleportee.teleport(location)) {
return true;
}
}
return false;
}
/**
* Returns a safe location for the entity to spawn at.
*
* @param e The entity to spawn
* @param d The MVDestination to take the entity to.
*
* @return A new location to spawn the entity at.
*/
public Location getSafeLocation(Entity e, MVDestination d) {
Location l = d.getLocation(e);
if (this.bs.playerCanSpawnHereSafely(l)) {
plugin.log(Level.FINE, "The first location you gave me was safe.");
return l;
}
if (e instanceof Minecart) {
Minecart m = (Minecart) e;
if (!this.bs.canSpawnCartSafely(m)) {
return null;
}
} else if (e instanceof Vehicle) {
Vehicle v = (Vehicle) e;
if (!this.bs.canSpawnVehicleSafely(v)) {
return null;
}
}
Location safeLocation = this.getSafeLocation(l);
if (safeLocation != null) {
// Add offset to account for a vehicle on dry land!
if (e instanceof Minecart && !this.bs.isEntitiyOnTrack(e, safeLocation)) {
safeLocation.setY(safeLocation.getBlockY() + .5);
this.plugin.log(Level.FINER, "Player was inside a minecart. Offsetting Y location.");
}
this.plugin.log(Level.FINE, "Had to look for a bit, but I found a safe place for ya!");
return safeLocation;
}
if (e instanceof Player) {
Player p = (Player) e;
this.plugin.getMessaging().sendMessage(p, "No safe locations found!");
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
} else if (e.getPassenger() instanceof Player) {
Player p = (Player) e.getPassenger();
this.plugin.getMessaging().sendMessage(p, "No safe locations found!");
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
}
this.plugin.log(Level.FINE, "Sorry champ, you're basically trying to teleport into a minefield. I should just kill you now.");
return null;
}
public static Location findPortalBlockNextTo(Location l) {
Block b = l.getWorld().getBlockAt(l);
Location foundLocation = null;
if (b.getRelative(BlockFace.NORTH).getType() == Material.PORTAL) {
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.NORTH).getLocation(), foundLocation);
}
if (b.getRelative(BlockFace.SOUTH).getType() == Material.PORTAL) {
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.SOUTH).getLocation(), foundLocation);
}
if (b.getRelative(BlockFace.EAST).getType() == Material.PORTAL) {
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.EAST).getLocation(), foundLocation);
}
if (b.getRelative(BlockFace.WEST).getType() == Material.PORTAL) {
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.WEST).getLocation(), foundLocation);
}
return foundLocation;
}
private static Location getCloserBlock(Location source, Location blockA, Location blockB) {
// If B wasn't given, return a.
if (blockB == null) {
return blockA;
}
// Center our calculations
blockA.add(.5,0,.5);
blockB.add(.5,0,.5);
// Retrieve the distance to the normalized blocks
double testA = source.distance(blockA);
double testB = source.distance(blockB);
// Compare and return
if(testA <= testB) {
return blockA;
}
return blockB;
}
}
@@ -0,0 +1,22 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import org.getspout.spoutapi.SpoutManager;
public class SpoutInterface {
private SpoutManager spoutManager;
public SpoutInterface() {
this.spoutManager = SpoutManager.getInstance();
}
public SpoutManager getManager() {
return this.spoutManager;
}
}
@@ -0,0 +1,107 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Logger;
import java.util.regex.Pattern;
public class UpdateChecker {
public static final Logger log = Logger.getLogger("Minecraft");
public Timer timer = new Timer(); // Create a new Timer.
private String name; // Hold the Plugins Name.
private String cversion; // Hold the Plugins Current Version.
public UpdateChecker(String name, String version) {
this.name = name;
this.cversion = version;
int delay = 0; // No Delay, fire the first check instantly.
int period = 1800; // Delay 30 Minutes
this.timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
checkUpdate();
}
}, delay * 1000, period * 1000);
}
public void checkUpdate() {
try {
URL url = new URL("http://bukkit.onarandombox.com/multiverse/version.php?n=" + URLEncoder.encode(this.name, "UTF-8") + "&v=" + this.cversion);
URLConnection conn = url.openConnection();
conn.setReadTimeout(2000); // 2000 = 2 Seconds.
int code = ((HttpURLConnection) conn).getResponseCode();
if (code != 200) {
return;
}
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
String version = null;
while ((line = rd.readLine()) != null) {
if (version == null) {
version = line;
}
}
if (version == null) {
rd.close();
return;
}
String v1 = normalisedVersion(version);
String v2 = normalisedVersion(this.cversion);
int compare = v1.compareTo(v2);
if (compare > 0) {
log.info("[" + this.name + "]" + " - Update Available (" + version + ")");
}
rd.close();
} catch (Exception e) {
// No need to alert the user of any error here... it's not important.
}
}
/**
* Convert the given Version String to a Normalised Version String so we can compare it.
*
* @param version
*
* @return
*/
public static String normalisedVersion(String version) {
return normalisedVersion(version, ".", 4);
}
public static String normalisedVersion(String version, String sep, int maxWidth) {
String[] split = Pattern.compile(sep, Pattern.LITERAL).split(version);
StringBuilder sb = new StringBuilder();
for (String s : split) {
sb.append(String.format("%" + maxWidth + 's', s));
}
return sb.toString();
}
}
@@ -0,0 +1,423 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldCreator;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.permissions.Permission;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
/**
* Public facing API to add/remove Multiverse worlds.
*
* @author fernferret, Rigby90
*/
public class WorldManager implements MVWorldManager {
private MultiverseCore plugin;
private PurgeWorlds worldPurger;
private HashMap<String, MultiverseWorld> worlds;
private FileConfiguration configWorlds = null;
public WorldManager(MultiverseCore core) {
this.plugin = core;
this.worlds = new HashMap<String, MultiverseWorld>();
this.worldPurger = new PurgeWorlds(this.plugin);
}
/** {@inheritDoc} */
public boolean addWorld(String name, Environment env, String seedString, String generator) {
plugin.log(Level.FINE, "Adding world with: " + name + ", " + env.toString() + ", " + seedString + ", " + generator);
Long seed = null;
WorldCreator c = new WorldCreator(name);
if (seedString != null && seedString.length() > 0) {
try {
seed = Long.parseLong(seedString);
} catch (NumberFormatException numberformatexception) {
seed = (long) seedString.hashCode();
}
c.seed(seed);
}
// TODO: Use the fancy kind with the commandSender
c.generator(generator);
c.environment(env);
World world = null;
if (seed != null) {
if (generator != null) {
this.plugin.log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env + " with seed: " + seed + " & Custom Generator: " + generator);
} else {
this.plugin.log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env + " with seed: " + seed);
}
} else {
if (generator != null) {
this.plugin.log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env + " & Custom Generator: " + generator);
} else {
this.plugin.log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env);
}
}
try {
world = c.createWorld();
} catch (Exception e) {
this.plugin.log(Level.SEVERE, "The world '" + name + "' could NOT be loaded because it contains errors!");
this.plugin.log(Level.SEVERE, "Try using Chukster to repair your world! '" + name + "'");
this.plugin.log(Level.SEVERE, "http://forums.bukkit.org/threads/admin-chunkster.8186/");
return false;
}
if (world == null) {
this.plugin.log(Level.SEVERE, "Failed to Create/Load the world '" + name + "'");
return false;
}
MultiverseWorld mvworld = new MVWorld(world, this.configWorlds, this.plugin, seed, generator);
this.worldPurger.purgeWorld(null, mvworld);
this.worlds.put(name, mvworld);
return true;
}
/**
* Verifies that a given Plugin generator string exists.
*
* @param generator The name of the generator plugin. This should be something like CleanRoomGenerator.
*
* @return True if the plugin exists and is enabled, false if not.
*/
private boolean pluginExists(String generator) {
Plugin plugin = this.plugin.getServer().getPluginManager().getPlugin(generator);
return plugin != null && plugin.isEnabled();
}
/** {@inheritDoc} */
public ChunkGenerator getChunkGenerator(String generator, String generatorID, String worldName) {
if (generator == null) {
return null;
}
Plugin plugin = this.plugin.getServer().getPluginManager().getPlugin(generator);
if (plugin == null) {
return null;
} else {
return plugin.getDefaultWorldGenerator(worldName, generatorID);
}
}
/**
* Remove the world from the Multiverse list and from the config
*
* @param name The name of the world to remove
*
* @return True if success, false if failure.
*/
public boolean removeWorldFromConfig(String name) {
if (this.configWorlds.get("worlds." + name) != null) {
unloadWorld(name);
this.plugin.log(Level.INFO, "World '" + name + "' was removed from config.yml");
this.configWorlds.set("worlds." + name, null);
this.saveWorldsConfig();
return true;
} else {
this.plugin.log(Level.INFO, "World '" + name + "' was already removed from config.yml");
}
return false;
}
/** {@inheritDoc} */
public boolean unloadWorld(String name) {
if (this.worlds.containsKey(name)) {
this.worlds.remove(name);
this.plugin.log(Level.INFO, "World '" + name + "' was unloaded from memory.");
this.unloadWorldFromBukkit(name, true);
return true;
} else if (this.plugin.getServer().getWorld(name) != null) {
this.plugin.log(Level.WARNING, "Hmm Multiverse does not know about this world but it's still loaded in memory.");
this.plugin.log(Level.WARNING, "To be on the safe side, you should import it then try unloading again...");
} else {
this.plugin.log(Level.INFO, "The world " + name + " was already unloaded/did not exist.");
}
return false;
}
/** {@inheritDoc} */
public boolean loadWorld(String name) {
// Check if the World is already loaded
if (this.worlds.containsKey(name)) {
return true;
}
// Grab all the Worlds from the Config.
Set<String> worldKeys = this.configWorlds.getConfigurationSection("worlds").getKeys(false);
// Check that the list is not null and that the config contains the world
if ((worldKeys != null) && (worldKeys.contains(name))) {
// Grab the initial values from the config file.
String environment = this.configWorlds.getString("worlds." + name + ".environment", "NORMAL"); // Grab the Environment as a String.
String seedString = this.configWorlds.getString("worlds." + name + ".seed", "");
String generatorString = this.configWorlds.getString("worlds." + name + ".generator");
addWorld(name, this.plugin.getEnvFromString(environment), seedString, generatorString);
return true;
} else {
return false;
}
}
/** {@inheritDoc} */
public Boolean deleteWorld(String name) {
if (this.plugin.getServer().getWorld(name) == null) {
// We can only delete loaded worlds
return false;
}
removeWorldFromConfig(name);
try {
File serverFolder = new File(this.plugin.getDataFolder().getAbsolutePath()).getParentFile().getParentFile();
File worldFile = new File(serverFolder.getAbsolutePath() + File.separator + name);
if (name.equalsIgnoreCase("plugins")) {
this.plugin.log(Level.SEVERE, "Really? Are you high? This would delete your plugins folder. Luckily the MV2 devs are crazy smart or you're server would be ended...");
return false;
} else if (name.toLowerCase().contains("plugins")) {
this.plugin.log(Level.SEVERE, "I'm sorry, did you mean to type: 'rm plugins" + File.separator + "Essential*'? I could do that for you if you'd like...");
return false;
} else if (name.contains("..")) {
this.plugin.log(Level.SEVERE, "Uh yea... No way i'm going to delete a parent directory for you. You can go do 'rm -rf *.*' on your own time...");
return false;
} else if (name.equals(".")) {
this.plugin.log(Level.SEVERE, "Why on earth would you want to use Multiverse-Core to delete your Bukkit Server! How many beers have you had tonight... Give the keys to a friend.");
return false;
} else if (!worldFile.isDirectory()) {
this.plugin.log(Level.SEVERE, "C'mon man... Really?!?! Multiverse-Core is a great way to get players from A to B, but not to manage your files. To delete this file type:");
this.plugin.log(Level.SEVERE, "stop");
this.plugin.log(Level.SEVERE, "rm " + worldFile.getAbsolutePath());
return false;
}
plugin.log(Level.FINER, "deleteWorld(): worldFile: " + worldFile.getAbsolutePath());
boolean deletedWorld = FileUtils.deleteFolder(worldFile);
if (deletedWorld) {
this.plugin.log(Level.INFO, "World " + name + " was DELETED.");
} else {
this.plugin.log(Level.SEVERE, "World " + name + " was NOT deleted.");
this.plugin.log(Level.SEVERE, "Are you sure the folder " + name + " exists?");
this.plugin.log(Level.SEVERE, "Please check your file permissions on " + name);
}
return deletedWorld;
} catch (Exception e) {
this.plugin.log(Level.SEVERE, "Hrm, something didn't go as planned. Here's an exception for ya.");
this.plugin.log(Level.SEVERE, "You can go politely explain your situation in #multiverse on esper.net");
this.plugin.log(Level.SEVERE, "But from here, it looks like your folder is oddly named.");
this.plugin.log(Level.SEVERE, "This world has been removed from Multiverse-Core so your best bet is to go delete the folder by hand. Sorry.");
System.out.print(e);
return false;
}
}
/**
* Unload a world from Bukkit
*
* @param name Name of the world to unload
* @param safely Perform this safely. Set to True to save world files before unloading.
*
* @return True if the world was unloaded, false if not.
*/
private boolean unloadWorldFromBukkit(String name, boolean safely) {
this.removePlayersFromWorld(name);
return this.plugin.getServer().unloadWorld(name, safely);
}
/** {@inheritDoc} */
public void removePlayersFromWorld(String name) {
World w = this.plugin.getServer().getWorld(name);
if (w != null) {
World safeWorld = this.plugin.getServer().getWorlds().get(0);
List<Player> ps = w.getPlayers();
SafeTTeleporter teleporter = this.plugin.getTeleporter();
for (Player p : ps) {
// We're removing players forcefully from a world, they'd BETTER spawn safely.
teleporter.safelyTeleport(null, p, safeWorld.getSpawnLocation(), true);
}
}
}
/** {@inheritDoc} */
public Collection<MultiverseWorld> getMVWorlds() {
return this.worlds.values();
}
/** {@inheritDoc} */
@Override
public MultiverseWorld getMVWorld(String name) {
if (this.worlds.containsKey(name)) {
return this.worlds.get(name);
}
return this.getMVWorldByAlias(name);
}
/** {@inheritDoc} */
@Override
public MultiverseWorld getMVWorld(World world) {
if (world != null) {
return this.getMVWorld(world.getName());
}
return null;
}
/**
* Returns a {@link MVWorld} if it exists, and null if it does not. This will search ONLY alias.
*
* @param alias The alias of the world to get.
*
* @return A {@link MVWorld} or null.
*/
private MultiverseWorld getMVWorldByAlias(String alias) {
for (MultiverseWorld w : this.worlds.values()) {
if (w.getAlias().equalsIgnoreCase(alias)) {
return w;
}
}
return null;
}
/** {@inheritDoc} */
@Override
public boolean isMVWorld(String name) {
return (this.worlds.containsKey(name) || isMVWorldAlias(name));
}
/** {@inheritDoc} */
@Override
public boolean isMVWorld(World world) {
return world != null && this.isMVWorld(world.getName());
}
/**
* This method ONLY checks the alias of each world.
*
* @param alias The alias of the world to check.
*
* @return True if the world exists, false if not.
*/
private boolean isMVWorldAlias(String alias) {
for (MultiverseWorld w : this.worlds.values()) {
if (w.getAlias().equalsIgnoreCase(alias)) {
return true;
}
}
return false;
}
/** {@inheritDoc} */
public void loadWorlds(boolean forceLoad) {
// Basic Counter to count how many Worlds we are loading.
int count = 0;
// Grab all the Worlds from the Config.
if (this.configWorlds.getConfigurationSection("worlds") == null) {
this.configWorlds.createSection("worlds");
try {
this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
} catch (IOException e) {
this.plugin.log(Level.SEVERE, "Failed to save worlds.yml. Please check your file permissions.");
}
}
Set<String> worldKeys = this.configWorlds.getConfigurationSection("worlds").getKeys(false);
// Force the worlds to be loaded, ie don't just load new worlds.
if (forceLoad) {
// Remove all world permissions.
Permission allAccess = this.plugin.getServer().getPluginManager().getPermission("multiverse.access.*");
Permission allExempt = this.plugin.getServer().getPluginManager().getPermission("multiverse.exempt.*");
for (MultiverseWorld w : this.worlds.values()) {
// Remove this world from the master list
if (allAccess != null) {
allAccess.getChildren().remove(w.getAccessPermission().getName());
}
if (allExempt != null) {
allExempt.getChildren().remove(w.getAccessPermission().getName());
}
this.plugin.getServer().getPluginManager().removePermission(w.getAccessPermission().getName());
this.plugin.getServer().getPluginManager().removePermission(w.getExemptPermission().getName());
}
// Recalc the all permission
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(allAccess);
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(allExempt);
this.worlds.clear();
}
// Check that the list is not null.
if (worldKeys != null) {
for (String worldKey : worldKeys) {
// Check if the World is already loaded within the Plugin.
if (this.worlds.containsKey(worldKey)) {
continue;
}
// Grab the initial values from the config file.
String environment = this.configWorlds.getString("worlds." + worldKey + ".environment", "NORMAL"); // Grab the Environment as a String.
String seedString = this.configWorlds.getString("worlds." + worldKey + ".seed", "");
String generatorString = this.configWorlds.getString("worlds." + worldKey + ".generator");
addWorld(worldKey, this.plugin.getEnvFromString(environment), seedString, generatorString);
// Increment the world count
count++;
}
}
// Simple Output to the Console to show how many Worlds were loaded.
this.plugin.log(Level.INFO, count + " - World(s) loaded.");
}
/** {@inheritDoc} */
public PurgeWorlds getWorldPurger() {
return this.worldPurger;
}
/**
* Load the config from a file.
*
* @param file The file to load.
*
* @return A loaded configuration.
*/
public FileConfiguration loadWorldConfig(File file) {
this.configWorlds = YamlConfiguration.loadConfiguration(file);
return this.configWorlds;
}
public boolean saveWorldsConfig() {
try {
this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
return true;
} catch (IOException e) {
this.plugin.log(Level.SEVERE, "Could not save worlds.yml. Please check your settings.");
return false;
}
}
}
@@ -0,0 +1,39 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
/**
* Multiverse 2
* Currently Unused
*/
public class WorldProperty<T> {
private Class<T> type;
private Object value;
public WorldProperty(Class<T> type, Object two, String propertyLocation) {
this.type = type;
this.value = two;
}
public Class<T> getType() {
return this.type;
}
public Object getValue() {
return this.value;
}
public boolean setValue(Object value) {
if (value.getClass().equals(this.type)) {
this.value = value;
return true;
}
return false;
}
}
@@ -0,0 +1,21 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.utils;
/**
* Dummy class to make old MV Plugins not explode.
* If this loads, the user WILL get a severe telling them to update said plugin!
* WILL BE DELETED ON 11/1/11
*/
@Deprecated
public class DebugLog extends com.onarandombox.MultiverseCore.utils.DebugLog {
public DebugLog(String logger, String file) {
super(logger, file);
}
}
Loaded 100 of 109 files, more files were not shown because too many files have changed in this diff. Show more