Permalink
Browse files

Now based on BasePlugin

  • Loading branch information...
1 parent 938020d commit 83a79dd107a24332379250791727af084f98086d @betterphp committed Jun 16, 2012
View
2 README
@@ -1,5 +1,3 @@
-This plugin will add a replacement for the default skylands world generator, the one in the game was never finished.
-
Stuff that this generator has that the default skylands doesn't:
Day-night cycle
@@ -0,0 +1,26 @@
+package uk.co.jacekk.bukkit.SkylandsPlus;
+
+import uk.co.jacekk.bukkit.baseplugin.config.PluginConfigKey;
+
+public enum Config implements PluginConfigKey {
+
+ PREVENT_SAND_FALLING( "prevent-sand-falling", true),
+ RESTRICT_MOB_SPAWNING( "restrict-mob-spawning", true);
+
+ private String key;
+ private Object defaultValue;
+
+ private Config(String key, Object defaultValue){
+ this.key = key;
+ this.defaultValue = defaultValue;
+ }
+
+ public Object getDefault(){
+ return this.defaultValue;
+ }
+
+ public String getKey(){
+ return this.key;
+ }
+
+}
@@ -3,43 +3,29 @@
import java.io.File;
import org.bukkit.generator.ChunkGenerator;
-import org.bukkit.plugin.PluginManager;
-import org.bukkit.plugin.java.JavaPlugin;
import uk.co.jacekk.bukkit.SkylandsPlus.listeners.MobSpawnListener;
import uk.co.jacekk.bukkit.SkylandsPlus.listeners.PhysicsListener;
import uk.co.jacekk.bukkit.SkylandsPlus.listeners.WorldListener;
+import uk.co.jacekk.bukkit.baseplugin.BasePlugin;
+import uk.co.jacekk.bukkit.baseplugin.config.PluginConfig;
-public class SkylandsPlus extends JavaPlugin {
-
- public SkylandsPlusLogger log;
- public SkylandsPlusConfig config;
+public class SkylandsPlus extends BasePlugin {
public void onEnable(){
- String pluginFolder = this.getDataFolder().getAbsolutePath();
-
- (new File(pluginFolder)).mkdirs();
-
- this.log = new SkylandsPlusLogger(this);
- this.config = new SkylandsPlusConfig(new File(pluginFolder + File.separator + "config.yml"), this);
+ super.onEnable(true);
- PluginManager manager = this.getServer().getPluginManager();
+ this.config = new PluginConfig(new File(this.baseDirPath + File.separator + "config.yml"), Config.values(), this.log);
- if (this.config.getBoolean("prevent-sand-falling")){
- manager.registerEvents(new PhysicsListener(), this);
+ if (this.config.getBoolean(Config.PREVENT_SAND_FALLING)){
+ this.pluginManager.registerEvents(new PhysicsListener(this), this);
}
- if (this.config.getBoolean("restrict-mob-spawning")){
- manager.registerEvents(new MobSpawnListener(), this);
+ if (this.config.getBoolean(Config.RESTRICT_MOB_SPAWNING)){
+ this.pluginManager.registerEvents(new MobSpawnListener(this), this);
}
- manager.registerEvents(new WorldListener(this), this);
-
- this.log.info("Enabled.");
- }
-
- public void onDisable(){
- this.log.info("Disabled.");
+ this.pluginManager.registerEvents(new WorldListener(this), this);
}
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id){
@@ -1,31 +0,0 @@
-package uk.co.jacekk.bukkit.SkylandsPlus;
-
-import java.util.logging.Logger;
-
-import org.bukkit.plugin.PluginDescriptionFile;
-
-public class SkylandsPlusLogger {
-
- private SkylandsPlus plugin;
- private Logger logger;
-
- public SkylandsPlusLogger(SkylandsPlus plugin){
- this.plugin = plugin;
- this.logger = Logger.getLogger("Minecraft");
- }
-
- private String buildString(String msg){
- PluginDescriptionFile pdFile = plugin.getDescription();
-
- return pdFile.getName() + " " + pdFile.getVersion() + ": " + msg;
- }
-
- public void info(String msg){
- this.logger.info(this.buildString(msg));
- }
-
- public void warn(String msg){
- this.logger.warning(this.buildString(msg));
- }
-
-}
@@ -3,13 +3,18 @@
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
-import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+import uk.co.jacekk.bukkit.SkylandsPlus.SkylandsPlus;
import uk.co.jacekk.bukkit.SkylandsPlus.generation.ChunkGenerator;
+import uk.co.jacekk.bukkit.baseplugin.BaseListener;
-public class MobSpawnListener implements Listener {
+public class MobSpawnListener extends BaseListener<SkylandsPlus> {
+
+ public MobSpawnListener(SkylandsPlus plugin){
+ super(plugin);
+ }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event){
@@ -3,12 +3,17 @@
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
-import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent;
+import uk.co.jacekk.bukkit.SkylandsPlus.SkylandsPlus;
import uk.co.jacekk.bukkit.SkylandsPlus.generation.ChunkGenerator;
+import uk.co.jacekk.bukkit.baseplugin.BaseListener;
-public class PhysicsListener implements Listener {
+public class PhysicsListener extends BaseListener<SkylandsPlus> {
+
+ public PhysicsListener(SkylandsPlus plugin){
+ super(plugin);
+ }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockPhysics(BlockPhysicsEvent event){
@@ -10,18 +10,16 @@
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
-import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldInitEvent;
import uk.co.jacekk.bukkit.SkylandsPlus.SkylandsPlus;
import uk.co.jacekk.bukkit.SkylandsPlus.generation.ChunkGenerator;
+import uk.co.jacekk.bukkit.baseplugin.BaseListener;
-public class WorldListener implements Listener {
-
- private SkylandsPlus plugin;
+public class WorldListener extends BaseListener<SkylandsPlus> {
public WorldListener(SkylandsPlus plugin){
- this.plugin = plugin;
+ super(plugin);
}
@EventHandler(priority = EventPriority.NORMAL)

0 comments on commit 83a79dd

Please sign in to comment.