sync event refactoring. Delombok some stuff and fix rogue classloading.

This commit is contained in:
FalsePattern committed 2022-08-18 17:45:42 +02:00
1 parent a479935017
commit aaa0fca75f
7 files changed
+97 -60

No files matched your search

@@ -21,8 +21,6 @@
package com.falsepattern.lib.config.event;
import com.falsepattern.lib.StableAPI;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.val;
import cpw.mods.fml.common.FMLCommonHandler;
@@ -37,10 +35,12 @@ import cpw.mods.fml.relauncher.SideOnly;
*/
@SideOnly(Side.CLIENT)
@StableAPI(since = "0.10.0")
@NoArgsConstructor(access = AccessLevel.PROTECTED,
onConstructor_ = @StableAPI.Internal)
public class AllConfigSyncEvent extends Event {
@StableAPI.Internal
public AllConfigSyncEvent() {
}
@StableAPI.Internal
public static boolean postStart() {
val event = new Start();
@@ -55,9 +55,11 @@ public class AllConfigSyncEvent extends Event {
@SideOnly(Side.CLIENT)
@StableAPI(since = "0.10.0")
@NoArgsConstructor(access = AccessLevel.PUBLIC,
onConstructor_ = @StableAPI.Internal)
public static final class Start extends AllConfigSyncEvent {
@StableAPI.Internal
public Start() {
}
@Override
public boolean isCancelable() {
return true;
@@ -66,8 +68,9 @@ public class AllConfigSyncEvent extends Event {
@SideOnly(Side.CLIENT)
@StableAPI(since = "0.10.0")
@NoArgsConstructor(access = AccessLevel.PUBLIC,
onConstructor_ = @StableAPI.Internal)
public static final class End extends AllConfigSyncEvent {
@StableAPI.Internal
public End() {
}
}
}
@@ -21,8 +21,6 @@
package com.falsepattern.lib.config.event;
import com.falsepattern.lib.StableAPI;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.val;
import cpw.mods.fml.common.FMLCommonHandler;
@@ -37,12 +35,15 @@ import cpw.mods.fml.relauncher.SideOnly;
*/
@SideOnly(Side.CLIENT)
@StableAPI(since = "0.10.0")
@RequiredArgsConstructor(access = AccessLevel.PROTECTED,
onConstructor_ = @StableAPI.Internal)
public class ConfigSyncEvent extends Event {
@StableAPI.Expose
public final Class<?> configClass;
@StableAPI.Internal
public ConfigSyncEvent(Class<?> configClass) {
this.configClass = configClass;
}
@StableAPI.Internal
public static boolean postStart(Class<?> configClass) {
val event = new Start(configClass);
@@ -21,8 +21,6 @@
package com.falsepattern.lib.config.event;
import com.falsepattern.lib.StableAPI;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import net.minecraft.entity.player.EntityPlayerMP;
import cpw.mods.fml.common.FMLCommonHandler;
@@ -38,9 +36,11 @@ import java.util.List;
* {@link #postClient}
*/
@StableAPI(since = "0.10.0")
@RequiredArgsConstructor(access = AccessLevel.PROTECTED,
onConstructor_ = @StableAPI.Internal)
public class ConfigSyncRequestEvent extends Event {
@StableAPI.Internal
public ConfigSyncRequestEvent() {
}
@StableAPI.Expose
public static void postClient() {
FMLCommonHandler.instance().bus().post(new Client());
@@ -52,18 +52,21 @@ public class ConfigSyncRequestEvent extends Event {
}
@StableAPI(since = "0.10.0")
@RequiredArgsConstructor(access = AccessLevel.PROTECTED,
onConstructor_ = @StableAPI.Internal)
public static final class Client extends ConfigSyncRequestEvent {
@StableAPI.Internal
public Client() {
}
}
@StableAPI(since = "0.10.0")
@RequiredArgsConstructor(access = AccessLevel.PUBLIC,
onConstructor_ = @StableAPI.Internal)
public static final class Server extends ConfigSyncRequestEvent {
private final List<EntityPlayerMP> players;
@StableAPI.Internal
public Server(List<EntityPlayerMP> players) {
this.players = players;
}
@StableAPI.Expose
public List<EntityPlayerMP> getPlayers() {
return Collections.unmodifiableList(players);
@@ -27,8 +27,6 @@ import com.falsepattern.lib.text.FormattedText;
import com.falsepattern.lib.toasts.GuiToast;
import com.falsepattern.lib.toasts.SimpleToast;
import com.falsepattern.lib.toasts.icon.ToastBG;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.val;
import net.minecraft.util.EnumChatFormatting;
@@ -40,8 +38,6 @@ import cpw.mods.fml.relauncher.SideOnly;
import java.lang.reflect.Field;
@StableAPI(since = "0.10.0")
@RequiredArgsConstructor(access = AccessLevel.PROTECTED,
onConstructor_ = @StableAPI.Internal)
public abstract class ConfigValidationFailureEvent extends Event {
@StableAPI.Expose
public final String reason;
@@ -54,6 +50,15 @@ public abstract class ConfigValidationFailureEvent extends Event {
@StableAPI.Expose
public final int listIndex;
@StableAPI.Internal
public ConfigValidationFailureEvent(String reason, Class<?> configClass, String fieldName, boolean listElement, int listIndex) {
this.reason = reason;
this.configClass = configClass;
this.fieldName = fieldName;
this.listElement = listElement;
this.listIndex = listIndex;
}
@StableAPI.Internal
public static void postNumericRangeOutOfBounds(Field field, int listIndex, String value, String min, String max) {
FMLCommonHandler.instance()