Skip to content

Commit ca6e6ad

Browse files
committed
fix config event crash
1 parent 627125b commit ca6e6ad

File tree

5 files changed

+14
-28
lines changed

5 files changed

+14
-28
lines changed

src/main/java/com/falsepattern/lib/config/event/AllConfigSyncEvent.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
* <p>
3636
* This is a client-only event, and is never triggered serverside!
3737
*/
38-
@SideOnly(Side.CLIENT)
3938
@StableAPI(since = "0.10.0")
4039
public class AllConfigSyncEvent extends Event {
4140

@@ -54,7 +53,7 @@ public static void postEnd() {
5453
EventUtil.postOnCommonBus(new End());
5554
}
5655

57-
@SideOnly(Side.CLIENT)
56+
// Only posted on client
5857
@StableAPI(since = "0.10.0")
5958
public static final class Start extends AllConfigSyncEvent {
6059
@StableAPI.Internal
@@ -67,7 +66,7 @@ public boolean isCancelable() {
6766
}
6867
}
6968

70-
@SideOnly(Side.CLIENT)
69+
// Only posted on client
7170
@StableAPI(since = "0.10.0")
7271
public static final class End extends AllConfigSyncEvent {
7372
@StableAPI.Internal

src/main/java/com/falsepattern/lib/config/event/ConfigSyncEvent.java

-5
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,12 @@
2727
import lombok.val;
2828

2929
import cpw.mods.fml.common.eventhandler.Event;
30-
import cpw.mods.fml.relauncher.Side;
31-
import cpw.mods.fml.relauncher.SideOnly;
3230

3331
/**
3432
* This event is pushed on the FMLCommonHandler event bus once each time a single config synchronization has finished.
3533
* <p>
3634
* This is a client-only event, and is never triggered serverside!
3735
*/
38-
@SideOnly(Side.CLIENT)
3936
@StableAPI(since = "0.10.0")
4037
public class ConfigSyncEvent extends Event {
4138
@StableAPI.Expose
@@ -62,7 +59,6 @@ public static void postEndFailure(Class<?> configClass, Throwable error) {
6259
EventUtil.postOnCommonBus(new End(configClass, false, error));
6360
}
6461

65-
@SideOnly(Side.CLIENT)
6662
@StableAPI(since = "0.10.0")
6763
public static final class Start extends ConfigSyncEvent {
6864

@@ -77,7 +73,6 @@ public boolean isCancelable() {
7773
}
7874
}
7975

80-
@SideOnly(Side.CLIENT)
8176
@StableAPI(since = "0.10.0")
8277
public static final class End extends ConfigSyncEvent {
8378
@StableAPI.Expose

src/main/java/com/falsepattern/lib/config/event/ConfigSyncRequestEvent.java

+2
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ public static void postServer(List<EntityPlayerMP> players) {
5353
EventUtil.postOnCommonBus(new Server(new ArrayList<>(players)));
5454
}
5555

56+
// Only posted on client
5657
@StableAPI(since = "0.10.0")
5758
public static final class Client extends ConfigSyncRequestEvent {
5859
@StableAPI.Internal
5960
public Client() {
6061
}
6162
}
6263

64+
// Only posted on server
6365
@StableAPI(since = "0.10.0")
6466
public static final class Server extends ConfigSyncRequestEvent {
6567
private final List<EntityPlayerMP> players;

src/main/java/com/falsepattern/lib/internal/impl/config/event/ClientEventHandlerPre.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import com.falsepattern.lib.config.event.ConfigValidationFailureEvent;
2929
import com.falsepattern.lib.internal.FPLog;
3030
import com.falsepattern.lib.internal.config.ConfigEngineConfig;
31-
import com.falsepattern.lib.internal.config.MiscConfig;
3231
import com.falsepattern.lib.text.FormattedText;
3332
import com.falsepattern.lib.toasts.GuiToast;
3433
import com.falsepattern.lib.toasts.SimpleToast;
@@ -75,6 +74,9 @@ public void onConfigSyncFinished(ConfigSyncEvent.End e) {
7574
false,
7675
5000));
7776
}
77+
if (ConfigEngineConfig.CONFIG_SYNC_SUCCESS_LOGGING != ConfigEngineConfig.LoggingLevel.None) {
78+
FPLog.LOG.info("Synced config: {}:{}", cfg.modid(), cfg.category());
79+
}
7880
} else {
7981
if (ConfigEngineConfig.CONFIG_SYNC_FAILURE_LOGGING == ConfigEngineConfig.LoggingLevel.LogAndToast) {
8082
GuiToast.add(new SimpleToast(ToastBG.TOAST_DARK,
@@ -86,6 +88,13 @@ public void onConfigSyncFinished(ConfigSyncEvent.End e) {
8688
false,
8789
5000));
8890
}
91+
if (ConfigEngineConfig.CONFIG_SYNC_FAILURE_LOGGING != ConfigEngineConfig.LoggingLevel.None) {
92+
FPLog.LOG.error("Failed to sync config: {}:{}", cfg.modid(), cfg.category());
93+
val t = e.error;
94+
if (t != null) {
95+
FPLog.LOG.error(t.getMessage(), t);
96+
}
97+
}
8998

9099
}
91100
}

src/main/java/com/falsepattern/lib/internal/impl/config/event/CommonEventHandlerPre.java

-19
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,4 @@ public void onValidationErrorLog(ConfigValidationFailureEvent e) {
5757
e.logWarn();
5858
}
5959
}
60-
61-
@SubscribeEvent
62-
public void onConfigSyncFinished(ConfigSyncEvent.End e) {
63-
if (e.successful) {
64-
if (ConfigEngineConfig.CONFIG_SYNC_SUCCESS_LOGGING != ConfigEngineConfig.LoggingLevel.None) {
65-
val cfg = e.configClass.getAnnotation(Config.class);
66-
FPLog.LOG.info("Synced config: {}:{}", cfg.modid(), cfg.category());
67-
}
68-
} else {
69-
if (ConfigEngineConfig.CONFIG_SYNC_FAILURE_LOGGING != ConfigEngineConfig.LoggingLevel.None) {
70-
val cfg = e.configClass.getAnnotation(Config.class);
71-
FPLog.LOG.error("Failed to sync config: {}:{}", cfg.modid(), cfg.category());
72-
val t = e.error;
73-
if (t != null) {
74-
FPLog.LOG.error(t.getMessage(), t);
75-
}
76-
}
77-
}
78-
}
7960
}

0 commit comments

Comments
 (0)