Malikk / Shield

Shield - A collection of common Bukkit protection plugin API
http://dev.bukkit.org/server-mods/shieldapi/
3 stars 3 forks source link

Plugin refactor #7

Open IDragonfire opened 11 years ago

IDragonfire commented 11 years ago

https://github.com/Malikk/Shield/pull/4

My current version: https://github.com/IDragonfire/Shield

  1. Why do you need a member for each class? https://github.com/Malikk/Shield/blob/893af1c52fe3699ad385800e2938c56bcfb80628/Shield/src/com/malikk/shield/Shield.java#L51
  2. These is duplicated code and can be done automaticly: https://github.com/Malikk/Shield/blob/893af1c52fe3699ad385800e2938c56bcfb80628/Shield/src/com/malikk/shield/Shield.java#L127
  3. Do it dynamicly, because it is easy to forget it: https://github.com/Malikk/Shield/blob/893af1c52fe3699ad385800e2938c56bcfb80628/Shield/src/com/malikk/shield/metrics/MetricsHandler.java#L31
  4. Duplicated enable message, bukkit print it already; https://github.com/Malikk/Shield/blob/893af1c52fe3699ad385800e2938c56bcfb80628/Shield/src/com/malikk/shield/Shield.java#L84
IDragonfire commented 11 years ago

My idea: Load every supported Protect class, hold a Protect ArrayList ... Possible over reflection ... http://java.raistudies.com/creating-object-using-reflection-in-java/ 2 and 3 can be done as a loop over the ArrayList ...

  1. For refactoring InstanceOf is better then equals ;)
Malikk commented 11 years ago

1) Those objects are so I don't have to use reflection during runtime. I add the ones I need to an array and then I can loop through them and check things for every plugin.

Also, the ShieldRegion objects need those protect objects to interface with their respective plugins (again, so that we don't need reflection)

2) I've been meaning to rewrite that whole section using enums with each plugins name and package information.

3) I'll use the array of protect objects once I've got the plugin information enums setup, but for now each plotter has to be explicity named.

4) This message is not a duplicate. Bukkit automatically outputs when my plugins onEnable is called; this message is sent once Shield has FINISHED enabling.