-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
189f49a
commit fe8b66b
Showing
5 changed files
with
95 additions
and
2 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
35 changes: 35 additions & 0 deletions
35
src/main/java/it/albertus/cyclesmod/common/data/DefaultCars.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package it.albertus.cyclesmod.common.data; | ||
|
||
import java.util.zip.DataFormatException; | ||
|
||
import it.albertus.cyclesmod.common.model.BikesInf; | ||
import it.albertus.cyclesmod.common.resources.CommonMessages; | ||
import it.albertus.cyclesmod.common.resources.Messages; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class DefaultCars { | ||
|
||
private static final long CRC32 = Integer.toUnsignedLong(0x8B31837B); | ||
|
||
private static final String DEFLATED_BASE64 = "eNpjZTDQeqCXwnCA+QBzGkcaBxMzEzObBAMDQxNDKoMfgy2DMQODBgwY2bhhA97YQCgURMXDQAoCgLgxMVGhAWClMHMYoICN4Y3OFYMKBgVmBWY+Nj62C0wXmHxkgRK9DHkMUQxeIFfB3aRhjgps4MARCKAme3j5+QUgAMxlKZmZeRVNPU0VFcVgUFCQl5OZEhWA1U0dOg/0poHddI3tGts7pncQN/Ux5DNEg91kRI6bgoJCQsIioqKiYoAAFkQFQLfk5WUCQXpKUjwsmDDcBAA7dXI/"; | ||
|
||
private static final Messages messages = CommonMessages.INSTANCE; | ||
|
||
public static byte[] getByteArray() { | ||
try { | ||
return DataUtils.inflate(DEFLATED_BASE64, BikesInf.FILE_SIZE, CRC32); | ||
} | ||
catch (final IllegalArgumentException | DataFormatException e) { | ||
throw new VerifyError(messages.get("common.error.original.file.corrupted", BikesInf.FILE_NAME), e); | ||
} | ||
catch (final InvalidSizeException e) { | ||
throw new VerifyError(messages.get("common.error.original.file.corrupted.size", BikesInf.FILE_NAME, e.getExpected(), e.getActual()), e); | ||
} | ||
catch (final InvalidChecksumException e) { | ||
throw new VerifyError(messages.get("common.error.original.file.corrupted.crc", BikesInf.FILE_NAME, String.format("%08X", e.getExpected()), String.format("%08X", e.getActual())), e); | ||
} | ||
} | ||
|
||
} |
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
35 changes: 35 additions & 0 deletions
35
src/main/java/it/albertus/cyclesmod/common/data/HiddenCar.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package it.albertus.cyclesmod.common.data; | ||
|
||
import java.util.zip.DataFormatException; | ||
|
||
import it.albertus.cyclesmod.common.model.BikesInf; | ||
import it.albertus.cyclesmod.common.resources.CommonMessages; | ||
import it.albertus.cyclesmod.common.resources.Messages; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class HiddenCar { | ||
|
||
private static final long CRC32 = Integer.toUnsignedLong(0x25C5E02D); | ||
|
||
private static final String DEFLATED_BASE64 = "eNpjZVDR4TFIYTjAfIA5jSONQ4xZjJlNgoGBoYkhlcGPwZbBmIFBAwaMbNywAW9sIBQKouJhIAUBQNyYmKjQALBSmDkMUAAAoWokhw=="; | ||
|
||
private static final Messages messages = CommonMessages.INSTANCE; | ||
|
||
public static byte[] getByteArray() { | ||
try { | ||
return DataUtils.inflate(DEFLATED_BASE64, BikesInf.FILE_SIZE / 3, CRC32); | ||
} | ||
catch (final IllegalArgumentException | DataFormatException e) { | ||
throw new VerifyError(messages.get("common.error.hidden.cfg.corrupted"), e); | ||
} | ||
catch (final InvalidSizeException e) { | ||
throw new VerifyError(messages.get("common.error.hidden.cfg.corrupted.size", e.getExpected(), e.getActual()), e); | ||
} | ||
catch (final InvalidChecksumException e) { | ||
throw new VerifyError(messages.get("common.error.hidden.cfg.corrupted.crc", String.format("%08X", e.getExpected()), String.format("%08X", e.getActual())), e); | ||
} | ||
} | ||
|
||
} |