-
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
adam
committed
Mar 20, 2024
1 parent
97fb007
commit dfcd7aa
Showing
13 changed files
with
107 additions
and
18 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
32 changes: 32 additions & 0 deletions
32
common/src/main/java/com/adamcalculator/dynamicpack/sync/SyncThread.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,32 @@ | ||
package com.adamcalculator.dynamicpack.sync; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class SyncThread extends Thread { | ||
private static int counter = 0; | ||
private static final long SLEEP_DELAY = 1000 * 60 * 60 * 24; // 24 hours | ||
|
||
private final Supplier<SyncingTask> taskSupplier; | ||
|
||
public SyncThread(Supplier<SyncingTask> taskSupplier) { | ||
super("SyncThread" + (counter++)); | ||
this.taskSupplier = taskSupplier; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
while (true) { | ||
startSync(); | ||
try { | ||
Thread.sleep(SLEEP_DELAY); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} | ||
|
||
|
||
private void startSync() { | ||
taskSupplier.get().run(); | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
src/client/java/com/adamcalculator/dynamicpack/Compat.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,13 @@ | ||
package com.adamcalculator.dynamicpack; | ||
|
||
import net.minecraft.client.gui.Drawable; | ||
import net.minecraft.client.gui.Element; | ||
import net.minecraft.client.gui.Selectable; | ||
import net.minecraft.client.gui.widget.ButtonWidget; | ||
import net.minecraft.text.Text; | ||
|
||
public class Compat { | ||
public static <T extends Element & Drawable & Selectable> T createButton(Text text, Runnable press, int w, int h, int x, int y) { | ||
return (T) ButtonWidget.builder(text, button -> press.run()).size(w, h).position(x, y).build(); | ||
} | ||
} |
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