Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
Source Code for the Custom Main Menu Minecraft Mod
================
# Patched Main Menu
### Fork of [Custom Main Menu](https://github.com/lumien231/Custom-Main-Menu)
This is a simple set of critical patches collected during the use of this mod:
* Uploading all file types in UTF-8 format.
(Previously, the standard system encoding was used)
* There will no longer be an LF ending at the end of lines that are loaded from the WEB
105 changes: 45 additions & 60 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,81 +1,66 @@
buildscript {
repositories {
jcenter()
maven { url = "https://files.minecraftforge.net/maven" }
maven { url = 'https://maven.minecraftforge.net/' }
mavenCentral()
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:3.+'
}
}
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.

apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'maven-publish'

version = "2.0.9"
group = "lumien.custommainmenu" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
version = '1.0'
group = 'lumien.custommainmenu'
archivesBaseName = 'custommainmenu'

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

minecraft {
version = "1.12.2-14.23.5.2847"
runDir = "run"

replaceIn "CustomMainMenu.java"
replace "@VERSION@",project.version

// 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_20171003"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
mappings channel: 'snapshot', version: '20171003-1.12'
runs {
client {
workingDirectory project.file('run')
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
}
server {
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
}
}
}

archivesBaseName = "CustomMainMenu-MC" + minecraft.version

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

// the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
//provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

// the deobf configurations: 'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
// except that these dependencies get remapped to your current MCP mappings
//deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
//deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

// for more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2860'
compile fileTree(dir: 'libs', include: '*.jar')
}

jar {
manifest {
attributes(["Specification-Title" : "custommainmenu",
"Specification-Vendor" : "examplemodsareus",
"Specification-Version" : "1",
"Implementation-Title" : project.name,
"Implementation-Version" : version,
"Implementation-Vendor" : "examplemodsareus",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")])
}
}

processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
jar.finalizedBy('reobfJar')

// 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
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
}
}
// copy everything else except the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
repositories {
maven {
url "file:///${project.projectDir}/mcmodsrepo"
}
}

}
3 changes: 0 additions & 3 deletions gradle.properties

This file was deleted.

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
Binary file added libs/japng-0.5.1.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/java/lumien/custommainmenu/CustomMainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class CustomMainMenu
{
public static final String MOD_ID = "custommainmenu";
public static final String MOD_NAME = "Custom Main Menu";
public static final String MOD_VERSION = "@VERSION@";
public static final String MOD_VERSION = "1.0";

@Instance(value = MOD_ID)
public static CustomMainMenu INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,172 +1,69 @@
package lumien.custommainmenu.configuration;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import lumien.custommainmenu.CustomMainMenu;
import lumien.custommainmenu.gui.GuiCustom;

import org.apache.commons.io.IOUtils;

import com.google.common.io.ByteStreams;
import com.google.common.io.Files;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.stream.JsonReader;
import lumien.custommainmenu.CustomMainMenu;
import lumien.custommainmenu.gui.GuiCustom;
import org.apache.commons.io.IOUtils;

public class ConfigurationLoader
{
Config config;

public ConfigurationLoader(Config config)
{
this.config = config;
}

public void load() throws Exception
{
JsonParser jsonParser = new JsonParser();

File configFolder = new File(CustomMainMenu.INSTANCE.configFolder, "CustomMainMenu");
if (!configFolder.exists())
{
configFolder.mkdir();
}

File mainmenuConfig = new File(configFolder, "mainmenu.json");
if (!mainmenuConfig.exists())
{
InputStream input = null;

OutputStream output = null;
try
{
output = new FileOutputStream(mainmenuConfig);
input = getClass().getResourceAsStream("/assets/custommainmenu/mainmenu_default.json");
ByteStreams.copy(input, output);
}
catch (FileNotFoundException e1)
{
e1.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
IOUtils.closeQuietly(output);
IOUtils.closeQuietly(input);
}
}

File[] jsonFiles = configFolder.listFiles();


// Preload Main Menu so that other menus can rely on it

for (File guiFile : jsonFiles)
{
if (guiFile.getName().equals("mainmenu.json"))
{
GuiConfig guiConfig = new GuiConfig();
String name = guiFile.getName().replace(".json", "");

JsonReader reader = null;
try
{
reader = new JsonReader(new FileReader(guiFile));
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
try
{
JsonElement jsonElement = jsonParser.parse(reader);
JsonObject jsonObject = jsonElement.getAsJsonObject();

guiConfig.load(name, jsonObject);
}
catch (Exception e)
{
try
{
reader.close();
}
catch (IOException io)
{
io.printStackTrace();
}
throw e;
}

try
{
reader.close();
}
catch (IOException io)
{
io.printStackTrace();
}

this.config.addGui(guiConfig.name, new GuiCustom(guiConfig));
}
}

for (File guiFile : jsonFiles)
{
if (!guiFile.getName().equals("mainmenu.json") && guiFile.getName().endsWith(".json"))
{
GuiConfig guiConfig = new GuiConfig();
String name = guiFile.getName().replace(".json", "");

JsonReader reader = null;
try
{
reader = new JsonReader(new FileReader(guiFile));
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
try
{
JsonElement jsonElement = jsonParser.parse(reader);
JsonObject jsonObject = jsonElement.getAsJsonObject();

guiConfig.load(name, jsonObject);
}
catch (Exception e)
{
try
{
reader.close();
}
catch (IOException io)
{
io.printStackTrace();
}
throw e;
}

try
{
reader.close();
}
catch (IOException io)
{
io.printStackTrace();
}

this.config.addGui(guiConfig.name, new GuiCustom(guiConfig));
}
}
}
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

public class ConfigurationLoader {
Config config;

public ConfigurationLoader(Config config) {
this.config = config;
}

public void load() {
JsonParser jsonParser = new JsonParser();

File configFolder = new File(CustomMainMenu.INSTANCE.configFolder, "CustomMainMenu");
if (!configFolder.exists())
if (!configFolder.mkdirs())
throw new RuntimeException(new IOException("Can't create folder"));

File mainConfig = new File(configFolder, "mainmenu.json");
if (!mainConfig.exists()) {
try (
InputStream input = getClass().getResourceAsStream("/assets/custommainmenu/mainmenu_default.json");
OutputStream output = Files.newOutputStream(mainConfig.toPath())
) {
if (input == null)
throw new RuntimeException(new IOException("Default config not exist (/assets/custommainmenu/mainmenu_default.json)"));
IOUtils.copy(input, output);
} catch (IOException e) {
throw new RuntimeException(e);
}
}

File[] jsonFiles = configFolder.listFiles();

if (jsonFiles == null)
return;
for (File guiFile : jsonFiles) {
if (!guiFile.getName().endsWith(".json"))
continue;
GuiConfig guiConfig = new GuiConfig();
String name = guiFile.getName().replace(".json", "");

try (
InputStream is = Files.newInputStream(guiFile.toPath());
InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);
JsonReader reader = new JsonReader(isr)
) {
JsonElement jsonElement = jsonParser.parse(reader);
JsonObject jsonObject = jsonElement.getAsJsonObject();
guiConfig.load(name, jsonObject);
} catch (Exception e) {
e.printStackTrace();
}

this.config.addGui(guiConfig.name, new GuiCustom(guiConfig));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ public IText getWantedText(JsonElement element)
String textString = getStringPlease(element);
if (textString.startsWith("web:"))
{
String url = textString.substring(4, textString.length());
String url = textString.substring(4);

TextURL tURL = new TextURL(url, -1);

Expand Down
Loading