Skip to content

Commit

Permalink
Merge pull request #2 from Maxwell-lt/v1.1.0
Browse files Browse the repository at this point in the history
V1.1.0
  • Loading branch information
Maxwell-lt authored Jan 30, 2017
2 parents 998bdca + c6721ab commit 5c4356b
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 37 deletions.
46 changes: 32 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,53 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.

ext.modid = "titlechanger"
ext.modname = "Title Changer"
ext.moddescription = "Changes the Minecraft window title."
ext.modauthors = "maxwell-lt"
ext.modversion = "1.1.0"
ext.modpackage = "maxwell_lt.titlechanger"
ext.modarchive = "titlechanger"

version = "1.0"
group = "maxwell_lt.titlechanger" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "titlechanger"
ext.url = "https://www.github.com/Maxwell-lt/TitleChanger"
ext.updatejson = "https://raw.githubusercontent.com/Maxwell-lt/TitleChanger/master/update.json"

sourceCompatibility = targetCompatibility = "1.6" // Need this here so eclipse task generates correctly.
ext.mcversion = "1.11.2"
ext.forgeversion = "13.20.0.2206"
ext.mcpmappings = "snapshot_20161220"


version = modversion
group = modpackage // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = modarchive

sourceCompatibility = targetCompatibility = "1.8" // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = "1.6"
sourceCompatibility = targetCompatibility = "1.8"
}

minecraft {
version = "1.11.2-13.20.0.2206"
version = mcversion + '-' + forgeversion
runDir = "run"

// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "snapshot_20161220"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
mappings = mcpmappings
makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
}


dependencies {


// you may put jars on which you depend on in ./libs
// or you may define them like so..
//compile "some.group:artifact:version:classifier"
//compile "some.group:artifact:version"

// real examples
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
Expand All @@ -65,13 +83,13 @@ processResources {
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'

// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
expand 'modid':modid, 'name':modname, 'description':moddescription, 'authors':modauthors, 'version':modversion, 'url':url, 'updatejson':updatejson
}

// copy everything else except the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
}
Binary file added releases/titlechanger-1.1.0.jar
Binary file not shown.
9 changes: 5 additions & 4 deletions src/main/java/maxwell_lt/titlechanger/ClientProxy.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package maxwell_lt.titlechanger;

import org.lwjgl.opengl.Display;

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

public class ClientProxy extends CommonProxy {

@Override
public void preInit(FMLPreInitializationEvent e) {
super.preInit(e);

if (Config.windowTitle != "") Display.setTitle(Config.windowTitle);

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

ReplaceTitle.Replace();
}

}
4 changes: 3 additions & 1 deletion src/main/java/maxwell_lt/titlechanger/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class Config {
private static final String CATEGORY_GENERAL = "general";

public static String windowTitle = "";
public static String timeFormat = "h:mm a";

public static void readConfig() {
Configuration cfg = CommonProxy.config;
Expand All @@ -25,7 +26,8 @@ public static void readConfig() {

private static void initGeneralConfig(Configuration cfg) {
cfg.addCustomCategoryComment(CATEGORY_GENERAL, "General configuration");
windowTitle = cfg.getString("windowtitle", CATEGORY_GENERAL, "", "The title of the Minecraft window. Leave blank to keep the default window title for your version of Minecraft.");
windowTitle = cfg.getString("windowtitle", CATEGORY_GENERAL, "", "The title of the Minecraft window. Leave blank to keep the default window title for your version of Minecraft.\nSome special values that will be inserted at runtime:\n%mcver% -> The current Minecraft version\n%modcount% -> Number of loaded mods\n%time% -> Current system time\n");
timeFormat = cfg.getString("timeformat", CATEGORY_GENERAL, "h:mm a", "Format to display time in. See http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns");
}

}
36 changes: 36 additions & 0 deletions src/main/java/maxwell_lt/titlechanger/ReplaceTitle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package maxwell_lt.titlechanger;

import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.opengl.Display;
import java.text.SimpleDateFormat;
import java.util.Date;


public class ReplaceTitle {

@SubscribeEvent(priority = EventPriority.LOWEST)
public void clientTick(TickEvent.ClientTickEvent e) {
Replace();
}

public static void Replace() {
if (Config.windowTitle != "") {
Display.setTitle(processText(Config.windowTitle));
}
}

public static String processText(String formatString) {
String mcVersion = Loader.instance().getMinecraftModContainer().getVersion();
String modCount = Integer.toString(Loader.instance().getModList().size());
String time = new SimpleDateFormat(Config.timeFormat).format(new Date()).toString();

formatString = formatString.replaceAll("%mcver%", mcVersion);
formatString = formatString.replaceAll("%modcount%", modCount);
formatString = formatString.replaceAll("%time%", time);

return formatString;
}
}
2 changes: 1 addition & 1 deletion src/main/java/maxwell_lt/titlechanger/TitleChanger.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

@Mod(modid = TitleChanger.MODID, version = TitleChanger.VERSION, name = TitleChanger.MODNAME, useMetadata = true, acceptedMinecraftVersions = "[1.10,1.11.2]")
@Mod(modid = TitleChanger.MODID, version = TitleChanger.VERSION, name = TitleChanger.MODNAME, useMetadata = true, acceptedMinecraftVersions = "[1.10,1.11.2]", updateJSON = "https://raw.githubusercontent.com/Maxwell-lt/TitleChanger/master/update.json")
public class TitleChanger
{
public static final String MODID = "titlechanger";
Expand Down
30 changes: 15 additions & 15 deletions src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[
{
"modid": "titlechanger",
"name": "Title Changer",
"description": "Changes the Minecraft window title.",
"version": "1.0",
"mcversion": "1.11.2",
"url": "https://github.com/Maxwell-lt/TitleChanger",
"updateJson": "https://raw.githubusercontent.com/Maxwell-lt/TitleChanger/master/update.json",
"authorList": ["maxwell-lt"],
"credits": "",
"logoFile": "",
"screenshots": [],
"dependencies": []
}
]
{
"modid": "${modid}",
"name": "${name}",
"description": "${description}",
"version": "${version}",
"mcversion": "1.11.2",
"url": "${url}",
"updateUrl": "${updatejson}",
"authorList": ["${authors}"],
"credits": "",
"logoFile": "",
"screenshots": [],
"dependencies": []
}
]
6 changes: 4 additions & 2 deletions update.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"homepage": "https://github.com/Maxwell-lt/TitleChanger/",
"1.10.2": {
"1.1.0": "Added runtime replacements",
"1.0": "First version"
},
"1.11.2": {
"1.1.0": "Added runtime replacements",
"1.0": "First version"
},
"promos": {
"1.10.2-latest": "1.0",
"1.11.2-latest": "1.0"
"1.10.2-latest": "1.1.0",
"1.11.2-latest": "1.1.0"
}
}

0 comments on commit 5c4356b

Please sign in to comment.