Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
reverted back to old way of getting the URL from the web. It makes mo…
Browse files Browse the repository at this point in the history
…re sense so users can create a web app to automatically change the file remotely without changing the jar file.
  • Loading branch information
Jake Rhoda committed Jun 5, 2014
1 parent 481e624 commit 92a0969
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
target/
build/
bin/
run/

# Other files and folders
.settings/
.gradle/
eclipse/
.idea/
*.iml

.project
.classpath
MANIFEST.MF
RankCapes.jardesc
build.properties
Thumbs.db
.DS_Store
.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,62 @@
*/
package com.jadarstudios.developercapes.standalone;

import com.google.common.base.Strings;
import com.google.common.base.Throwables;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import com.jadarstudios.developercapes.DevCapes;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.relauncher.Side;
import org.apache.logging.log4j.Logger;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;

@Mod(name="DeveloperCapes", modid="devcapesstandalone", version="${version}")
@Mod(name="DeveloperCapes", modid="DevCapesStandalone", version="${version}")
public class DevCapesStandalone {

@Instance
public static DevCapesStandalone instance;
public static Logger logger;

public String capeConfigUrl;
public String modId;

@EventHandler
public void preLoad(FMLPreInitializationEvent event) {
this.logger = event.getModLog();
this.modId = event.getModMetadata().modId;

InputStream is = getClass().getResourceAsStream("/capeInfo.json");
InputStreamReader reader = new InputStreamReader(is);
try {
Gson gson = new Gson();

HashMap map = gson.fromJson(reader, HashMap.class);

Object urlStringObject = map.get("capeConfigUrl");
if (urlStringObject != null && (urlStringObject instanceof String)) {
capeConfigUrl = Strings.nullToEmpty((String)urlStringObject);
} else {
throw new JsonParseException("Could not find key 'capeConfigUrl'");
}
} catch (JsonParseException e) {
logger.error("Failed to parse capeInfo.json. This means you could have a corrupt mod jar.");
e.printStackTrace();
} catch (Exception e) {
throw Throwables.propagate(e);
}

}



/**
* Sets up DeveloperCapes.
Expand All @@ -30,10 +71,9 @@ public class DevCapesStandalone {
public void load(FMLInitializationEvent event) {
if(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
{
DevCapes.logger.info("Initializing DevCapes Standalone.");
InputStream stream = this.getClass().getResourceAsStream("/capeInfo.json");
if (stream == null) return;
DevCapes.getInstance().registerConfig(stream, "devcapesstandalone");
logger.info("Initializing DevCapes Standalone.");
if (this.capeConfigUrl == null) return;
DevCapes.getInstance().registerConfig(this.capeConfigUrl, this.modId);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/capeInfo.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"capeTxtUrl": " *Cape info text URL here* "
"capeConfigUrl": "Your config url goes here."
}
2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"modid" : "devcapesstandalone",
"modid" : "DevCapesStandalone",
"name" : "DeveloperCapes",
"version" : "2.1",
"url" : "http://www.github.com/Jadar/DeveloperCapes",
Expand Down

0 comments on commit 92a0969

Please sign in to comment.