Compare commits

..
205 Commits
Author SHA1 Message Date
Jeremy Wood 29360feb4e Fix potential bug in debug logging. Possibly fixes issue with debug logging not appearing in debug.log. 2012-01-23 13:02:46 -05:00
main() c7d35f13f4 _Never_ System.out.println() exceptions! 2012-01-23 17:43:21 +01:00
main() eebc5c6e62 Mocking is better than implementing mock-classes.
(déjà vu ... ;) )
2012-01-23 16:02:44 +01:00
Eric Stokes ecb97fd5c1 Migrate to the new event system 2012-01-22 21:44:43 -07:00
Eric Stokes bf76b77cf6 Add New api methods, Write location format better
Closes #411
2012-01-22 14:21:18 -07:00
Eric Stokes 21571bf54b Made MockBlock compatible with latest 1.1 builds 2012-01-22 14:20:45 -07:00
Eric Stokes 7b8f73f0af Bump Allpay version.
This adds EconXP support.
2012-01-16 19:45:29 -07:00
Eric Stokes 9313ff82ae Bump protocol to 11, since we changed the api classes 2012-01-15 14:17:51 -07:00
Eric Stokes c22acd6dd1 Fix arg range errors, add examples of WorldType. 2012-01-15 13:29:35 -07:00
Eric Stokes 0f3fd89228 Add new WorldTypes to Multiverse
This closed #394
2012-01-15 13:15:08 -07:00
Eric Stokes 7f93eedbac Spout fixed mentioned issue!
Commit it was fixed in:
https://github.com/SpoutDev/SpoutPlugin/commit/1157e6b6422ae156dd692f38e895ae0c5c5570a2

Build it was fixed in:
http://ci.spout.org/job/SpoutPlugin/681/
2012-01-14 13:57:31 -07:00
Eric Stokes b2457f38b1 Bump version to 2.3 2012-01-13 18:48:16 -07:00
Eric Stokes 04366dd50e Fix Properties not loading properly
Closes #397
This also fixes Active Properties not saving properly
2012-01-13 17:49:22 -07:00
main() dc0121509a Fixed shouldWeKillThisCreature() in MVEntityListener. 2012-01-12 19:01:10 +01:00
Eric Stokes 91c9e175d0 Add setActualDifficulty; Fixes #382
I also changed the difficulty properties to use setActualDifficulty.
2012-01-10 19:29:55 -07:00
Tim Ekl b006a458db Make syncMobs() public and Javadoc it 2012-01-06 20:53:38 -05:00
main() 1af30dad1d Added collection-support for sendMessages in MVMessaging. 2012-01-06 18:00:34 +01:00
Eric Stokes 79c06b5c42 Fix null worlds blowing up player money; Closes #373 2012-01-05 22:16:34 -07:00
main() 6861021c7a C'mon, avoiding bad style can't be that hard! 2012-01-05 11:49:01 +01:00
Eric Stokes 5435fca6b3 Fix pvp and a few other active settings 2012-01-04 23:00:40 -07:00
Eric Stokes 53c801bb81 Move to ActiveConfig Properties.
This still needs some cleanup, but works well.

I'd like some users to test (and comment here) on the following
commands:
mvm set pvp true/false (can't test this by myself)

Everything else looks good. All tests pass. Think this one (due to the
active properties) fixes #322
2012-01-04 21:46:19 -07:00
main() bb0b26e03c Another huge commit. Style once again, hopefully for the last time.
And we're now using CheckStyle-suppression-comments, thanks @lithium3141.
2012-01-04 13:17:10 +01:00
Eric Stokes 10d849dc51 Add time, remove global gamemode, see below:
- Add Time as a settable (but not stored) function proptery.
 - Add Function properties (They're called tempStringConfigProperties until I make them more generic. deal with it :P)
 - Remove the globalgamemode setting, since it's already covered with the new perms.

When I move TempStringConfigProperty to a seperate superclass (ActiveConfigProperty) we won't have the issue of things getting set anymore, as ActiveConfigProperties will change an active setting (gamemode for example) **when** they're set, not after some cleanup function gets run. Hell. Yes.

Off to bed... I promised this commit to someone which is why it's a lil' sloppy. Sorry :( Will fix tomorrow!
2012-01-03 21:01:51 -07:00
main() b69403e00c I knew it... 2012-01-03 16:30:23 +01:00
main() 120009c6b4 Let's go ahead and see if everything explodes. 2012-01-03 16:26:26 +01:00
main() 940dfa4a7e Removed unused PermissionTools in MVEntityListener 2012-01-03 15:06:47 +01:00
main() b7d3ae039c Improved the MVPlayerListener (style). 2012-01-03 15:03:28 +01:00
main() 5b056388a0 Style-fixes... They're driving me mad... 2012-01-03 15:01:44 +01:00
main() 9d16b7c445 Whitespace is allowed when arrays are initialized. 2012-01-03 15:00:39 +01:00
main() cf21793262 package-info.java 2012-01-03 13:41:49 +01:00
main() 632e926098 Added missing copyright-notice 2012-01-02 11:54:29 +01:00
main() aaa1d18865 Added MultiverseCoreListener. 2012-01-02 11:42:10 +01:00
Eric Stokes 851c6de3eb Prettied upthe buffer, added missing values 2012-01-01 15:06:51 -07:00
Eric Stokes 9963e6f29f Merge branch 'master' of github.com:Multiverse/Multiverse-Core 2012-01-01 13:56:33 -07:00
Eric Stokes d31ee6a5b8 Implement MVMessaging in the Teleport command 2012-01-01 13:56:20 -07:00
main() a5650f1f35 New "/mv version"-system. 2012-01-01 21:10:51 +01:00
main() 426a3bf252 I forgot to put that back in... 2012-01-01 21:09:52 +01:00
Eric Stokes 736eff06ea Add Messaging! (finally) 2012-01-01 12:56:36 -07:00
main() ac5f249164 Fixing the next bunch of CheckStyle-warnings.
I just pushed this without checking it, could somebody please review this commit?
2012-01-01 20:38:37 +01:00
Eric Stokes 0841362c26 Remove * imports. 2012-01-01 11:24:19 -07:00
Eric Stokes e344b0860d Changed priorities of the listeners to not cancel events too soon.
- Add the MVPortal Adjust Listener (lowest)
 - Change the PlayerListener to (High)
Remember that the priories are really just order, so if PlayerListener
was set to lowest, and cancelled the event, no one else would see it.

These changes are required for the fix that i'm finishing up for NPs
and SPs
2012-01-01 11:24:19 -07:00
main() c0d029c71d Fixed tests (I forgot that in 07247a1afd) 2012-01-01 17:32:32 +01:00
main() 07247a1afd ImportCommand now checks if the world was successfully imported.
Fixes #359
2012-01-01 17:28:44 +01:00
main() 47e052d180 Style-fixes. Tons of them. I was too lazy to pack them into different commits. 2012-01-01 17:22:05 +01:00
main() da0bed3b5e Added missing javadoc in the configuration-package. 2011-12-31 20:49:17 +01:00
main() c9b409844f Fixed redundant modifiers in MVWorldManager
... and changed Boolean to boolean
2011-12-31 20:40:28 +01:00
main() 2c392a53e6 Added missing javadoc for MVPlugin 2011-12-31 20:39:10 +01:00
main() f18d457a83 Added javadoc for FancyText 2011-12-31 20:38:53 +01:00
main() 6f884c9308 Style-fixes in MultiverseCore.
Oh, and String.format is better than string concatenation.
2011-12-31 20:30:09 +01:00
main() a45bfa4dc3 Nobody needs that anymore. 2011-12-31 20:29:20 +01:00
main() 1529f3e6dc Lines too long... -.- 2011-12-31 19:57:22 +01:00
main() d48927787b Fixed MagicNumberCheck in MVWorld 2011-12-31 19:56:53 +01:00
main() 76629ebd25 Now you can't set "respawnworld" to invalid values. 2011-12-31 18:32:58 +01:00
main() 659301a808 MVWorld wants a toString()! :P 2011-12-31 18:32:58 +01:00
Rusty Burchfield 408c09541a Add build instructions to README; Fix double-slash 2011-12-31 10:28:14 -07:00
Eric Stokes 29ddb5e5c1 Hmm apparently Beer helps with coding, but not version control... 2011-12-30 20:15:57 -07:00
Eric Stokes 4429bdcf8e Not sure how this stuff got left out... 2011-12-30 20:15:31 -07:00
Eric Stokes 9f12f6362b Bump config, Add workaround for spout issue.
Closes #355, Closes #149, Closes #349

This adds a new config var: firstspawnoverride that defaults to true.
You should disable this if you don't want mv to do your spawning (if
you have Spout, a warning will print and it will be disabled
automatically. The firstspawn feature will NOT work with spout at this
time.) When the spout bug is fixed, someone should open an issue. I
will not be monitoring this :)
2011-12-30 20:14:44 -07:00
Eric Stokes 9fa29bcde7 Minor Fix: Don't warn when players join the server. That's normal :) 2011-12-29 19:05:10 -07:00
Eric Stokes 346f1591ef Fix OPs/multiverse.* always having gamemode bypass.
I've added a separate namespace:
mv.bypass.gamemode.[*|X]
where X is a world name.

If a player has the * one, they ignore game mode changes GLOBALLY.

This perm defaults to FALSE, meaning OPS will NOT get it by default.
2011-12-29 18:55:24 -07:00
Eric Stokes 749ea12b4a Change warnings to fine/finer, ref #338 (and other issues) 2011-12-25 08:53:42 -07:00
Tim Ekl 20ad724e5a Merge branch 'plugin-smackdown'
Closes #328
2011-12-22 22:01:38 -06:00
Tim Ekl 8f44a8e77a Remove redundant TeleportIntercept check 2011-12-22 09:50:06 -06:00
Tim Ekl 8345c83afd Add config value (teleportintercept)
New config value sets whether to attempt to block non-permissible
teleport attempts initiated from other plugins. Previous behavior
was new config value `false` - MV would not intercept these outside
teleports. New default configured value is `true` - MV will intercept
(and possibly block) other plugins' teleports.
2011-12-21 23:34:35 -06:00
Tim Ekl 6761be6952 Intercept other plugins' teleports properly
This commit will eventually provide a fix for #328, when it gets merged
2011-12-21 23:20:58 -06:00
Tim Ekl 2879c2a96e Add bonus log messages for teleport permissions 2011-12-21 22:44:26 -06:00
dumptruckman a092dd8760 Added permission check with permissions "multiverse.gamemode.ignore.NAME" and of course "multiverse.gamemode.ignore.*" 2011-12-20 07:54:14 -05:00
dumptruckman 4246149bf2 Added checking for gamemode restriction bypass before trying to change gamemode
removed unreachable statement.
2011-12-20 07:54:10 -05:00
dumptruckman c2ad331ca5 added playerCanIgnoreGameModeRestriction() to be checked before changing game modes. 2011-12-20 07:52:33 -05:00
Eric Stokes fc24062f66 Add firstworldspawn, safe spawn disabling, fix a few neat bugs. 2011-12-19 20:03:36 -07:00
main() 8164f484dd Why is an if() without braces bad style!? Seriously!? 2011-12-19 20:53:38 +01:00
main() 2721419324 Added MVWorldDeleteEvent. 2011-12-19 20:48:14 +01:00
Tim Ekl 251b66a8d0 Additional null check; fix signportals issue 17 2011-12-18 21:16:13 -05:00
Tim Ekl fdb8c862f9 Merge branch 'perm-errors'
Closes #286
2011-12-18 15:37:06 -05:00
Tim Ekl 3d518f2e8e Update CommandHandler 2011-12-18 01:29:52 -05:00
Tim Ekl 9cfc75b7db Mark anchor destinations valid if they pass location checks
This commit closes portals bug #92
2011-12-17 14:27:58 -05:00
Tim Ekl 528b448450 Condense color alternation on generator lists; closes #318 2011-12-17 13:32:34 -05:00
Tim Ekl 48f8e033b6 Add a null check around some block safety checks 2011-12-16 00:41:57 -05:00
Tim Ekl 761c3b95d9 Implement support for CommandHandler's optional error displays
This commit relates to #286 and will eventually close it when it gets
merged
2011-12-15 23:19:14 -05:00
Tim Ekl ac229bfcd6 Update CommandHandler lib to v5; relates to #286 2011-12-15 23:07:14 -05:00
Tim Ekl 1894a2e4e7 Set up config support for suppressing perms errors; relates to #286 2011-12-15 22:57:54 -05:00
main() 327f0ce7c4 Pulled some methods up into the Core-interface
(amended, sorry)
2011-12-12 20:59:00 +01:00
main() 5ae12022d1 Lots of javadoc-fixes 2011-12-12 20:48:55 +01:00
main() 18ccb32bfe Javadoc-fixes + added missing @Overrides + fixed one name hiding in MVWorld 2011-12-12 20:09:21 +01:00
main() d7303f1289 Making the constructor private broke MVA...
Thanks to Jenkins for immediately reporting that!
2011-12-12 19:26:00 +01:00
main() cab8aaf040 JavadocStyleCheck: First sentence should end with a period.
Yes, one character can be that important. *sigh*
2011-12-12 17:40:33 +01:00
main() ca21047859 Fixed HideUtilityClassConstructorCheck 2011-12-12 17:26:17 +01:00
main() ae27a34bb0 Empty catch blocks are okay. 2011-12-12 17:22:47 +01:00
main() 90305a4379 Changed ITEMS_PER_PAGE to itemsPerPage since it's not a constant. 2011-12-12 17:15:23 +01:00
main() 033df2f407 Inline conditionals are awesome! 2011-12-12 17:14:54 +01:00
main() b2b1f91f38 Fixed warnings about RedundantModifierCheck. 2011-12-12 17:07:38 +01:00
main() 947235fa72 Parameters are allowed to hide fields. 2011-12-12 16:58:19 +01:00
main() 329ded9615 CheckStyle for Eclipse! :D 2011-12-12 16:57:44 +01:00
main() 86cfa9d98f Fixed another bunch of CheckStyle-warnings (VisibilityModifierCheck)
This time because of default visibility instead of private.

