Skip to content

Commit

Permalink
Moved config loading code to DragonMounts
Browse files Browse the repository at this point in the history
  • Loading branch information
ata4 committed Aug 13, 2014
1 parent 434d36e commit 7bfb5bd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
12 changes: 7 additions & 5 deletions src/main/java/info/ata4/minecraft/dragon/DragonMounts.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import info.ata4.minecraft.dragon.server.ServerProxy;
import net.minecraftforge.common.config.Configuration;

/**
* Main control class for Forge.
Expand All @@ -45,20 +46,21 @@ public class DragonMounts {
@Instance(ID)
public static DragonMounts instance;

public static DragonMountsConfig getConfig() {
return proxy.getConfig();
}

private ModMetadata metadata;
private DragonMountsConfig config;

public DragonMountsConfig getConfig() {
return config;
}

public ModMetadata getMetadata() {
return metadata;
}

@EventHandler
public void onPreInit(FMLPreInitializationEvent evt) {
config = new DragonMountsConfig(new Configuration(evt.getSuggestedConfigurationFile()));
metadata = evt.getModMetadata();
proxy.onPreInit(evt);
}

@EventHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void onInit(FMLInitializationEvent evt) {

MinecraftForge.EVENT_BUS.register(new DragonSplash());

if (DragonMounts.getConfig().isDebug()) {
if (DragonMounts.instance.getConfig().isDebug()) {
MinecraftForge.EVENT_BUS.register(new GuiDragonDebug());
}
}
Expand Down
15 changes: 2 additions & 13 deletions src/main/java/info/ata4/minecraft/dragon/server/ServerProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
package info.ata4.minecraft.dragon.server;

import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.registry.EntityRegistry;
import info.ata4.minecraft.dragon.DragonMounts;
import info.ata4.minecraft.dragon.DragonMountsConfig;
import info.ata4.minecraft.dragon.server.cmd.CommandDragon;
import info.ata4.minecraft.dragon.server.entity.EntityTameableDragon;
import info.ata4.minecraft.dragon.server.handler.DragonEggBlockHandler;
Expand All @@ -27,7 +25,6 @@
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;

/**
*
Expand All @@ -36,24 +33,16 @@
public class ServerProxy {

private DragonControlChannelHandler controlChannel;
private DragonMountsConfig config;

public DragonMountsConfig getConfig() {
return config;
}

public DragonControlChannelHandler getControlChannel() {
return controlChannel;
}

public void onPreInit(FMLPreInitializationEvent evt) {
config = new DragonMountsConfig(new Configuration(evt.getSuggestedConfigurationFile()));
}

public void onInit(FMLInitializationEvent evt) {
registerEntities();

if (DragonMounts.getConfig().isEggsInChests()) {
if (DragonMounts.instance.getConfig().isEggsInChests()) {
registerChestItems();
}

Expand All @@ -72,7 +61,7 @@ public void onServerStopped(FMLServerStoppedEvent evt) {
}

private void registerEntities() {
int dragonEntityID = getConfig().getDragonEntityID();
int dragonEntityID = DragonMounts.instance.getConfig().getDragonEntityID();
if (dragonEntityID == -1) {
dragonEntityID = EntityRegistry.findGlobalUniqueEntityId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ protected void entityInit() {
addHelper(new DragonReproductionHelper(this, INDEX_BREEDER, INDEX_REPRO_COUNT));
addHelper(new DragonParticleHelper(this));

if (DragonMounts.getConfig().isDebug()) {
if (DragonMounts.instance.getConfig().isDebug()) {
addHelper(new DragonDebug(this));
}

Expand Down

0 comments on commit 7bfb5bd

Please sign in to comment.