Skip to content

Commit

Permalink
[1.11.2] Upgraded to current Forge
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryLoenwind committed Jan 23, 2017
1 parent bcdd529 commit abee5a6
Show file tree
Hide file tree
Showing 20 changed files with 189 additions and 126 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ compileJava {

boolean dev = System.getenv("RELEASE") == null || System.getenv("RELEASE").equalsIgnoreCase("false")

def type = 'release'
def type = 'alpha'
if (project.hasProperty('mod_appendix')) {
version += "-${project.mod_appendix}"
type = project.mod_appendix
Expand Down Expand Up @@ -133,13 +133,13 @@ publishing {

task checkTranslations << {
Map<String, String> mapen = new HashMap<String, String>()
(new File('resources/assets/enderio/lang/en_US.lang')).eachLine {
(new File('resources/assets/endercore/lang/en_US.lang')).eachLine {
def (value1, value2) = it.tokenize( '=' )
if (value1 == null || value2 == null) {return}
mapen.put(value1, value2)
}

new File('resources/assets/enderio/lang/').eachFileMatch( ~".*\\.lang\$" ) { langfile ->
new File('resources/assets/endercore/lang/').eachFileMatch( ~".*\\.lang\$" ) { langfile ->
if (!langfile.getName().contains("en_US")) {
Map<String, String> map = new HashMap<String, String>()
File outfile = new File("${langfile}.txt")
Expand Down
3 changes: 1 addition & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
0.3.0:
Initial 1.8.9 Release
see http://ci.tterrag.com/job/EnderCore-1.11/ for details
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
minecraft_version=1.11.2
forge_version=13.20.0.2201
forge_version=13.20.0.2224

mod_version=0.5.0
mod_version=0.5

#Comment out this line to get rid of the appendix
mod_appendix=alpha
#mod_appendix=alpha

projectId=231868
11 changes: 8 additions & 3 deletions src/main/java/com/enderio/core/EnderCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCEvent;
Expand All @@ -51,8 +52,7 @@
public class EnderCore implements IEnderMod {

public static final @Nonnull String MODID = "endercore";
@SuppressWarnings("null")
public static final @Nonnull String DOMAIN = MODID.toLowerCase(Locale.US);
public static final @Nonnull String DOMAIN = NullHelper.notnullJ(MODID.toLowerCase(Locale.US), "String.toLowerCase()");
public static final @Nonnull String NAME = "EnderCore";
public static final @Nonnull String BASE_PACKAGE = "com.enderio";
public static final @Nonnull String VERSION = "@VERSION@";
Expand All @@ -75,7 +75,12 @@ public class EnderCore implements IEnderMod {
* user forcibly disables invisible mode in the config.
*/
public void requestInvisibleMode() {
invisibleRequesters.add(Loader.instance().activeModContainer().getName());
final ModContainer activeModContainer = Loader.instance().activeModContainer();
if (activeModContainer != null) {
invisibleRequesters.add(activeModContainer.getName());
} else {
invisibleRequesters.add("null");
}
}

public boolean invisibilityRequested() {
Expand Down
16 changes: 6 additions & 10 deletions src/main/java/com/enderio/core/client/gui/button/CycleButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.enderio.core.api.client.gui.IGuiScreen;
import com.enderio.core.api.client.render.IWidgetIcon;
import com.enderio.core.client.gui.button.CycleButton.ICycleEnum;
import com.enderio.core.common.util.NNList;

import net.minecraft.client.Minecraft;

Expand All @@ -33,15 +34,14 @@ public interface ICycleEnum {
List<String> getTooltipLines();
}

private final @Nonnull T[] modes;
private final @Nonnull NNList<T> modes;

private @Nonnull T mode;

@SuppressWarnings("null")
public CycleButton(@Nonnull IGuiScreen gui, int id, int x, int y, @Nonnull Class<T> enumClass) {
super(gui, id, x, y, null);
modes = enumClass.getEnumConstants();
setMode(mode = modes[0]);
modes = NNList.of(enumClass);
setMode(mode = modes.get(0));
}

@Override
Expand All @@ -63,15 +63,11 @@ public boolean mousePressedButton(@Nonnull Minecraft mc, int x, int y, int butto
}

private void nextMode() {
setMode(modes[(mode.ordinal() + 1) % modes.length]);
setMode(modes.next(mode));
}

private void prevMode() {
int ord = mode.ordinal() - 1;
if (ord < 0) {
ord = modes.length - 1;
}
setMode(modes[ord]);
setMode(modes.prev(mode));
}

public void setMode(T newMode) {
Expand Down
13 changes: 5 additions & 8 deletions src/main/java/com/enderio/core/common/Lang.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.enderio.core.common.util.NullHelper;
import com.google.common.collect.Lists;

import net.minecraft.util.text.translation.I18n;
Expand All @@ -17,9 +18,8 @@ public class Lang {

private final @Nonnull String prefix;

@SuppressWarnings("null")
public Lang(@Nonnull String locKey) {
this.prefix = locKey.concat(".");
this.prefix = NullHelper.notnullJ(locKey.concat("."), "String.concat()");
}

/**
Expand All @@ -37,9 +37,8 @@ public Lang(@Nonnull String locKey) {
* The suffix string
* @return The full string
*/
@SuppressWarnings("null")
public @Nonnull String addPrefix(@Nonnull String suffix) {
return prefix.concat(suffix);
return NullHelper.notnullJ(prefix.concat(suffix), "String.concat()");
}

/**
Expand Down Expand Up @@ -157,14 +156,12 @@ public Lang(@Nonnull String locKey) {
* The list of strings to split
* @return An array of strings split on {@value #CHAR}
*/
@SuppressWarnings("null")
public @Nonnull String[] splitList(@Nonnull String list) {
return list.split(REGEX);
return NullHelper.notnullJ(list.split(REGEX), "String.split()");
}

@SuppressWarnings("null")
public @Nonnull String[] splitList(@Nonnull String list, @Nonnull String split) {
return list.split(split);
return NullHelper.notnullJ(list.split(split), "String.split()");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.enderio.core.EnderCore;
import com.enderio.core.common.event.ConfigFileChangedEvent;
import com.enderio.core.common.util.NullHelper;

import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
Expand Down Expand Up @@ -62,16 +63,15 @@ public int getRequiredPermissionLevel() {
return 2;
}

@SuppressWarnings("null")
@Override
public @Nonnull List<String> getTabCompletions(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args,
@Nullable BlockPos pos) {
if (args.length >= 1) {
@Nonnull
String[] avail = validModIDs.toArray(new String[validModIDs.size()]);
String[] avail = NullHelper.notnullJ(validModIDs.toArray(new String[validModIDs.size()]), "List.toArray()");

for (int i = 0; i < args.length - 1; i++) {
avail = ArrayUtils.removeElement(avail, args[i]);
avail = NullHelper.notnullJ(ArrayUtils.removeElement(avail, args[i]), "ArrayUtils.removeElement()");
}

return getListOfStringsMatchingLastWord(args, avail);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.enderio.core.common.Lang;
import com.enderio.core.common.event.ConfigFileChangedEvent;
import com.enderio.core.common.util.Bound;
import com.enderio.core.common.util.NullHelper;
import com.google.common.collect.ImmutableList;

import net.minecraftforge.common.MinecraftForge;
Expand Down Expand Up @@ -74,7 +75,7 @@ public Property apply(Property prop) {

@Nonnull
String modid;
Configuration config;
private Configuration config;

@Nonnull
List<Section> sections = new ArrayList<Section>();
Expand All @@ -94,12 +95,17 @@ public final void initialize(@Nonnull File cfg) {
saveConfigFile();
}

@Nonnull
Configuration getConfig() {
return NullHelper.notnull(config, "Configuration getConfig()");
}

protected void loadConfigFile() {
config.load();
getConfig().load();
}

protected void saveConfigFile() {
config.save();
getConfig().save();
}

@SubscribeEvent
Expand Down Expand Up @@ -192,7 +198,7 @@ protected Section addSection(String sectionName, String langKey, String comment)
}

if (comment != null) {
config.addCustomCategoryComment(sectionName, comment);
getConfig().addCustomCategoryComment(sectionName, comment);
}

return section.register();
Expand Down Expand Up @@ -592,29 +598,29 @@ protected <T> Property getProperty(String key, T defaultVal, RestartReqs req) {
// same logic as above method, mostly
if (defaultVal instanceof Integer)
{
prop = config.get(section.name, key, (Integer) defaultVal);
prop = getConfig().get(section.name, key, (Integer) defaultVal);
}
if (defaultVal instanceof Boolean)
{
prop = config.get(section.name, key, (Boolean) defaultVal);
prop = getConfig().get(section.name, key, (Boolean) defaultVal);
}
if (defaultVal instanceof int[])
{
prop = config.get(section.name, key, (int[]) defaultVal);
prop = getConfig().get(section.name, key, (int[]) defaultVal);
}
if (defaultVal instanceof String)
{
prop = config.get(section.name, key, (String) defaultVal);
prop = getConfig().get(section.name, key, (String) defaultVal);
}
if (defaultVal instanceof String[])
{
prop = config.get(section.name, key, (String[]) defaultVal);
prop = getConfig().get(section.name, key, (String[]) defaultVal);
}
// @formatter:on

if (defaultVal instanceof Float || defaultVal instanceof Double) {
double val = defaultVal instanceof Float ? ((Float) defaultVal).doubleValue() : ((Double) defaultVal).doubleValue();
prop = config.get(section.name, key, val);
prop = getConfig().get(section.name, key, val);
}

if (prop != null) {
Expand Down Expand Up @@ -653,7 +659,7 @@ public void postInitHook() {

@Override
public final @Nonnull ConfigCategory getCategory(String name) {
final ConfigCategory category = config.getCategory(name);
final ConfigCategory category = getConfig().getCategory(name);
if (category == null) {
throw new NullPointerException("Forge is rejecting to create a config category '" + name + "'");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.lang.reflect.Field;
import java.util.Locale;

import javax.annotation.Nonnull;

import com.enderio.core.EnderCore;
import com.enderio.core.common.config.ConfigProcessor.IReloadCallback;
import com.enderio.core.common.config.JsonConfigReader.ModToken;
Expand Down Expand Up @@ -131,7 +133,7 @@ public void init() {
processor = new ConfigProcessor(getClass(), this, this) {

@Override
protected Object getConfigValue(String section, String[] commentLines, Field f, Object defVal) {
protected Object getConfigValue(@Nonnull String section, @Nonnull String[] commentLines, @Nonnull Field f, @Nonnull Object defVal) {
Object res = super.getConfigValue(section, commentLines, f, defVal);
if (f.getName() == "invisibleMode") {
if (res.equals(0)) {
Expand Down Expand Up @@ -161,7 +163,7 @@ protected void reloadNonIngameConfigs() {
}

@Override
public void callback(ConfigProcessor inst) {
public void callback(@Nonnull ConfigProcessor inst) {
Tweaks.loadIngameTweaks();
}

Expand All @@ -174,7 +176,7 @@ public boolean addBooleanFor(Tweak tweak) {

public boolean showInvisibleWarning() {
activateSection("invisibility");
ConfigCategory cat = config.getCategory("invisibility");
ConfigCategory cat = getConfig().getCategory("invisibility");
boolean ret = false;
if (!cat.containsKey("invisibilityWarning")) {
ret = true;
Expand Down
Loading

0 comments on commit abee5a6

Please sign in to comment.