How to implement your own achievement? by Roland Hackl 1.Introduction To make new achievements you have to make a netbeans module which has a dependency to the AchievementsInterface module. To implement a new achievement you need to implement 2 interfaces. At first the IAchievement interface which is responsible for the visual representation of the achievement and secondly you have to make a class which implements one of the listener interfaces and is responsible for collecting statistics. You can implement every interface in a separate class or make just one class for all interfaces. 2.Implementing the IAchievement interface. (at.ssw.achievements.interfaces) String getName(); This function has to return the unique name of the achievement which is also the name of the icon. String getTitle(); This method has to return a catchy title for the achievement. String getDescription(); This method has to return a catchy description for the achievement. int getValue(); This method has to return a value, which is used to compare it to the bounds returned by getBounds(). int[] getBounds(); This method has to return the valuebounds for all the achievement levels. E.g. 1,10,100,500,6000 int getLevel(); Has to return in which level the achievement is. So e.g. if the second bound is 10 and the value is 12 it has to return 2. boolean isMultiAchievement(); Multiachievement are achievements which for example save statistics per file or class. List getSubAchievements(); If the achievement is a MultiAchievement it should return subachievements. SubAchievement If you want to create a hierarchical achievement you have to subclass SubAchievement. 3.Implementing a listener interface. (at.ssw.achievements.listeners) IEditorListener If you implement the IEditorListener interface you can listen to changes in currently edited files. ILogListener The ILogListener lets you react to some log-messages which are thrown mostly when button presses occur and similar things. 4.Using the StatsCollector (at.ssw.achievements) The StatsCollector is used to manage your statistics. They are automatically stored and restored into/from a file. Its a singleton and you can retrieve it through StatsCollector.createStatsCollector(). With setStat, increaseStat, containsStat and getStat you can either manage global statistics or hierarchical statistics with the globalKey parameter. Its implemented via HashMaps. 5.Where to put the icon? You need an icon for your achievement. It has to be an PNG and you have to put it in a subpackage of the package of the achievement called icon. So if you put your achievement in a package called "asdf.qwer" you have to put the icon into a package called "asdf.qwer.icon". The icons filename has to follow the pattern IAchievement.getName()+".png". 6.Add your classes to the global lookup. Create a folder in your project called META-INF/services. There you create a simple text file called "at.ssw.achievements.interfaces.IAchievement". There you just write a line for each achievement which references to your implementing class in the style of packagename.classname which for example looks like this: "at.ssw.achievements.achievements.Run". The same way you add the listeners to the lookup. You just have to create one or more of the following files depending on which interface you have implemented: at.ssw.achievements.listeners.IEditorListener at.ssw.achievements.listeners.ILogListener at.ssw.achievements.listeners.IStartListener and then add a line with a reference to your listenerclass (packagename.classname). 7.Naming conflicts and so on ... You have to give attention to not use any key already used by another achievement in the StatsCollector. So just use a unique prefix, inspect the source code or write an email to us to prevent using already used keys. 8.If you have any questions... write an email either in English or German to netbeans.achievements@gmx.net