We need a better way for these global config variables in MultiverseCore.java
2011-12-12 16:45:54 +01:00
main() 1bdca7e615 TODO-Comments are a nice information, but no big deal.
CheckStyle, stop erroring about them!
2011-12-12 16:39:01 +01:00
main() 36c33fba14 We don't need javadoc for private stuff and constructors 2011-12-12 16:33:29 +01:00
main() 71794e0164 No @author tags! 2011-12-12 16:31:04 +01:00
main() 3b784b64c0 CheckStyle-warnings about AvoidStarImport should now be fixed! 2011-12-12 16:25:10 +01:00
Tim Ekl 06f3bb4f63 Remove remnants of old Pneumaticsystem repo; add distro information 2011-12-11 21:09:58 -05:00
Eric Stokes 7685af770c Add b to build # 2011-12-11 15:03:29 -07:00
Eric Stokes 80510a778b Add the onarandombox repo back! Yay! 2011-12-11 13:08:30 -07:00
Eric Stokes d7c1b8b0e2 Fix AIOOB. Fixes #303
Fixed an AIOOB when players had the list perm, but not perm to view any
world.
2011-12-11 12:02:01 -07:00
Eric Stokes bf0b70cbcd Let's try a png rather than a psd. 2011-12-11 11:44:36 -07:00
Eric Stokes 1fa79af412 Add 2 new logos 2011-12-11 11:42:35 -07:00
Eric Stokes 42f5d28b77 Add a properly sized logo. 2011-12-11 11:11:49 -07:00
Eric Stokes a5cfb81cc4 Add the logo to the config. 2011-12-11 10:54:45 -07:00
main() 4b53a8dfea Mocking is better than implementing Mock-classes 2011-12-11 13:33:50 +01:00
main() 32ccfe3458 General test-cleanups 2011-12-11 13:33:49 +01:00
Eric Stokes fe71006542 Keep the docs directory. 2011-12-10 22:38:40 -07:00
Eric Stokes 8a337fbf2a Add Doxygen files. 2011-12-10 22:33:59 -07:00
Eric Stokes ff514f8663 Testing Git Build Hook 2011-12-10 18:37:54 -07:00
Eric Stokes 97d905cf51 Add initial check style plugin. Default settings. 2011-12-10 17:44:11 -07:00
Eric Stokes ddc2850632 Merge branch 'master' of github.com:Multiverse/Multiverse-Core 2011-12-10 14:15:27 -07:00
Eric Stokes ea6b020850 Add test for Failure to select a valid command 2011-12-10 14:15:18 -07:00
main() d40ae35505 The config was awesome, but now it's REALLY AWESOME.
Java generics might be weak, but they can avoid permanent casting, resulting in better code :D
2011-12-10 21:04:34 +01:00
main() c9cd2a0f5c Prevented properties from getting null if they were invalid in worlds.yml 2011-12-10 21:03:38 +01:00
main() c0ae0e3eea Javadoc wants <p>, not <p/> 2011-12-10 11:21:26 +01:00
main() 0b2233cf7b We have to use the WorldContainer in the CreateCommand, too.
(This should have been changed in af439b678e)
2011-12-10 11:04:29 +01:00
Eric Stokes d8cb6497f0 Display the spawn location when changing it. Closes #295.
I'm closing this issue and "moving" the rest of it, the ability to
import/create a world without using the checker to Issue #300
2011-12-10 00:53:02 -07:00
Eric Stokes e5d468f03f Fix properties not reporting when the value was wrong, but the key was. 2011-12-10 00:41:28 -07:00
Eric Stokes a33d1420ba Add game mode test.
This test should pass, but alas it fails :(
2011-12-10 00:36:40 -07:00
Eric Stokes 70f03e80bc Update the POM to use parallelized tests.
Don't try and run our cool classes.
2011-12-09 19:58:11 -07:00
main() f091a32174 Now saving mob exceptions correctly. Fixes #287 2011-12-09 16:53:50 +01:00
Tim Ekl ff8b9eb3b7 Remove onarandombox repo; fix the build version number replacement 2011-12-09 10:04:46 -05:00
fernferret 08736cca16 Time for bed. Too many mistakes. Fixed the Core Pom (again) 2011-12-09 01:00:49 -07:00
fernferret 10a4ec1c0b Add WorldContainer to tests, they pass again. Yay! 2011-12-09 00:39:57 -07:00
fernferret 5159fe7a17 Add new repo to the POM. 2011-12-09 00:06:34 -07:00
Eric Stokes fe52040b48 Merge pull request #298 from 4am/master
Fixed Importing from a world container directory which is not the default
2011-12-08 19:35:32 -08:00
4am af439b678e Changed runCommand to look in world container directory (defined in bukkit.yml) instead of in the server folder when attempting to load world files. 2011-12-08 19:19:17 -05:00
Tim Ekl 77ced857ea Merge branch 'master' of github.com:Multiverse/Multiverse-Core 2011-12-08 18:25:38 -05:00
Tim Ekl 24efbf2ea9 Remove UNKNOWN version number from pom.xml 2011-12-08 18:25:05 -05:00
main() 5b17df65e9 Removed unused imports 2011-12-08 19:59:20 +01:00
main() 8b721886f5 Yes, the MVConfigMigrator is old and uses deprecated stuff. 2011-12-08 19:59:10 +01:00
main() dbf109f051 Raw types are evil. 2011-12-08 19:17:55 +01:00
main() 56e4e493b1 Fixed all javadoc warnings and some typos. 2011-12-08 19:08:07 +01:00
Tim Ekl 8916f0dbbc Combine JUnit dependencies 2011-12-07 00:16:42 -05:00
Eric Stokes 3a5bc6adda Actually fixed #294 2011-12-06 18:40:09 -07:00
Eric Stokes f6e49bd8eb Fix pitch/yaw switched for mvss on reload 2011-12-06 18:14:34 -07:00
Eric Stokes 15ce10671e Fix colors bleeding into the next name, Fixes #285 2011-12-02 18:19:26 -07:00
Eric Stokes a0ab24a132 Merge branch 'master' of github.com:Multiverse/Multiverse-Core 2011-11-30 19:38:58 -07:00
Eric Stokes ee75392a9e Fix anchor direction, Fixes #283 2011-11-30 19:38:35 -07:00
Tim Ekl 6fd7c84276 Fix Javadoc on PasteService interface 2011-11-30 11:44:18 -05:00
Tim Ekl df5bfdde80 Allow posting to pastie.org or pastebin.com (pastie.org is the new default); closes #277 2011-11-29 20:55:13 -07:00
Tim Ekl 8e74945b7e Add null check for files returned in world check; closes #278 2011-11-29 20:14:11 -05:00
Eric Stokes 5d2a1e478c Fix Anchors not being saved proplery, Fix safe spawn disabling, closes #207, Remove server.properties code, that bukkit bug is gone, closes #275 2011-11-28 00:08:39 -07:00
Eric Stokes e110b1f6a5 Add anchors 2011-11-27 18:50:42 -07:00
Eric Stokes 803eb84f3f Commit paginated changes, Add PermissionsTools 2011-11-27 01:42:18 -07:00
Eric Stokes 562de0f002 Fix tp perms to take into account teleporter and teleportee. This may eat your server 2011-11-26 19:38:57 -07:00
Eric Stokes 156e7ce373 Fix tests, and caught NPE 2011-11-26 17:42:58 -07:00
Eric Stokes 939a2e8b1f Add paginated commands, Closes #203, Add folder suggestions when your import fails 2011-11-26 17:24:17 -07:00
Eric Stokes 792d2ce5e6 Remove PaginatedCommand 2011-11-26 15:20:08 -07:00
Eric Stokes 03424165a4 Fix world.dat being adjusted every time, Fixes #268 2011-11-26 15:00:52 -07:00
Eric Stokes f2a65b4fd9 Fix bedrespawn not being checked. Fixes #240 2011-11-26 13:01:45 -07:00
Eric Stokes 6afbd1d13d Bump API version to 8, Remove junk, Update CommandHandler (Closes #267) 2011-11-26 12:33:12 -07:00
Eric Stokes d2a5898e53 Fix seeds (Closes #266), Allow Regeneration of map (Closes #202)
Fixed long seeds not loading properly (this happened with the new
config), Add Regenning of worlds. This works for the same seed, but new
seeds are still in the works.
2011-11-26 11:28:44 -07:00
main() fa0c843f39 Improved (or broke) tests. 2011-11-26 12:07:28 +01:00
main() 459aad2d2b Fixed NPE when there was no worlds-section in bukkit.yml 2011-11-26 12:07:28 +01:00
Eric Stokes 0fa8f4e824 Force default worlds to be imported, Closes #265 2011-11-26 01:49:46 -07:00
Eric Stokes 82eff21dbf Revert earlier changes about using the repo, fix awesome unload bug. Now you can't unload defaultly loaded worlds 2011-11-26 00:35:07 -07:00
Eric Stokes 6bf9d1c9bb Add Help to the Import Command 2011-11-25 22:59:06 -07:00
Eric Stokes 71bfd2a1ad Remove submodules in favor of deployments 2011-11-25 22:45:27 -07:00
Eric Stokes 4b2152a05c Add new world delete method (Closes #260), Remove world from unloaded list when it's removed from the configs 2011-11-25 19:29:00 -07:00
Eric Stokes 6a80c8c1de Merge branch 'fixed-tests' Closes #261
Tested, and the tests all pass!
2011-11-25 18:17:32 -07:00
Eric Stokes c4dd2e3005 Much needed code re-format 2011-11-25 18:13:14 -07:00
Eric Stokes 4006e53243 Fix formatting with pullrequest, remove dragon, to @Rigby90's point, this will be bad for 3rd party addons. 2011-11-25 18:07:46 -07:00
Eric Stokes f894859df9 Fix the pastebin.com poster (Bad API request bug) 2011-11-25 17:44:52 -07:00
sthycb c9a33350ac Added Support for EnderDragon purging now Supports Dragon or EnderDragon as the keyword (No changes needed to this file if this functionality is not desired) Ie: With the old code player must enter the correct "enderdragon" entering "dragon" on any other invalid keyword will report "0 - mobs purged". NOTE: This change would break for a player has a mod that has an entity called "Dragon". 2011-11-25 17:23:31 -07:00
Eric Stokes 0c847eefdf Add more fixes that I broke when fixing #255 2011-11-25 16:57:01 -07:00
Eric Stokes 9710501a03 Fix lots of bad things with #255 2011-11-25 16:56:36 -07:00
main() 11fe1aee10 Fixed the tests. Closes #252 2011-11-25 18:02:41 +01:00
Eric Stokes 3e3990eba4 Add WorldPropertyChang event Fixes #255, reduce the search radius until we can find a better place in the end. 2011-11-24 18:41:09 -07:00
Tim Ekl 06f53a0b47 Fix NPE on incorrect world chat color & correct in config 2011-11-23 20:02:06 -06:00
Eric Stokes 9a7c6202cc Add bedrespawn as a per-world property. Fixes #192. Fixes #221. 2011-11-22 21:52:18 -07:00
Eric Stokes 5d932060ee Removed deprecated items, Add autoload (Fixes #241) 2011-11-22 21:01:00 -07:00
Eric Stokes 8803374126 Fix colors not persisting through reloads 2011-11-22 19:50:52 -07:00
Eric Stokes 3c424c1c33 Fix aliases not working when setting 2011-11-22 19:41:56 -07:00
Eric Stokes 9f8e1689f6 Fix silly list mistake in worlds, fix gamemode not switching, fix a bunch of npes 2011-11-22 19:27:03 -07:00
Eric Stokes 2717a7bbee Attempted fix for npe on worldmanager 2011-11-22 00:14:54 -07:00
Eric Stokes 29bc8bfbfc Fix massive NPEs for real, Don't comment out tests, use @Ignore, Thanks @main-- 2011-11-21 22:44:36 -07:00
Eric Stokes af428a236d Merge with betterproperties 2011-11-21 21:56:34 -07:00
Eric Stokes 25be687762 Fix NPE 2011-11-21 21:55:28 -07:00
Eric Stokes d6b5fb9a25 Update for MC 1.0.0 2011-11-21 21:07:20 -07:00
Eric Stokes e818b1ee73 Merge with test branch 2011-11-06 10:00:44 -07:00
Eric Stokes 92db828e3a Merge branch 'master' into better-properties 2011-11-05 12:08:10 -06:00
Tim Ekl 61bed8e72d Merge pull request #229 from Multiverse/broadcasts
Broadcast-Messages
2011-11-03 08:22:02 -07:00
Eric Stokes f774d861c2 Fix typos 2011-10-23 11:01:42 -06:00
Eric Stokes 65b375edeb Added item specific help to config properties. 2011-10-23 10:47:46 -06:00
Eric Stokes b19799f764 Cleanup old variables 2011-10-22 17:45:03 -06:00
Eric Stokes 2e41d149fe Done converting MVWorld, now needs testing 2011-10-22 17:38:00 -06:00
Eric Stokes c576d5a3a2 Add the new style of saving/loading world properties.
All properties have been converted, but are not all implemented yet. I'm just committing because it's been several hours... o.O
2011-10-22 14:16:00 -06:00
Eric Stokes 6b95be4ca5 Add new interface, and a new paginated command, both shells 2011-10-22 11:01:05 -06:00
Eric Stokes 1712b175d8 Add autoheal and adjustSpawn as per-world properties 2011-10-22 11:00:32 -06:00
Eric Stokes 46db76a6cc Add new test stuff 2011-10-21 18:37:18 -06:00
Eric Stokes 0e708a1f51 Move utils to a different package, add skylands to import test 2011-10-21 18:03:34 -06:00
Eric Stokes 65369b6a4b refactor rests even more 2011-10-21 17:48:28 -06:00
Eric Stokes ab311dd8d9 Reorged the tests, LOTS OF CLEANUP 2011-10-20 18:36:33 -06:00
Eric Stokes 2b2a406cce Merge branch 'master' into test 2011-10-20 17:31:39 -06:00
Eric Stokes 3ad1bfad2b Woohoo! All tests passgsgs 2011-10-20 17:30:29 -06:00
Eric Stokes b028811d36 Merge branch 'master' into test 2011-10-20 16:44:02 -06:00
main() 6a6b29923d Bump version to 2.2 2011-10-19 19:59:03 +02:00
main() 0581415ae5 Added broadcast-messages (Closes #197) 2011-10-19 19:48:43 +02:00
Eric Stokes 728002ecce Still not working :/ Need to simulate worlds now... 2011-10-15 12:38:34 -06:00
Eric Stokes e45ae8f9dc Much farther with testing. Keep testing... 2011-10-15 12:23:13 -06:00
Eric Stokes edb999578a Seperated MockWorld tests 2011-10-15 08:20:29 -06:00
fernferret d1f51acb1c Add Broken tests 2011-10-15 09:47:07 -04:00
151 changed files with 10062 additions and 2135 deletions

No files matched your search

+9 -1
View File
@@ -2,6 +2,7 @@
/.classpath
/.project
/.settings
/.checkstyle
# netbeans
/nbproject
@@ -33,4 +34,11 @@
.idea/
# Fern's utils
uploadtoserver.sh
uploadtoserver.sh
# Testing files:
debug.log
# Doxygen
/docs/html
debug.txt
+14 -1
View File
@@ -1,5 +1,18 @@
Building
========
Update the submodules after you clone and before you build with maven.
```
$ git submodule update --init --recursive
$ mvn install
```
More details are available on the [build instructions wiki page](https://github.com/Multiverse/Multiverse-Core/wiki/Building).
License
=======
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.
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.
+1813
View File
File diff suppressed because it is too large. Load diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

+142
View File
@@ -0,0 +1,142 @@
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ 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. ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!-- Future reference: valid severity values are 'ignore', 'info', 'warning', 'error' -->
<module name="Checker">
<module name="JavadocPackage">
<property name="allowLegacy" value="true"/>
</module>
<module name="NewlineAtEndOfFile">
<property name="severity" value="info"/>
</module>
<module name="Translation"/>
<module name="FileLength"/>
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<module name="RegexpSingleline">
<property name="message" value="Line has trailing spaces."/>
<property name="format" value="\s+$"/>
</module>
<module name="SuppressWithNearbyCommentFilter">
<property name="commentFormat" value="SUPPRESS CHECKSTYLE: (\w+)"/>
<property name="checkFormat" value="$1"/>
</module>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="BEGIN CHECKSTYLE-SUPPRESSION\: (\w+)"/>
<property name="onCommentFormat" value="END CHECKSTYLE-SUPPRESSION\: (\w+)"/>
<property name="checkFormat" value="$1"/>
</module>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="BEGIN CHECKSTYLE-SUPPRESSION\: ALL"/>
<property name="onCommentFormat" value="END CHECKSTYLE-SUPPRESSION\: ALL"/>
</module>
<module name="TreeWalker">
<!-- Make suppression possible -->
<module name="FileContentsHolder"/>
<!-- Actual checks -->
<module name="LineLength">
<property name="max" value="160"/>
<property name="severity" value="warning"/>
</module>
<module name="JavadocMethod">
<property name="scope" value="package"/><!-- We don't need javadoc for private methods -->
<property name="tokens" value="METHOD_DEF"/><!-- We don't need javadoc for constructors -->
</module>
<module name="JavadocType"/>
<module name="JavadocVariable">
<property name="scope" value="package"/><!-- We don't need javadoc for private variables -->
</module>
<module name="JavadocStyle"/>
<module name="WriteTag">
<property name="tag" value="@author"/>
<property name="tagFormat" value="\S"/>
<property name="severity" value="ignore"/>
<property name="tagSeverity" value="warning"/>
</module>
<module name="ConstantName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<module name="AvoidStarImport">
<property name="severity" value="warning"/>
<property name="excludes" value="com.onarandombox.MultiverseCore.utils,com.onarandombox.MultiverseCore.configuration,com.onarandombox.MultiverseCore.commands,com.onarandombox.MultiverseCore.destination"/>
</module>
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>
</module>
<module name="MethodLength"/>
<module name="ParameterNumber"/>
<module name="EmptyForIteratorPad"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter">
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS"/>
</module>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter">
<property name="severity" value="warning"/>
</module>
<module name="WhitespaceAround">
<property name="severity" value="warning"/>
</module>
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock">
<property name="tokens" value="LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_IF,LITERAL_FOR,LITERAL_TRY,LITERAL_WHILE,INSTANCE_INIT,STATIC_INIT"/>
</module>
<module name="LeftCurly"/>
<module name="RightCurly"/>
<module name="DoubleCheckedLocking"/>
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField">
<property name="tokens" value="VARIABLE_DEF"/><!-- We don't care if parameters hide fields. -->
</module>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber">
<property name="ignoreNumbers" value="-1, 0, 0.5, 1, 2, 3"/>
</module>
<module name="MissingSwitchDefault"/>
<module name="RedundantThrows"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<!-- Don't like errors for `final` missing
<module name="DesignForExtension"/>
<module name="FinalClass"/>
-->
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier">
<property name="protectedAllowed" value="true"/>
</module>
<module name="ArrayTypeStyle"/>
<!-- Don't like errors for `final` missing
<module name="FinalParameters"/>
-->
<module name="TodoComment">
<property name="severity" value="info"/>
</module>
<module name="UpperEll"/>
<module name="Indentation"/>
<module name="MissingDeprecated"/>
<module name="MissingOverride"/>
</module>
</module>
View File
Whitespace-only changes.
+96 -11
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.onarandombox.multiversecore</groupId>
<artifactId>Multiverse-Core</artifactId>
<version>2.1</version>
<version>2.3</version>
<name>Multiverse-Core</name>
<description>World Management Plugin</description>
<properties>
@@ -13,8 +13,8 @@
<repositories>
<repository>
<id>OnARandomBox</id>
<url>http://repo.onarandombox.com/artifactory/repo</url>
<id>onarandombox</id>
<url>http://repo.onarandombox.com/content/groups/public</url>
</repository>
</repositories>
@@ -34,6 +34,22 @@
<url>http://ci.onarandombox.com</url>
</ciManagement>
<!-- Profiles are used to detect whether this is a local or Jenkins build
and adjust the build number accordingly -->
<profiles>
<profile>
<id>jenkins</id>
<activation>
<property>
<name>env.BUILD_NUMBER</name>
</property>
</activation>
<properties>
<project.build.number>${env.BUILD_NUMBER}</project.build.number>
</properties>
</profile>
</profiles>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
@@ -61,7 +77,7 @@
</goals>
<configuration>
<sources>
<source>${project.basedir}/lib/allpay/src</source>
<source>${project.basedir}/lib/allpay/src/main/java</source>
<source>${project.basedir}/lib/commandhandler/src</source>
<source>${project.basedir}/lib/commandhandler/lib/ShellParser/src</source>
</sources>
@@ -86,7 +102,7 @@
<replacements>
<replacement>
<token>maven-version-number</token>
<value>${project.version}-${project.build.number}</value>
<value>${project.version}-b${project.build.number}</value>
</replacement>
</replacements>
</configuration>
@@ -109,6 +125,35 @@
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<configuration>
<parallel>methods</parallel>
<threadCount>10</threadCount>
<excludes>
<exclude>**/TestCommandSender.java</exclude>
<exclude>**/TestInstanceCreator.java</exclude>
</excludes>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.11</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.8</version>
<configuration>
<enableRulesSummary>true</enableRulesSummary>
<configLocation>${project.basedir}/config/mv_checks.xml</configLocation>
</configuration>
</plugin>
</plugins>
</build>
@@ -117,7 +162,7 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.1-R1-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
@@ -125,7 +170,7 @@
<!-- Start of Spout -->
<dependency>
<groupId>org.getspout</groupId>
<artifactId>spoutapi</artifactId>
<artifactId>spoutpluginapi</artifactId>
<version>dev-SNAPSHOT</version>
</dependency>
<!-- End of Spout -->
@@ -184,13 +229,53 @@
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End of Economy Dependencies -->
<!-- Start of JUnit Dependencies -->
<dependency>
<groupId>org.junit</groupId>
<groupId>ca.agnate</groupId>
<artifactId>EconXP</artifactId>
<version>1.0.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End of Economy Dependencies -->
<!-- Start of Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
<!-- End of JUnit Dependencies -->
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.4.9</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<version>1.4.9</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.4.9</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>
<!-- End of Test Dependencies -->
</dependencies>
<distributionManagement>
<repository>
<id>OnARandomBox</id>
<url>http://repo.onarandombox.com/content/repositories/multiverse</url>
</repository>
</distributionManagement>
</project>
@@ -1,17 +0,0 @@
/******************************************************************************
* 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 {
}
@@ -1,20 +0,0 @@
/******************************************************************************
* 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);
}
}
File diff suppressed because it is too large. Load diff
@@ -11,52 +11,110 @@ 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.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
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.destination.AnchorDestination;
import com.onarandombox.MultiverseCore.destination.BedDestination;
import com.onarandombox.MultiverseCore.destination.CannonDestination;
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
import com.onarandombox.MultiverseCore.destination.ExactDestination;
import com.onarandombox.MultiverseCore.destination.PlayerDestination;
import com.onarandombox.MultiverseCore.destination.WorldDestination;
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
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.AnchorManager;
import com.onarandombox.MultiverseCore.utils.DebugLog;
import com.onarandombox.MultiverseCore.utils.MVMessaging;
import com.onarandombox.MultiverseCore.utils.MVPermissions;
import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.SpoutInterface;
import com.onarandombox.MultiverseCore.utils.WorldManager;
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.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* The implementation of the Multiverse-{@link Core}.
*/
public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
private final static int Protocol = 7;
private static final int PROTOCOL = 12;
// Global Multiverse config variable, states whether or not
// Multiverse should stop other plugins from teleporting players
// to worlds.
// TODO This is REALLY bad style! We have to change this!
// No, I'm NOT going to suppress these warnings because we HAVE TO CHANGE THIS!
public static boolean EnforceAccess;
public static boolean EnforceGameModes;
public static boolean PrefixChat;
public static boolean BedRespawn;
public static boolean DisplayPermErrors;
public static boolean TeleportIntercept;
public static boolean FirstSpawnOverride;
public static Map<String, String> teleportQueue = new HashMap<String, String>();
public static int GlobalDebug = 0;
private AnchorManager anchorManager = new AnchorManager(this);
/**
* This method is used to find out who is teleporting a player.
* @param playerName The teleported player (the teleportee).
* @return The player that teleported the other one (the teleporter).
*/
public static String getPlayerTeleporter(String playerName) {
if (teleportQueue.containsKey(playerName)) {
String teleportee = teleportQueue.get(playerName);
teleportQueue.remove(playerName);
return teleportee;
}
return null;
}
/**
* This method is used to add a teleportation to the teleportQueue.
*
* @param teleporter The name of the player that initiated the teleportation.
* @param teleportee The name of the player that was teleported.
*/
public static void addPlayerToTeleportQueue(String teleporter, String teleportee) {
staticLog(Level.FINEST, "Adding mapping '" + teleporter + "' => '" + teleportee + "' to teleport queue");
teleportQueue.put(teleportee, teleporter);
}
@Override
public String toString() {
return "The Multiverse-Core Plugin";
}
/**
* {@inheritDoc}
* @deprecated This is now deprecated, nobody needs it any longer.
* All version info-dumping is now done with {@link MVVersionEvent}.
*/
@Override
@Deprecated
public String dumpVersionInfo(String buffer) {
// I'm kinda cheating on this one, since we call the init event.
return buffer;
}
@@ -67,23 +125,23 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
@Override
public void setCore(MultiverseCore core) {
// This method is required by the interface (so core is effectively a plugin of itself) and therefore
// this is never used.
}
@Override
public int getProtocolVersion() {
return MultiverseCore.Protocol;
return MultiverseCore.PROTOCOL;
}
// Useless stuff to keep us going.
private static final Logger log = Logger.getLogger("Minecraft");
private static final Logger LOGGER = 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]";
private static final String LOG_TAG = "[Multiverse-Core]";
// Multiverse Permissions Handler
private MVPermissions ph;
@@ -91,7 +149,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// Configurations
private FileConfiguration multiverseConfig = null;
private WorldManager worldManager = new WorldManager(this);
private MVWorldManager worldManager = new WorldManager(this);
// Setup the block/player/entity listener.
private MVPlayerListener playerListener = new MVPlayerListener(this);
@@ -100,22 +158,21 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
private MVPluginListener pluginListener = new MVPluginListener(this);
private MVWeatherListener weatherListener = new MVWeatherListener(this);
public UpdateChecker updateCheck;
public static int GlobalDebug = 0;
//public UpdateChecker updateCheck;
// 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 int pluginCount;
private DestinationFactory destFactory;
private SpoutInterface spoutInterface = null;
private double allpayversion = 3;
private double chversion = 1;
private static final double ALLPAY_VERSION = 5;
private static final double CH_VERSION = 4;
private MVMessaging messaging;
private File serverFolder = new File(System.getProperty("user.dir"));
@Override
public void onLoad() {
// Create our DataFolder
@@ -124,24 +181,39 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
debugLog = new DebugLog("Multiverse-Core", getDataFolder() + File.separator + "debug.log");
}
/**
* {@inheritDoc}
*/
@Override
public FileConfiguration getMVConfiguration() {
return this.multiverseConfig;
}
/**
* {@inheritDoc}
*/
@Override
public GenericBank getBank() {
return this.bank;
}
/**
* {@inheritDoc}
*/
@Override
public void onEnable() {
//this.worldManager = new WorldManager(this);
// Perform initial checks for AllPay
if (!this.validateAllpay() || !this.validateCH()) {
this.getServer().getPluginManager().disablePlugin(this);
return;
}
this.banker = new AllPay(this, tag + " ");
this.messaging = new MVMessaging();
this.banker = new AllPay(this, LOG_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.log(Level.INFO, "- Version " + this.getDescription().getVersion() + " (API v" + PROTOCOL + ") Enabled - By " + getAuthors());
// Load the defaultWorldGenerators
this.worldManager.getDefaultWorldGenerators();
this.registerEvents();
// Setup Permissions, we'll do an initial check for the Permissions plugin then fall back on isOP().
@@ -168,53 +240,62 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// Setup & Load our Configuration files.
loadConfigs();
if (this.multiverseConfig != null) {
this.worldManager.loadDefaultWorlds();
this.worldManager.loadWorlds(true);
} else {
this.log(Level.SEVERE, "Your configs were not loaded. Very little will function in Multiverse.");
}
this.anchorManager.loadAnchors();
// Now set the firstspawnworld (after the worlds are loaded):
// Default as the server.props world.
this.worldManager.setFirstSpawnWorld(this.multiverseConfig.getString("firstspawnworld", getDefaultWorldName()));
// We have to set this one here, if it's not present, we don't know the name of the default world.
// and this one won't be in the defaults yml file.
try {
this.multiverseConfig.set("firstspawnworld", this.worldManager.getFirstSpawnWorld().getName());
} catch (NullPointerException e) {
// A test that had no worlds loaded was being run. This should never happen in production
}
this.saveMVConfig();
// Check to see if spout was already loaded (most likely):
if (this.getServer().getPluginManager().getPlugin("Spout") != null) {
this.setSpout();
this.log(Level.INFO, "Spout integration enabled.");
}
}
private boolean validateAllpay() {
try {
this.banker = new AllPay(this, "Verify");
if (this.banker.getVersion() >= allpayversion) {
if (this.banker.getVersion() >= ALLPAY_VERSION) {
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!");
LOGGER.info(String.format("%s - Version %s was NOT ENABLED!!!", LOG_TAG, this.getDescription().getVersion()));
LOGGER.info(String.format("%s A plugin that has loaded before %s has an incompatible version of AllPay (an internal library)!",
LOG_TAG, this.getDescription().getName()));
LOGGER.info(String.format("%s The Following Plugins MAY out of date: %s", LOG_TAG, AllPay.pluginsThatUseUs.toString()));
LOGGER.info(String.format("%s This plugin needs AllPay v%f or higher and another plugin has loaded v%f!",
LOG_TAG, ALLPAY_VERSION, this.banker.getVersion()));
return false;
}
private boolean validateCH() {
try {
this.commandHandler = new CommandHandler(this, null);
if (this.commandHandler.getVersion() >= chversion) {
if (this.commandHandler.getVersion() >= CH_VERSION) {
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!");
LOGGER.info(String.format("%s - Version %s was NOT ENABLED!!!", LOG_TAG, this.getDescription().getVersion()));
LOGGER.info(String.format("%s A plugin that has loaded before %s has an incompatible version of CommandHandler (an internal library)!",
LOG_TAG, this.getDescription().getName()));
LOGGER.info(String.format("%s Please contact this plugin author!!!", LOG_TAG));
LOGGER.info(String.format("%s This plugin needs CommandHandler v%f or higher and another plugin has loaded v%f!",
LOG_TAG, CH_VERSION, this.commandHandler.getVersion()));
return false;
}
@@ -226,33 +307,24 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
this.destFactory.registerDestinationType(PlayerDestination.class, "pl");
this.destFactory.registerDestinationType(CannonDestination.class, "ca");
this.destFactory.registerDestinationType(BedDestination.class, "b");
this.destFactory.registerDestinationType(AnchorDestination.class, "a");
}
/** Function to Register all the Events needed. */
/**
* 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);
pm.registerEvents(this.playerListener, this);
pm.registerEvents(this.entityListener, this);
pm.registerEvents(this.pluginListener, this);
pm.registerEvents(this.weatherListener, this);
}
/** Load the Configuration files OR create the default config files. */
/**
* {@inheritDoc}
*/
@Override
public void loadConfigs() {
// Now grab the Configuration Files.
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
@@ -267,19 +339,50 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
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));
// Should MV Intercept teleports by other plugins?
TeleportIntercept = this.multiverseConfig.getBoolean("teleportintercept", true);
// Should MV do the first spawn stuff?
FirstSpawnOverride = this.multiverseConfig.getBoolean("firstspawnoverride", true);
// Should permissions errors display to users?
DisplayPermErrors = this.multiverseConfig.getBoolean("displaypermerrors", true);
this.messaging.setCooldown(this.multiverseConfig.getInt("messagecooldown", 5000)); // SUPPRESS CHECKSTYLE: MagicNumberCheck
// Update the version of the config!
this.multiverseConfig.set("version", coreDefaults.get("version"));
// Remove old values.
this.multiverseConfig.set("enforcegamemodes", null);
this.multiverseConfig.set("bedrespawn", null);
this.multiverseConfig.set("opfallback", null);
this.saveMVConfigs();
}
/**
* Safely return a world name.
* (The tests call this with no worlds loaded)
*
* @return The default world name.
*/
private String getDefaultWorldName() {
if (this.getServer().getWorlds().size() > 0) {
return this.getServer().getWorlds().get(0).getName();
}
return "";
}
/**
* {@inheritDoc}
*/
@Override
public MVMessaging getMessaging() {
return this.messaging;
}
/** Register Multiverse-Core commands to Command Manager. */
/**
* Register Multiverse-Core commands to Command Manager.
*/
private void registerCommands() {
// Intro Commands
this.commandHandler.registerCommand(new HelpCommand(this));
@@ -299,6 +402,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
this.commandHandler.registerCommand(new LoadCommand(this));
this.commandHandler.registerCommand(new RemoveCommand(this));
this.commandHandler.registerCommand(new DeleteCommand(this));
this.commandHandler.registerCommand(new RegenCommand(this));
this.commandHandler.registerCommand(new ConfirmCommand(this));
// Modification commands
this.commandHandler.registerCommand(new ModifyCommand(this));
@@ -308,6 +412,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
this.commandHandler.registerCommand(new ModifyRemoveCommand(this));
this.commandHandler.registerCommand(new ModifyClearCommand(this));
this.commandHandler.registerCommand(new ConfigCommand(this));
this.commandHandler.registerCommand(new AnchorCommand(this));
// Misc Commands
this.commandHandler.registerCommand(new EnvironmentCommand(this));
this.commandHandler.registerCommand(new DebugCommand(this));
@@ -315,40 +420,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
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.
* {@inheritDoc}
*/
@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... */
@Override
public void onDisable() {
debugLog.close();
this.banker = null;
@@ -356,6 +431,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
log(Level.INFO, "- Disabled");
}
/**
* {@inheritDoc}
*/
@Override
public MVPlayerSession getPlayerSession(Player player) {
if (this.playerSessions.containsKey(player.getName())) {
@@ -367,34 +445,24 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
}
/**
* Grab and return the Teleport class.
*
* @return
* {@inheritDoc}
*/
@Override
public SafeTTeleporter getTeleporter() {
return new SafeTTeleporter(this);
}
/**
* Grab the Permissions Handler for Multiverse
*
* @return A valid {@link MVPermissions}.
* {@inheritDoc}
*/
@Override
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 */
/**
* {@inheritDoc}
*/
@Override
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
if (!this.isEnabled()) {
@@ -403,20 +471,23 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
}
ArrayList<String> allArgs = new ArrayList<String>(Arrays.asList(args));
allArgs.add(0, command.getName());
return this.commandHandler.locateAndRunCommand(sender, allArgs);
return this.commandHandler.locateAndRunCommand(sender, allArgs, DisplayPermErrors);
}
/**
* 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
* {@inheritDoc}
*/
@Override
public void log(Level level, String msg) {
staticLog(level, msg);
}
/**
* Logs a message at the specified level.
*
* @param level The Log-{@link Level}.
* @param msg The message to log.
*/
public static void staticLog(Level level, String msg) {
if (level == Level.FINE && GlobalDebug >= 1) {
staticDebugLog(Level.INFO, msg);
@@ -428,8 +499,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
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);
LOGGER.log(level, String.format("%s %s", LOG_TAG, msg));
debugLog.log(level, String.format("%s %s", LOG_TAG, msg));
}
}
@@ -437,22 +508,24 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
* 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
* @param level The Log-{@link Level}
* @param msg The message
*/
public static void staticDebugLog(Level level, String msg) {
log.log(level, "[MVCore-Debug] " + msg);
LOGGER.log(level, "[MVCore-Debug] " + msg);
debugLog.log(level, "[MVCore-Debug] " + msg);
}
/**
* Parse the Authors Array into a readable String with ',' and 'and'.
*
* @return
* {@inheritDoc}
*/
private String getAuthors() {
@Override
public String getAuthors() {
String authors = "";
ArrayList<String> auths = this.getDescription().getAuthors();
if (auths.size() == 0) {
return "";
}
if (auths.size() == 1) {
return auths.get(0);
@@ -468,45 +541,40 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
return authors.substring(2);
}
/**
* {@inheritDoc}
*/
@Override
public CommandHandler getCommandHandler() {
return this.commandHandler;
}
/**
* Gets the log-tag.
*
* @return The log-tag
*/
// TODO this should be static!
public String getTag() {
return MultiverseCore.tag;
return MultiverseCore.LOG_TAG;
}
/**
* This code should get moved somewhere more appropriate, but for now, it's here.
* Shows a message that the given world is not a MultiverseWorld.
*
* @param env
*
* @return
* @param sender The {@link CommandSender} that should receive the message
* @param worldName The name of the invalid world
*/
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!");
}
/**
* Removes a player-session.
*
* @param player The {@link Player} that owned the session.
*/
public void removePlayerSession(Player player) {
if (this.playerSessions.containsKey(player.getName())) {
this.playerSessions.remove(player.getName());
@@ -514,101 +582,125 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
}
/**
* Returns the number of plugins that have specifically hooked into core.
*
* @return
* {@inheritDoc}
*/
@Override
public int getPluginCount() {
return this.pluginCount;
}
/** Increments the number of plugins that have specifically hooked into core. */
/**
* {@inheritDoc}
*/
@Override
public void incrementPluginCount() {
this.pluginCount += 1;
}
/** Decrements the number of plugins that have specifically hooked into core. */
/**
* {@inheritDoc}
*/
@Override
public void decrementPluginCount() {
this.pluginCount -= 1;
}
/**
* {@inheritDoc}
*/
@Override
public AllPay getBanker() {
return this.banker;
}
/**
* {@inheritDoc}
*/
@Override
public void setBank(GenericBank bank) {
this.bank = bank;
}
/**
* {@inheritDoc}
*/
@Override
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.
* @param teleporter The Person requesting that the teleport should happen.
* @param p Player The Person being teleported.
* @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());
}
/**
* Gets the server's root-folder as {@link File}.
*
* @return The server's root-folder
*/
public File getServerFolder() {
return serverFolder;
}
/**
* Sets this server's root-folder.
*
* @param newServerFolder The new server-root
*/
public void setServerFolder(File newServerFolder) {
if (!newServerFolder.isDirectory())
throw new IllegalArgumentException("That's not a folder!");
this.serverFolder = newServerFolder;
}
/**
* Initializes Spout.
*/
public void setSpout() {
this.spoutInterface = new SpoutInterface();
this.commandHandler.registerCommand(new SpoutCommand(this));
}
/**
* Gets our {@link SpoutInterface}.
*
* @return The {@link SpoutInterface} we're using.
*/
public SpoutInterface getSpout() {
return this.spoutInterface;
}
public WorldManager getMVWorldManager() {
/**
* {@inheritDoc}
*/
@Override
public MVWorldManager getMVWorldManager() {
return this.worldManager;
}
@Deprecated
public com.onarandombox.utils.WorldManager getWorldManager() {
return new com.onarandombox.utils.WorldManager(this);
}
/**
* Gets the {@link MVPlayerListener}.
*
* @return The {@link MVPlayerListener}.
*/
public MVPlayerListener getPlayerListener() {
return this.playerListener;
}
public boolean loadMVConfigs() {
return false;
}
/**
* Saves the Multiverse-Config.
*
* @return Whether the Multiverse-Config was successfully saved
*/
public boolean saveMVConfig() {
try {
this.multiverseConfig.save(new File(getDataFolder(), "config.yml"));
@@ -619,11 +711,74 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
}
}
/**
* Saves the world config.
*
* @return Whether the world-config was successfully saved
*/
public boolean saveWorldConfig() {
return this.worldManager.saveWorldsConfig();
}
/**
* {@inheritDoc}
*/
@Override
public boolean saveMVConfigs() {
return this.saveMVConfig() && this.saveWorldConfig();
}
/**
* NOT deprecated for the time as queued commands use this.
* However, this is not in the API and other plugins should therefore not use it.
*
* @param name World to delete
* @return True if success, false if fail.
*/
public Boolean deleteWorld(String name) {
return this.worldManager.deleteWorld(name);
}
/**
* {@inheritDoc}
*/
@Override
public Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed) {
MultiverseWorld world = this.worldManager.getMVWorld(name);
if (world == null) {
return false;
}
List<Player> ps = world.getCBWorld().getPlayers();
if (useNewSeed) {
// Set the worldseed.
if (randomSeed) {
Random random = new Random();
Long newseed = random.nextLong();
seed = newseed.toString();
}
((WorldManager) this.worldManager).getConfigWorlds().set("worlds." + name + ".seed", seed);
}
if (this.worldManager.deleteWorld(name, false)) {
this.worldManager.loadWorlds(false);
SafeTTeleporter teleporter = this.getTeleporter();
Location newSpawn = this.getServer().getWorld(name).getSpawnLocation();
// Send all players that were in the old world, BACK to it!
for (Player p : ps) {
teleporter.safelyTeleport(null, p, newSpawn, true);
}
return true;
}
return false;
}
/**
* {@inheritDoc}
*/
@Override
public AnchorManager getAnchorManager() {
return this.anchorManager;
}
}
@@ -7,6 +7,7 @@
package com.onarandombox.MultiverseCore.api;
import com.fernferret.allpay.AllPay;
import com.fernferret.allpay.GenericBank;
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
import com.onarandombox.MultiverseCore.utils.*;
@@ -16,7 +17,7 @@ import org.bukkit.entity.Player;
/**
* Multiverse 2 Core API
* <p/>
* <p>
* This API contains a bunch of useful things you can get out of Multiverse in general!
*/
public interface Core {
@@ -26,20 +27,20 @@ public interface Core {
*
* @return The Multiverse config file.
*/
public FileConfiguration getMVConfiguration();
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();
GenericBank getBank();
/**
* Reloads the Multiverse Configuration files:
* worlds.yml and config.yml.
*/
public void loadConfigs();
void loadConfigs();
/**
* Gets the Multiverse message system. This allows you to send messages
@@ -47,7 +48,7 @@ public interface Core {
*
* @return The loaded {@link MVMessaging}.
*/
public MVMessaging getMessaging();
MVMessaging getMessaging();
/**
* Gets the {@link MVPlayerSession} for the given player.
@@ -58,7 +59,7 @@ public interface Core {
*
* @return The corresponding {@link MVPlayerSession}.
*/
public MVPlayerSession getPlayerSession(Player player);
MVPlayerSession getPlayerSession(Player player);
/**
* Gets the instantiated Safe-T-Teleporter for performing
@@ -66,7 +67,7 @@ public interface Core {
*
* @return A non-null {@link SafeTTeleporter}.
*/
public SafeTTeleporter getTeleporter();
SafeTTeleporter getTeleporter();
/**
* Multiverse uses an advanced permissions setup, this object
@@ -74,7 +75,7 @@ public interface Core {
*
* @return A non-null {@link MVPermissions}.
*/
public MVPermissions getMVPerms();
MVPermissions getMVPerms();
/**
* Multiverse uses {@link CommandHandler} to make adding and using commands
@@ -82,7 +83,7 @@ public interface Core {
*
* @return A non-null {@link CommandHandler}.
*/
public CommandHandler getCommandHandler();
CommandHandler getCommandHandler();
/**
* Gets the factory class responsible for loading many different destinations
@@ -90,12 +91,76 @@ public interface Core {
*
* @return A valid {@link DestinationFactory}.
*/
public DestinationFactory getDestFactory();
DestinationFactory getDestFactory();
/**
* Gets the primary class responsible for managing Multiverse Worlds.
*
* @return {@link WorldManager}.
*/
public WorldManager getMVWorldManager();
MVWorldManager getMVWorldManager();
/**
* Saves all configs.
*
* @return Whether the config was successfully saved
*/
boolean saveMVConfigs();
/**
* Gets the {@link AnchorManager}.
*
* @return The {@link AnchorManager}
*/
AnchorManager getAnchorManager();
/**
* Used by queued commands to regenerate a world on a delay.
*
* @param name Name of the world to regenerate
* @param useNewSeed If a new seed should be used
* @param randomSeed IF the new seed should be random
* @param seed The seed of the world.
*
* @return True if success, false if fail.
*/
Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed);
/**
* Sets the {@link GenericBank}-Bank AllPay is using.
*
* @param bank The new {@link GenericBank}
*/
void setBank(GenericBank bank);
/**
* Gets this plugin's {@link AllPay}-Banker.
*
* @return An {@link AllPay}-Banker
*/
AllPay getBanker();
/**
* Decrements the number of plugins that have specifically hooked into core.
*/
void decrementPluginCount();
/**
* Increments the number of plugins that have specifically hooked into core.
*/
void incrementPluginCount();
/**
* Returns the number of plugins that have specifically hooked into core.
*
* @return The number if plugins that have hooked into core.
*/
int getPluginCount();
/**
* Parse the Authors Array into a readable String with ',' and 'and'.
*
* @return The readable authors-{@link String}
*/
String getAuthors();
}
@@ -7,11 +7,14 @@
package com.onarandombox.MultiverseCore.api;
/**
* A fancy text.
*/
public interface FancyText {
/**
* TODO: Write something useful here.
* Gets the {@link String}-representation of this {@link FancyText}.
*
* @return And Here.
* @return The {@link String}-representation of this {@link FancyText}.
*/
public String getFancyText();
String getFancyText();
}
@@ -16,15 +16,15 @@ public interface LoggablePlugin {
/**
* Logs a message at the specified level.
*
* @param level The severity of the log.
* @param level The Log-{@link Level}.
* @param msg The message to log.
*/
public void log(Level level, String msg);
void log(Level level, String msg);
/**
* Gets the server instance that this plugin is attached to.
*
* @return A {@link Server} instance.
*/
public Server getServer();
Server getServer();
}
@@ -15,24 +15,22 @@ 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/>
* <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();
String getIdentifier();
/**
* Allows you to determine if a Destination is valid for the type it thinks it is.
* <p/>
* <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
@@ -44,35 +42,35 @@ public interface MVDestination {
*
* @return True if the destination is valid, false if not.
*/
public boolean isThisType(JavaPlugin plugin, String destination);
boolean isThisType(JavaPlugin plugin, String destination);
/**
* Returns the location a specific entity will spawn at.
* <p/>
* <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/>
* <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);
Location getLocation(Entity entity);
/**
* Returns the velocity vector for this destination.
* <p/>
* <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();
Vector getVelocity();
/**
* Sets the destination string.
* <p/>
* <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
@@ -81,63 +79,63 @@ public interface MVDestination {
* @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);
void setDestination(JavaPlugin plugin, String destination);
/**
* Returns true if the destination is valid and players will be taken to it.
* <p/>
* <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();
boolean isValid();
/**
* Gives you a general friendly description of the type of destination.
* <p/>
* <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();
String getType();
/**
* Gives you a specific name of the destination.
* <p/>
* <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();
String getName();
/**
* Returns a string that can easily be saved in the config that contains all the details needed to rebuild this
* destination.
* <p/>
* <p>
* ex: e:0,0,0:50:50
*
* @return The savable config string.
*/
public String toString();
String toString();
/**
* Returns the permissions string required to go here.
* <p/>
* <p>
* ex: multiverse.access.world
* <p/>
* <p>
* NOTE: This is NOT the permission to use the teleport command.
*
* @return the permissions string required to go here.
*/
public String getRequiredPermission();
String getRequiredPermission();
/**
* Should the Multiverse SafeTeleporter be used?
* <p/>
* <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();
boolean useSafeTeleporter();
}
@@ -8,7 +8,11 @@
package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
/**
* This interface is implemented by every official Multiverse-plugin.
*/
public interface MVPlugin extends LoggablePlugin {
/**
* Adds This plugin's version information to the buffer and returns the new string.
@@ -16,22 +20,26 @@ public interface MVPlugin extends LoggablePlugin {
* @param buffer The string that contains Core and all other MV plugins' versions.
*
* @return A modified buffer that contains this MVPlugin's version information.
*
* @deprecated This is now deprecated, nobody needs it any longer.
* All version info-dumping is now done with {@link MVVersionEvent}.
*/
public String dumpVersionInfo(String buffer);
@Deprecated
String dumpVersionInfo(String buffer);
/**
* Gets the reference to MultiverseCore.
*
* @return A valid {@link MultiverseCore}.
*/
public MultiverseCore getCore();
MultiverseCore getCore();
/**
* Sets the reference to MultiverseCore.
*
* @param core A valid {@link MultiverseCore}.
*/
public void setCore(MultiverseCore core);
void setCore(MultiverseCore core);
/**
* Allows Multiverse or a plugin to query another Multiverse plugin to see what version its protocol is. This
@@ -40,5 +48,5 @@ public interface MVPlugin extends LoggablePlugin {
*
* @return The Integer protocol version.
*/
public int getProtocolVersion();
int getProtocolVersion();
}
@@ -10,13 +10,17 @@ package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldType;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.generator.ChunkGenerator;
import java.io.File;
import java.util.Collection;
import java.util.List;
/**
* Multiverse 2 World Manager API
* <p/>
* <p>
* This API contains all of the world managing
* functions that your heart desires!
*/
@@ -29,47 +33,70 @@ public interface MVWorldManager {
* @param seedString The seed in the form of a string.
* If the seed is a Long,
* it will be interpreted as such.
* @param type The Type of the world to be made.
* @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);
boolean addWorld(String name, Environment env, String seedString, WorldType type, String generator);
/**
* 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 type The Type of the world to be made.
* @param generator The Custom generator plugin to use.
* @param useSpawnAdjust If true, multiverse will search for a safe spawn. If not, It will not modify the level.dat.
* @return True if the world is added, false if not.
*/
boolean addWorld(String name, Environment env, String seedString, WorldType type, String generator, boolean useSpawnAdjust);
/**
* Remove the world from the Multiverse list, from the
* config and deletes the folder
* 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);
boolean deleteWorld(String name);
/**
* Unload a world from Multiverse
* Remove the world from the Multiverse list, from the
* config if wanted, and deletes the folder.
*
* @param name The name of the world to remove
* @param removeConfig If true(default), we'll remove the entries from the
* config. If false, they'll stay and the world may come back.
* @return True if success, false if failure.
*/
boolean deleteWorld(String name, boolean removeConfig);
/**
* 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);
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);
boolean loadWorld(String name);
/**
* Removes all players from the specified world.
*
* @param name World to remove players from.
*/
public void removePlayersFromWorld(String name);
void removePlayersFromWorld(String name);
/**
* Test if a given chunk generator is valid.
@@ -77,17 +104,16 @@ public interface MVWorldManager {
* @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);
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();
Collection<MultiverseWorld> getMVWorlds();
/**
@@ -95,37 +121,33 @@ public interface MVWorldManager {
* 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);
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);
MultiverseWorld getMVWorld(World world);
/**
* Checks to see if the given name is a valid {@link MultiverseWorld}
* 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);
boolean isMVWorld(String name);
/**
* Checks to see if the given world is a valid {@link MultiverseWorld}
* 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);
boolean isMVWorld(World world);
/**
* Load the Worlds & Settings from the configuration file.
@@ -133,12 +155,76 @@ public interface MVWorldManager {
* @param forceLoad If set to true, this will perform a total
* reset and not just load new worlds.
*/
public void loadWorlds(boolean forceLoad);
void loadWorlds(boolean forceLoad);
/**
* Loads the Worlds & Settings for any worlds that bukkit loaded before us.
* <p>
* This way people will _always_ have some worlds in the list.
*/
void loadDefaultWorlds();
/**
* Return the World Purger.
*
* @return A valid {@link PurgeWorlds}.
*/
public PurgeWorlds getWorldPurger();
PurgeWorlds getWorldPurger();
/**
* Gets the world players will spawn in on first join.
* Currently this always returns worlds.get(0) from Bukkit.
*
* @return A Multiverse world that players will spawn in or null if no MV world has been set.
*/
MultiverseWorld getSpawnWorld();
/**
* Gets the list of worlds in the config, but unloaded.
*
* @return A List of worlds as strings.
*/
List<String> getUnloadedWorlds();
/**
* This method populates an internal list and needs to be called after multiverse initialization.
*/
void getDefaultWorldGenerators();
/**
* Load the config from a file.
*
* @param file The file to load.
* @return A loaded configuration.
*/
FileConfiguration loadWorldConfig(File file);
/**
* Saves the world config to disk.
*
* @return True if success, false if fail.
*/
boolean saveWorldsConfig();
/**
* 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.
*/
boolean removeWorldFromConfig(String name);
/**
* Sets the initial spawn world for new players.
*
* @param world The World new players should spawn in.
*/
void setFirstSpawnWorld(String world);
/**
* Gets the world players should spawn in first.
*
* @return The {@link MultiverseWorld} new players should spawn in.
*/
MultiverseWorld getFirstSpawnWorld();
}
@@ -7,15 +7,22 @@
package com.onarandombox.MultiverseCore.api;
import org.bukkit.*;
import com.onarandombox.MultiverseCore.configuration.MVConfigProperty;
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
import org.bukkit.ChatColor;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldType;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import java.util.List;
/**
* The API for a Multiverse Handled World.
* <p/>
* Currently INCOMPLETE
*/
public interface MultiverseWorld {
@@ -24,36 +31,72 @@ public interface MultiverseWorld {
*
* @return A {@link World}
*/
public World getCBWorld();
World getCBWorld();
/**
* Adds the property to the given value. The property must be a {@link com.onarandombox.MultiverseCore.enums.SetProperties}.
* Adds the property to the given value.
* It will throw a PropertyDoesNotExistException if the property is not found.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.SetProperties} to set.
* @param property The name of a world property to set.
* @param value A value in string representation, it will be parsed to the correct type.
*
* @param sender The sender who wants this value to be set.
* @return True if the value was set, false if not.
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
*/
public boolean setVariable(String property, String value);
boolean setProperty(String property, String value, CommandSender sender) throws PropertyDoesNotExistException;
/**
* Gets the actual MVConfigProperty from this world.
* It will throw a PropertyDoesNotExistException if the property is not found.
*
* @param property The name of a world property to get.
* @return A valid MVWorldProperty.
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
* @deprecated Use {@link #getProperty(String, Class)} instead
*/
@Deprecated
MVConfigProperty<?> getProperty(String property) throws PropertyDoesNotExistException;
/**
* Gets the string representation of a property.
* It will throw a PropertyDoesNotExistException if the property is not found.
*
* @param property The name of a world property to get.
* @return A valid MVWorldProperty.
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
*/
String getPropertyValue(String property) throws PropertyDoesNotExistException;
/**
* Gets the actual MVConfigProperty from this world.
* It will throw a PropertyDoesNotExistException if the property is not found.
*
* @param property The name of a world property to get.
* @param expected The type of the expected property. Use Object.class if this doesn't matter for you.
* @param <T> The type of the expected property.
*
* @return A valid MVWorldProperty.
*
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
*/
<T> MVConfigProperty<T> getProperty(String property, Class<T> expected) throws PropertyDoesNotExistException;
/**
* 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);
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);
boolean addToVariable(String property, String value);
/**
* Removes a value from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
@@ -61,130 +104,141 @@ public interface MultiverseWorld {
* @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);
boolean removeFromVariable(String property, String value);
/**
* Gets the environment of this world.
*
* @return A {@link org.bukkit.World.Environment}.
*/
public World.Environment getEnvironment();
World.Environment getEnvironment();
/**
* Sets the environment of a world.
* <p/>
* <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);
void setEnvironment(World.Environment environment);
/**
* Gets the world seed of this world.
*
* @return The Long version of the seed.
*/
public Long getSeed();
Long getSeed();
/**
* Sets the seed of this world.
*
* @param seed A Long that is the seed.
*/
public void setSeed(Long seed);
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();
String getName();
/**
* Gets the lowercased name of the world. This method is required, since the permissables
* lowercase all permissions when recalculating.
* <p>
* Note: This also means if a user has worlds named: world and WORLD, that they can both
* exist, and both be teleported to independently, but their permissions **cannot** be
* uniqueified at this time. See bug report #.
*
* @return The lowercased name of the world.
*/
String getPermissibleName();
/**
* Gets the alias of this world.
* <p/>
* <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();
String getAlias();
/**
* Sets the alias of the world.
*
* @param alias A string that is the new alias.
*/
public void setAlias(String alias);
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);
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();
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);
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();
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();
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();
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);
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
* @deprecated This is deprecated.
*/
public boolean getFakePVP();
@Deprecated
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();
boolean isPVPEnabled();
/**
* Gets whether or not this world will display in chat, mvw and mvl regardless if a user has the
@@ -192,7 +246,7 @@ public interface MultiverseWorld {
*
* @return True if the world will be hidden, false if not.
*/
public boolean isHidden();
boolean isHidden();
/**
* Sets whether or not this world will display in chat, mvw and mvl regardless if a user has the
@@ -200,7 +254,7 @@ public interface MultiverseWorld {
*
* @param hidden Set
*/
public void setHidden(boolean hidden);
void setHidden(boolean hidden);
/**
* Sets whether or not there will be weather events in a given world.
@@ -208,14 +262,14 @@ public interface MultiverseWorld {
*
* @param enableWeather True if weather events should occur in a world, false if not.
*/
public void setEnableWeather(boolean enableWeather);
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();
boolean isWeatherEnabled();
/**
* If true, tells Craftbukkit to keep a worlds spawn chunks loaded in memory (default: true)
@@ -224,14 +278,14 @@ public interface MultiverseWorld {
*
* @param keepSpawnInMemory If true, CraftBukkit will keep the spawn chunks loaded in memory.
*/
public void setKeepSpawnInMemory(boolean keepSpawnInMemory);
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();
boolean isKeepingSpawnInMemory();
/**
* Sets the difficulty of this world and returns true if success.
@@ -239,32 +293,31 @@ public interface MultiverseWorld {
* 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);
boolean setDifficulty(String difficulty);
/**
* Gets the difficulty of this world.
*
* @return The difficulty of this world.
*/
public Difficulty getDifficulty();
Difficulty getDifficulty();
/**
* Sets the spawn location for a world.
*
* @param spawnLocation The spawn location for a world.
*/
public void setSpawnLocation(Location spawnLocation);
void setSpawnLocation(Location spawnLocation);
/**
* Gets the spawn location of this world.
*
* @return The spawn location of this world.
*/
public Location getSpawnLocation();
Location getSpawnLocation();
/**
* Sets whether or not the hunger level of players will go down in a world.
@@ -272,45 +325,44 @@ public interface MultiverseWorld {
* @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);
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();
boolean getHunger();
/**
* Sets the game mode of this world
* 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);
boolean setGameMode(String gameMode);
/**
* Gets the GameMode of this world.
*
* @return The GameMode of this world.
*/
public GameMode getGameMode();
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();
Permission getAccessPermission();
/**
* Gets the permission required to be exempt when entering.
*
* @return The permission required to be exempt when entering.
*/
public Permission getExemptPermission();
Permission getExemptPermission();
/**
* Sets the price for entry to this world.
@@ -319,14 +371,14 @@ public interface MultiverseWorld {
*
* @param price The Amount of money/item to enter the world.
*/
public void setPrice(double price);
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();
double getPrice();
/**
* Sets the type of item that will be required given the price is not 0.
@@ -334,39 +386,39 @@ public interface MultiverseWorld {
*
* @param item The Type of currency that will be used when users enter this world.
*/
public void setCurrency(int item);
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();
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);
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();
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.
* @return Whether the scale was set successfully.
*/
public boolean setScaling(double scaling);
boolean setScaling(double scaling);
/**
* Gets the scaling value of this world.Really only has an effect if you use
@@ -374,7 +426,7 @@ public interface MultiverseWorld {
*
* @return This world's non-negative, non-zero scale.
*/
public double getScaling();
double getScaling();
/**
* Gets a list of all the worlds that players CANNOT travel to from this world,
@@ -382,14 +434,14 @@ public interface MultiverseWorld {
*
* @return A List of world names.
*/
public List<String> getWorldBlacklist();
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();
List<String> getAnimalList();
/**
* Sets whether or not animals can spawn.
@@ -398,14 +450,14 @@ public interface MultiverseWorld {
*
* @param allowAnimalSpawn True to allow spawning of monsters, false to prevent.
*/
public void setAllowAnimalSpawn(boolean allowAnimalSpawn);
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();
List<String> getMonsterList();
/**
* Sets whether or not monsters can spawn.
@@ -414,28 +466,111 @@ public interface MultiverseWorld {
*
* @param allowMonsterSpawn True to allow spawning of monsters, false to prevent.
*/
public void setAllowMonsterSpawn(boolean allowMonsterSpawn);
void setAllowMonsterSpawn(boolean allowMonsterSpawn);
/**
* TODO: Write these docs.
* Clears a list property (sets it to []).
*
* @param property
*
* @return
* @param property The property to clear.
* @return True if success, false if fail.
*/
public boolean clearList(String property);
boolean clearList(String property);
/**
* Sets whether or not a world will autoheal players if the difficulty is on peaceful.
* Sets whether or not a world will auto-heal players if the difficulty is on peaceful.
*
* @param heal True if the world will heal.
*/
public void setAutoHeal(boolean heal);
void setAutoHeal(boolean heal);
/**
* Gets whether or not a world will autoheal players if the difficulty is on peaceful.
* Gets whether or not a world will auto-heal players if the difficulty is on peaceful.
*
* @return True if the world should heal (default), false if not.
*/
public boolean getAutoHeal();
boolean getAutoHeal();
/**
* Sets whether or not Multiverse should auto-adjust the spawn for this world.
*
* @param adjust True if multiverse should adjust the spawn, false if not.
*/
void setAdjustSpawn(boolean adjust);
/**
* Gets whether or not Multiverse should auto-adjust the spawn for this world.
*
* @return True if Multiverse should adjust the spawn, false if not.
*/
boolean getAdjustSpawn();
/**
* Sets whether or not Multiverse should auto-load this world.
* <p>
* True is default.
*
* @param autoLoad True if multiverse should autoload this world the spawn, false if not.
*/
void setAutoLoad(boolean autoLoad);
/**
* Gets whether or not Multiverse should auto-load this world.
*
* @return True if Multiverse should auto-load this world.
*/
boolean getAutoLoad();
/**
* Sets whether or not a player who dies in this world will respawn in their
* bed or follow the normal respawn pattern.
* <p>
* True is default.
*
* @param autoLoad True if players dying in this world respawn at their bed.
*/
void setBedRespawn(boolean autoLoad);
/**
* Gets whether or not a player who dies in this world will respawn in their
* bed or follow the normal respawn pattern.
*
* @return True if players dying in this world should respawn at their bed.
*/
boolean getBedRespawn();
/**
* Gets all the names of all properties that can be SET.
*
* @return All property names, with alternating colors.
*/
String getAllPropertyNames();
/**
* Sets the current time in a world.
* <p>
* This method will take the following formats:
* 11:37am
* 4:30p
* day(morning), night, noon, midnight
*
* @param timeAsString The formatted time to set the world to.
* @return True if the time was set, false if not.
*/
boolean setTime(String timeAsString);
/**
* Same as {@link #getTime()}, but returns a string.
* @return The time as a short string: 12:34pm
*/
String getTime();
/**
* Gets the type of this world. As of 1.1-R1 this will be:
* FLAT or NORMAL
* <p>
* This is *not* the generator.
*
* @return The Type of this world.
*/
WorldType getWorldType();
}
@@ -0,0 +1,5 @@
/**
* The Multiverse-API, containing lots of interfaces that can be quite useful for other
* plugins when interacting with Multiverse.
*/
package com.onarandombox.MultiverseCore.api;
@@ -0,0 +1,138 @@
/******************************************************************************
* 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 java.util.ArrayList;
import java.util.List;
/**
* Allows management of Anchor Destinations.
*/
public class AnchorCommand extends PaginatedCoreCommand<String> {
public AnchorCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Create, Delete and Manage Anchor Destinations.");
this.setCommandUsage("/mv anchor " + ChatColor.GREEN + "{name}" + ChatColor.GOLD + " [-d]");
this.setArgRange(0, 2);
this.addKey("mv anchor");
this.addKey("mv anchors");
this.addKey("mvanchor");
this.addKey("mvanchors");
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "awesomething");
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "otherthing");
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "awesomething " + ChatColor.RED + "-d");
this.addCommandExample("/mv anchors ");
this.setPermission("multiverse.core.anchor", "Allows management of Anchor Destinations.", PermissionDefault.OP);
this.setItemsPerPage(8); // SUPPRESS CHECKSTYLE: MagicNumberCheck
}
private List<String> getFancyAnchorList(Player p) {
List<String> anchorList = new ArrayList<String>();
ChatColor color = ChatColor.GREEN;
for (String anchor : this.plugin.getAnchorManager().getAnchors(p)) {
anchorList.add(color + anchor);
color = (color == ChatColor.GREEN) ? ChatColor.GOLD : ChatColor.GREEN;
}
return anchorList;
}
private void showList(CommandSender sender, List<String> args) {
sender.sendMessage(ChatColor.LIGHT_PURPLE + "====[ Multiverse Anchor List ]====");
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
FilterObject filterObject = this.getPageAndFilter(args);
List<String> availableAnchors = new ArrayList<String>(this.getFancyAnchorList(p));
if (filterObject.getFilter().length() > 0) {
availableAnchors = this.getFilteredItems(availableAnchors, filterObject.getFilter());
if (availableAnchors.size() == 0) {
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE
+ "No anchors matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
return;
}
} else {
if (availableAnchors.size() == 0) {
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE + "No anchors were defined.");
return;
}
}
if (!(sender instanceof Player)) {
for (String c : availableAnchors) {
sender.sendMessage(c);
}
return;
}
int totalPages = (int) Math.ceil(availableAnchors.size() / (this.itemsPerPage + 0.0));
if (filterObject.getPage() > totalPages) {
filterObject.setPage(totalPages);
}
sender.sendMessage(ChatColor.AQUA + " Page " + filterObject.getPage() + " of " + totalPages);
this.showPage(filterObject.getPage(), sender, availableAnchors);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.size() == 0) {
this.showList(sender, args);
return;
}
if (args.size() == 2) {
if (this.plugin.getAnchorManager().deleteAnchor(args.get(0))) {
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.RED + "deleted!");
} else {
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "deleted!");
}
return;
}
if (!(sender instanceof Player)) {
sender.sendMessage("You must be a player to create Anchors.");
return;
}
Player player = (Player) sender;
if (this.plugin.getAnchorManager().saveAnchorLocation(args.get(0), player.getLocation())) {
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.GREEN + "created!");
} else {
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "created!");
}
}
@Override
protected List<String> getFilteredItems(List<String> availableItems, String filter) {
List<String> filtered = new ArrayList<String>();
for (String s : availableItems) {
if (s.matches("(?i).*" + filter + ".*")) {
filtered.add(s);
}
}
return filtered;
}
@Override
protected String getItemText(String item) {
return item;
}
}
@@ -11,16 +11,16 @@ 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;
/**
* Checks to see if a player can go to a destination.
*/
public class CheckCommand extends MultiverseCommand {
private WorldManager worldManager;
public CheckCommand(MultiverseCore plugin) {
super(plugin);
@@ -33,7 +33,6 @@ public class CheckCommand extends MultiverseCommand {
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
@@ -8,7 +8,6 @@
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;
@@ -16,9 +15,10 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Allows you to set Global MV Variables.
*/
public class ConfigCommand extends MultiverseCommand {
private MVWorldManager worldManager;
public ConfigCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Configuration");
@@ -32,9 +32,7 @@ public class ConfigCommand extends MultiverseCommand {
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
@@ -55,7 +53,12 @@ public class ConfigCommand extends MultiverseCommand {
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")) {
if (args.get(0).equalsIgnoreCase("firstspawnworld")) {
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), args.get(1));
// Don't forget to set the world!
this.plugin.getMVWorldManager().setFirstSpawnWorld(args.get(1));
} else 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) {
@@ -67,7 +70,8 @@ public class ConfigCommand extends MultiverseCommand {
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.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;
@@ -13,6 +13,9 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Confirms actions.
*/
public class ConfirmCommand extends MultiverseCommand {
public ConfirmCommand(MultiverseCore plugin) {
@@ -8,9 +8,9 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
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;
@@ -21,8 +21,11 @@ import org.bukkit.permissions.PermissionDefault;
import java.text.DecimalFormat;
import java.util.List;
/**
* Returns detailed information on the Players where abouts.
*/
public class CoordCommand extends MultiverseCommand {
private WorldManager worldManager;
private MVWorldManager worldManager;
public CoordCommand(MultiverseCore plugin) {
super(plugin);
@@ -8,31 +8,37 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.pneumaticraft.commandhandler.CommandHandler;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.WorldType;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.io.File;
import java.util.List;
/**
* Creates a new world and loads it.
*/
public class CreateCommand extends MultiverseCommand {
private WorldManager worldManager;
private MVWorldManager 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.setCommandUsage("/mv create" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:ID]] -t [WORLDTYPE] [-n]");
this.setArgRange(2, 9); // SUPPRESS CHECKSTYLE: MagicNumberCheck
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 + "starwars" + ChatColor.AQUA + " end");
this.addCommandExample("/mv create " + ChatColor.GOLD + "flatroom" + ChatColor.GREEN + " normal" + ChatColor.AQUA + " -t flat");
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();
@@ -40,32 +46,48 @@ public class CreateCommand extends MultiverseCommand {
@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);
File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
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)) {
String typeString = CommandHandler.getFlag("-t", args);
boolean useSpawnAdjust = true;
for (String s : args) {
if (s.equalsIgnoreCase("-n")) {
useSpawnAdjust = false;
}
}
if (worldFile.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);
Environment environment = EnvironmentCommand.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!");
// If they didn't specify a type, default to NORMAL
if (typeString == null) {
typeString = "NORMAL";
}
WorldType type = EnvironmentCommand.getWorldTypeFromString(typeString);
if (type == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid World Type.");
EnvironmentCommand.showWorldTypes(sender);
return;
}
Command.broadcastCommandMessage(sender, "Starting creation of world '" + worldName + "'...");
if (this.worldManager.addWorld(worldName, environment, seed, type, generator, useSpawnAdjust)) {
Command.broadcastCommandMessage(sender, "Complete!");
} else {
sender.sendMessage(ChatColor.RED + "FAILED.");
Command.broadcastCommandMessage(sender, "FAILED.");
}
}
}
@@ -15,6 +15,9 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.List;
import java.util.logging.Level;
/**
* Enables debug-information.
*/
public class DebugCommand extends MultiverseCommand {
public DebugCommand(MultiverseCore plugin) {
@@ -42,7 +45,8 @@ public class DebugCommand extends MultiverseCommand {
}
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!)");
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE
+ " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
}
}
@@ -15,6 +15,9 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
/**
* Deletes worlds.
*/
public class DeleteCommand extends MultiverseCommand {
public DeleteCommand(MultiverseCore plugin) {
@@ -30,8 +33,9 @@ public class DeleteCommand extends MultiverseCommand {
@Override
public void runCommand(CommandSender sender, List<String> args) {
Class<?> paramTypes[] = {String.class};
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!");
this.plugin.getCommandHandler().queueCommand(sender, "mvdelete", "deleteWorld", objectArgs,
paramTypes, ChatColor.GREEN + "World Deleted!", ChatColor.RED + "World could NOT be deleted!");
}
}
@@ -9,11 +9,16 @@ package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.WorldType;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Lists valid known environments.
*/
public class EnvironmentCommand extends MultiverseCommand {
public EnvironmentCommand(MultiverseCore plugin) {
@@ -23,21 +28,85 @@ public class EnvironmentCommand extends MultiverseCommand {
this.setArgRange(0, 0);
this.addKey("mvenv");
this.addKey("mv env");
this.addKey("mv type");
this.addKey("mv environment");
this.addKey("mv environments");
this.addCommandExample("/mv env");
this.setPermission("multiverse.core.list.environments", "Lists valid known environments.", PermissionDefault.OP);
this.setPermission("multiverse.core.list.environments", "Lists valid known environments/world types.", PermissionDefault.OP);
}
/**
* Shows all valid known environments to a {@link CommandSender}.
*
* @param sender The {@link CommandSender}.
*/
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");
sender.sendMessage(ChatColor.AQUA + "END");
}
/**
* Shows all valid known world types to a {@link CommandSender}.
*
* @param sender The {@link CommandSender}.
*/
public static void showWorldTypes(CommandSender sender) {
sender.sendMessage(ChatColor.YELLOW + "Valid World Types are:");
sender.sendMessage(String.format("%sNORMAL %sor %sFLAT",
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA));
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
EnvironmentCommand.showEnvironments(sender);
EnvironmentCommand.showWorldTypes(sender);
}
/**
* Converts a {@link String} into a {@link WorldType}.
*
* @param type The WorldType as a {@link String}
* @return The WorldType as a {@link WorldType}
*/
public static WorldType getWorldTypeFromString(String type) {
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
if (type.equalsIgnoreCase("normal"))
type = "NORMAL";
if (type.equalsIgnoreCase("flat"))
type = "FLAT";
try {
// Now that we've converted a potentially unfriendly value
// to a friendly one, get it from the ENUM!
return WorldType.valueOf(type);
} catch (IllegalArgumentException e) {
return null;
}
}
/**
* Converts a {@link String} into an {@link org.bukkit.World.Environment}.
*
* @param env The environment as {@link String}
* @return The environment as {@link org.bukkit.World.Environment}
*/
public static World.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("END") || env.equalsIgnoreCase("THEEND") || env.equalsIgnoreCase("STARWARS"))
env = "THE_END";
if (env.equalsIgnoreCase("NORMAL") || env.equalsIgnoreCase("WORLD"))
env = "NORMAL";
try {
// Now that we've converted a potentially unfriendly value
// to a friendly one, get it from the ENUM!
return World.Environment.valueOf(env);
} catch (IllegalArgumentException e) {
return null;
}
}
}
@@ -17,6 +17,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
/**
* Returns a list of loaded generator plugins.
*/
public class GeneratorCommand extends MultiverseCommand {
public GeneratorCommand(MultiverseCore plugin) {
@@ -46,13 +49,8 @@ public class GeneratorCommand extends MultiverseCommand {
String loadedGens = "";
boolean altColor = false;
for (String s : generators) {
if (altColor) {
altColor = false;
loadedGens += ChatColor.YELLOW + s + "";
} else {
altColor = true;
loadedGens += ChatColor.WHITE + s + "";
}
loadedGens += (altColor ? ChatColor.YELLOW : ChatColor.WHITE) + s + " ";
altColor = !altColor;
}
if (loadedGens.length() == 0) {
loadedGens = ChatColor.RED + "No Generator Plugins found.";
@@ -5,7 +5,6 @@
* 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;
@@ -18,8 +17,10 @@ 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;
/**
* Displays a nice help menu.
*/
public class HelpCommand extends PaginatedCoreCommand<Command> {
public HelpCommand(MultiverseCore plugin) {
super(plugin);
@@ -34,40 +35,51 @@ public class HelpCommand extends MultiverseCommand {
this.addKey("mv search");
this.addCommandExample("/mv help ?");
this.setPermission("multiverse.help", "Displays a nice help menu.", PermissionDefault.TRUE);
this.setItemsPerPage(7); // SUPPRESS CHECKSTYLE: MagicNumberCheck
}
@Override
protected List<Command> getFilteredItems(List<Command> availableItems, String filter) {
List<Command> filtered = new ArrayList<Command>();
for (Command c : availableItems) {
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);
} else {
for (String example : c.getCommandExamples()) {
if (example.matches("(?i).*" + filter + ".*")) {
filtered.add(c);
break;
}
}
}
}
return filtered;
}
@Override
protected String getItemText(Command item) {
return ChatColor.AQUA + item.getCommandUsage();
}
@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;
}
}
FilterObject filterObject = this.getPageAndFilter(args);
List<Command> availableCommands = new ArrayList<Command>(this.plugin.getCommandHandler().getCommands(sender));
if (filter.length() > 0) {
availableCommands = this.getFilteredCommands(availableCommands, filter);
if (filterObject.getFilter().length() > 0) {
availableCommands = this.getFilteredItems(availableCommands, filterObject.getFilter());
if (availableCommands.size() == 0) {
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE + "No commands matched your filter: " + ChatColor.AQUA + filter);
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE
+ "No commands matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
return;
}
}
@@ -80,55 +92,15 @@ public class HelpCommand extends MultiverseCommand {
return;
}
int totalPages = (int) Math.ceil(availableCommands.size() / (CMDS_PER_PAGE + 0.0));
int totalPages = (int) Math.ceil(availableCommands.size() / (this.itemsPerPage + 0.0));
if (page > totalPages) {
page = totalPages;
if (filterObject.getPage() > totalPages) {
filterObject.setPage(totalPages);
}
sender.sendMessage(ChatColor.AQUA + " Page " + page + " of " + totalPages);
sender.sendMessage(ChatColor.AQUA + " Page " + filterObject.getPage() + " 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);
this.showPage(filterObject.getPage(), 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(" ");
}
}
}
}
@@ -8,66 +8,168 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.pneumaticraft.commandhandler.CommandHandler;
import org.bukkit.ChatColor;
import org.bukkit.World.Environment;
import org.bukkit.WorldType;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* Imports a new world of the specified type.
*/
public class ImportCommand extends MultiverseCommand {
private WorldManager worldManager;
private MVWorldManager 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.setCommandUsage("/mv import" + ChatColor.GREEN + " {NAME} {ENV} " + ChatColor.GOLD + " -g [GENERATOR[:ID]] [-n] -t [TYPE]");
this.setArgRange(2, 5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
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 + "flatroom" + ChatColor.GREEN + " normal" + ChatColor.AQUA + " -t flat");
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();
}
/**
* A very basic check to see if a folder has a level.dat file.
* If it does, we can safely assume it's a world folder.
*
* @param worldFolder The File that may be a world.
* @return True if it looks like a world, false if not.
*/
private boolean checkIfIsWorld(File worldFolder) {
if (worldFolder.isDirectory()) {
File[] files = worldFolder.listFiles(new FilenameFilter() {
@Override
public boolean accept(File file, String name) {
return name.equalsIgnoreCase("level.dat");
}
});
if (files != null && files.length > 0) {
return true;
}
}
return false;
}
private String getPotentialWorlds() {
File worldFolder = this.plugin.getServer().getWorldContainer();
if (worldFolder == null) {
return "";
}
File[] files = worldFolder.listFiles();
String worldList = "";
Collection<MultiverseWorld> worlds = this.worldManager.getMVWorlds();
List<String> worldStrings = new ArrayList<String>();
for (MultiverseWorld world : worlds) {
worldStrings.add(world.getName());
}
for (String world : this.worldManager.getUnloadedWorlds()) {
worldStrings.add(world);
}
ChatColor currColor = ChatColor.WHITE;
for (File file : files) {
if (file.isDirectory() && checkIfIsWorld(file) && !worldStrings.contains(file.getName())) {
worldList += currColor + file.getName() + " ";
if (currColor == ChatColor.WHITE) {
currColor = ChatColor.YELLOW;
} else {
currColor = ChatColor.WHITE;
}
}
}
return worldList;
}
@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!");
if (worldName.toLowerCase().equals("--list") || worldName.toLowerCase().equals("-l")) {
String worldList = this.getPotentialWorlds();
if (worldList.length() > 2) {
sender.sendMessage(ChatColor.AQUA + "====[ These look like worlds ]====");
sender.sendMessage(worldList);
} else {
sender.sendMessage(ChatColor.RED + "No potential worlds found. Sorry!");
}
return;
}
// Since we made an exception for the list, we have to make sure they have at least 2 params:
// Note the exception is --list, which is covered above.
if (args.size() == 1) {
this.showHelp(sender);
return;
}
String generator = null;
if (args.size() == 3) {
generator = args.get(2);
// Make sure we don't already know about this world.
if (this.worldManager.isMVWorld(worldName)) {
sender.sendMessage(ChatColor.GREEN + "Multiverse" + ChatColor.WHITE
+ " already knows about '" + ChatColor.AQUA + worldName + ChatColor.WHITE + "'!");
return;
}
File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
String generator = CommandHandler.getFlag("-g", args);
String typeString = CommandHandler.getFlag("-t", args);
boolean useSpawnAdjust = true;
for (String s : args) {
if (s.equalsIgnoreCase("-n")) {
useSpawnAdjust = false;
}
}
String env = args.get(1);
Environment environment = this.plugin.getEnvFromString(env);
Environment environment = EnvironmentCommand.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!");
// If they didn't specify a type, default to NORMAL
if (typeString == null) {
typeString = "NORMAL";
}
WorldType type = EnvironmentCommand.getWorldTypeFromString(typeString);
if (type == null) {
sender.sendMessage(ChatColor.RED + "That is not a valid World Type.");
EnvironmentCommand.showWorldTypes(sender);
return;
}
if (worldFile.exists() && env != null) {
Command.broadcastCommandMessage(sender, String.format("Starting import of world '%s'...", worldName));
if (this.worldManager.addWorld(worldName, environment, null, type, generator, useSpawnAdjust))
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Complete!");
else
Command.broadcastCommandMessage(sender, ChatColor.RED + "Failed!");
} 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");
sender.sendMessage("That world environment did not exist.");
sender.sendMessage("For a list of available world types, type: " + ChatColor.AQUA + "/mvenv");
} else {
sender.sendMessage(ChatColor.RED + "FAILED.");
sender.sendMessage("That world folder does not exist...");
String worldList = this.getPotentialWorlds();
sender.sendMessage("That world folder does not exist. These look like worlds to me:");
sender.sendMessage(worldList);
}
}
}
@@ -9,8 +9,12 @@ package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.FancyText;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.*;
import com.onarandombox.MultiverseCore.utils.FancyColorScheme;
import com.onarandombox.MultiverseCore.utils.FancyHeader;
import com.onarandombox.MultiverseCore.utils.FancyMessage;
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
@@ -23,8 +27,11 @@ import java.util.List;
// Will use when we can compile with JDK 6
//import com.sun.xml.internal.ws.util.StringUtils;
/**
* Returns detailed information about a world.
*/
public class InfoCommand extends MultiverseCommand {
private WorldManager worldManager;
private MVWorldManager worldManager;
public InfoCommand(MultiverseCore plugin) {
super(plugin);
@@ -102,17 +109,15 @@ public class InfoCommand extends MultiverseCommand {
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: ", world.getGameMode().toString(), colors));
message.add(new FancyMessage("World Type: ", world.getWorldType().toString(), 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));
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));
}
@@ -138,20 +143,16 @@ public class InfoCommand extends MultiverseCommand {
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));
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));
}
@@ -167,7 +168,8 @@ public class InfoCommand extends MultiverseCommand {
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));
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));
}
@@ -195,6 +197,12 @@ public class InfoCommand extends MultiverseCommand {
return result;
}
/**
* Gets a "positive" or "negative" {@link ChatColor}.
*
* @param positive Whether this {@link ChatColor} should be "positive".
* @return The {@link ChatColor}.
*/
protected ChatColor getChatColor(boolean positive) {
return positive ? ChatColor.GREEN : ChatColor.RED;
}
@@ -15,29 +15,28 @@ 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 ListCommand extends MultiverseCommand {
/**
* Displays a listing of all worlds that a player can enter.
*/
public class ListCommand extends PaginatedCoreCommand<String> {
public ListCommand(MultiverseCore plugin) {
super(plugin);
this.setName("World Listing");
this.setCommandUsage("/mv list");
this.setArgRange(0, 0);
this.setArgRange(0, 2);
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);
this.setItemsPerPage(8); // SUPPRESS CHECKSTYLE: MagicNumberCheck
}
@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";
private List<String> getFancyWorldList(Player p) {
List<String> worldList = new ArrayList<String>();
for (MultiverseWorld world : this.plugin.getMVWorldManager().getMVWorlds()) {
if (p != null && (!this.plugin.getMVPerms().canEnterWorld(p, world))) {
@@ -50,24 +49,80 @@ public class ListCommand extends MultiverseCommand {
color = ChatColor.RED;
} else if (env == Environment.NORMAL) {
color = ChatColor.GREEN;
} else if (env == Environment.SKYLANDS) {
} else if (env == Environment.THE_END) {
color = ChatColor.AQUA;
}
String outputCache = world.getColoredWorldString() + ChatColor.WHITE + " - " + color + world.getEnvironment() + " \n";
String outputCache = world.getColoredWorldString() + ChatColor.WHITE + " - " + color + world.getEnvironment();
if (world.isHidden()) {
// TODO: Add an actual permission for this.
if (p == null || p.isOp()) {
if (p == null || p.hasPermission("multiverse.core.modify")) {
// Prefix hidden worlds with an "[H]"
outputCache = ChatColor.GRAY + "[H]" + outputCache;
output += outputCache;
worldList.add(ChatColor.GRAY + "[H]" + outputCache);
}
} else {
output += outputCache;
worldList.add(outputCache);
}
}
String[] response = output.split("\n");
for (String msg : response) {
sender.sendMessage(msg);
for (String name : this.plugin.getMVWorldManager().getUnloadedWorlds()) {
if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + name, true)) {
worldList.add(ChatColor.GRAY + name + " - UNLOADED");
}
}
return worldList;
}
@Override
protected List<String> getFilteredItems(List<String> availableItems, String filter) {
List<String> filtered = new ArrayList<String>();
for (String s : availableItems) {
if (s.matches("(?i).*" + filter + ".*")) {
filtered.add(s);
}
}
return filtered;
}
@Override
protected String getItemText(String item) {
return item;
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
sender.sendMessage(ChatColor.LIGHT_PURPLE + "====[ Multiverse World List ]====");
Player p = null;
if (sender instanceof Player) {
p = (Player) sender;
}
FilterObject filterObject = this.getPageAndFilter(args);
List<String> availableWorlds = new ArrayList<String>(this.getFancyWorldList(p));
if (filterObject.getFilter().length() > 0) {
availableWorlds = this.getFilteredItems(availableWorlds, filterObject.getFilter());
if (availableWorlds.size() == 0) {
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE
+ "No worlds matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
return;
}
}
if (!(sender instanceof Player)) {
for (String c : availableWorlds) {
sender.sendMessage(c);
}
return;
}
int totalPages = (int) Math.ceil(availableWorlds.size() / (this.itemsPerPage + 0.0));
if (filterObject.getPage() > totalPages) {
filterObject.setPage(totalPages);
}
sender.sendMessage(ChatColor.AQUA + " Page " + filterObject.getPage() + " of " + totalPages);
this.showPage(filterObject.getPage(), sender, availableWorlds);
}
}
@@ -9,11 +9,15 @@ package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Loads a world into Multiverse.
*/
public class LoadCommand extends MultiverseCommand {
public LoadCommand(MultiverseCore plugin) {
@@ -30,9 +34,9 @@ public class LoadCommand extends MultiverseCommand {
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (this.plugin.getMVWorldManager().loadWorld(args.get(0))) {
sender.sendMessage("World Loaded!");
Command.broadcastCommandMessage(sender, "Loaded world '" + args.get(0) + "'!");
} else {
sender.sendMessage("Error trying to load world!");
sender.sendMessage("Error trying to load world '" + args.get(0) + "'!");
}
}
}
@@ -8,9 +8,9 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
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;
@@ -21,8 +21,11 @@ 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
/**
* Used to modify various aspects of worlds.
*/
public class ModifyAddCommand extends MultiverseCommand {
private WorldManager worldManager;
private MVWorldManager worldManager;
public ModifyAddCommand(MultiverseCore plugin) {
super(plugin);
@@ -36,7 +39,8 @@ public class ModifyAddCommand extends MultiverseCommand {
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.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();
}
@@ -78,7 +82,8 @@ public class ModifyAddCommand extends MultiverseCommand {
}
if (world.addToVariable(property, value)) {
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + value + ChatColor.WHITE + " was " + ChatColor.GREEN + "added to " + ChatColor.GREEN + property);
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);
}
@@ -8,9 +8,9 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
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;
@@ -18,8 +18,11 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Removes all values from a world-property.
*/
public class ModifyClearCommand extends MultiverseCommand {
private WorldManager worldManager;
private MVWorldManager worldManager;
public ModifyClearCommand(MultiverseCore plugin) {
super(plugin);
@@ -33,7 +36,8 @@ public class ModifyClearCommand extends MultiverseCommand {
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.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();
}
@@ -73,9 +77,11 @@ public class ModifyClearCommand extends MultiverseCommand {
}
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.");
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.");
sender.sendMessage(ChatColor.RED + "Error: " + ChatColor.GOLD + property
+ ChatColor.WHITE + " was " + ChatColor.GOLD + "NOT" + ChatColor.WHITE + " cleared.");
}
}
@@ -10,7 +10,6 @@ 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;
@@ -20,6 +19,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Used to modify various aspects of worlds.
*/
public class ModifyCommand extends MultiverseCommand {
public ModifyCommand(MultiverseCore plugin) {
@@ -35,19 +37,24 @@ public class ModifyCommand extends MultiverseCommand {
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);
Permission modify = new Permission("multiverse.core.modify",
"Modify various aspects of worlds. It requires add/set/clear/remove. See the examples below", PermissionDefault.OP, children);
this.addCommandExample(ChatColor.AQUA + "/mv modify set ?");
this.addCommandExample(ChatColor.GREEN + "/mv modify add ?");
this.addCommandExample(ChatColor.BLUE + "/mv modify clear ?");
this.addCommandExample(ChatColor.RED + "/mv modify remove ?");
this.setPermission(modify);
}
/**
* Validates the specified action.
*
* @param action The {@link Action}.
* @param property The property.
* @return Whether this action is valid.
*/
protected static boolean validateAction(Action action, String property) {
if (action == Action.Set) {
try {
SetProperties.valueOf(property);
return true;
} catch (IllegalArgumentException e) {
return false;
}
} else {
if (action != Action.Set) {
try {
AddProperties.valueOf(property);
return true;
@@ -55,6 +62,7 @@ public class ModifyCommand extends MultiverseCommand {
return false;
}
}
return false;
}
@Override
@@ -8,9 +8,9 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
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;
@@ -18,8 +18,11 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Removes values from a world-property.
*/
public class ModifyRemoveCommand extends MultiverseCommand {
private WorldManager worldManager;
private MVWorldManager worldManager;
public ModifyRemoveCommand(MultiverseCore plugin) {
super(plugin);
@@ -37,7 +40,8 @@ public class ModifyRemoveCommand extends MultiverseCommand {
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.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();
}
@@ -78,9 +82,11 @@ public class ModifyRemoveCommand extends MultiverseCommand {
return;
}
if (world.removeFromVariable(property, value)) {
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + value + ChatColor.WHITE + " was " + ChatColor.RED + "removed from " + ChatColor.GREEN + property);
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);
sender.sendMessage(ChatColor.RED + "There was an error removing " + ChatColor.GRAY
+ value + ChatColor.WHITE + " from " + ChatColor.GOLD + property);
}
}
@@ -8,10 +8,10 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
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 com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -19,11 +19,15 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Used to set world-properties.
*/
public class ModifySetCommand extends MultiverseCommand {
private WorldManager worldManager;
private MVWorldManager worldManager;
public ModifySetCommand(MultiverseCore plugin) {
super(plugin);
this.worldManager = this.plugin.getMVWorldManager();
this.setName("Modify a World (Set a value)");
this.setCommandUsage("/mv modify" + ChatColor.GREEN + " set {PROPERTY} {VALUE}" + ChatColor.GOLD + " [WORLD]");
this.setArgRange(1, 3);
@@ -44,15 +48,21 @@ public class ModifySetCommand extends MultiverseCommand {
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 + "heal " + ChatColor.RED + "true");
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "adjustspawn " + 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();
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);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Special case for spawn:
if (args.size() == 1) {
if (!(sender instanceof Player)) {
sender.sendMessage("You must be a player to set the" + ChatColor.GREEN + " spawn");
return;
}
if (args.get(0).equalsIgnoreCase("spawn")) {
SetSpawnCommand c = new SetSpawnCommand(this.plugin);
c.setWorldSpawn(sender);
@@ -92,18 +102,22 @@ public class ModifySetCommand extends MultiverseCommand {
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);
return;
}
try {
if (world.setProperty(property, value, sender)) {
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + property
+ ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
} else {
sender.sendMessage(world.getProperty(property, Object.class).getHelp());
}
} catch (PropertyDoesNotExistException e) {
sender.sendMessage(ChatColor.RED + "Sorry, You can't set: '" + ChatColor.GRAY + property + ChatColor.RED + "'");
// TODO: Display the list
sender.sendMessage(ChatColor.GOLD + "For a full list of thingys, see our wiki.");
}
}
}
@@ -8,18 +8,30 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.utils.MVMessaging;
import com.pneumaticraft.commandhandler.Command;
import org.bukkit.command.CommandSender;
import java.util.List;
/**
* A generic Multiverse-command.
*/
public abstract class MultiverseCommand extends Command {
/**
* The reference to the core.
*/
protected MultiverseCore plugin;
/**
* The reference to {@link MVMessaging}.
*/
protected MVMessaging messaging;
public MultiverseCommand(MultiverseCore plugin) {
super(plugin);
this.plugin = plugin;
this.messaging = this.plugin.getMessaging();
}
@Override
@@ -0,0 +1,164 @@
/******************************************************************************
* 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.pneumaticraft.commandhandler.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;
/**
* A generic paginated command.
* @param <T> The type of items on the page.
*/
public abstract class PaginatedCommand<T> extends Command {
private static final int DEFAULT_ITEMS_PER_PAGE = 9;
/**
* The number of items per page.
*/
protected int itemsPerPage = DEFAULT_ITEMS_PER_PAGE;
public PaginatedCommand(JavaPlugin plugin) {
super(plugin);
}
/**
* Set the number of items per page.
*
* @param items The new number of items per page.
*/
protected void setItemsPerPage(int items) {
itemsPerPage = items;
}
/**
* Gets filtered items.
* @param availableItems All available items.
* @param filter The filter-{@link String}.
* @return A list of items that match the filter.
*/
protected abstract List<T> getFilteredItems(List<T> availableItems, String filter);
/**
* Constructs a single string from a list of strings.
*
* @param list The {@link List} of strings.
* @return A single {@link String}.
*/
protected String stitchThisString(List<String> list) {
StringBuilder builder = new StringBuilder();
for (String s : list) {
builder.append(s);
builder.append(' ');
}
return builder.toString();
}
/**
* Shows a page.
*
* @param page The number of the page to show.
* @param sender The {@link CommandSender} that wants to see the page.
* @param cmds The items that should be displayed on the page.
*/
protected void showPage(int page, CommandSender sender, List<T> cmds) {
// Ensure the page is at least 1.
page = (page <= 0) ? 1 : page;
int start = (page - 1) * itemsPerPage;
int end = start + itemsPerPage;
for (int i = start; i < end; i++) {
// For consistancy, print some extra lines if it's a player:
if (i < cmds.size()) {
sender.sendMessage(this.getItemText(cmds.get(i)));
} else if (sender instanceof Player) {
sender.sendMessage(" ");
}
}
}
/**
* Converts an item into a string.
*
* @param item The item.
* @return A {@link String}.
*/
protected abstract String getItemText(T item);
/**
* Constructs a {@link FilterObject} from a {@link List} of arguments.
*
* @param args The {@link List} of arguments.
* @return The {@link FilterObject}.
*/
protected FilterObject getPageAndFilter(List<String> args) {
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;
}
}
return new FilterObject(page, filter);
}
/**
* "Key-Object" containing information about the page and the filter that were requested.
*/
protected class FilterObject {
private Integer page;
private String filter;
public FilterObject(Integer page, String filter) {
this.page = page;
this.filter = filter;
}
/**
* Gets the page.
* @return The page.
*/
public Integer getPage() {
return this.page;
}
/**
* Sets the page.
*
* @param page The new page.
*/
public void setPage(int page) {
this.page = page;
}
/**
* Gets the filter.
* @return The filter.
*/
public String getFilter() {
return this.filter;
}
}
}
@@ -5,18 +5,22 @@
* with this project. *
******************************************************************************/
package com.onarandombox.utils;
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.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
* A generic paginated Multiverse-command.
* @param <T> The type of items on the page.
*/
@Deprecated
public class WorldManager extends com.onarandombox.MultiverseCore.utils.WorldManager {
public WorldManager(MultiverseCore core) {
super(core);
public abstract class PaginatedCoreCommand<T> extends PaginatedCommand<T> {
/**
* The reference to the core.
*/
protected MultiverseCore plugin;
public PaginatedCoreCommand(MultiverseCore plugin) {
super(plugin);
this.plugin = plugin;
}
}
@@ -8,9 +8,9 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
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;
@@ -20,8 +20,11 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Removes a type of mob from a world.
*/
public class PurgeCommand extends MultiverseCommand {
private WorldManager worldManager;
private MVWorldManager worldManager;
public PurgeCommand(MultiverseCore plugin) {
super(plugin);
@@ -85,8 +88,5 @@ public class PurgeCommand extends MultiverseCommand {
for (MultiverseWorld w : worldsToRemoveEntitiesFrom) {
purger.purgeWorld(sender, w, thingsToKill, false, false);
}
return;
}
}
@@ -0,0 +1,53 @@
/******************************************************************************
* 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;
/**
* Regenerates a world.
*/
public class RegenCommand extends MultiverseCommand {
public RegenCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Regenerates a World");
this.setCommandUsage("/mv regen" + ChatColor.GREEN + " {WORLD}" + ChatColor.GOLD + " [-s [SEED]]");
this.setArgRange(1, 3);
this.addKey("mvregen");
this.addKey("mv regen");
this.addCommandExample("You can use the -s with no args to get a new seed:");
this.addCommandExample("/mv regen " + ChatColor.GREEN + "MyWorld" + ChatColor.GOLD + " -s");
this.addCommandExample("or specifiy a seed to get that one:");
this.addCommandExample("/mv regen " + ChatColor.GREEN + "MyWorld" + ChatColor.GOLD + " -s" + ChatColor.AQUA + " gargamel");
this.setPermission("multiverse.core.regen", "Regenerates a world on your server. The previous state will be lost "
+ ChatColor.RED + "PERMANENTLY.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Boolean useseed = (!(args.size() == 1));
Boolean randomseed = (args.size() == 2 && args.get(1).equalsIgnoreCase("-s"));
String seed = (args.size() == 3) ? args.get(2) : "";
Class<?>[] paramTypes = {String.class, Boolean.class, Boolean.class, String.class};
List<Object> objectArgs = new ArrayList<Object>();
objectArgs.add(args.get(0));
objectArgs.add(useseed);
objectArgs.add(randomseed);
objectArgs.add(seed);
this.plugin.getCommandHandler().queueCommand(sender, "mvregen", "regenWorld", objectArgs,
paramTypes, ChatColor.GREEN + "World Regenerated!", ChatColor.RED + "World could NOT be regenerated!");
}
}
@@ -16,6 +16,9 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
/**
* Reloads worlds.yml and config.yml.
*/
public class ReloadCommand extends MultiverseCommand {
public ReloadCommand(MultiverseCore plugin) {
@@ -33,11 +36,13 @@ public class ReloadCommand extends MultiverseCommand {
public void runCommand(CommandSender sender, List<String> args) {
sender.sendMessage(ChatColor.GOLD + "Reloading all Multiverse Plugin configs...");
this.plugin.loadConfigs();
this.plugin.getAnchorManager().loadAnchors();
this.plugin.getMVWorldManager().loadWorlds(true);
List<String> configsLoaded = new ArrayList<String>();
configsLoaded.add("Multiverse-Core - config.yml");
configsLoaded.add("Multiverse-Core - worlds.yml");
configsLoaded.add("Multiverse-Core - anchors.yml");
// Create the event
MVConfigReloadEvent configReload = new MVConfigReloadEvent(configsLoaded);
// Fire it off
@@ -14,6 +14,9 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Unloads a world and removes it from the config.
*/
public class RemoveCommand extends MultiverseCommand {
public RemoveCommand(MultiverseCore plugin) {
@@ -24,7 +27,8 @@ public class RemoveCommand extends MultiverseCommand {
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);
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
@@ -9,7 +9,9 @@ package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.BlockSafety;
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
@@ -18,8 +20,10 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Sets the spawn for a world.
*/
public class SetSpawnCommand extends MultiverseCommand {
public SetSpawnCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Set World Spawn");
@@ -39,6 +43,11 @@ public class SetSpawnCommand extends MultiverseCommand {
setWorldSpawn(sender);
}
/**
* Does the actual spawn-setting-work.
*
* @param sender The {@link CommandSender} that's setting the spawn.
*/
protected void setWorldSpawn(CommandSender sender) {
if (sender instanceof Player) {
Player p = (Player) sender;
@@ -47,6 +56,14 @@ public class SetSpawnCommand extends MultiverseCommand {
MultiverseWorld foundWorld = this.plugin.getMVWorldManager().getMVWorld(w.getName());
if (foundWorld != null) {
foundWorld.setSpawnLocation(p.getLocation());
BlockSafety bs = new BlockSafety();
if (!bs.playerCanSpawnHereSafely(p.getLocation()) && foundWorld.getAdjustSpawn()) {
sender.sendMessage("It looks like that location would normally be unsafe. But I trust you.");
sender.sendMessage("I'm turning off the Safe-T-Teleporter for spawns to this world.");
sender.sendMessage("If you want this turned back on just do:");
sender.sendMessage(ChatColor.AQUA + "/mvm set adjustspawn true " + foundWorld.getAlias());
foundWorld.setAdjustSpawn(false);
}
sender.sendMessage("Spawn was set to: " + LocationManipulation.strCoords(p.getLocation()));
} else {
w.setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
@@ -14,6 +14,9 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Takes the player to the latest bed he's slept in.
*/
public class SleepCommand extends MultiverseCommand {
public SleepCommand(MultiverseCore plugin) {
@@ -18,11 +18,15 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Teleports a player to the spawn.
*/
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);
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);
@@ -19,6 +19,9 @@ import org.getspout.spoutapi.player.SpoutPlayer;
import java.util.List;
/**
* Edit a world with spout.
*/
public class SpoutCommand extends MultiverseCommand {
public SpoutCommand(MultiverseCore plugin) {
@@ -48,10 +51,13 @@ public class SpoutCommand extends MultiverseCommand {
}
PopupScreen pop = new GenericPopup();
GenericButton button = new GenericButton("Fish");
// TODO maybe use constants for these
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
button.setX(50);
button.setY(50);
button.setWidth(100);
button.setHeight(40);
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
pop.attachWidget(this.plugin, button);
sender.sendMessage(ChatColor.GREEN + "YAY!");
p.getMainScreen().attachPopupScreen(pop);
@@ -12,9 +12,9 @@ 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.enums.TeleportResult;
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;
@@ -28,6 +28,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
/**
* Used to teleport players.
*/
public class TeleportCommand extends MultiverseCommand {
private SafeTTeleporter playerTeleporter;
@@ -44,6 +47,8 @@ public class TeleportCommand extends MultiverseCommand {
this.setPermission(menu);
}
private static final int UNSAFE_TELEPORT_EXPIRE_DELAY = 15;
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Check if the command was sent from a Player.
@@ -58,7 +63,8 @@ public class TeleportCommand extends MultiverseCommand {
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));
this.messaging.sendMessage(sender, String.format("Sorry, I couldn't find player: %s%s",
ChatColor.GOLD, args.get(0)), false);
return;
}
destinationName = args.get(1);
@@ -66,7 +72,7 @@ public class TeleportCommand extends MultiverseCommand {
} else {
destinationName = args.get(0);
if (!(sender instanceof Player)) {
sender.sendMessage("From the console, you must specify a player to teleport");
this.messaging.sendMessage(sender, String.format("From the console, you must specify a player to teleport"), false);
return;
}
teleportee = (Player) sender;
@@ -76,7 +82,9 @@ public class TeleportCommand extends MultiverseCommand {
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;
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";
}
@@ -94,7 +102,8 @@ public class TeleportCommand extends MultiverseCommand {
}
if (d != null && d instanceof InvalidDestination) {
sender.sendMessage("Multiverse does not know how to take you to: " + ChatColor.RED + destinationName);
this.messaging.sendMessage(sender, String.format("Multiverse does not know how to take you to %s%s",
ChatColor.RED, destinationName), false);
return;
}
@@ -106,14 +115,17 @@ public class TeleportCommand extends MultiverseCommand {
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...");
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());
this.messaging.sendMessage(teleporter, String.format("DOH! Doesn't look like you can get to %s%s %sfrom where you are...",
ChatColor.GREEN, d.toString(), ChatColor.WHITE), false);
} else {
teleporter.sendMessage("DOH! Doesn't look like " + ChatColor.GREEN + ((Player) teleporter).getWorld().getName() + " can get to " + ChatColor.RED + "THERE from where they are...");
this.messaging.sendMessage(teleporter, String.format("DOH! Doesn't look like %s%s %scan get to %sTHERE from where they are...",
ChatColor.GREEN, ((Player) teleporter).getWorld().getName(), ChatColor.WHITE, ChatColor.RED), false);
}
return;
}
@@ -126,14 +138,19 @@ public class TeleportCommand extends MultiverseCommand {
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)");
this.messaging.sendMessages(teleporter, new String[]{
String.format("Sorry you don't have permission to go to the world spawn!"),
String.format("%s (multiverse.core.spawn.self)",
ChatColor.RED) }, false);
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)");
this.messaging.sendMessages(teleporter, new String[]{
String.format("Sorry you don't have permission to send %s to the world spawn!",
teleportee.getDisplayName()),
String.format("%s (multiverse.core.spawn.other)",
ChatColor.RED) }, false);
return;
}
}
@@ -141,13 +158,14 @@ public class TeleportCommand extends MultiverseCommand {
}
if (d.getLocation(teleportee) == null) {
teleporter.sendMessage("Sorry Boss, I tried everything, but just couldn't teleport ya there!");
this.messaging.sendMessage(teleporter, "Sorry Boss, I tried everything, but just couldn't teleport ya there!", false);
return;
}
if (!this.playerTeleporter.safelyTeleport(teleporter, teleportee, d)) {
TeleportResult result = this.playerTeleporter.safelyTeleport(teleporter, teleportee, d);
if (result == TeleportResult.FAIL_UNSAFE) {
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};
Class<?>[] paramTypes = { CommandSender.class, Player.class, Location.class };
List<Object> items = new ArrayList<Object>();
items.add(teleporter);
items.add(teleportee);
@@ -156,24 +174,31 @@ public class TeleportCommand extends MultiverseCommand {
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);
String message = String.format("%sMultiverse %sdid not teleport %s%s%sto %s%s%sbecause it was unsafe.",
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, player, ChatColor.WHITE, ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE);
this.plugin.getCommandHandler().queueCommand(sender, "mvteleport", "teleportPlayer", items,
paramTypes, message, "Would you like to try anyway?", "", "", UNSAFE_TELEPORT_EXPIRE_DELAY);
}
// 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() + ")"});
this.messaging.sendMessages(teleporter, new String[]{
String.format("%sYou don't have permission to teleport %syourself %sto a %s%s %sDestination",
ChatColor.WHITE, ChatColor.AQUA, ChatColor.WHITE, ChatColor.RED, destination.getType(), ChatColor.WHITE),
String.format("%s (multiverse.teleport.self.%s)",
ChatColor.RED, destination.getIdentifier()) }, false);
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() + ")"});
this.messaging.sendMessages(teleporter, new String[]{
String.format("You don't have permission to teleport another player to a %s%s Destination.",
ChatColor.GREEN, destination.getType()),
String.format("%s(multiverse.teleport.other.%s)",
ChatColor.RED, destination.getIdentifier()) }, false);
return false;
}
}
@@ -9,11 +9,15 @@ package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Unloads worlds from Multiverse.
*/
public class UnloadCommand extends MultiverseCommand {
public UnloadCommand(MultiverseCore plugin) {
@@ -23,15 +27,16 @@ public class UnloadCommand extends MultiverseCommand {
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);
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!");
Command.broadcastCommandMessage(sender, "Unloaded world '" + args.get(0) + "'!");
} else {
sender.sendMessage("Error trying to unload world!");
sender.sendMessage("Error trying to unload world '" + args.get(0) + "'!");
}
}
}
@@ -8,39 +8,36 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.event.MVVersionRequestEvent;
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
import com.onarandombox.MultiverseCore.utils.webpaste.PasteFailedException;
import com.onarandombox.MultiverseCore.utils.webpaste.PasteService;
import com.onarandombox.MultiverseCore.utils.webpaste.PasteServiceFactory;
import com.onarandombox.MultiverseCore.utils.webpaste.PasteServiceType;
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;
/**
* Dumps version info to the console.
*/
public class VersionCommand extends MultiverseCommand {
public VersionCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Multiverse Version");
this.setCommandUsage("/mv version " + ChatColor.GOLD + "-p");
this.setCommandUsage("/mv version " + ChatColor.GOLD + "-[pb]");
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);
this.setPermission("multiverse.core.version",
"Dumps version info to the console, optionally to pastie.org with -p or pastebin.com with a -b.", PermissionDefault.TRUE);
}
private String pasteBinBuffer = "";
@Override
public void runCommand(CommandSender sender, List<String> args) {
// Check if the command was sent from a Player.
@@ -48,68 +45,65 @@ public class VersionCommand extends MultiverseCommand {
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");
StringBuilder buffer = new StringBuilder();
buffer.append("[Multiverse-Core] Multiverse-Core Version: ").append(this.plugin.getDescription().getVersion()).append('\n');
buffer.append("[Multiverse-Core] Bukkit Version: ").append(this.plugin.getServer().getVersion()).append('\n');
buffer.append("[Multiverse-Core] Loaded Worlds: ").append(this.plugin.getMVWorldManager().getMVWorlds().size()).append('\n');
buffer.append("[Multiverse-Core] Multiverse Plugins Loaded: ").append(this.plugin.getPluginCount()).append('\n');
buffer.append("[Multiverse-Core] Economy being used: ").append(this.plugin.getBank().getEconUsed()).append('\n');
buffer.append("[Multiverse-Core] Permissions Plugin: ").append(this.plugin.getMVPerms().getType()).append('\n');
buffer.append("[Multiverse-Core] Dumping Config Values: (version ")
.append(this.plugin.getMVConfiguration().getDouble("version", -1)).append(")").append('\n');
buffer.append("[Multiverse-Core] messagecooldown: ").append(this.plugin.getMessaging().getCooldown()).append('\n');
buffer.append("[Multiverse-Core] teleportcooldown: ").append("Not yet IMPLEMENTED").append('\n');
buffer.append("[Multiverse-Core] worldnameprefix: ").append(MultiverseCore.PrefixChat).append('\n');
buffer.append("[Multiverse-Core] enforceaccess: ").append(MultiverseCore.EnforceAccess).append('\n');
buffer.append("[Multiverse-Core] displaypermerrors: ").append(MultiverseCore.DisplayPermErrors).append('\n');
buffer.append("[Multiverse-Core] teleportintercept: ").append(MultiverseCore.TeleportIntercept).append('\n');
buffer.append("[Multiverse-Core] firstspawnoverride: ").append(MultiverseCore.FirstSpawnOverride).append('\n');
buffer.append("[Multiverse-Core] firstspawnworld: ").append(this.plugin.getMVConfiguration().getString("firstspawnworld", "NOT SET")).append('\n');
buffer.append("[Multiverse-Core] debug: ").append(MultiverseCore.GlobalDebug).append('\n');
buffer.append("[Multiverse-Core] Special Code: FRN002").append('\n');
MVVersionRequestEvent versionEvent = new MVVersionRequestEvent(pasteBinBuffer);
MVVersionEvent versionEvent = new MVVersionEvent(buffer.toString());
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);
// log to console
String data = versionEvent.getVersionInfo();
String[] lines = data.split("\n");
for (String line : lines) {
this.plugin.log(Level.INFO, line);
}
if (args.size() == 1) {
String pasteUrl = "";
if (args.get(0).equalsIgnoreCase("-p")) {
pasteUrl = postToService(PasteServiceType.PASTIE, true, data); // private post to pastie
} else if (args.get(0).equalsIgnoreCase("-b")) {
pasteUrl = postToService(PasteServiceType.PASTEBIN, true, data); // private post to pastie
} else {
return;
}
sender.sendMessage("Version info dumped here: " + ChatColor.GREEN + pasteUrl);
this.plugin.log(Level.INFO, "Version info dumped here: " + pasteUrl);
}
}
private void logAndAddToPasteBinBuffer(String string) {
this.pasteBinBuffer += "[Multiverse-Core] " + string + "\n";
this.plugin.log(Level.INFO, string);
}
private String postToPasteBin() {
/**
* Send the current contents of this.pasteBinBuffer to a web service.
*
* @param type Service type to send to
* @param isPrivate Should the paste be marked as private.
* @return URL of visible paste
*/
private static String postToService(PasteServiceType type, boolean isPrivate, String pasteData) {
PasteService ps = PasteServiceFactory.getService(type, isPrivate);
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) {
return ps.postData(ps.encodeData(pasteData), ps.getPostURL());
} catch (PasteFailedException e) {
System.out.print(e);
return "Error Posting to pastebin.com";
return "Error posting to service";
}
}
}
@@ -8,8 +8,8 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
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;
@@ -18,9 +18,12 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
/**
* States who is in what world.
*/
public class WhoCommand extends MultiverseCommand {
private WorldManager worldManager;
private MVWorldManager worldManager;
public WhoCommand(MultiverseCore plugin) {
super(plugin);
@@ -91,7 +94,7 @@ public class WhoCommand extends MultiverseCommand {
result = "Empty";
} else {
for (Player player : players) {
result += player.getDisplayName() + " ";
result += player.getDisplayName() + " " + ChatColor.WHITE;
}
}
@@ -0,0 +1,4 @@
/**
* This package contains all Commands.
*/
package com.onarandombox.MultiverseCore.commands;
@@ -0,0 +1,115 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2012. *
* 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;
/**
* A {@link String} config-property that will NOT be saved to the config.
*/
public class ActiveStringConfigProperty implements MVActiveConfigProperty<String> {
private String name;
private String value;
private String method;
private String help;
public ActiveStringConfigProperty(String name, String defaultValue, String help) {
this.name = name;
this.help = help;
this.value = defaultValue;
this.parseValue(defaultValue);
}
public ActiveStringConfigProperty(String name, String defaultValue, String help, String method) {
this(name, defaultValue, help);
this.method = method;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return this.name;
}
/**
* {@inheritDoc}
*/
@Override
public String getValue() {
return this.value;
}
/**
* {@inheritDoc}
*/
@Override
public String getMethod() {
return this.method;
}
/**
* {@inheritDoc}
*/
@Override
public void setMethod(String methodName) {
this.method = methodName;
}
/**
* {@inheritDoc}
*/
@Override
public Class<?> getPropertyClass() {
return String.class;
}
/**
* {@inheritDoc}
*/
@Override
public boolean parseValue(String value) {
if (value == null) {
return false;
}
this.setValue(value);
return true;
}
/**
* {@inheritDoc}
*/
@Override
public String getConfigNode() {
return "";
}
/**
* {@inheritDoc}
*/
@Override
public String getHelp() {
return this.help;
}
/**
* {@inheritDoc}
*/
@Override
public boolean setValue(String value) {
if (value == null) {
return false;
}
this.value = value;
return true;
}
@Override
public String toString() {
return value;
}
}
@@ -0,0 +1,135 @@
/******************************************************************************
* 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 org.bukkit.configuration.ConfigurationSection;
/**
* A {@link Boolean} config-property.
*/
public class BooleanConfigProperty implements MVActiveConfigProperty<Boolean> {
private String name;
private Boolean value;
private String configNode;
private ConfigurationSection section;
private String help;
private String method;
public BooleanConfigProperty(ConfigurationSection section, String name, Boolean defaultValue, String help) {
this(section, name, defaultValue, name, help);
}
public BooleanConfigProperty(ConfigurationSection section, String name, Boolean defaultValue, String configNode, String help) {
this.name = name;
this.configNode = configNode;
this.section = section;
this.help = help;
this.value = defaultValue;
this.setValue(this.section.getBoolean(this.configNode, defaultValue));
}
public BooleanConfigProperty(ConfigurationSection section, String name, Boolean defaultValue, String configNode, String help, String method) {
this(section, name, defaultValue, configNode, help);
this.method = method;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return this.name;
}
/**
* {@inheritDoc}
*/
@Override
public Boolean getValue() {
return this.value;
}
/**
* {@inheritDoc}
*/
@Override
public boolean setValue(Boolean value) {
if (value == null) {
return false;
}
this.value = value;
this.section.set(configNode, this.value);
return true;
}
/**
* {@inheritDoc}
*/
@Override
public boolean parseValue(String value) {
if (value == null) {
return false;
}
if (value.toLowerCase().equals("true") || value.toLowerCase().equals("false")) {
this.setValue(Boolean.parseBoolean(value));
return true;
}
return false;
}
/**
* {@inheritDoc}
*/
@Override
public String getConfigNode() {
return this.configNode;
}
/**
* {@inheritDoc}
*/
@Override
public String getHelp() {
return this.help;
}
@Override
public String toString() {
return value.toString();
}
/**
* Gets the method that will be executed.
*
* @return The name of the method in MVWorld to be called.
*/
@Override
public String getMethod() {
return this.method;
}
/**
* Sets the method that will be executed.
*
* @param methodName The name of the method in MVWorld to be called.
*/
@Override
public void setMethod(String methodName) {
this.method = methodName;
}
/**
* Returns the class of the object we're looking at.
*
* @return the class of the object we're looking at.
*/
@Override
public Class<?> getPropertyClass() {
return Boolean.class;
}
}
@@ -0,0 +1,98 @@
/******************************************************************************
* 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.enums.EnglishChatColor;
import org.bukkit.configuration.ConfigurationSection;
/**
* A {@link EnglishChatColor} config-property.
*/
public class ColorConfigProperty implements MVConfigProperty<EnglishChatColor> {
private String name;
private EnglishChatColor value;
private String configNode;
private ConfigurationSection section;
private String help;
public ColorConfigProperty(ConfigurationSection section, String name, EnglishChatColor defaultValue, String help) {
this(section, name, defaultValue, name, help);
}
public ColorConfigProperty(ConfigurationSection section, String name, EnglishChatColor defaultValue, String configNode, String help) {
this.name = name;
this.configNode = configNode;
this.section = section;
this.help = help;
this.value = defaultValue;
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return this.name;
}
/**
* {@inheritDoc}
*/
@Override
public EnglishChatColor getValue() {
return this.value;
}
/**
* {@inheritDoc}
*/
@Override
public boolean setValue(EnglishChatColor value) {
if (value == null) {
return false;
}
this.value = value;
this.section.set(configNode, this.value.getText());
return true;
}
/**
* {@inheritDoc}
*/
@Override
public boolean parseValue(String value) {
EnglishChatColor color = EnglishChatColor.fromString(value);
if (color == null) {
return false;
}
this.setValue(color);
return true;
}
/**
* {@inheritDoc}
*/
@Override
public String getConfigNode() {
return this.configNode;
}
/**
* {@inheritDoc}
*/
@Override
public String getHelp() {
return this.help;
}
@Override
public String toString() {
return value.toString();
}
}
@@ -0,0 +1,292 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2012. *
* 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.enums.EnglishChatColor;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
/** A factory to create config properties for a given world. */
public class ConfigPropertyFactory {
private ConfigurationSection section;
public ConfigPropertyFactory(ConfigurationSection section) {
this.section = section;
}
// Booleans
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param help The text that's displayed when a user failed to set the property.
* @return The ConfigProperty.
*/
public BooleanConfigProperty getNewProperty(String name, boolean defaultValue, String help) {
return new BooleanConfigProperty(this.section, name, defaultValue, help);
}
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param node The name of the configuration-node this ConfigProperty will be stored as.
* @param help The text that's displayed when a user failed to set the property.
* @return The ConfigProperty.
*/
public BooleanConfigProperty getNewProperty(String name, boolean defaultValue, String node, String help) {
return new BooleanConfigProperty(this.section, name, defaultValue, node, help);
}
/**
* Constructs a new ActiveBooleanConfigProperty
*
* This property will execute 'method' after it has been successfully set.
*
* @param name The name of this ConifgProperty
* @param defaultValue The default value.
* @param help What string is shown for help.
* @param node The name of the configuration-node this ConfigProperty will be stored as.
* @param method The method that should be executed.
* @return The ActiveStringConfigProperty
*/
public BooleanConfigProperty getNewProperty(String name, boolean defaultValue, String help, String node, String method) {
return new BooleanConfigProperty(this.section, name, defaultValue, help, node, method);
}
// Integers
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param help The text that's displayed when a user failed to set the property.
* @return The ConfigProperty.
*/
public IntegerConfigProperty getNewProperty(String name, int defaultValue, String help) {
return new IntegerConfigProperty(this.section, name, defaultValue, help);
}
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param node The name of the configuration-node this ConfigProperty will be stored as.
* @param help The text that's displayed when a user failed to set the property.
* @return The ConfigProperty.
*/
public IntegerConfigProperty getNewProperty(String name, int defaultValue, String node, String help) {
return new IntegerConfigProperty(this.section, name, defaultValue, node, help);
}
// Doubles
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param help The text that's displayed when a user failed to set the property.
* @return The ConfigProperty.
*/
public DoubleConfigProperty getNewProperty(String name, double defaultValue, String help) {
return new DoubleConfigProperty(this.section, name, defaultValue, help);
}
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param node The name of the configuration-node this ConfigProperty will be stored as.
* @param help The text that's displayed when a user failed to set the property.
* @return The ConfigProperty.
*/
public DoubleConfigProperty getNewProperty(String name, double defaultValue, String node, String help) {
return new DoubleConfigProperty(this.section, name, defaultValue, node, help);
}
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param node The name of the configuration-node this ConfigProperty will be stored as.
* @param help The text that's displayed when a user failed to set the property.
* @param method The name of the method that's used to set this property.
* @return The ConfigProperty.
*/
public DoubleConfigProperty getNewProperty(String name, double defaultValue, String node, String help, String method) {
return new DoubleConfigProperty(this.section, name, defaultValue, node, help, method);
}
// Strings
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param help The text that's displayed when a user failed to set the property.
* @return The ConfigProperty.
*/
public StringConfigProperty getNewProperty(String name, String defaultValue, String help) {
return new StringConfigProperty(this.section, name, defaultValue, help);
}
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param node The name of the configuration-node this ConfigProperty will be stored as.
* @param help The text that's displayed when a user failed to set the property.
* @return The ConfigProperty.
*/
public StringConfigProperty getNewProperty(String name, String defaultValue, String node, String help) {
return new StringConfigProperty(this.section, name, defaultValue, node, help);
}
// Colors
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param help The text that's displayed when a user failed to set the property.
* @return The ConfigProperty.
*/
public ColorConfigProperty getNewProperty(String name, EnglishChatColor defaultValue, String help) {
return new ColorConfigProperty(this.section, name, defaultValue, help);
}
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param node The name of the configuration-node this ConfigProperty will be stored as.
* @param help The text that's displayed when a user failed to set the property.
* @return The ConfigProperty.
*/
public ColorConfigProperty getNewProperty(String name, EnglishChatColor defaultValue, String node, String help) {
return new ColorConfigProperty(this.section, name, defaultValue, node, help);
}
// Difficulty
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param help The text that's displayed when a user failed to set the property.
* @return The ConfigProperty.
*/
public DifficultyConfigProperty getNewProperty(String name, Difficulty defaultValue, String help) {
return new DifficultyConfigProperty(this.section, name, defaultValue, help);
}
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param node The name of the configuration-node this ConfigProperty will be stored as.
* @param help The text that's displayed when a user failed to set the property.
* @return The ConfigProperty.
*/
public DifficultyConfigProperty getNewProperty(String name, Difficulty defaultValue, String node, String help) {
return new DifficultyConfigProperty(this.section, name, defaultValue, node, help);
}
// GameMode
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param help The text that's displayed when a user failed to set the property.
* @return The ConfigProperty.
*/
public GameModeConfigProperty getNewProperty(String name, GameMode defaultValue, String help) {
return new GameModeConfigProperty(this.section, name, defaultValue, help);
}
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param node The name of the configuration-node this ConfigProperty will be stored as.
* @param help The text that's displayed when a user failed to set the property.
* @return The ConfigProperty.
*/
public GameModeConfigProperty getNewProperty(String name, GameMode defaultValue, String node, String help) {
return new GameModeConfigProperty(this.section, name, defaultValue, node, help);
}
// GameMode
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param help The text that's displayed when a user failed to set the property.
* @return The ConfigProperty.
*/
public LocationConfigProperty getNewProperty(String name, Location defaultValue, String help) {
return new LocationConfigProperty(this.section, name, defaultValue, help);
}
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param node The name of the configuration-node this ConfigProperty will be stored as.
* @param help The text that's displayed when a user failed to set the property.
* @return The ConfigProperty.
*/
public LocationConfigProperty getNewProperty(String name, Location defaultValue, String node, String help) {
return new LocationConfigProperty(this.section, name, defaultValue, node, help);
}
/**
* Constructs a new ConfigProperty.
*
* @param name The name of this ConfigProperty.
* @param defaultValue The default-value.
* @param node The name of the configuration-node this ConfigProperty will be stored as.
* @param help The text that's displayed when a user failed to set the property.
* @param method The name of the method that's used to set this property.
* @return The ConfigProperty.
*/
public LocationConfigProperty getNewProperty(String name, Location defaultValue, String node, String help, String method) {
return new LocationConfigProperty(this.section, name, defaultValue, node, help, method);
}
/**
* Constructs a new ActiveStringConfigProperty
*
* This property will execute 'method' after it has been successfully set.
* This string will NOT be saved to the config file.
*
* @param name The name of this ConifgProperty
* @param defaultValue The default value.
* @param help What string is shown for help.
* @param method The method that should be executed.
* @param saveToConfig Should the variable save to the config?
* @return The ActiveStringConfigProperty
*/
public ActiveStringConfigProperty getNewProperty(String name, String defaultValue, String help, String method, boolean saveToConfig) {
return new ActiveStringConfigProperty(name, defaultValue, help, method);
}
}
@@ -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.configuration;
import org.bukkit.Difficulty;
import org.bukkit.configuration.ConfigurationSection;
/**
* A {@link Difficulty} config-property.
*/
public class DifficultyConfigProperty implements MVActiveConfigProperty<Difficulty> {
private String name;
private Difficulty value;
private String configNode;
private ConfigurationSection section;
private String help;
public DifficultyConfigProperty(ConfigurationSection section, String name, Difficulty defaultValue, String help) {
this(section, name, defaultValue, name, help);
}
public DifficultyConfigProperty(ConfigurationSection section, String name, Difficulty defaultValue, String configNode, String help) {
this.name = name;
this.configNode = configNode;
this.section = section;
this.help = help;
this.value = defaultValue;
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return this.name;
}
/**
* {@inheritDoc}
*/
@Override
public Difficulty getValue() {
return this.value;
}
/**
* {@inheritDoc}
*/
@Override
public boolean setValue(Difficulty value) {
if (value == null) {
return false;
}
this.value = value;
this.section.set(configNode, this.value.toString());
return true;
}
/**
* {@inheritDoc}
*/
@Override
public boolean parseValue(String value) {
try {
return this.setValue(Difficulty.getByValue(Integer.parseInt(value)));
} catch (NumberFormatException nfe) {
try {
return this.setValue(Difficulty.valueOf(value.toUpperCase()));
} catch (Exception e) {
return false;
}
}
}
/**
* {@inheritDoc}
*/
@Override
public String getConfigNode() {
return this.configNode;
}
/**
* {@inheritDoc}
*/
@Override
public String getHelp() {
return this.help;
}
@Override
public String toString() {
return value.toString();
}
/**
* Gets the method that will be executed.
*
* @return The name of the method in MVWorld to be called.
*/
@Override
public String getMethod() {
return "setActualDifficulty";
}
/**
* Sets the method that will be executed.
*
* @param methodName The name of the method in MVWorld to be called.
*/
@Override
public void setMethod(String methodName) {
// Unused here. This will only ever be setDifficulty.
}
/**
* {@inheritDoc}
*/
@Override
public Class<?> getPropertyClass() {
return Difficulty.class;
}
}
@@ -0,0 +1,133 @@
/******************************************************************************
* 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 org.bukkit.configuration.ConfigurationSection;
/**
* A {@link Double} config-property.
*/
public class DoubleConfigProperty implements MVActiveConfigProperty<Double> {
private String name;
private Double value;
private String configNode;
private ConfigurationSection section;
private String help;
private String method;
public DoubleConfigProperty(ConfigurationSection section, String name, Double defaultValue, String help) {
this(section, name, defaultValue, name, help);
}
public DoubleConfigProperty(ConfigurationSection section, String name, Double defaultValue, String configNode, String help) {
this.name = name;
this.configNode = configNode;
this.section = section;
this.help = help;
this.value = defaultValue;
this.setValue(this.section.getDouble(this.configNode, defaultValue));
}
public DoubleConfigProperty(ConfigurationSection section, String name, Double defaultValue, String configNode, String help, String method) {
this(section, name, defaultValue, configNode, help);
this.method = method;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return this.name;
}
/**
* {@inheritDoc}
*/
@Override
public Double getValue() {
return this.value;
}
/**
* {@inheritDoc}
*/
@Override
public boolean setValue(Double value) {
if (value == null) {
return false;
}
this.value = value;
this.section.set(configNode, this.value);
return true;
}
/**
* {@inheritDoc}
*/
@Override
public boolean parseValue(String value) {
try {
this.setValue(Double.parseDouble(value));
return true;
} catch (NumberFormatException e) {
return false;
}
}
/**
* {@inheritDoc}
*/
@Override
public String getConfigNode() {
return this.configNode;
}
/**
* {@inheritDoc}
*/
@Override
public String getHelp() {
return this.help;
}
@Override
public String toString() {
return value.toString();
}
/**
* Gets the method that will be executed.
*
* @return The name of the method in MVWorld to be called.
*/
@Override
public String getMethod() {
return this.method;
}
/**
* Sets the method that will be executed.
*
* @param methodName The name of the method in MVWorld to be called.
*/
@Override
public void setMethod(String methodName) {
this.method = methodName;
}
/**
* Returns the class of the object we're looking at.
*
* @return the class of the object we're looking at.
*/
@Override
public Class<?> getPropertyClass() {
return Double.class;
}
}
@@ -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.configuration;
import org.bukkit.GameMode;
import org.bukkit.configuration.ConfigurationSection;
/**
* A {@link GameMode} config-property.
*/
public class GameModeConfigProperty implements MVActiveConfigProperty<GameMode> {
private String name;
private GameMode value;
private String configNode;
private ConfigurationSection section;
private String help;
public GameModeConfigProperty(ConfigurationSection section, String name, GameMode defaultValue, String help) {
this(section, name, defaultValue, name, help);
}
public GameModeConfigProperty(ConfigurationSection section, String name, GameMode defaultValue, String configNode, String help) {
this.name = name;
this.configNode = configNode;
this.section = section;
this.help = help;
this.value = defaultValue;
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return this.name;
}
/**
* {@inheritDoc}
*/
@Override
public GameMode getValue() {
return this.value;
}
/**
* {@inheritDoc}
*/
@Override
public boolean setValue(GameMode value) {
if (value == null) {
return false;
}
this.value = value;
this.section.set(configNode, this.value.toString());
return true;
}
/**
* {@inheritDoc}
*/
@Override
public boolean parseValue(String value) {
try {
return this.setValue(GameMode.getByValue(Integer.parseInt(value)));
} catch (NumberFormatException nfe) {
try {
return this.setValue(GameMode.valueOf(value.toUpperCase()));
} catch (Exception e) {
return false;
}
}
}
/**
* {@inheritDoc}
*/
@Override
public String getConfigNode() {
return this.configNode;
}
/**
* {@inheritDoc}
*/
@Override
public String getHelp() {
return this.help;
}
@Override
public String toString() {
return value.toString();
}
/**
* Gets the method that will be executed.
*
* @return The name of the method in MVWorld to be called.
*/
@Override
public String getMethod() {
return "setActualGameMode";
}
/**
* Sets the method that will be executed.
*
* @param methodName The name of the method in MVWorld to be called.
*/
@Override
public void setMethod(String methodName) {
// Not required. Gamemode will only ever be one.
}
/**
* {@inheritDoc}
*/
@Override
public Class<?> getPropertyClass() {
return GameMode.class;
}
}
@@ -0,0 +1,97 @@
/******************************************************************************
* 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 org.bukkit.configuration.ConfigurationSection;
/**
* A {@link Integer} config-property.
*/
public class IntegerConfigProperty implements MVConfigProperty<Integer> {
private String name;
private Integer value;
private String configNode;
private ConfigurationSection section;
private String help;
public IntegerConfigProperty(ConfigurationSection section, String name, Integer defaultValue, String help) {
this(section, name, defaultValue, name, help);
}
public IntegerConfigProperty(ConfigurationSection section, String name, Integer defaultValue, String configNode, String help) {
this.name = name;
this.configNode = configNode;
this.section = section;
this.help = help;
this.value = defaultValue;
this.setValue(this.section.getInt(this.configNode, defaultValue));
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return this.name;
}
/**
* {@inheritDoc}
*/
@Override
public Integer getValue() {
return this.value;
}
/**
* {@inheritDoc}
*/
@Override
public boolean setValue(Integer value) {
if (value == null) {
return false;
}
this.value = value;
this.section.set(configNode, this.value);
return true;
}
/**
* {@inheritDoc}
*/
@Override
public boolean parseValue(String value) {
try {
this.setValue(Integer.parseInt(value));
return true;
} catch (NumberFormatException e) {
return false;
}
}
/**
* {@inheritDoc}
*/
@Override
public String getConfigNode() {
return this.configNode;
}
/**
* {@inheritDoc}
*/
@Override
public String getHelp() {
return this.help;
}
@Override
public String toString() {
return value.toString();
}
}
@@ -0,0 +1,151 @@
/******************************************************************************
* 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.utils.LocationManipulation;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
/**
* A {@link Location} config-property.
*/
public class LocationConfigProperty implements MVActiveConfigProperty<Location> {
private String name;
private Location value;
private String configNode;
private ConfigurationSection section;
private String help;
private String method;
public LocationConfigProperty(ConfigurationSection section, String name, Location defaultValue, String help) {
this(section, name, defaultValue, name, help);
}
public LocationConfigProperty(ConfigurationSection section, String name, Location defaultValue, String configNode, String help) {
this.name = name;
this.configNode = configNode;
this.section = section;
this.help = help;
this.value = defaultValue;
this.setValue(this.getLocationFromConfig(defaultValue));
}
public LocationConfigProperty(ConfigurationSection section, String name, Location defaultValue, String configNode, String help, String method) {
this(section, name, defaultValue, configNode, help);
this.method = method;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return this.name;
}
/**
* {@inheritDoc}
*/
@Override
public Location getValue() {
return this.value;
}
/**
* {@inheritDoc}
*/
@Override
public boolean parseValue(String value) {
Location parsed = LocationManipulation.stringToLocation(value);
return this.setValue(parsed);
}
/**
* {@inheritDoc}
*/
@Override
public String getConfigNode() {
return this.configNode;
}
/**
* {@inheritDoc}
*/
@Override
public String getHelp() {
return this.help;
}
/**
* {@inheritDoc}
*/
@Override
public boolean setValue(Location value) {
if (value == null) {
return false;
}
this.value = value;
this.section.set(configNode + ".x", this.value.getX());
this.section.set(configNode + ".y", this.value.getY());
this.section.set(configNode + ".z", this.value.getZ());
this.section.set(configNode + ".pitch", this.value.getPitch());
this.section.set(configNode + ".yaw", this.value.getYaw());
this.section.set(configNode + ".world", this.value.getWorld().getName());
return true;
}
private Location getLocationFromConfig(Location defaultValue) {
double x = this.section.getDouble(this.configNode + ".x", defaultValue.getX());
double y = this.section.getDouble(this.configNode + ".y", defaultValue.getY());
double z = this.section.getDouble(this.configNode + ".z", defaultValue.getZ());
double pitch = this.section.getDouble(this.configNode + ".pitch", defaultValue.getPitch());
double yaw = this.section.getDouble(this.configNode + ".yaw", defaultValue.getYaw());
String w = this.section.getString(this.configNode + ".world", defaultValue.getWorld().getName());
Location found = LocationManipulation.stringToLocation(w + ":" + x + "," + y + "," + z + ":" + yaw + ":" + pitch);
if (found != null) {
return found;
}
return defaultValue;
}
@Override
public String toString() {
return LocationManipulation.strCoordsRaw(this.value);
}
/**
* Gets the method that will be executed.
*
* @return The name of the method in MVWorld to be called.
*/
@Override
public String getMethod() {
return this.method;
}
/**
* Sets the method that will be executed.
*
* @param methodName The name of the method in MVWorld to be called.
*/
@Override
public void setMethod(String methodName) {
this.method = methodName;
}
/**
* Returns the class of the object we're looking at.
*
* @return the class of the object we're looking at.
*/
@Override
public Class<?> getPropertyClass() {
return Location.class;
}
}
@@ -0,0 +1,35 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2012. *
* 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;
/**
* An "active" {@link MVConfigProperty} that uses the specified method to be "actually" set.
* @param <T> The type of the config-property.
* @see MVConfigProperty
*/
public interface MVActiveConfigProperty<T> extends MVConfigProperty<T> {
/**
* Gets the method that will be executed.
*
* @return The name of the method in MVWorld to be called.
*/
String getMethod();
/**
* Sets the method that will be executed.
*
* @param methodName The name of the method in MVWorld to be called.
*/
void setMethod(String methodName);
/**
* Returns the class of the object we're looking at.
* @return the class of the object we're looking at.
*/
Class<?> getPropertyClass();
}
@@ -17,7 +17,17 @@ import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
/*
* This is a mess, so I'm just going to suppress all warnings here.
* BEGIN CHECKSTYLE-SUPPRESSION: ALL
*/
/**
* @deprecated This isn't used any more, is it?
*/
@Deprecated
public abstract class MVConfigMigrator {
public List<String> createdDefaults = new ArrayList<String>();
public abstract boolean migrate(String name, File folder);
@@ -59,3 +69,7 @@ public abstract class MVConfigMigrator {
return oldFolder;
}
}
/*
* END CHECKSTYLE-SUPPRESSION: ALL
*/
@@ -0,0 +1,67 @@
/******************************************************************************
* 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;
/**
* A generic config-property.
*
* @param <T> The type of the config-property.
*/
public interface MVConfigProperty<T> {
/**
* Gets the name of this property.
*
* @return The name of this property.
*/
String getName();
/**
* Gets the value of this property.
*
* @return The value of this property.
*/
T getValue();
/**
* Gets the string representation of this value.
*
* @return The value of this property as a string.
*/
String toString();
/**
* Gets the help string for this.
*
* @return The value of this property as a string.
*/
String getHelp();
/**
* Sets the value of this property.
*
* @param value The T representation of this value.
* @return True the value was successfully set.
*/
boolean setValue(T value);
/**
* This parseValue should be used with strings.
*
* @param value The string representation of the value to set.
*
* @return True if the value was set, false if not.
*/
boolean parseValue(String value);
/**
* Gets the name of the config-node that this {@link MVConfigProperty} is saved as.
*
* @return The name of the config-node that this {@link MVConfigProperty} is saved as.
*/
String getConfigNode();
}
@@ -1,82 +0,0 @@
/******************************************************************************
* 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,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.configuration;
import org.bukkit.configuration.ConfigurationSection;
/**
* A {@link String} config-property.
*/
public class StringConfigProperty implements MVConfigProperty<String> {
private String name;
private String value;
private String configNode;
private ConfigurationSection section;
private String help;
public StringConfigProperty(ConfigurationSection section, String name, String defaultValue, String help) {
this(section, name, defaultValue, defaultValue, help);
}
public StringConfigProperty(ConfigurationSection section, String name, String defaultValue, String configNode, String help) {
this.name = name;
this.configNode = configNode;
this.section = section;
this.help = help;
this.value = defaultValue;
this.parseValue(this.section.getString(this.configNode, defaultValue));
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return this.name;
}
/**
* {@inheritDoc}
*/
@Override
public String getValue() {
return this.value;
}
/**
* {@inheritDoc}
*/
@Override
public boolean parseValue(String value) {
if (value == null) {
return false;
}
this.setValue(value);
return true;
}
/**
* {@inheritDoc}
*/
@Override
public String getConfigNode() {
return this.configNode;
}
/**
* {@inheritDoc}
*/
@Override
public String getHelp() {
return this.help;
}
/**
* {@inheritDoc}
*/
@Override
public boolean setValue(String value) {
if (value == null) {
return false;
}
this.value = value;
this.section.set(configNode, this.value);
return true;
}
@Override
public String toString() {
return value;
}
}
@@ -0,0 +1,4 @@
/**
* This package contains the Multiverse-configuration.
*/
package com.onarandombox.MultiverseCore.configuration;
@@ -0,0 +1,148 @@
/******************************************************************************
* 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;
/**
* An anchor-{@link MVDestination}.
*/
public class AnchorDestination implements MVDestination {
private boolean isValid;
private Location location;
private MultiverseCore plugin;
private String name;
/**
* {@inheritDoc}
*/
@Override
public String getIdentifier() {
return "a";
}
/**
* {@inheritDoc}
*/
@Override
public Vector getVelocity() {
return new Vector(0, 0, 0);
}
/**
* {@inheritDoc}
*/
@Override
public boolean isThisType(JavaPlugin plugin, String destination) {
if (!(plugin instanceof MultiverseCore)) {
return false;
}
this.plugin = (MultiverseCore) plugin;
List<String> parsed = Arrays.asList(destination.split(":"));
// Need at least: a:name
if (!(parsed.size() == 2)) {
return false;
}
// If it's not an Anchor type
return parsed.get(0).equalsIgnoreCase("a");
}
/**
* {@inheritDoc}
*/
@Override
public Location getLocation(Entity e) {
return this.location;
}
/**
* {@inheritDoc}
*/
@Override
public boolean isValid() {
return this.isValid;
}
/**
* {@inheritDoc}
*/
@Override
public void setDestination(JavaPlugin plugin, String destination) {
if (!(plugin instanceof MultiverseCore)) {
return;
}
this.plugin = (MultiverseCore) plugin;
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() == 2)) {
this.isValid = false;
return;
}
this.name = parsed.get(1);
this.location = this.plugin.getAnchorManager().getAnchorLocation(parsed.get(1));
if (this.location == null) {
this.isValid = false;
return;
}
if (!parsed.get(0).equalsIgnoreCase(this.getIdentifier())) {
this.isValid = false;
}
this.isValid = true;
}
/**
* {@inheritDoc}
*/
@Override
public String getType() {
return "Anchor";
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return "Anchor: " + this.name;
}
@Override
public String toString() {
if (isValid) {
return "a:" + this.name;
}
return "i:Invalid Destination";
}
/**
* {@inheritDoc}
*/
@Override
public String getRequiredPermission() {
return "multiverse.access." + this.location.getWorld().getName();
}
/**
* {@inheritDoc}
*/
@Override
public boolean useSafeTeleporter() {
// This is an ANCHOR destination, don't safely teleport here.
return false;
}
}
@@ -15,20 +15,24 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
/**
* Multiverse 2
*
* @author fernferret
* A bed-{@link MVDestination}.
*/
public class BedDestination implements MVDestination {
private boolean isValid;
private Location knownBedLoc;
/**
* {@inheritDoc}
*/
@Override
public String getIdentifier() {
return "b";
}
/**
* {@inheritDoc}
*/
@Override
public boolean isThisType(JavaPlugin plugin, String destination) {
String[] split = destination.split(":");
@@ -36,6 +40,9 @@ public class BedDestination implements MVDestination {
return this.isValid;
}
/**
* {@inheritDoc}
*/
@Override
public Location getLocation(Entity entity) {
if (entity instanceof Player) {
@@ -45,31 +52,49 @@ public class BedDestination implements MVDestination {
return null;
}
/**
* {@inheritDoc}
*/
@Override
public Vector getVelocity() {
return new Vector();
}
/**
* {@inheritDoc}
*/
@Override
public void setDestination(JavaPlugin plugin, String destination) {
// Not needed.
}
/**
* {@inheritDoc}
*/
@Override
public boolean isValid() {
return this.isValid;
}
/**
* {@inheritDoc}
*/
@Override
public String getType() {
return "Bed";
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return "Bed";
}
/**
* {@inheritDoc}
*/
@Override
public String getRequiredPermission() {
if (knownBedLoc != null) {
@@ -78,6 +103,9 @@ public class BedDestination implements MVDestination {
return "";
}
/**
* {@inheritDoc}
*/
@Override
public boolean useSafeTeleporter() {
// Bukkit should have already checked this.
@@ -17,12 +17,19 @@ import org.bukkit.util.Vector;
import java.util.Arrays;
import java.util.List;
/**
* A cannon-{@link MVDestination}.
*/
public class CannonDestination implements MVDestination {
private final String coordRegex = "(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*)";
private boolean isValid;
private Location location;
private double speed;
/**
* {@inheritDoc}
*/
@Override
public Vector getVelocity() {
double pitchRadians = Math.toRadians(location.getPitch());
double yawRadians = Math.toRadians(location.getYaw());
@@ -35,20 +42,28 @@ public class CannonDestination implements MVDestination {
return new Vector(x, y, z);
}
/**
* {@inheritDoc}
*/
@Override
public String getIdentifier() {
return "ca";
}
// NEED ca:world:x,y,z:pitch:yaw:speed
// so basically 6
private static final int SPLIT_SIZE = 6;
/**
* {@inheritDoc}
*/
@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) {
if (parsed.size() != SPLIT_SIZE) {
return false;
}
// If it's not an Cannon type
@@ -66,35 +81,44 @@ public class CannonDestination implements MVDestination {
}
try {
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
Float.parseFloat(parsed.get(3));
Float.parseFloat(parsed.get(4));
Float.parseFloat(parsed.get(5));
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
} catch (NumberFormatException e) {
return false;
}
return true;
}
/**
* {@inheritDoc}
*/
@Override
public Location getLocation(Entity e) {
return this.location;
}
/**
* {@inheritDoc}
*/
@Override
public boolean isValid() {
return this.isValid;
}
/**
* {@inheritDoc}
*/
@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) {
if (parsed.size() != SPLIT_SIZE) {
this.isValid = false;
return;
}
@@ -129,9 +153,11 @@ public class CannonDestination implements MVDestination {
this.location.setZ(coords[2]);
try {
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
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)));
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
} catch (NumberFormatException e) {
this.isValid = false;
return;
@@ -141,18 +167,30 @@ public class CannonDestination implements MVDestination {
}
/**
* {@inheritDoc}
*/
@Override
public String getType() {
return "Cannon!";
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return "Cannon (" + this.location.getX() + ", " + this.location.getY() + ", " + this.location.getZ() + ":" +
this.location.getPitch() + ":" + this.location.getYaw() + ":" + this.speed + ")";
return "Cannon (" + this.location.getX() + ", " + this.location.getY() + ", " + this.location.getZ() + ":"
+ this.location.getPitch() + ":" + this.location.getYaw() + ":" + this.speed + ")";
}
/**
* Sets this {@link CannonDestination}.
*
* @param location The {@link Location}.
* @param speed The speed.
*/
public void setDestination(Location location, double speed) {
if (location != null) {
this.location = location;
@@ -162,21 +200,28 @@ public class CannonDestination implements MVDestination {
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";
}
/**
* {@inheritDoc}
*/
@Override
public String getRequiredPermission() {
return "multiverse.access." + this.location.getWorld().getName();
}
/**
* {@inheritDoc}
*/
@Override
public boolean useSafeTeleporter() {
return 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";
}
}
@@ -66,6 +66,13 @@ public class DestinationFactory {
return new InvalidDestination();
}
/**
* Registers a {@link MVDestination}.
*
* @param c The {@link Class} of the {@link MVDestination} to register.
* @param identifier The {@link String}-identifier.
* @return True if the class was successfully registered.
*/
public boolean registerDestinationType(Class<? extends MVDestination> c, String identifier) {
if (this.destList.containsKey(identifier)) {
return false;
@@ -79,12 +86,14 @@ public class DestinationFactory {
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);
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);
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);
}
@@ -17,20 +17,33 @@ import org.bukkit.util.Vector;
import java.util.Arrays;
import java.util.List;
/**
* An exact {@link MVDestination}.
*/
public class ExactDestination implements MVDestination {
private final String coordRegex = "(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*)";
private boolean isValid;
private Location location;
/**
* {@inheritDoc}
*/
@Override
public String getIdentifier() {
return "e";
}
/**
* {@inheritDoc}
*/
@Override
public Vector getVelocity() {
return new Vector(0, 0, 0);
}
/**
* {@inheritDoc}
*/
@Override
public boolean isThisType(JavaPlugin plugin, String destination) {
if (!(plugin instanceof MultiverseCore)) {
@@ -40,7 +53,7 @@ public class ExactDestination implements MVDestination {
// 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)) {
if (!(parsed.size() == 3 || parsed.size() == 5)) { // SUPPRESS CHECKSTYLE: MagicNumberCheck
return false;
}
// If it's not an Exact type
@@ -63,23 +76,32 @@ public class ExactDestination implements MVDestination {
try {
Float.parseFloat(parsed.get(3));
Float.parseFloat(parsed.get(4));
Float.parseFloat(parsed.get(4)); // SUPPRESS CHECKSTYLE: MagicNumberCheck
} catch (NumberFormatException e) {
return false;
}
return true;
}
/**
* {@inheritDoc}
*/
@Override
public Location getLocation(Entity e) {
return this.location;
}
/**
* {@inheritDoc}
*/
@Override
public boolean isValid() {
return this.isValid;
}
/**
* {@inheritDoc}
*/
@Override
public void setDestination(JavaPlugin plugin, String destination) {
if (!(plugin instanceof MultiverseCore)) {
@@ -89,7 +111,7 @@ public class ExactDestination implements MVDestination {
// 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)) {
if (!(parsed.size() == 3 || parsed.size() == 5)) { // SUPPRESS CHECKSTYLE: MagicNumberCheck
this.isValid = false;
return;
}
@@ -130,7 +152,7 @@ public class ExactDestination implements MVDestination {
try {
this.location.setPitch(Float.parseFloat(parsed.get(3)));
this.location.setYaw(Float.parseFloat(parsed.get(4)));
this.location.setYaw(Float.parseFloat(parsed.get(4))); // SUPPRESS CHECKSTYLE: MagicNumberCheck
} catch (NumberFormatException e) {
this.isValid = false;
return;
@@ -139,16 +161,28 @@ public class ExactDestination implements MVDestination {
}
/**
* {@inheritDoc}
*/
@Override
public String getType() {
return "Exact";
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return "Exact (" + this.location.getX() + ", " + this.location.getY() + ", " + this.location.getZ() + ":" + location.getPitch() + ":" + location.getYaw() + ")";
return "Exact (" + this.location.getX() + ", " + this.location.getY() + ", " + this.location.getZ()
+ ":" + location.getPitch() + ":" + location.getYaw() + ")";
}
/**
* Sets this {@link ExactDestination}.
*
* @param location The {@link Location}.
*/
public void setDestination(Location location) {
if (location != null) {
this.location = location;
@@ -157,19 +191,29 @@ public class ExactDestination implements MVDestination {
this.isValid = false;
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
if (isValid) {
return "e:" + location.getWorld().getName() + ":" + location.getX() + "," + location.getY() + "," + location.getZ() + ":" + location.getPitch() + ":" + location.getYaw();
return "e:" + location.getWorld().getName() + ":" + location.getX() + "," + location.getY()
+ "," + location.getZ() + ":" + location.getPitch() + ":" + location.getYaw();
}
return "i:Invalid Destination";
}
/**
* {@inheritDoc}
*/
@Override
public String getRequiredPermission() {
return "multiverse.access." + this.location.getWorld().getName();
}
/**
* {@inheritDoc}
*/
@Override
public boolean useSafeTeleporter() {
// This is an EXACT destination, don't safely teleport here.
@@ -14,38 +14,62 @@ import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
/**
* An invalid {@link MVDestination}.
*/
public class InvalidDestination implements MVDestination {
/**
* {@inheritDoc}
*/
@Override
public String getIdentifier() {
return "i";
}
/**
* {@inheritDoc}
*/
@Override
public boolean isThisType(JavaPlugin plugin, String destination) {
return false;
}
/**
* {@inheritDoc}
*/
@Override
public Location getLocation(Entity e) {
return null;
}
/**
* {@inheritDoc}
*/
@Override
public boolean isValid() {
return false;
}
/**
* {@inheritDoc}
*/
@Override
public void setDestination(JavaPlugin plugin, String destination) {
// Nothing needed, it's invalid.
}
/**
* {@inheritDoc}
*/
@Override
public String getType() {
return ChatColor.RED + "Invalid Destination";
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return ChatColor.RED + "Invalid Destination";
@@ -56,15 +80,25 @@ public class InvalidDestination implements MVDestination {
return "i:Invalid Destination";
}
/**
* {@inheritDoc}
*/
@Override
public String getRequiredPermission() {
return null;
}
/**
* {@inheritDoc}
*/
@Override
public Vector getVelocity() {
return new Vector(0, 0, 0);
}
/**
* {@inheritDoc}
*/
@Override
public boolean useSafeTeleporter() {
return false;
@@ -14,16 +14,25 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
/**
* A player-{@link MVDestination}.
*/
public class PlayerDestination implements MVDestination {
String player;
private String player;
private boolean isValid;
private JavaPlugin plugin;
/**
* {@inheritDoc}
*/
@Override
public String getIdentifier() {
return "pl";
}
/**
* {@inheritDoc}
*/
@Override
public boolean isThisType(JavaPlugin plugin, String destination) {
String[] items = destination.split(":");
@@ -36,6 +45,9 @@ public class PlayerDestination implements MVDestination {
return true;
}
/**
* {@inheritDoc}
*/
@Override
public Location getLocation(Entity e) {
Player p = plugin.getServer().getPlayer(this.player);
@@ -46,17 +58,23 @@ public class PlayerDestination implements MVDestination {
plLoc = (Player) e.getPassenger();
}
if (p != null && plLoc != null && !plLoc.getName().equalsIgnoreCase(p.getName())) {
if (p != null && plLoc != null) {
return p.getLocation();
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public boolean isValid() {
return this.isValid;
}
/**
* {@inheritDoc}
*/
@Override
public void setDestination(JavaPlugin plugin, String destination) {
String[] items = destination.split(":");
@@ -71,11 +89,17 @@ public class PlayerDestination implements MVDestination {
this.plugin = plugin;
}
/**
* {@inheritDoc}
*/
@Override
public String getType() {
return "Player";
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return this.player;
@@ -86,15 +110,25 @@ public class PlayerDestination implements MVDestination {
return "pl:" + this.player;
}
/**
* {@inheritDoc}
*/
@Override
public String getRequiredPermission() {
return "";
}
/**
* {@inheritDoc}
*/
@Override
public Vector getVelocity() {
return new Vector(0, 0, 0);
}
/**
* {@inheritDoc}
*/
@Override
public boolean useSafeTeleporter() {
return true;
@@ -16,17 +16,26 @@ import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
/**
* A world-{@link MVDestination}.
*/
public class WorldDestination implements MVDestination {
private boolean isValid;
private MultiverseWorld world;
float yaw = -1;
String direction = "";
private float yaw = -1;
private String direction = "";
/**
* {@inheritDoc}
*/
@Override
public String getIdentifier() {
return "w";
}
/**
* {@inheritDoc}
*/
@Override
public boolean isThisType(JavaPlugin plugin, String destination) {
String[] items = destination.split(":");
@@ -48,6 +57,9 @@ public class WorldDestination implements MVDestination {
return false;
}
/**
* {@inheritDoc}
*/
@Override
public Location getLocation(Entity e) {
Location spawnLoc = getAcurateSpawnLocation(e, this.world);
@@ -62,15 +74,23 @@ public class WorldDestination implements MVDestination {
if (world != null) {
return world.getSpawnLocation();
} else {
// add 0.5 to x and z to center people
// (spawn location is stored as int meaning that you would spawn in the corner of a block)
return e.getWorld().getSpawnLocation().add(.5, 0, .5);
}
}
/**
* {@inheritDoc}
*/
@Override
public boolean isValid() {
return this.isValid;
}
/**
* {@inheritDoc}
*/
@Override
public void setDestination(JavaPlugin plugin, String destination) {
String[] items = destination.split(":");
@@ -97,11 +117,17 @@ public class WorldDestination implements MVDestination {
}
}
/**
* {@inheritDoc}
*/
@Override
public String getType() {
return "World";
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return this.world.getColoredWorldString();
@@ -115,6 +141,9 @@ public class WorldDestination implements MVDestination {
return this.world.getCBWorld().getName();
}
/**
* {@inheritDoc}
*/
@Override
public String getRequiredPermission() {
// TODO: Potenitally replace spaces wiht tabs for friendlier yaml.
@@ -122,10 +151,17 @@ public class WorldDestination implements MVDestination {
return "multiverse.access." + this.world.getName();
}
/**
* {@inheritDoc}
*/
@Override
public Vector getVelocity() {
return new Vector(0, 0, 0);
}
/**
* {@inheritDoc}
*/
@Override
public boolean useSafeTeleporter() {
return true;
@@ -0,0 +1,4 @@
/**
* This package contains all destination-types.
*/
package com.onarandombox.MultiverseCore.destination;
@@ -8,10 +8,23 @@
package com.onarandombox.MultiverseCore.enums;
/**
* Multiverse 2
*
* @author fernferret
* A enum containing all actions that can be used to modify world-properties.
*/
public enum Action {
Set, Add, Remove, Clear
/**
* Setting a property.
*/
Set,
/**
* Adding something to a list-property.
*/
Add,
/**
* Removing something from a list-property.
*/
Remove,
/**
* Clearing a list-property.
*/
Clear
}
@@ -8,10 +8,19 @@
package com.onarandombox.MultiverseCore.enums;
/**
* Multiverse 2
*
* @author fernferret
* An enum containing all list-properties.
*/
public enum AddProperties {
worldblacklist, animals, monsters
/**
* Worlds that people cannot go to from a world.
*/
worldblacklist,
/**
* Animal-exceptions.
*/
animals,
/**
* Monster-exceptions.
*/
monsters
}
@@ -7,11 +7,52 @@
package com.onarandombox.MultiverseCore.enums;
/** Multiverse 2 */
/**
* An enum containing all config-properties that can be set.
*/
public enum ConfigProperty {
messagecooldown, teleportcooldown, worldnameprefix, bedrespawn, enforcegamemodes, enforceaccess, debug;
/**
* How long to leave in between sending a message to the player. (NOT YET IMPLEMENTED)
*/
messagecooldown,
/**
* How fast are people allowed to use /MVTP (NOT YET IMPLEMENTED).
*/
teleportcooldown,
/**
* Prefix chat-messages with world-names.
*/
worldnameprefix,
/**
* If value is set to false, Multiverse will NOT enforce world access permissions.
*/
enforceaccess,
/**
* Whether users should get detailed information about the permissions they would need.
*/
displaypermerrors,
/**
* Debug-information.
*/
debug,
/**
* The world new users will spawn in.
*/
firstspawnworld,
/**
* Whether Multiverse should intercept teleports.
*/
teleportintercept,
/**
* Whether Multiverse should override the first spawn.
*/
firstspawnoverride;
/**
* Constructs a string containing all values in this enum.
*
* @return That {@link String}.
*/
public static String getAllValues() {
String buffer = "";
for (ConfigProperty c : ConfigProperty.values()) {
@@ -10,26 +10,43 @@ package com.onarandombox.MultiverseCore.enums;
import org.bukkit.ChatColor;
/**
* Multiverse 2
*
* @author fernferret
* A regular {@link ChatColor} represented by an english string.
*/
public enum EnglishChatColor {
/*
* I know. this is quite ugly.
*/
/** AQUA. */
AQUA("AQUA", ChatColor.AQUA),
/** BLACK. */
BLACK("BLACK", ChatColor.BLACK),
/** BLUE. */
BLUE("BLUE", ChatColor.BLUE),
/** DARKAQUA. */
DARKAQUA("DARKAQUA", ChatColor.DARK_AQUA),
/** DARKBLUE. */
DARKBLUE("DARKBLUE", ChatColor.DARK_BLUE),
/** DARKGRAY. */
DARKGRAY("DARKGRAY", ChatColor.DARK_GRAY),
/** DARKGREEN. */
DARKGREEN("DARKGREEN", ChatColor.DARK_GREEN),
/** DARKPURPLE. */
DARKPURPLE("DARKPURPLE", ChatColor.DARK_PURPLE),
/** DARKRED. */
DARKRED("DARKRED", ChatColor.DARK_RED),
/** GOLD. */
GOLD("GOLD", ChatColor.GOLD),
/** GRAY. */
GRAY("GRAY", ChatColor.GRAY),
/** GREEN. */
GREEN("GREEN", ChatColor.GREEN),
/** LIGHTPURPLE. */
LIGHTPURPLE("LIGHTPURPLE", ChatColor.LIGHT_PURPLE),
/** RED. */
RED("RED", ChatColor.RED),
/** YELLOW. */
YELLOW("YELLOW", ChatColor.YELLOW),
/** WHITE. */
WHITE("WHITE", ChatColor.WHITE);
private ChatColor color;
private String text;
@@ -39,14 +56,26 @@ public enum EnglishChatColor {
this.text = name;
}
/**
* Gets the text.
* @return The text.
*/
public String getText() {
return this.text;
}
/**
* Gets the color.
* @return The color as {@link ChatColor}.
*/
public ChatColor getColor() {
return this.color;
}
/**
* Constructs a string containing all available colors.
* @return That {@link String}.
*/
public static String getAllColors() {
String buffer = "";
for (EnglishChatColor c : EnglishChatColor.values()) {
@@ -55,6 +84,11 @@ public enum EnglishChatColor {
return buffer;
}
/**
* Constructs an {@link EnglishChatColor} from a {@link String}.
* @param text The {@link String}.
* @return The {@link EnglishChatColor}.
*/
public static EnglishChatColor fromString(String text) {
if (text != null) {
for (EnglishChatColor c : EnglishChatColor.values()) {
@@ -8,12 +8,31 @@
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
* An enum containing possible teleport-results.
*/
public enum TeleportResult {
/**
* Insufficient permissions.
*/
FAIL_PERMISSION,
/**
* The teleport was unsafe.
*/
FAIL_UNSAFE,
/**
* The player was to poor.
*/
FAIL_TOO_POOR,
/**
* The teleport was invalid.
*/
FAIL_INVALID,
/**
* Unknown reason.
*/
FAIL_OTHER,
/**
* The player was successfully teleported.
*/
SUCCESS
}
@@ -0,0 +1,4 @@
/**
* This package contains all enums.
*/
package com.onarandombox.MultiverseCore.enums;
@@ -1,30 +0,0 @@
/******************************************************************************
* 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;
}
}
@@ -11,6 +11,9 @@ import org.bukkit.event.Event;
import java.util.List;
/**
* Called when the Multiverse-config should be reloaded.
*/
public class MVConfigReloadEvent extends Event {
private static final long serialVersionUID = 3647950355746345397L;
private List<String> configsLoaded;
@@ -20,10 +23,18 @@ public class MVConfigReloadEvent extends Event {
this.configsLoaded = configsLoaded;
}
/**
* Adds a config to this event.
* @param config The config to add.
*/
public void addConfig(String config) {
this.configsLoaded.add(config);
}
/**
* Gets all loaded configs.
* @return A list of all loaded configs.
*/
public List<String> getAllConfigsLoaded() {
return this.configsLoaded;
}
@@ -0,0 +1,54 @@
/******************************************************************************
* 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.Cancellable;
import org.bukkit.event.Event;
/**
* This event is thrown when a portal is touched.
*/
public class MVPlayerTouchedPortalEvent extends Event implements Cancellable {
private Player p;
private Location l;
private boolean isCancelled;
public MVPlayerTouchedPortalEvent(Player p, Location l) {
super("MVPlayerTouchedPortalEvent");
this.p = p;
this.l = l;
}
/**
* Gets the {@link Location} of the portal-block that was touched.
* @return The {@link Location} of the portal-block that was touched.
*/
public Location getBlockTouched() {
return this.l;
}
/**
* Gets the {@link Player} that's touching the portal.
* @return The {@link Player} that's touching the portal.
*/
public Player getPlayer() {
return this.p;
}
@Override
public boolean isCancelled() {
return this.isCancelled;
}
@Override
public void setCancelled(boolean b) {
this.isCancelled = b;
}
}
@@ -11,8 +11,10 @@ import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
/**
* Called when a player is respawning.
*/
public class MVRespawnEvent extends Event {
private static final long serialVersionUID = -2991894063331856687L;
private Player player;
private Location location;
private String respawnMethod;
@@ -25,18 +27,34 @@ public class MVRespawnEvent extends Event {
this.respawnMethod = respawnMethod;
}
/**
* Gets the {@link Player} that's respawning.
* @return The {@link Player} that's respawning.
*/
public Player getPlayer() {
return this.player;
}
/**
* Gets the respawn-method.
* @return The respawn-method.
*/
public String getRespawnMethod() {
return this.respawnMethod;
}
/**
* Gets the player's respawn-{@link Location}.
* @return The player's respawn-{@link Location}.
*/
public Location getPlayersRespawnLocation() {
return this.location;
}
/**
* Sets the player's respawn-{@link Location}.
* @param l The new respawn-{@link Location}.
*/
public void setRespawnLocation(Location l) {
this.location = l;
}
@@ -8,6 +8,7 @@
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;
@@ -15,9 +16,7 @@ import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
/**
* Event that gets called when a player use the /mvtp command
*
* @author fernferret
* Event that gets called when a player use the /mvtp command.
*/
public class MVTeleportEvent extends Event implements Cancellable {
private Player teleportee;
@@ -53,9 +52,9 @@ public class MVTeleportEvent extends Event implements Cancellable {
}
/**
* Returns the player who requested the Teleport
* Gets the {@link CommandSender} who requested the Teleport.
*
* @return
* @return The {@link CommandSender} who requested the Teleport
*/
public CommandSender getTeleporter() {
return this.teleporter;
@@ -70,6 +69,14 @@ public class MVTeleportEvent extends Event implements Cancellable {
return this.dest;
}
/**
* Looks if this {@link MVTeleportEvent} is using the {@link SafeTTeleporter}.
* @return True if this {@link MVTeleportEvent} is using the {@link SafeTTeleporter}.
*/
public boolean isUsingSafeTTeleporter() {
return useSafeTeleport;
}
@Override
public boolean isCancelled() {
return this.isCancelled;
@@ -0,0 +1,32 @@
package com.onarandombox.MultiverseCore.event;
import org.bukkit.event.Event;
/**
* Called when somebody requests version information about Multiverse.
*/
public class MVVersionEvent extends Event {
private final StringBuilder versionInfoBuilder;
public MVVersionEvent(String versionInfo) {
super("MVVersionEvent");
versionInfoBuilder = new StringBuilder(versionInfo);
}
/**
* Gets the version-info currently saved in this event.
* @return The version-info.
*/
public String getVersionInfo() {
return versionInfoBuilder.toString();
}
/**
* Appends more version-info to the version-info currently saved in this event.
* @param moreVersionInfo The version-info to add. Should end with '\n'.
*/
public void appendVersionInfo(String moreVersionInfo) {
versionInfoBuilder.append(moreVersionInfo);
}
}
@@ -9,6 +9,11 @@ package com.onarandombox.MultiverseCore.event;
import org.bukkit.event.Event;
/**
* Called when somebody requests version information about Multiverse.
* @deprecated Use {@link MVVersionEvent} instead.
*/
@Deprecated
public class MVVersionRequestEvent extends Event {
private String pasteBinBuffer;
@@ -18,10 +23,22 @@ public class MVVersionRequestEvent extends Event {
this.pasteBinBuffer = pasteBinBuffer;
}
/**
* Gets the pasteBinBuffer.
* @return The pasteBinBuffer.
* @deprecated Use {@link MVVersionEvent} instead.
*/
@Deprecated
public String getPasteBinBuffer() {
return this.pasteBinBuffer;
}
/**
* Sets the pasteBinBuffer.
* @param buffer The new pasteBinBuffer.
* @deprecated Use {@link MVVersionEvent} instead.
*/
@Deprecated
public void setPasteBinBuffer(String buffer) {
this.pasteBinBuffer = buffer;
}
@@ -0,0 +1,61 @@
package com.onarandombox.MultiverseCore.event;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
/**
* Called when a world is about to be deleted by Multiverse.
*/
public class MVWorldDeleteEvent extends Event implements Cancellable {
private boolean cancelled = false;
private final MultiverseWorld world;
private final boolean removeFromConfig;
public MVWorldDeleteEvent(MultiverseWorld world, boolean removeFromConfig) {
super("MVWorldDeleteEvent");
if (world == null)
throw new IllegalArgumentException("world can't be null!");
this.world = world;
this.removeFromConfig = removeFromConfig;
}
/**
* {@inheritDoc}
*/
@Override
public boolean isCancelled() {
return cancelled;
}
/**
* {@inheritDoc}
*/
@Override
public void setCancelled(boolean cancel) {
cancelled = cancel;
}
/**
* Gets the world that's about to be deleted.
*
* @return That {@link MultiverseWorld}.
*/
public MultiverseWorld getWorld() {
return world;
}
/**
* Is the world about to be removed from the config?
*
* @return True if yes, false if no.
*/
public boolean removeWorldFromConfig() {
return removeFromConfig;
}
}
@@ -0,0 +1,90 @@
/******************************************************************************
* 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.MultiverseWorld;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
/**
* This event is fired *before* the property is actually changed.
* <p>
* If it is cancelled, no change will happen.
* <p>
* If you want to get the values of the world before the change, query the world.
* If you want to get the value being changed, use getProperty()
*/
public class MVWorldPropertyChangeEvent extends Event implements Cancellable {
private MultiverseWorld world;
private CommandSender changer;
private boolean isCancelled = false;
private String value;
private String name;
public MVWorldPropertyChangeEvent(MultiverseWorld world, CommandSender changer, String name, String value) {
super("MVWorldPropertyChange");
this.world = world;
this.changer = changer;
this.name = name;
this.value = value;
}
/**
* Gets the changed world property's name.
* @return The changed world property's name.
*/
public String getPropertyName() {
return this.name;
}
/**
* Gets the new value.
* @return The new value.
*/
public String getNewValue() {
return this.value;
}
/**
* Sets the new value.
* @param value The new new value.
*/
public void setNewValue(String value) {
this.value = value;
}
/**
* Get the world targeted because of this change.
*
* @return A valid MultiverseWorld.
*/
public MultiverseWorld getWorld() {
return this.world;
}
/**
* Gets the person (or console) who was responsible for the change.
*
* @return The person (or console) who was responsible for the change.
*/
public CommandSender getCommandSender() {
return this.changer;
}
@Override
public boolean isCancelled() {
return this.isCancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.isCancelled = cancelled;
}
}
Loaded 100 of 151 files, more files were not shown because too many files have changed in this diff. Show more