mirror of
https://github.com/FalsePattern/FalsePatternLib.git
synced 2026-11-17 05:15:02 +00:00
Fix some fatal errors when config validation fails in coremods
This commit is contained in:
7 files changed
+73
-44
No files matched your search
@@ -21,9 +21,9 @@
|
||||
package com.falsepattern.lib.config.event;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.EventUtil;
|
||||
import lombok.val;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -44,13 +44,12 @@ public class AllConfigSyncEvent extends Event {
|
||||
@StableAPI.Internal
|
||||
public static boolean postStart() {
|
||||
val event = new Start();
|
||||
FMLCommonHandler.instance().bus().post(event);
|
||||
return !event.isCanceled();
|
||||
return EventUtil.postOnCommonBus(event);
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void postEnd() {
|
||||
FMLCommonHandler.instance().bus().post(new End());
|
||||
EventUtil.postOnCommonBus(new End());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
package com.falsepattern.lib.config.event;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.EventUtil;
|
||||
import lombok.val;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -47,18 +47,17 @@ public class ConfigSyncEvent extends Event {
|
||||
@StableAPI.Internal
|
||||
public static boolean postStart(Class<?> configClass) {
|
||||
val event = new Start(configClass);
|
||||
FMLCommonHandler.instance().bus().post(event);
|
||||
return !event.isCanceled();
|
||||
return EventUtil.postOnCommonBus(event);
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void postEndSuccess(Class<?> configClass) {
|
||||
FMLCommonHandler.instance().bus().post(new End(configClass, true, null));
|
||||
EventUtil.postOnCommonBus(new End(configClass, true, null));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void postEndFailure(Class<?> configClass, Throwable error) {
|
||||
FMLCommonHandler.instance().bus().post(new End(configClass, false, error));
|
||||
EventUtil.postOnCommonBus(new End(configClass, false, error));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
package com.falsepattern.lib.config.event;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.EventUtil;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -43,12 +43,12 @@ public class ConfigSyncRequestEvent extends Event {
|
||||
|
||||
@StableAPI.Expose
|
||||
public static void postClient() {
|
||||
FMLCommonHandler.instance().bus().post(new Client());
|
||||
EventUtil.postOnCommonBus(new Client());
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static void postServer(List<EntityPlayerMP> players) {
|
||||
FMLCommonHandler.instance().bus().post(new Server(new ArrayList<>(players)));
|
||||
EventUtil.postOnCommonBus(new Server(new ArrayList<>(players)));
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
|
||||
@@ -22,6 +22,7 @@ package com.falsepattern.lib.config.event;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.config.Config;
|
||||
import com.falsepattern.lib.internal.EventUtil;
|
||||
import com.falsepattern.lib.internal.Share;
|
||||
import com.falsepattern.lib.text.FormattedText;
|
||||
import com.falsepattern.lib.toasts.GuiToast;
|
||||
@@ -30,7 +31,6 @@ import com.falsepattern.lib.toasts.icon.ToastBG;
|
||||
import lombok.val;
|
||||
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -61,53 +61,45 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void postNumericRangeOutOfBounds(Field field, int listIndex, String value, String min, String max) {
|
||||
FMLCommonHandler.instance()
|
||||
.bus()
|
||||
.post(new NumericRangeOutOfBounds(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
listIndex,
|
||||
value,
|
||||
min,
|
||||
max));
|
||||
EventUtil.postOnCommonBus(new NumericRangeOutOfBounds(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
listIndex,
|
||||
value,
|
||||
min,
|
||||
max));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void postSize(Field field, int requestedSize, boolean fixedSize, int maxSize, int defaultSize) {
|
||||
FMLCommonHandler.instance()
|
||||
.bus()
|
||||
.post(new ListSizeOutOfBounds(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
requestedSize,
|
||||
fixedSize,
|
||||
maxSize,
|
||||
defaultSize));
|
||||
EventUtil.postOnCommonBus(new ListSizeOutOfBounds(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
requestedSize,
|
||||
fixedSize,
|
||||
maxSize,
|
||||
defaultSize));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void postStringSizeOutOfBounds(Field field, int listIndex, String text, int maxSize) {
|
||||
FMLCommonHandler.instance()
|
||||
.bus()
|
||||
.post(new StringSizeOutOfBounds(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
listIndex,
|
||||
text,
|
||||
maxSize));
|
||||
EventUtil.postOnCommonBus(new StringSizeOutOfBounds(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
listIndex,
|
||||
text,
|
||||
maxSize));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void fieldIsNull(Field field, int listIndex) {
|
||||
FMLCommonHandler.instance().bus().post(new FieldIsNull(field.getDeclaringClass(), field.getName(), listIndex));
|
||||
EventUtil.postOnCommonBus(new FieldIsNull(field.getDeclaringClass(), field.getName(), listIndex));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
public static void postStringPatternMismatch(Field field, int listIndex, String text, String pattern) {
|
||||
FMLCommonHandler.instance()
|
||||
.bus()
|
||||
.post(new StringPatternMismatch(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
listIndex,
|
||||
text,
|
||||
pattern));
|
||||
EventUtil.postOnCommonBus(new StringPatternMismatch(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
listIndex,
|
||||
text,
|
||||
pattern));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
Reference in new issue
Block a user