Skip to content

Commit

Permalink
Merge pull request #321 from NOVA-Team/fix/compiler-warnings
Browse files Browse the repository at this point in the history
 Fix compiler warnings
  • Loading branch information
ExE-Boss authored Jun 26, 2018
2 parents f241f25 + bc6f1c9 commit 9fc6e96
Show file tree
Hide file tree
Showing 95 changed files with 484 additions and 229 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ public static void chunkSetBlockEvent(Chunk chunk, int x, int y, int z, Block ol

/**
* Used to inject forwarded TileEntites
* @param data
* @param clazz
* @return
* @throws Exception
* @param data The TileEntity data
* @param clazz The TileEntity class
* @return The new TileEntity instance
* @throws Exception If an exception occurred
*/
public static TileEntity loadTileEntityHook(NBTTagCompound data, Class<? extends TileEntity> clazz) throws Exception {
if (clazz.equals(FWTile.class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public class ASMHelper {

static {
try {
defineClass1 = ClassLoader.class.getDeclaredMethod("defineClass", new Class[] { String.class, byte[].class, int.class, int.class });
defineClass2 = ClassLoader.class.getDeclaredMethod("defineClass", new Class[] { String.class, byte[].class, int.class, int.class, ProtectionDomain.class });
defineClass1 = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class);
defineClass2 = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class, ProtectionDomain.class);
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -135,7 +135,7 @@ public static byte[] injectMethods(String name, byte[] bytes, Multimap<String, M
if (method == null) {
throw new RuntimeException("Method not found: " + injector.method);
}
Game.logger().info("Injecting into {}\n", injector.method, printInsnList(injector.injection));
Game.logger().info("Injecting into {}\n{}", injector.method, printInsnList(injector.injection));

List<AbstractInsnNode> callNodes;
if (injector.before) {
Expand Down Expand Up @@ -314,6 +314,7 @@ public static <T> Class<T> defineClass(ClassNode cn, int flags) {
try {
byte[] bytes = createBytes(cn, flags);
defineClass1.setAccessible(true);
@SuppressWarnings("unchecked")
Class<T> clazz = (Class<T>) defineClass1.invoke(Thread.currentThread().getContextClassLoader(), cn.name.replaceAll("/", "."), bytes, 0, bytes.length);
defineClass1.setAccessible(false);
return clazz;
Expand All @@ -329,6 +330,7 @@ public static <T> Class<T> defineClass(ClassNode cn, int flags, ProtectionDomain
try {
byte[] bytes = createBytes(cn, flags);
defineClass2.setAccessible(true);
@SuppressWarnings("unchecked")
Class<T> clazz = (Class<T>) defineClass2.invoke(Thread.currentThread().getContextClassLoader(), cn.name.replaceAll("/", "."), bytes, 0, bytes.length, domain);
defineClass2.setAccessible(false);
return clazz;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public static String unKey(String name) {
}

/**
* Returns true if clazz extends, either directly or indirectly, superclass.
* Returns true if the class extends, either directly or indirectly, the superclass.
* @param name The class in question
* @param superclass The class being extended
* @return
* @return If the class extends or not
*/
public static boolean classExtends(String name, String superclass) {
name = toKey(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* The ComponentInjector is capable of creating dynamic classes that implement a
* specified super class and implement the interfaces specified by
* {@link Component} and {@link Passthrough}.
* @param <T>
* @param <T> The component type
* @author Vic Nightfall
*/
public class ComponentInjector<T> implements Opcodes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public void visitInsn(AbstractInsnNode insn) {
_visitInsn(insn);
}

@SuppressWarnings("deprecation")
private void _visitInsn(AbstractInsnNode insn) {
switch (insn.getType()) {
case 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public boolean matches(MethodInsnNode node) {
return s_owner.equals(node.owner) && s_name.equals(node.name) && s_desc.equals(node.desc);
}

@SuppressWarnings("deprecation")
public AbstractInsnNode toInsn(int opcode) {
if (isClass()) {
return new TypeInsnNode(opcode, s_owner);
Expand All @@ -132,6 +133,7 @@ public void visitTypeInsn(MethodVisitor mv, int opcode) {
mv.visitTypeInsn(opcode, s_owner);
}

@SuppressWarnings("deprecation")
public void visitMethodInsn(MethodVisitor mv, int opcode) {
mv.visitMethodInsn(opcode, s_owner, s_name, s_desc);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class TemplateInjector {
* @param className - Class that will be injected
* @param template - Default interface used as a template to inject in the templateName
*/
public void registerTemplate(String className, Class template) {
public void registerTemplate(String className, Class<?> template) {
templates.put(className, new InjectionTemplate(template.getName()));
}

Expand Down Expand Up @@ -83,8 +83,8 @@ public InjectionTemplate(String templateName) {

/**
* Patches the cnode withPriority the methods from this template.
* @param cnode
* @return
* @param cnode The ClassNode instance
* @return If the class node was modified
*/
public boolean inject(ClassNode cnode) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.ProgressManager;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
Expand Down Expand Up @@ -73,8 +72,9 @@ public void preInit(FMLPreInitializationEvent evt) {
@SuppressWarnings({"unchecked", "deprecation"})
public void loadLanguage(LanguageManager languageManager) {
super.loadLanguage(languageManager);
ProgressManager.ProgressBar progressBar = ProgressManager.push("Loading NOVA language files",
NovaMinecraftPreloader.novaResourcePacks.size() + 1);
cpw.mods.fml.common.ProgressManager.ProgressBar progressBar
= cpw.mods.fml.common.ProgressManager.push("Loading NOVA language files",
NovaMinecraftPreloader.novaResourcePacks.size() + 1);
FMLProgressBar fmlProgressBar = new FMLProgressBar(progressBar);
fmlProgressBar.step("nova");
SortedSet<Language> languages = Minecraft.getMinecraft().getLanguageManager().getLanguages();
Expand Down Expand Up @@ -107,7 +107,7 @@ public void loadLanguage(LanguageManager languageManager) {
});
});
fmlProgressBar.finish();
ProgressManager.pop(progressBar);
cpw.mods.fml.common.ProgressManager.pop(progressBar);
}

private void loadLanguage(LanguageManager languageManager, String langName, InputStream stream) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

package nova.core.wrapper.mc.forge.v17.launcher;

import cpw.mods.fml.common.ProgressManager.ProgressBar;
import nova.core.util.AbstractProgressBar;

/**
Expand All @@ -30,9 +29,11 @@
*/
public class FMLProgressBar extends AbstractProgressBar {

private final ProgressBar progressBar;
@SuppressWarnings("deprecation")
private final cpw.mods.fml.common.ProgressManager.ProgressBar progressBar;

public FMLProgressBar(ProgressBar progressBar) {
public FMLProgressBar(@SuppressWarnings("deprecation")
cpw.mods.fml.common.ProgressManager.ProgressBar progressBar) {
this.progressBar = progressBar;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,29 @@
*
* @author ExE Boss
*/
// TODO Maybe replace with wrapper events.
public interface ForgeLoadable {

default void preInit(FMLPreInitializationEvent event) {
/**
* Pre‑initialize the wrapper code.
*
* @param evt The Minecraft Forge pre-initialization event
*/
default void preInit(FMLPreInitializationEvent evt) {
}

default void init(FMLInitializationEvent event) {
/**
* Initialize the wrapper code.
*
* @param evt The Minecraft Forge initialization event
*/
default void init(FMLInitializationEvent evt) {
}

default void postInit(FMLPostInitializationEvent event) {
/**
* Post-initialize the wrapper code.
*
* @param evt The Minecraft Forge post-initialization event
*/
default void postInit(FMLPostInitializationEvent evt) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.ProgressManager;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
Expand Down Expand Up @@ -74,7 +73,7 @@
* @author Calclavia
*/
@Mod(modid = NovaMinecraft.id, name = NovaMinecraft.name, version = NovaMinecraftPreloader.version, acceptableRemoteVersions = "*")
public class NovaMinecraft {
public class NovaMinecraft implements ForgeLoadable {

public static final String id = "nova";
public static final String name = "NOVA";
Expand All @@ -98,8 +97,12 @@ public static void registerWrapper(ForgeLoadable wrapper) {
* ORDER OF LOADING.
*
* 1. Native Loaders 2. Native Converters 3. Mods
*
* @param evt {@inheritDoc}
*/
@Mod.EventHandler
@Override
@SuppressWarnings("deprecation")
public void preInit(FMLPreInitializationEvent evt) {
try {
/**
Expand Down Expand Up @@ -158,9 +161,10 @@ public void preInit(FMLPreInitializationEvent evt) {
e.printStackTrace();
}

ProgressManager.ProgressBar progressBar = ProgressManager.push("Loading NOVA mods", modClasses.isEmpty() ? 1 : modClasses.size());
cpw.mods.fml.common.ProgressManager.ProgressBar progressBar
= cpw.mods.fml.common.ProgressManager.push("Loading NOVA mods", modClasses.isEmpty() ? 1 : modClasses.size());
launcher.load(new FMLProgressBar(progressBar));
ProgressManager.pop(progressBar);
cpw.mods.fml.common.ProgressManager.pop(progressBar);
novaModWrappers = launcher.getOrdererdMods().stream().filter(mod -> mod instanceof ForgeLoadable).map(mod -> (ForgeLoadable) mod).collect(Collectors.toList());
novaWrappers.removeAll(novaModWrappers);

Expand All @@ -182,7 +186,8 @@ public void preInit(FMLPreInitializationEvent evt) {
Game.entities().init();

//Load preInit
progressBar = ProgressManager.push("Pre-initializing NOVA wrappers", (novaModWrappers.isEmpty() ? 1 : novaModWrappers.size()) + novaWrappers.size());
progressBar = cpw.mods.fml.common.ProgressManager.push("Pre-initializing NOVA wrappers",
(novaModWrappers.isEmpty() ? 1 : novaModWrappers.size()) + novaWrappers.size());
FMLProgressBar fmlProgressBar = new FMLProgressBar(progressBar);
novaModWrappers.stream().forEachOrdered(wrapper -> {
fmlProgressBar.step(wrapper.getClass());
Expand All @@ -193,7 +198,7 @@ public void preInit(FMLPreInitializationEvent evt) {
wrapper.preInit(evt);
});
fmlProgressBar.finish();
ProgressManager.pop(progressBar);
cpw.mods.fml.common.ProgressManager.pop(progressBar);

proxy.preInit(evt);

Expand All @@ -211,11 +216,15 @@ public void preInit(FMLPreInitializationEvent evt) {
}

@Mod.EventHandler
@Override
@SuppressWarnings("deprecation")
public void init(FMLInitializationEvent evt) {
try {
proxy.init(evt);
nativeConverters.stream().forEachOrdered(forgeLoadable -> forgeLoadable.init(evt));
ProgressManager.ProgressBar progressBar = ProgressManager.push("Initializing NOVA wrappers", (novaModWrappers.isEmpty() ? 1 : novaModWrappers.size()) + novaWrappers.size());
cpw.mods.fml.common.ProgressManager.ProgressBar progressBar
= cpw.mods.fml.common.ProgressManager.push("Initializing NOVA wrappers",
(novaModWrappers.isEmpty() ? 1 : novaModWrappers.size()) + novaWrappers.size());
FMLProgressBar fmlProgressBar = new FMLProgressBar(progressBar);
novaModWrappers.stream().forEachOrdered(wrapper -> {
fmlProgressBar.step(wrapper.getClass());
Expand All @@ -226,7 +235,7 @@ public void init(FMLInitializationEvent evt) {
wrapper.init(evt);
});
fmlProgressBar.finish();
ProgressManager.pop(progressBar);
cpw.mods.fml.common.ProgressManager.pop(progressBar);
} catch (Exception e) {
Game.logger().error("Error during init", e);
e.printStackTrace();
Expand All @@ -235,12 +244,16 @@ public void init(FMLInitializationEvent evt) {
}

@Mod.EventHandler
@Override
@SuppressWarnings("deprecation")
public void postInit(FMLPostInitializationEvent evt) {
try {
proxy.postInit(evt);
nativeConverters.stream().forEachOrdered(forgeLoadable -> forgeLoadable.postInit(evt));
Game.recipes().init();
ProgressManager.ProgressBar progressBar = ProgressManager.push("Post-initializing NOVA wrappers", (novaModWrappers.isEmpty() ? 1 : novaModWrappers.size()) + novaWrappers.size());
cpw.mods.fml.common.ProgressManager.ProgressBar progressBar
= cpw.mods.fml.common.ProgressManager.push("Post-initializing NOVA wrappers",
(novaModWrappers.isEmpty() ? 1 : novaModWrappers.size()) + novaWrappers.size());
FMLProgressBar fmlProgressBar = new FMLProgressBar(progressBar);
novaModWrappers.stream().forEachOrdered(wrapper -> {
fmlProgressBar.step(wrapper.getClass());
Expand All @@ -251,7 +264,7 @@ public void postInit(FMLPostInitializationEvent evt) {
wrapper.postInit(evt);
});
fmlProgressBar.finish();
ProgressManager.pop(progressBar);
cpw.mods.fml.common.ProgressManager.pop(progressBar);
} catch (Exception e) {
Game.logger().error("Error during postInit", e);
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
*/
public class NovaGuiConfig extends GuiConfig {
public NovaGuiConfig(GuiScreen parentScreen, Configuration config, String modID) {
super(parentScreen, new ConfigElement(config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), modID, false, false, GuiConfig.getAbridgedConfigPath(config.toString()));
super(parentScreen, new ConfigElement<>(config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(),
modID, false, false, GuiConfig.getAbridgedConfigPath(config.toString()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
* adjustment - as such, those have been collected here.
* @author Stan Hebben
*/
@SuppressWarnings("unchecked")
public class ReflectionUtil {
private static final Field NBTTAGLIST_TAGLIST;
private static final Field OREDICTIONARY_IDTOSTACK;
Expand Down Expand Up @@ -129,6 +130,7 @@ public static List<NBTBase> getTagList(NBTTagList list) {
}
}

@SuppressWarnings("rawtypes")
public static List getSeeds() {
return getPrivateStaticObject(ForgeHooks.class, "seedList");
}
Expand All @@ -137,7 +139,7 @@ public static Map<String, ChestGenHooks> getChestLoot() {
return getPrivateStaticObject(ChestGenHooks.class, "chestInfo");
}

public static Map getTranslations() {
public static Map<String, String> getTranslations() {
return getPrivateObject(
getPrivateStaticObject(StatCollector.class, "localizedName", "field_74839_a"),
"languageList",
Expand Down Expand Up @@ -308,7 +310,7 @@ public static boolean setPrivateObject(Object object, Object value, String... na
// ### Private Methods ###
// #######################

private static Field getField(Class cls, String... names) {
private static Field getField(Class<?> cls, String... names) {
for (String name : names) {
try {
Field field = cls.getDeclaredField(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public net.minecraft.block.Block toNative(BlockFactory blockFactory) {
/**
* Register all Nova blocks
*
* @param evt The Minecraft Forge pre-initialization event
* @param evt {@inheritDoc}
*/
@Override
public void preInit(FMLPreInitializationEvent evt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static FWTile loadTile(NBTTagCompound data) {
try {
String blockID = data.getString("novaID");
Block block = createBlock(blockID);
FWTile tile = injector.inject(block, new Class[0], new Object[0]);
FWTile tile = injector.inject(block, new Class<?>[0], new Object[0]);
tile.setBlock(block);
WrapperEvent.FWTileCreate event = new WrapperEvent.FWTileCreate(block, tile);
Game.events().publish(event);
Expand All @@ -56,7 +56,7 @@ public static FWTile loadTile(NBTTagCompound data) {
public static FWTile loadTile(String blockID) {
try {
Block block = createBlock(blockID);
FWTile tile = injector.inject(block, new Class[] { String.class }, new Object[] { blockID });
FWTile tile = injector.inject(block, new Class<?>[] { String.class }, new Object[] { blockID });
tile.setBlock(block);
WrapperEvent.FWTileCreate event = new WrapperEvent.FWTileCreate(block, tile);
Game.events().publish(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ public Entity addClientEntity(EntityFactory factory) {

@Override
@SuppressWarnings("unchecked")
public Entity addClientEntity(Entity entity) {
return NovaMinecraft.proxy.spawnParticle(world(), entity);
public <T extends Entity> T addClientEntity(T entity) {
return (T) NovaMinecraft.proxy.spawnParticle(world(), entity);
}

@Override
Expand Down
Loading

0 comments on commit 9fc6e96

Please sign in to comment.