Skip to content

Commit

Permalink
> vC1.12.3a
Browse files Browse the repository at this point in the history
Additions:
- Added splash screen texts

Deletions:
none

Other:
- Fixed minecraft staying running for no reason

Notes:
- Time taken: ~1 hours

https://discord.gg/2WsVCQDpwy
  • Loading branch information
tudbut committed Jun 8, 2021
1 parent f9e2621 commit 8831bdf
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 25 deletions.
36 changes: 20 additions & 16 deletions src/main/java/tudbut/mod/client/ttc/TTC.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class TTC {
// FML stuff and version
public static final String MODID = "ttc";
public static final String NAME = "TTC Client";
public static final String VERSION = "vC1.12.2a";
public static final String VERSION = "vC1.12.3a";
// TODO: PLEASE change this when skidding or rebranding.
// It is used for analytics and doesn't affect gameplay
public static final String BRAND = "TudbuT/ttc:master";
Expand Down Expand Up @@ -171,23 +171,11 @@ public void init(FMLInitializationEvent event) {

System.out.println("Starting threads...");
sa = new Date().getTime();

boolean[] b = {true, true};
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
b[0] = false;
while(b[1]);
if(AltControl.getInstance().mode != 1) {
try {
saveConfig();
}
catch (IOException e) {
e.printStackTrace();
}
}
}));


// Starting thread to regularly save config
ThreadManager.run(() -> {
Thread saveThread = ThreadManager.run(() -> {
Lock lock = new Lock();
while (b[0]) {
lock.lock(1000);
Expand All @@ -204,6 +192,22 @@ public void init(FMLInitializationEvent event) {
}
b[1] = false;
});

Runtime.getRuntime().addShutdownHook(new Thread(() -> {
b[0] = false;
Lock timer = new Lock();
timer.lock(5000);
while(saveThread.isAlive() && b[1] && timer.isLocked());
if(AltControl.getInstance().mode != 1) {
try {
saveConfig();
}
catch (IOException e) {
e.printStackTrace();
}
}
}));

sa = new Date().getTime() - sa;
System.out.println("Done in " + sa + "ms");

Expand Down
8 changes: 5 additions & 3 deletions src/main/java/tudbut/mod/client/ttc/mods/Update.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,17 @@ else if(res.getStatusCode() != HTTPResponseCode.NotFound.asInt) {
byte[] bytes = res.getBodyBytes();
ChatUtils.print("Download finished. Saving to disk...");
File mods = new File("mods");
File old = new File(mods, "old/ttc/" + TTC.VERSION);
File old = new File("mods/old/ttc/" + TTC.VERSION);
old.mkdirs();
//noinspection ConstantConditions
for (File file : mods.listFiles()) {
if(file.getName().startsWith("ttc") && file.getName().endsWith(".jar")) {
file.renameTo(new File(old, file.getName()));
if(!file.renameTo(new File(old, file.getName()))) {
file.delete();
}
}
}
File f = new File(mods, "ttc.jar");
File f = new File("mods/ttc.jar");
FileOutputStream stream = new FileOutputStream(f);
stream.write(bytes);
ChatUtils.print("Finishing off...");
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/tudbut/mod/client/ttc/utils/ThreadManager.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package tudbut.mod.client.ttc.utils;

public class ThreadManager { // Self-explanatory
public static void run(Runnable runnable) {
new Thread(runnable).start();
public static Thread run(Runnable runnable) {
Thread t = new Thread(runnable);
t.start();
return t;
}
public static void run(String name, Runnable runnable) {
new Thread(runnable, name).start();
public static Thread run(String name, Runnable runnable) {
Thread t = new Thread(runnable, name);
t.start();
return t;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"modid": "ttc",
"name": "TTC Client",
"description": "",
"version": "vC1.12.2a",
"version": "vC1.12.3a",
"mcversion": "1.12.2",
"url": "",
"updateUrl": "",
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
vC1.12.2a
vC1.12.3a

0 comments on commit 8831bdf

Please sign in to comment.