blob: 22ae6f29c6919cbe2587e98351b94543b36820df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
package gtPlusPlus.plugin.fixes.vanilla;
import java.util.Timer;
import java.util.TimerTask;
import gtPlusPlus.api.interfaces.IPlugin;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.plugin.fixes.interfaces.IBugFix;
import gtPlusPlus.plugin.fixes.vanilla.music.MusicTocker;
import gtPlusPlus.preloader.CORE_Preloader;
public class VanillaBackgroundMusicFix implements IBugFix {
private final IPlugin mParent;
private final boolean enabled;
private MusicTocker mFixInstance;
public VanillaBackgroundMusicFix(IPlugin minstance) {
mParent = minstance;
if (CORE_Preloader.enableWatchdogBGM > 0 && Utils.isClient()) {
mParent.log("[BGM] Registering BGM delay Fix.");
enabled = true;
mFixInstance = new MusicTocker(mParent);
} else if (CORE_Preloader.enableWatchdogBGM > 0 && Utils.isServer()) {
mParent.log("[BGM] Tried registering BGM delay Fix on Server, disabling.");
enabled = false;
} else {
mParent.log("[BGM] Not registering BGM delay Fix.");
enabled = false;
}
}
@Override
public boolean isFixValid() {
return enabled;
}
public void manage() {
if (CORE_Preloader.enableWatchdogBGM > 0 && Utils.isClient()) {
TimerTask task = new ManageTask(this.mFixInstance);
Timer timer = new Timer("BGM-WatchDog");
long delay = 1000 * 60;
timer.scheduleAtFixedRate(task, delay, 5000);
}
}
private static class ManageTask extends TimerTask {
private final MusicTocker A;
public ManageTask(MusicTocker a) {
A = a;
}
@Override
public void run() {
if (CORE_Preloader.enableWatchdogBGM > 0 && Utils.isClient()) {
if (!A.mVanillaManager) {
A.run();
}
}
}
}
}
|