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