Skip to content

Commit

Permalink
5.4 & fix auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
Dituon committed Mar 21, 2023
1 parent 1f6a640 commit ff02763
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ apply plugin: "java"


group = 'xmmt.dituon'
version = '5.4-M2'
version = '5.4'

repositories {
maven { url 'https://maven.aliyun.com/repository/public' }
Expand Down
2 changes: 1 addition & 1 deletion index.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 5.3,
"version": 5.4,
"dataList": [
"screen",
"always",
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/moe/dituon/petpet/plugin/DataUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void updateData() {
break;
}
short i = 0;
while (saveAs(targetDir.getPath() + pet, i + ".png")) i++;
while (saveAs(pet, i + ".png")) i++;
System.out.println("PetData/" + pet + "下载成功 (length:" + i + ')');
}

Expand Down Expand Up @@ -92,14 +92,13 @@ private String getUrlText(String url) {
connection.disconnect();
return str.toString();
} catch (IOException ignored) {
System.out.println("无法连接到远程资源: " + url);
return null;
throw new RuntimeException("无法连接到远程资源: " + url);
}
}

private boolean saveAs(String key, String fileName) {
String url = getRepositoryFileUrl(key, fileName);
Path target = Paths.get(targetDir.getAbsolutePath(), fileName);
Path target = Paths.get(targetDir.getAbsolutePath() + '/' + key, fileName);
try (InputStream ins = new URL(url).openStream()) {
Files.createDirectories(target.getParent());
Files.copy(ins, target, StandardCopyOption.REPLACE_EXISTING);
Expand Down

0 comments on commit ff02763

Please sign in to comment.