Skip to content

Instantly share code, notes, and snippets.

@shoghicp
Created December 25, 2014 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shoghicp/88acec9d15564ccc8e75 to your computer and use it in GitHub Desktop.
Save shoghicp/88acec9d15564ccc8e75 to your computer and use it in GitHub Desktop.
  • Why load: STARTUP?
  • You don't need to reload the configuration, and saving it on close is OK (instead of saving each time something is set).
  • Loader->getPlayer() is exactly the same as Server->getPlayerExact(), except that it does not check by displayName (that is not needed).
  • Loader->isReparable() is really SLOW and can be implemented in O(1) instead of O(44). It could even just check Armor and Tool instance (making it future-compatible, no update needed).
  • Lots of arrays D: (MOAR objects and properties!)
  • I just saw a 4-dimensional array. This can cause Exceptions and things could go wrong
  • Nice events, plugins for a plugin! Be sure to document them somewhere
  • You can use Player->getId() for key setting instead of Player->getName() (no hashing needed, faster array access)
  • Loader->getHome() might create invalid position objects (beware of unknown/unloaded Levels on Server->getLevelByName()!)
  • PhpStorm typehints FTW :D
  • On Event Handler you can just pass the values instead of storing them on a temporal variable, faster (and this matters on event handling)
  • Use Server::getGamemodeFromString(), then do direct constant checks. This decreases the amount of duplicated code.
  • Players could be kicked before the min AFK time happens, you should check the time they have been AFKing and check often :)
  • I've edited the plugin release page to remove some offending lines (Download latest release. The rules only allow this for development builds)
@iksaku
Copy link

iksaku commented Dec 25, 2014

  • I will remove the "load: STARTUP"
  • Arrays will be replaced with Objects
  • Saving every time anything is modified is just for preventing data loss on crash
  • Loader->getPlayer() is intended to be used because of custom nicks (unless you add it to PocketMine-MP)
  • Loader->isReparable() will be removed later
  • We're already working over the API documentation
  • Level->getHome() will be fixed!
  • I will remove the unnecessary code of EventHandler
  • Player kick time for AFK function will not change due to it is intended to be customized by the user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment