Skip to content

Commit

Permalink
Force overwrite when extracted marker does not exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
iChun committed May 16, 2021
1 parent 38a150d commit dc27534
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static void register(CommandDispatcher<CommandSource> dispatcher)
.executes(context -> {
try
{
int i = HeadHandler.extractFiles();
int i = HeadHandler.extractFiles(true);
HeadHandler.loadHeadInfos();

context.getSource().sendFeedback(new TranslationTextComponent("commands.hats.reextract.success", i), true);
Expand All @@ -103,7 +103,7 @@ public static void register(CommandDispatcher<CommandSource> dispatcher)
.executes(context -> {
try
{
int i = HatResourceHandler.extractHats();
int i = HatResourceHandler.extractHats(true);
HatResourceHandler.loadAllHats();
HatHandler.allocateHatPools();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static synchronized boolean init()
File extractedMarker = new File(hatsDir.toFile(), "files.extracted");
if(!extractedMarker.exists()) //presume we haven't extracted anything yet
{
Hats.LOGGER.info("Extracted {} Hat files.", extractHats());
Hats.LOGGER.info("Extracted {} Hat files.", extractHats(true));

FileUtils.writeStringToFile(extractedMarker, "", StandardCharsets.UTF_8);
}
Expand All @@ -65,7 +65,7 @@ public static synchronized boolean init()
return init;
}

public static int extractHats() throws IOException
public static int extractHats(boolean overwrite) throws IOException
{
int i = 0;
InputStream in = Hats.class.getResourceAsStream("/hats.zip");
Expand All @@ -77,7 +77,7 @@ public static int extractHats() throws IOException
while((entry = zipStream.getNextEntry()) != null)
{
File file = new File(hatsDir.toFile(), entry.getName());
if(file.exists() && file.length() > 3L)
if(!overwrite && file.exists() && file.length() > 3L)
{
continue;
}
Expand Down

0 comments on commit dc27534

Please sign in to comment.