mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-22 13:09:59 +00:00
Clean up uses of deprecated library functions (#4130)
Avoid catching and rethrowing runtime exceptions Append error messages to exceptions instead of the log
This commit is contained in:
1 parent
ead0e81025
commit
0fde64ac38
44 files changed
+118
-232
No files matched your search
@@ -25,6 +25,8 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -57,7 +59,6 @@ import net.minecraft.world.storage.WorldInfo;
|
||||
import net.minecraftforge.client.model.animation.Animation;
|
||||
import net.minecraftforge.common.ForgeVersion;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.util.CompoundDataFixer;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventBus;
|
||||
@@ -67,14 +68,11 @@ import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.thread.SidedThreadGroup;
|
||||
import net.minecraftforge.fml.common.thread.SidedThreadGroups;
|
||||
import net.minecraftforge.fml.relauncher.CoreModManager;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.server.FMLServerHandler;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
@@ -83,11 +81,9 @@ import com.google.common.collect.ImmutableList.Builder;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* The main class for non-obfuscated hook handling code
|
||||
*
|
||||
@@ -116,7 +112,7 @@ public class FMLCommonHandler
|
||||
private List<String> brandings;
|
||||
private List<String> brandingsNoMC;
|
||||
private List<ICrashCallable> crashCallables = Lists.newArrayList(Loader.instance().getCallableCrashInformation());
|
||||
private Set<SaveHandler> handlerSet = Sets.newSetFromMap(new MapMaker().weakKeys().<SaveHandler,Boolean>makeMap());
|
||||
private Set<SaveHandler> handlerSet = Collections.newSetFromMap(new MapMaker().weakKeys().<SaveHandler,Boolean>makeMap());
|
||||
private WeakReference<SaveHandler> handlerToCheck;
|
||||
private EventBus eventBus = MinecraftForge.EVENT_BUS;
|
||||
private volatile CountDownLatch exitLatch = null;
|
||||
@@ -722,7 +718,7 @@ public class FMLCommonHandler
|
||||
byte[] data = IOUtils.toByteArray(inputstream);
|
||||
|
||||
boolean isEnhanced = false;
|
||||
for (String line : IOUtils.readLines(new ByteArrayInputStream(data), Charsets.UTF_8))
|
||||
for (String line : IOUtils.readLines(new ByteArrayInputStream(data), StandardCharsets.UTF_8))
|
||||
{
|
||||
if (!line.isEmpty() && line.charAt(0) == '#')
|
||||
{
|
||||
@@ -739,7 +735,7 @@ public class FMLCommonHandler
|
||||
return new ByteArrayInputStream(data);
|
||||
|
||||
Properties props = new Properties();
|
||||
props.load(new InputStreamReader(new ByteArrayInputStream(data), Charsets.UTF_8));
|
||||
props.load(new InputStreamReader(new ByteArrayInputStream(data), StandardCharsets.UTF_8));
|
||||
for (Entry<Object, Object> e : props.entrySet())
|
||||
{
|
||||
table.put((String)e.getKey(), (String)e.getValue());
|
||||
|
||||
@@ -20,6 +20,7 @@ package net.minecraftforge.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
@@ -55,7 +56,6 @@ import net.minecraftforge.fml.common.versioning.VersionRange;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -65,7 +65,6 @@ import java.util.zip.ZipFile;
|
||||
|
||||
import java.util.function.Function;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableList.Builder;
|
||||
@@ -328,9 +327,8 @@ public class FMLModContainer implements ModContainer
|
||||
}
|
||||
return version;
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (IOException e)
|
||||
{
|
||||
Throwables.propagateIfPossible(e);
|
||||
modLog.trace("Failed to find a usable version.properties file");
|
||||
return null;
|
||||
}
|
||||
@@ -494,9 +492,8 @@ public class FMLModContainer implements ModContainer
|
||||
isStatic = Modifier.isStatic(f.getModifiers());
|
||||
injectedMod = retriever.apply(mc);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (ReflectiveOperationException e)
|
||||
{
|
||||
Throwables.propagateIfPossible(e);
|
||||
modLog.warn("Attempting to load @{} in class {} for {} and failing", annotationName, targets.getClassName(), mc.getModId(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,6 @@ import net.minecraftforge.fml.common.event.FMLServerStoppedEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLStateEvent;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
/**
|
||||
* The state enum used to help track state progression for the loader
|
||||
* @author cpw
|
||||
@@ -89,9 +87,9 @@ public enum LoaderState
|
||||
{
|
||||
return eventClass.getConstructor(Object[].class).newInstance((Object)eventData);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (ReflectiveOperationException e)
|
||||
{
|
||||
throw Throwables.propagate(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
public LoaderState requiredState()
|
||||
|
||||
@@ -27,9 +27,6 @@ import java.util.Map;
|
||||
import net.minecraftforge.fml.common.versioning.ArtifactVersion;
|
||||
import net.minecraftforge.fml.common.versioning.VersionParser;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
@@ -86,13 +83,8 @@ public class MetadataCollection
|
||||
FMLLog.log.error("The mcmod.info file in {} cannot be parsed as valid JSON. It will be ignored", sourceName, e);
|
||||
return new MetadataCollection();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void parseModMetadataList()
|
||||
{
|
||||
for (ModMetadata modMetadata : modList)
|
||||
|
||||
@@ -28,10 +28,8 @@ import net.minecraftforge.fml.common.discovery.ModCandidate;
|
||||
import net.minecraftforge.fml.common.discovery.asm.ASMModParser;
|
||||
import net.minecraftforge.fml.common.discovery.asm.ModAnnotation;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -52,12 +50,14 @@ public class ModContainerFactory
|
||||
|
||||
public void registerContainerType(Type type, Class<? extends ModContainer> container)
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
Constructor<? extends ModContainer> constructor = container.getConstructor(new Class<?>[] { String.class, ModCandidate.class, Map.class });
|
||||
modTypes.put(type, constructor);
|
||||
} catch (Exception e) {
|
||||
FMLLog.log.error("Critical error : cannot register mod container type {}, it has an invalid constructor", container.getName(), e);
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException("Critical error : cannot register mod container type " + container.getName() + ", it has an invalid constructor", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ package net.minecraftforge.fml.common.asm;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.CodeSource;
|
||||
import java.security.cert.Certificate;
|
||||
import java.util.Map;
|
||||
@@ -39,7 +40,6 @@ import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
|
||||
import net.minecraftforge.fml.relauncher.IFMLCallHook;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import static net.minecraftforge.fml.common.FMLLog.log;
|
||||
@@ -110,7 +110,7 @@ public class FMLSanityChecker implements IFMLCallHook
|
||||
{
|
||||
String mcPath = codeSource.getLocation().getPath().substring(5);
|
||||
mcPath = mcPath.substring(0, mcPath.lastIndexOf('!'));
|
||||
mcPath = URLDecoder.decode(mcPath, Charsets.UTF_8.name());
|
||||
mcPath = URLDecoder.decode(mcPath, StandardCharsets.UTF_8.name());
|
||||
mcJarFile = new JarFile(mcPath,true);
|
||||
mcJarFile.getManifest();
|
||||
JarEntry cbrEntry = mcJarFile.getJarEntry("net/minecraft/client/ClientBrandRetriever.class");
|
||||
|
||||
@@ -36,6 +36,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -54,7 +55,6 @@ import org.objectweb.asm.tree.FieldNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Iterables;
|
||||
@@ -124,7 +124,7 @@ public class AccessTransformer implements IClassTransformer
|
||||
{
|
||||
rulesResource = Resources.getResource(rulesFile);
|
||||
}
|
||||
processATFile(Resources.asCharSource(rulesResource, Charsets.UTF_8));
|
||||
processATFile(Resources.asCharSource(rulesResource, StandardCharsets.UTF_8));
|
||||
FMLLog.log.debug("Loaded {} rules from AccessTransformer config file {}", modifiers.size(), rulesFile);
|
||||
}
|
||||
protected void processATFile(CharSource rulesResource) throws IOException
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
@@ -40,7 +41,6 @@ import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Iterables;
|
||||
@@ -74,7 +74,7 @@ public class MarkerTransformer implements IClassTransformer
|
||||
{
|
||||
rulesResource = Resources.getResource(rulesFile);
|
||||
}
|
||||
Resources.readLines(rulesResource, Charsets.UTF_8, new LineProcessor<Void>()
|
||||
Resources.readLines(rulesResource, StandardCharsets.UTF_8, new LineProcessor<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void getResult()
|
||||
|
||||
+2
-2
@@ -22,6 +22,7 @@ package net.minecraftforge.fml.common.asm.transformers;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
@@ -29,7 +30,6 @@ import java.util.jar.Manifest;
|
||||
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.CharSource;
|
||||
@@ -70,7 +70,7 @@ public class ModAccessTransformer extends AccessTransformer {
|
||||
if (jarEntry != null)
|
||||
{
|
||||
embedded.put(String.format("%s!META-INF/%s", jar.getName(), at),
|
||||
new JarByteSource(jar,jarEntry).asCharSource(Charsets.UTF_8).read());
|
||||
new JarByteSource(jar,jarEntry).asCharSource(StandardCharsets.UTF_8).read());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -23,6 +23,7 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -38,7 +39,6 @@ import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.BiMap;
|
||||
@@ -84,7 +84,7 @@ public class FMLDeobfuscatingRemapper extends Remapper {
|
||||
{
|
||||
File mapData = new File(deobfFileName);
|
||||
LZMAInputSupplier zis = new LZMAInputSupplier(new FileInputStream(mapData));
|
||||
CharSource srgSource = zis.asCharSource(Charsets.UTF_8);
|
||||
CharSource srgSource = zis.asCharSource(StandardCharsets.UTF_8);
|
||||
List<String> srgList = srgSource.readLines();
|
||||
rawMethodMaps = Maps.newHashMap();
|
||||
rawFieldMaps = Maps.newHashMap();
|
||||
@@ -130,13 +130,13 @@ public class FMLDeobfuscatingRemapper extends Remapper {
|
||||
// get as a resource
|
||||
InputStream classData = getClass().getResourceAsStream(deobfFileName);
|
||||
LZMAInputSupplier zis = new LZMAInputSupplier(classData);
|
||||
CharSource srgSource = zis.asCharSource(Charsets.UTF_8);
|
||||
CharSource srgSource = zis.asCharSource(StandardCharsets.UTF_8);
|
||||
srgList = srgSource.readLines();
|
||||
FMLLog.log.debug("Loading deobfuscation resource {} with {} records", deobfFileName, srgList.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
srgList = Files.readLines(new File(gradleStartProp), Charsets.UTF_8);
|
||||
srgList = Files.readLines(new File(gradleStartProp), StandardCharsets.UTF_8);
|
||||
FMLLog.log.debug("Loading deobfuscation resource {} with {} records", gradleStartProp, srgList.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ import java.util.List;
|
||||
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
public enum ContainerType
|
||||
{
|
||||
JAR(JarDiscoverer.class),
|
||||
@@ -38,9 +36,9 @@ public enum ContainerType
|
||||
{
|
||||
this.discoverer = discovererClass.newInstance();
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (ReflectiveOperationException e)
|
||||
{
|
||||
throw Throwables.propagate(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ package net.minecraftforge.fml.common.discovery;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -34,9 +35,7 @@ import net.minecraftforge.fml.common.ModContainerFactory;
|
||||
import net.minecraftforge.fml.common.discovery.asm.ASMModParser;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -122,9 +121,9 @@ public class DirectoryDiscoverer implements ITypeDiscoverer
|
||||
FMLLog.log.error("There was a problem reading the file {} - probably this is a corrupt file", file.getPath(), e);
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (IOException e)
|
||||
{
|
||||
throw Throwables.propagate(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -31,9 +31,6 @@ import net.minecraftforge.fml.common.ModContainer;
|
||||
import net.minecraftforge.fml.relauncher.CoreModManager;
|
||||
import net.minecraftforge.fml.relauncher.FileListHelper;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.ObjectArrays;
|
||||
@@ -152,10 +149,6 @@ public class ModDiscoverer
|
||||
{
|
||||
FMLLog.log.warn("Identified a problem with the mod candidate {}, ignoring this source", candidate.getModContainer(), le);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
Throwables.propagate(t);
|
||||
}
|
||||
}
|
||||
|
||||
return modList;
|
||||
|
||||
@@ -182,7 +182,8 @@ public class EventBus implements IEventExceptionHandler
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
exceptionHandler.handleException(this, event, listeners, index, throwable);
|
||||
Throwables.propagate(throwable);
|
||||
Throwables.throwIfUnchecked(throwable);
|
||||
throw new RuntimeException(throwable);
|
||||
}
|
||||
return (event.isCancelable() ? event.isCanceled() : false);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import net.minecraftforge.fml.relauncher.FMLSecurityManager;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
@@ -128,7 +127,7 @@ public class FMLTweaker implements ITweaker {
|
||||
catch (URISyntaxException e)
|
||||
{
|
||||
LogManager.getLogger("FMLTWEAK").log(Level.ERROR, "Missing URI information for FML tweak");
|
||||
throw Throwables.propagate(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.Map;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.mojang.authlib.Agent;
|
||||
import com.mojang.authlib.exceptions.AuthenticationException;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
||||
@@ -50,8 +49,7 @@ public class Yggdrasil
|
||||
catch (AuthenticationException e)
|
||||
{
|
||||
LogManager.getLogger("FMLTWEAK").error("-- Login failed! {}", e.getMessage(), e);
|
||||
Throwables.propagate(e);
|
||||
return; // don't set other variables
|
||||
throw new RuntimeException(e); // don't set other variables
|
||||
}
|
||||
|
||||
args.put("--username", auth.getSelectedProfile().getName());
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package net.minecraftforge.fml.common.network;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -36,9 +37,6 @@ import net.minecraftforge.registries.RegistryManager;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -151,7 +149,7 @@ public class ByteBufUtils {
|
||||
public static String readUTF8String(ByteBuf from)
|
||||
{
|
||||
int len = readVarInt(from,2);
|
||||
String str = from.toString(from.readerIndex(), len, Charsets.UTF_8);
|
||||
String str = from.toString(from.readerIndex(), len, StandardCharsets.UTF_8);
|
||||
from.readerIndex(from.readerIndex() + len);
|
||||
return str;
|
||||
}
|
||||
@@ -164,7 +162,7 @@ public class ByteBufUtils {
|
||||
*/
|
||||
public static void writeUTF8String(ByteBuf to, String string)
|
||||
{
|
||||
byte[] utf8Bytes = string.getBytes(Charsets.UTF_8);
|
||||
byte[] utf8Bytes = string.getBytes(StandardCharsets.UTF_8);
|
||||
Validate.isTrue(varIntByteCount(utf8Bytes.length) < 3, "The string is too long for this encoding.");
|
||||
writeVarInt(to, utf8Bytes.length, 2);
|
||||
to.writeBytes(utf8Bytes);
|
||||
@@ -194,10 +192,11 @@ public class ByteBufUtils {
|
||||
try
|
||||
{
|
||||
return pb.readItemStack();
|
||||
} catch (IOException e)
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Unpossible?
|
||||
throw Throwables.propagate(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -22,6 +22,7 @@ package net.minecraftforge.fml.common.network.handshake;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.network.NetworkManager;
|
||||
@@ -30,9 +31,6 @@ import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
public class ChannelRegistrationHandler extends SimpleChannelInboundHandler<FMLProxyPacket> {
|
||||
@@ -45,7 +43,7 @@ public class ChannelRegistrationHandler extends SimpleChannelInboundHandler<FMLP
|
||||
{
|
||||
byte[] data = new byte[msg.payload().readableBytes()];
|
||||
msg.payload().readBytes(data);
|
||||
String channels = new String(data,Charsets.UTF_8);
|
||||
String channels = new String(data, StandardCharsets.UTF_8);
|
||||
String[] split = channels.split("\0");
|
||||
Set<String> channelSet = ImmutableSet.copyOf(split);
|
||||
FMLCommonHandler.instance().fireNetRegistrationEvent(manager, channelSet, msg.channel(), side);
|
||||
|
||||
+2
-2
@@ -22,6 +22,7 @@ package net.minecraftforge.fml.common.network.handshake;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -37,7 +38,6 @@ import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||
import net.minecraftforge.registries.ForgeRegistry;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
@@ -47,7 +47,7 @@ public abstract class FMLHandshakeMessage {
|
||||
public static FMLProxyPacket makeCustomChannelRegistration(Set<String> channels)
|
||||
{
|
||||
String salutation = Joiner.on('\0').join(Iterables.concat(Arrays.asList("FML|HS","FML", "FML|MP"),channels));
|
||||
FMLProxyPacket proxy = new FMLProxyPacket(new PacketBuffer(Unpooled.wrappedBuffer(salutation.getBytes(Charsets.UTF_8))), "REGISTER");
|
||||
FMLProxyPacket proxy = new FMLProxyPacket(new PacketBuffer(Unpooled.wrappedBuffer(salutation.getBytes(StandardCharsets.UTF_8))), "REGISTER");
|
||||
return proxy;
|
||||
}
|
||||
public static class ServerHello extends FMLHandshakeMessage {
|
||||
|
||||
+3
-7
@@ -22,8 +22,6 @@ package net.minecraftforge.fml.common.network.internal;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -43,8 +41,6 @@ import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
import net.minecraftforge.fml.common.registry.IThrowableEntity;
|
||||
import net.minecraftforge.fml.common.registry.EntityRegistry.EntityRegistration;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
public class EntitySpawnHandler extends SimpleChannelInboundHandler<FMLMessage.EntityMessage> {
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, final EntityMessage msg) throws Exception
|
||||
@@ -132,10 +128,10 @@ public class EntitySpawnHandler extends SimpleChannelInboundHandler<FMLMessage.E
|
||||
((IEntityAdditionalSpawnData) entity).readSpawnData(spawnMsg.dataStream);
|
||||
}
|
||||
wc.addEntityToWorld(spawnMsg.entityId, entity);
|
||||
} catch (Exception e)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log.error("A severe problem occurred during the spawning of an entity at ({}, {}, {})", spawnMsg.rawX, spawnMsg.rawY, spawnMsg.rawZ, e);
|
||||
throw Throwables.propagate(e);
|
||||
throw new RuntimeException("A severe problem occurred during the spawning of an entity at (" + spawnMsg.rawX + ", " + spawnMsg.rawY + ", " + spawnMsg.rawZ + ")", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,10 +38,6 @@ import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
import net.minecraftforge.fml.common.registry.IThrowableEntity;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
public abstract class FMLMessage {
|
||||
public static class CompleteHandshake extends FMLMessage {
|
||||
Side target;
|
||||
@@ -181,10 +177,11 @@ public abstract class FMLMessage {
|
||||
try
|
||||
{
|
||||
entity.getDataManager().writeEntries(pb);
|
||||
} catch (IOException e)
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log.fatal("Encountered fatal exception trying to send entity spawn data watchers", e);
|
||||
throw Throwables.propagate(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
buf.writeBytes(tmpBuf);
|
||||
|
||||
@@ -233,10 +230,11 @@ public abstract class FMLMessage {
|
||||
try
|
||||
{
|
||||
dataWatcherList = EntityDataManager.readEntries(new PacketBuffer(dat));
|
||||
} catch (IOException e)
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
FMLLog.log.fatal("There was a critical error decoding the datawatcher stream for a mod entity.", e);
|
||||
throw Throwables.propagate(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
throwerId = dat.readInt();
|
||||
|
||||
+5
-10
@@ -24,10 +24,7 @@ import io.netty.channel.ChannelFutureListener;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.EnumMap;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import net.minecraft.util.IThreadListener;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
@@ -35,7 +32,6 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.network.FMLEmbeddedChannel;
|
||||
@@ -128,8 +124,7 @@ public class SimpleNetworkWrapper {
|
||||
catch (Exception e)
|
||||
{
|
||||
// How is this possible?
|
||||
FMLLog.log.fatal("What? Netty isn't installed, what magic is this?", e);
|
||||
throw Throwables.propagate(e);
|
||||
throw new RuntimeException("What? Netty isn't installed, what magic is this?", e);
|
||||
}
|
||||
}
|
||||
public SimpleNetworkWrapper(String channelName)
|
||||
@@ -146,8 +141,7 @@ public class SimpleNetworkWrapper {
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log.fatal("It appears we somehow have a not-standard pipeline. Huh", e);
|
||||
throw Throwables.propagate(e);
|
||||
throw new RuntimeException("It appears we somehow have a not-standard pipeline. Huh", e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -169,9 +163,10 @@ public class SimpleNetworkWrapper {
|
||||
try
|
||||
{
|
||||
return handler.newInstance();
|
||||
} catch (Exception e)
|
||||
}
|
||||
catch (ReflectiveOperationException e)
|
||||
{
|
||||
throw Throwables.propagate(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ import net.minecraftforge.fml.repackage.com.nothome.delta.GDiffPatcher;
|
||||
import LZMA.LzmaInputStream;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Maps;
|
||||
@@ -186,8 +185,7 @@ public class ClassPatchManager {
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log.error("Error occurred reading binary patches. Expect severe problems!", e);
|
||||
throw Throwables.propagate(e);
|
||||
throw new RuntimeException("Error occurred reading binary patches. Expect severe problems!", e);
|
||||
}
|
||||
|
||||
patches = ArrayListMultimap.create();
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
package net.minecraftforge.fml.common.registry;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
@@ -55,10 +52,6 @@ public class EntityEntry extends Impl<EntityEntry>
|
||||
{
|
||||
throw new RuntimeException("Invalid class " + this.cls + " no constructor taking " + World.class.getName());
|
||||
}
|
||||
catch (SecurityException e)
|
||||
{
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Class<? extends Entity> getEntityClass(){ return this.cls; }
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -43,9 +42,7 @@ import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -67,12 +64,10 @@ import net.minecraftforge.registries.RegistryManager;
|
||||
import net.minecraftforge.fml.common.IEntitySelectorFactory;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -348,24 +343,13 @@ public class GameRegistry
|
||||
ItemStack is = new ItemStack(item, stackSize, meta);
|
||||
if (!Strings.isNullOrEmpty(nbtString))
|
||||
{
|
||||
NBTBase nbttag = null;
|
||||
try
|
||||
{
|
||||
nbttag = JsonToNBT.getTagFromJson(nbtString);
|
||||
} catch (NBTException e)
|
||||
{
|
||||
FMLLog.log.warn("Encountered an exception parsing ItemStack NBT string {}", nbtString, e);
|
||||
Throwables.throwIfUnchecked(e);
|
||||
throw new RuntimeException(e);
|
||||
is.setTagCompound(JsonToNBT.getTagFromJson(nbtString));
|
||||
}
|
||||
if (!(nbttag instanceof NBTTagCompound))
|
||||
catch (NBTException e)
|
||||
{
|
||||
FMLLog.log.warn("Unexpected NBT string - multiple values {}", nbtString);
|
||||
throw new RuntimeException("Invalid NBT JSON");
|
||||
}
|
||||
else
|
||||
{
|
||||
is.setTagCompound((NBTTagCompound)nbttag);
|
||||
throw new RuntimeException("Encountered an exception parsing ItemStack NBT string " + nbtString, e);
|
||||
}
|
||||
}
|
||||
return is;
|
||||
|
||||
@@ -28,13 +28,9 @@ import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.discovery.ASMDataTable;
|
||||
import net.minecraftforge.fml.common.discovery.ASMDataTable.ASMData;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
|
||||
public enum ItemStackHolderInjector
|
||||
{
|
||||
INSTANCE;
|
||||
@@ -80,10 +76,10 @@ public enum ItemStackHolderInjector
|
||||
clazz = Class.forName(className, true, getClass().getClassLoader());
|
||||
classCache.put(className, clazz);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (ClassNotFoundException ex)
|
||||
{
|
||||
// unpossible?
|
||||
throw Throwables.propagate(ex);
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
try
|
||||
@@ -91,10 +87,10 @@ public enum ItemStackHolderInjector
|
||||
Field f = clazz.getField(annotationTarget);
|
||||
itemStackHolders.add(new ItemStackHolderRef(f, value, meta, nbt));
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (NoSuchFieldException ex)
|
||||
{
|
||||
// unpossible?
|
||||
throw Throwables.propagate(ex);
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,12 +26,6 @@ import java.lang.reflect.Modifier;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal class used in tracking {@link GameRegistry.ItemStackHolder} references
|
||||
*
|
||||
@@ -72,9 +66,10 @@ class ItemStackHolderRef {
|
||||
modifiersField.setAccessible(true);
|
||||
}
|
||||
modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL);
|
||||
} catch (Exception e)
|
||||
}
|
||||
catch (ReflectiveOperationException e)
|
||||
{
|
||||
throw Throwables.propagate(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user