-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
166 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 14 additions & 5 deletions
19
mc-server-updater-lib/src/main/java/me/hsgamer/mcserverupdater/api/SimpleChecksum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
package me.hsgamer.mcserverupdater.api; | ||
|
||
import me.hsgamer.mcserverupdater.util.ChecksumUtils; | ||
|
||
import java.io.File; | ||
|
||
public interface SimpleChecksum extends Checksum { | ||
String getChecksum(String version, String build); | ||
|
||
String getFileChecksum(File file) throws Exception; | ||
default String getCurrentChecksum(File file) throws Exception { | ||
return ChecksumUtils.getChecksumSupplier().get(); | ||
} | ||
|
||
@Override | ||
default boolean checksum(File file, String version, String build) throws Exception { | ||
String checksumCode = getChecksum(version, build); | ||
if (checksumCode == null) { | ||
String checksum = getChecksum(version, build); | ||
if (checksum == null) { | ||
return false; | ||
} | ||
String checksumString = getFileChecksum(file); | ||
return checksumString.equals(checksumCode); | ||
String currentChecksum = getCurrentChecksum(file); | ||
return currentChecksum.equals(checksum); | ||
} | ||
|
||
@Override | ||
default void setChecksum(File file, String version, String build) throws Exception { | ||
ChecksumUtils.getChecksumConsumer().accept(getChecksum(version, build)); | ||
} | ||
} |
Oops, something went wrong.