Clean up null issues, add more annotations (#3590)

This commit is contained in:
James Mitchell authored and LexManos committed 2017-01-11 15:17:56 -08:00
1 parent 43efa3cfc4
commit c545b8ecd4
130 files changed
+629 -262

No files matched your search

@@ -135,6 +135,8 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import javax.annotation.Nullable;
/**
* Handles primary communication from hooked code into the system
@@ -512,7 +514,7 @@ public class FMLClientHandler implements IFMLSidedHandler
}
@Override
public void showGuiScreen(Object clientGuiElement)
public void showGuiScreen(@Nullable Object clientGuiElement)
{
GuiScreen gui = (GuiScreen) clientGuiElement;
client.displayGuiScreen(gui);
@@ -813,6 +815,7 @@ public class FMLClientHandler implements IFMLSidedHandler
private static final ResourceLocation iconSheet = new ResourceLocation("fml:textures/gui/icons.png");
private static final CountDownLatch startupConnectionData = new CountDownLatch(1);
@Nullable
public String enhanceServerListEntry(ServerListEntryNormal serverListEntry, ServerData serverEntry, int x, int width, int y, int relativeMouseX, int relativeMouseY)
{
String tooltip;
@@ -29,6 +29,7 @@ import java.util.Comparator;
import java.util.List;
import java.util.Map.Entry;
import javax.annotation.Nullable;
import javax.imageio.ImageIO;
import net.minecraft.client.Minecraft;
@@ -84,6 +85,7 @@ public class GuiModList extends GuiScreen
this.buttonID = buttonID;
}
@Nullable
public static SortType getTypeForButton(GuiButton button)
{
for (SortType t : values())
@@ -468,11 +470,12 @@ public class GuiModList extends GuiScreen
private class Info extends GuiScrollingList
{
@Nullable
private ResourceLocation logoPath;
private Dimension logoDims;
private List<ITextComponent> lines = null;
public Info(int width, List<String> lines, ResourceLocation logoPath, Dimension logoDims)
public Info(int width, List<String> lines, @Nullable ResourceLocation logoPath, Dimension logoDims)
{
super(GuiModList.this.getMinecraftInstance(),
width,
@@ -25,6 +25,8 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import javax.annotation.Nullable;
public interface IModGuiFactory {
/**
* Called when instantiated to initialize with the active minecraft instance.
@@ -85,6 +87,7 @@ public interface IModGuiFactory {
* @param element The element we wish to paint for
* @return The Handler for painting it
*/
@Nullable
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element);
/**
@@ -38,6 +38,8 @@ import java.util.concurrent.Semaphore;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
@@ -731,12 +733,12 @@ public class SplashProgress
private final int frames;
private final int size;
public Texture(ResourceLocation location, ResourceLocation fallback)
public Texture(ResourceLocation location, @Nullable ResourceLocation fallback)
{
this(location, fallback, true);
}
public Texture(ResourceLocation location, ResourceLocation fallback, boolean allowRP)
public Texture(ResourceLocation location, @Nullable ResourceLocation fallback, boolean allowRP)
{
InputStream s = null;
try
@@ -881,14 +883,15 @@ public class SplashProgress
}
@Override
protected void bindTexture(ResourceLocation location)
protected void bindTexture(@Nonnull ResourceLocation location)
{
if(location != locationFontTexture) throw new IllegalArgumentException();
fontTexture.bind();
}
@Nonnull
@Override
protected IResource getResource(ResourceLocation location) throws IOException
protected IResource getResource(@Nonnull ResourceLocation location) throws IOException
{
DefaultResourcePack pack = Minecraft.getMinecraft().mcDefaultResourcePack;
return new SimpleResource(pack.getPackName(), location, pack.getInputStream(location), null, null);
@@ -920,7 +923,7 @@ public class SplashProgress
}
}
private static InputStream open(ResourceLocation loc, ResourceLocation fallback, boolean allowRP) throws IOException
private static InputStream open(ResourceLocation loc, @Nullable ResourceLocation fallback, boolean allowRP) throws IOException
{
if (!allowRP)
return mcPack.getInputStream(loc);
@@ -28,6 +28,8 @@ import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.client.config.GuiConfigEntries.IConfigEntry;
import net.minecraftforge.fml.client.config.GuiEditArrayEntries.IArrayEntry;
import javax.annotation.Nullable;
/**
* This class's main purpose is to provide the necessary objects for a sample Config GUI for FML, although
@@ -56,6 +58,7 @@ public class DummyConfigElement implements IConfigElement
protected boolean isListFixedLength = false;
protected int maxListLength = -1;
protected List<IConfigElement> childElements;
@Nullable
protected Class<? extends IConfigEntry> configEntryClass;
protected Class<? extends IArrayEntry> arrayEntryClass;
@@ -75,7 +78,7 @@ public class DummyConfigElement implements IConfigElement
this(name, langKey, new ArrayList<IConfigElement>(), customListEntryClass);
}
public DummyCategoryElement(String name, String langKey, List<IConfigElement> childElements, Class<? extends IConfigEntry> customListEntryClass)
public DummyCategoryElement(String name, String langKey, List<IConfigElement> childElements, @Nullable Class<? extends IConfigEntry> customListEntryClass)
{
super(name, null, ConfigGuiType.CONFIG_CATEGORY, langKey);
this.childElements = childElements;
@@ -89,7 +92,7 @@ public class DummyConfigElement implements IConfigElement
*/
public static class DummyListElement extends DummyConfigElement
{
public DummyListElement(String name, Object[] defaultValues, ConfigGuiType type, String langKey, boolean isListFixedLength, int maxListLength, Pattern validStringPattern, Object minValue, Object maxValue)
public DummyListElement(String name, Object[] defaultValues, ConfigGuiType type, String langKey, boolean isListFixedLength, int maxListLength, @Nullable Pattern validStringPattern, @Nullable Object minValue, @Nullable Object maxValue)
{
super(name, null, type, langKey, minValue, maxValue);
this.defaultValues = defaultValues;
@@ -42,6 +42,8 @@ import net.minecraftforge.fml.common.eventhandler.Event.Result;
import org.lwjgl.input.Keyboard;
import javax.annotation.Nullable;
/**
* This class is the base GuiScreen for all config GUI screens. It can be extended by mods to provide the top-level config screen
* that will be called when the Config button is clicked from the Main Menu Mods list.
@@ -55,6 +57,7 @@ public class GuiConfig extends GuiScreen
*/
public final GuiScreen parentScreen;
public String title = "Config GUI";
@Nullable
public String titleLine2;
public final List<IConfigElement> configElements;
public final List<IConfigEntry> initEntries;
@@ -68,6 +71,7 @@ public class GuiConfig extends GuiScreen
* if any configElements were changed (includes child screens). If not defined, the events will be posted if the parent gui is null
* or if the parent gui is not an instance of GuiConfig.
*/
@Nullable
public final String configID;
public final boolean isWorldRunning;
public final boolean allRequireWorldRestart;
@@ -154,8 +158,8 @@ public class GuiConfig extends GuiScreen
* @param titleLine2 the desired title second line for this screen. Typically this is used to send the category name of the category
* currently being edited.
*/
public GuiConfig(GuiScreen parentScreen, List<IConfigElement> configElements, String modID, String configID,
boolean allRequireWorldRestart, boolean allRequireMcRestart, String title, String titleLine2)
public GuiConfig(GuiScreen parentScreen, List<IConfigElement> configElements, String modID, @Nullable String configID,
boolean allRequireWorldRestart, boolean allRequireMcRestart, String title, @Nullable String titleLine2)
{
this.mc = Minecraft.getMinecraft();
this.parentScreen = parentScreen;
@@ -20,16 +20,17 @@
package net.minecraftforge.fml.client.config;
import net.minecraft.client.gui.GuiDisconnected;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.ITextComponent;
import javax.annotation.Nullable;
public class GuiMessageDialog extends GuiDisconnected
{
protected String buttonText;
public GuiMessageDialog(GuiScreen nextScreen, String title, ITextComponent message, String buttonText)
public GuiMessageDialog(@Nullable GuiScreen nextScreen, String title, ITextComponent message, String buttonText)
{
super(nextScreen, title, message);
this.buttonText = buttonText;
@@ -22,6 +22,8 @@ package net.minecraftforge.fml.client.config;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import javax.annotation.Nullable;
/**
* This class is blatantly stolen from iChunUtils with permission.
*
@@ -42,6 +44,7 @@ public class GuiSlider extends GuiButtonExt
public double maxValue = 5.0D;
public int precision = 1;
@Nullable
public ISlider parent = null;
public String suffix = "";
@@ -53,7 +56,7 @@ public class GuiSlider extends GuiButtonExt
this(id, xPos, yPos, width, height, prefix, suf, minVal, maxVal, currentVal, showDec, drawStr, null);
}
public GuiSlider(int id, int xPos, int yPos, int width, int height, String prefix, String suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, ISlider par)
public GuiSlider(int id, int xPos, int yPos, int width, int height, String prefix, String suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, @Nullable ISlider par)
{
super(id, xPos, yPos, width, height, prefix);
minValue = minVal;
@@ -36,7 +36,7 @@ import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import javax.annotation.Nonnull;
/**
* This class provides several methods and constants used by the Config GUI classes.
@@ -210,14 +210,15 @@ public class GuiUtils
tessellator.draw();
}
private static ItemStack cachedTooltipStack;
@Nonnull
private static ItemStack cachedTooltipStack = ItemStack.EMPTY;
/**
* Must be called from {@code GuiScreen.renderToolTip} before {@code GuiScreen.drawHoveringText} is called.
*
* @param stack The stack for which a tooltip is about to be drawn.
*/
public static void preItemToolTip(ItemStack stack)
public static void preItemToolTip(@Nonnull ItemStack stack)
{
cachedTooltipStack = stack;
}
@@ -227,7 +228,7 @@ public class GuiUtils
*/
public static void postItemToolTip()
{
cachedTooltipStack = null;
cachedTooltipStack = ItemStack.EMPTY;
}
/**
@@ -255,8 +256,7 @@ public class GuiUtils
*
* @see #drawHoveringText(List, int, int, int, int, int, FontRenderer)
*/
public static void drawHoveringText(@Nullable final ItemStack stack, List<String> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
int maxTextWidth, FontRenderer font)
public static void drawHoveringText(@Nonnull final ItemStack stack, List<String> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font)
{
if (!textLines.isEmpty())
{
@@ -22,6 +22,8 @@ package net.minecraftforge.fml.client.event;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import javax.annotation.Nullable;
/**
* These events are posted from the GuiConfig screen when the done button is pressed. The events are only posted
* if the parent screen is not an instance of GuiConfig or if the configID field has been set for
@@ -39,9 +41,10 @@ public class ConfigChangedEvent extends Event
private final String modID;
private final boolean isWorldRunning;
private final boolean requiresMcRestart;
@Nullable
private final String configID;
public ConfigChangedEvent(String modID, String configID, boolean isWorldRunning, boolean requiresMcRestart)
public ConfigChangedEvent(String modID, @Nullable String configID, boolean isWorldRunning, boolean requiresMcRestart)
{
this.modID = modID;
this.configID = configID;
@@ -76,6 +79,7 @@ public class ConfigChangedEvent extends Event
/**
* A String identifier for this ConfigChangedEvent.
*/
@Nullable
public String getConfigID()
{
return configID;
@@ -92,7 +96,7 @@ public class ConfigChangedEvent extends Event
*/
public static class OnConfigChangedEvent extends ConfigChangedEvent
{
public OnConfigChangedEvent(String modID, String configID, boolean isWorldRunning, boolean requiresMcRestart)
public OnConfigChangedEvent(String modID, @Nullable String configID, boolean isWorldRunning, boolean requiresMcRestart)
{
super(modID, configID, isWorldRunning, requiresMcRestart);
}
@@ -104,7 +108,7 @@ public class ConfigChangedEvent extends Event
*/
public static class PostConfigChangedEvent extends ConfigChangedEvent
{
public PostConfigChangedEvent(String modID, String configID, boolean isWorldRunning, boolean requiresMcRestart)
public PostConfigChangedEvent(String modID, @Nullable String configID, boolean isWorldRunning, boolean requiresMcRestart)
{
super(modID, configID, isWorldRunning, requiresMcRestart);
}