forked from ChomeNS/chipmunkmod
make the limit UNLIMITED
This commit is contained in:
parent
d286767f7a
commit
a2b2de94f9
4 changed files with 11 additions and 14 deletions
|
@ -4,8 +4,8 @@ org.gradle.parallel=true
|
|||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.20
|
||||
yarn_mappings=1.20+build.1
|
||||
minecraft_version=1.20.1
|
||||
yarn_mappings=1.20.1+build.2
|
||||
loader_version=0.14.21
|
||||
|
||||
# Mod Properties
|
||||
|
@ -14,5 +14,6 @@ org.gradle.parallel=true
|
|||
archives_base_name = chipmunkmod
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.83.0+1.20
|
||||
fabric_version=0.83.1+1.20.1
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public class MidiConverter {
|
|||
public static final int NOTE_OFF = 0x80;
|
||||
|
||||
public static Song getSongFromUrl(URL url) throws IOException, InvalidMidiDataException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException {
|
||||
Sequence sequence = MidiSystem.getSequence(DownloadUtilities.DownloadToInputStream(url, 5*1024*1024));
|
||||
Sequence sequence = MidiSystem.getSequence(DownloadUtilities.DownloadToInputStream(url));
|
||||
return getSong(sequence, Paths.get(url.toURI().getPath()).getFileName().toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public class SongLoaderThread extends Thread {
|
|||
public SongLoaderException exception;
|
||||
public Song song;
|
||||
|
||||
private boolean isUrl = false;
|
||||
private boolean isUrl;
|
||||
|
||||
public SongLoaderThread (URL location) throws SongLoaderException {
|
||||
isUrl = true;
|
||||
|
@ -34,7 +34,7 @@ public class SongLoaderThread extends Thread {
|
|||
String name;
|
||||
try {
|
||||
if (isUrl) {
|
||||
bytes = DownloadUtilities.DownloadToByteArray(songUrl, 10*1024*1024);
|
||||
bytes = DownloadUtilities.DownloadToByteArray(songUrl);
|
||||
name = Paths.get(songUrl.toURI().getPath()).getFileName().toString();
|
||||
} else {
|
||||
bytes = Files.readAllBytes(songPath.toPath());
|
||||
|
|
|
@ -28,7 +28,7 @@ public class DownloadUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
public static byte[] DownloadToByteArray(URL url, int maxSize) throws IOException, KeyManagementException, NoSuchAlgorithmException {
|
||||
public static byte[] DownloadToByteArray(URL url) throws IOException, KeyManagementException, NoSuchAlgorithmException {
|
||||
SSLContext ctx = SSLContext.getInstance("TLS");
|
||||
ctx.init(new KeyManager[0], new TrustManager[] {new DefaultTrustManager()}, new SecureRandom());
|
||||
SSLContext.setDefault(ctx);
|
||||
|
@ -41,13 +41,9 @@ public class DownloadUtilities {
|
|||
ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream();
|
||||
byte[] buf = new byte[1024];
|
||||
int n;
|
||||
int tot = 0;
|
||||
while ((n = downloadStream.read(buf)) > 0) {
|
||||
byteArrayStream.write(buf, 0, n);
|
||||
tot += n;
|
||||
if (tot > maxSize) {
|
||||
throw new IOException("File is too large");
|
||||
}
|
||||
|
||||
if (Thread.interrupted()) {
|
||||
return null;
|
||||
}
|
||||
|
@ -57,7 +53,7 @@ public class DownloadUtilities {
|
|||
// Closing a ByteArrayInputStream has no effect, so I do not close it.
|
||||
}
|
||||
|
||||
public static InputStream DownloadToInputStream(URL url, int maxSize) throws KeyManagementException, NoSuchAlgorithmException, IOException {
|
||||
return new ByteArrayInputStream(DownloadToByteArray(url, maxSize));
|
||||
public static InputStream DownloadToInputStream(URL url) throws KeyManagementException, NoSuchAlgorithmException, IOException {
|
||||
return new ByteArrayInputStream(DownloadToByteArray(url));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue