diff --git a/source/funkin/data/DataError.hx b/source/funkin/data/DataError.hx index 87c99fff5..82f8d9aaf 100644 --- a/source/funkin/data/DataError.hx +++ b/source/funkin/data/DataError.hx @@ -4,6 +4,7 @@ import json2object.Position; import json2object.Position.Line; import json2object.Error; +@:nullSafety class DataError { public static function printError(error:Error):Void diff --git a/source/funkin/data/DataWrite.hx b/source/funkin/data/DataWrite.hx index e277cb01c..e7be178b7 100644 --- a/source/funkin/data/DataWrite.hx +++ b/source/funkin/data/DataWrite.hx @@ -12,6 +12,7 @@ import haxe.ds.Either; * * NOTE: Result must include quotation marks if the value is a string! json2object will not add them for you! */ +@:nullSafety class DataWrite { /** diff --git a/source/funkin/data/dialogue/conversation/ConversationRegistry.hx b/source/funkin/data/dialogue/conversation/ConversationRegistry.hx index 2f79cf973..8eb280046 100644 --- a/source/funkin/data/dialogue/conversation/ConversationRegistry.hx +++ b/source/funkin/data/dialogue/conversation/ConversationRegistry.hx @@ -5,6 +5,7 @@ import funkin.play.cutscene.dialogue.ScriptedConversation; import funkin.util.tools.ISingleton; import funkin.data.DefaultRegistryImpl; +@:nullSafety class ConversationRegistry extends BaseRegistry implements ISingleton implements DefaultRegistryImpl { /** diff --git a/source/funkin/data/dialogue/dialoguebox/DialogueBoxRegistry.hx b/source/funkin/data/dialogue/dialoguebox/DialogueBoxRegistry.hx index 681f8566f..ab2474e99 100644 --- a/source/funkin/data/dialogue/dialoguebox/DialogueBoxRegistry.hx +++ b/source/funkin/data/dialogue/dialoguebox/DialogueBoxRegistry.hx @@ -6,6 +6,7 @@ import funkin.play.cutscene.dialogue.ScriptedDialogueBox; import funkin.util.tools.ISingleton; import funkin.data.DefaultRegistryImpl; +@:nullSafety class DialogueBoxRegistry extends BaseRegistry implements ISingleton implements DefaultRegistryImpl { /** diff --git a/source/funkin/data/dialogue/speaker/SpeakerRegistry.hx b/source/funkin/data/dialogue/speaker/SpeakerRegistry.hx index 96e85aca2..d7263406a 100644 --- a/source/funkin/data/dialogue/speaker/SpeakerRegistry.hx +++ b/source/funkin/data/dialogue/speaker/SpeakerRegistry.hx @@ -5,6 +5,7 @@ import funkin.play.cutscene.dialogue.ScriptedSpeaker; import funkin.util.tools.ISingleton; import funkin.data.DefaultRegistryImpl; +@:nullSafety class SpeakerRegistry extends BaseRegistry implements ISingleton implements DefaultRegistryImpl { /** diff --git a/source/funkin/data/freeplay/album/AlbumRegistry.hx b/source/funkin/data/freeplay/album/AlbumRegistry.hx index a7c3d3990..64b8f8dbd 100644 --- a/source/funkin/data/freeplay/album/AlbumRegistry.hx +++ b/source/funkin/data/freeplay/album/AlbumRegistry.hx @@ -6,6 +6,7 @@ import funkin.ui.freeplay.ScriptedAlbum; import funkin.util.tools.ISingleton; import funkin.data.DefaultRegistryImpl; +@:nullSafety class AlbumRegistry extends BaseRegistry implements ISingleton implements DefaultRegistryImpl { /** diff --git a/source/funkin/data/freeplay/player/PlayerRegistry.hx b/source/funkin/data/freeplay/player/PlayerRegistry.hx index 7d6c6df94..b87bfe11b 100644 --- a/source/funkin/data/freeplay/player/PlayerRegistry.hx +++ b/source/funkin/data/freeplay/player/PlayerRegistry.hx @@ -7,6 +7,7 @@ import funkin.save.Save; import funkin.util.tools.ISingleton; import funkin.data.DefaultRegistryImpl; +@:nullSafety class PlayerRegistry extends BaseRegistry implements ISingleton implements DefaultRegistryImpl { /** diff --git a/source/funkin/data/freeplay/style/FreeplayStyleRegistry.hx b/source/funkin/data/freeplay/style/FreeplayStyleRegistry.hx index f6d75a86a..4142f7321 100644 --- a/source/funkin/data/freeplay/style/FreeplayStyleRegistry.hx +++ b/source/funkin/data/freeplay/style/FreeplayStyleRegistry.hx @@ -6,6 +6,7 @@ import funkin.ui.freeplay.ScriptedFreeplayStyle; import funkin.util.tools.ISingleton; import funkin.data.DefaultRegistryImpl; +@:nullSafety class FreeplayStyleRegistry extends BaseRegistry implements ISingleton implements DefaultRegistryImpl { /** diff --git a/source/funkin/data/stage/StageRegistry.hx b/source/funkin/data/stage/StageRegistry.hx index 0398222d8..5092756ef 100644 --- a/source/funkin/data/stage/StageRegistry.hx +++ b/source/funkin/data/stage/StageRegistry.hx @@ -5,6 +5,7 @@ import funkin.play.stage.ScriptedStage; import funkin.util.tools.ISingleton; import funkin.data.DefaultRegistryImpl; +@:nullSafety class StageRegistry extends BaseRegistry implements ISingleton implements DefaultRegistryImpl { /** diff --git a/source/funkin/data/story/level/LevelRegistry.hx b/source/funkin/data/story/level/LevelRegistry.hx index 4e4f66019..a01fc04a7 100644 --- a/source/funkin/data/story/level/LevelRegistry.hx +++ b/source/funkin/data/story/level/LevelRegistry.hx @@ -6,6 +6,7 @@ import funkin.ui.story.ScriptedLevel; import funkin.util.tools.ISingleton; import funkin.data.DefaultRegistryImpl; +@:nullSafety class LevelRegistry extends BaseRegistry implements ISingleton implements DefaultRegistryImpl { /** diff --git a/source/funkin/input/TurboActionHandler.hx b/source/funkin/input/TurboActionHandler.hx index 9425db8cd..16f258f8d 100644 --- a/source/funkin/input/TurboActionHandler.hx +++ b/source/funkin/input/TurboActionHandler.hx @@ -13,6 +13,7 @@ import funkin.input.Controls.Action; * * Example: Pressing Ctrl+Z will undo, while holding Ctrl+Z will start to undo repeatedly. */ +@:nullSafety class TurboActionHandler extends FlxBasic { /** diff --git a/source/funkin/input/TurboButtonHandler.hx b/source/funkin/input/TurboButtonHandler.hx index 63c2a294b..0e569cde1 100644 --- a/source/funkin/input/TurboButtonHandler.hx +++ b/source/funkin/input/TurboButtonHandler.hx @@ -12,6 +12,7 @@ import flixel.FlxBasic; * * Example: Pressing Ctrl+Z will undo, while holding Ctrl+Z will start to undo repeatedly. */ +@:nullSafety class TurboButtonHandler extends FlxBasic { /** diff --git a/source/funkin/input/TurboKeyHandler.hx b/source/funkin/input/TurboKeyHandler.hx index 36b8e2087..9495b5802 100644 --- a/source/funkin/input/TurboKeyHandler.hx +++ b/source/funkin/input/TurboKeyHandler.hx @@ -11,6 +11,7 @@ import flixel.FlxBasic; * * Example: Pressing Ctrl+Z will undo, while holding Ctrl+Z will start to undo repeatedly. */ +@:nullSafety class TurboKeyHandler extends FlxBasic { /** diff --git a/source/funkin/modding/PolymodErrorHandler.hx b/source/funkin/modding/PolymodErrorHandler.hx index dc387900b..63c705f61 100644 --- a/source/funkin/modding/PolymodErrorHandler.hx +++ b/source/funkin/modding/PolymodErrorHandler.hx @@ -2,6 +2,7 @@ package funkin.modding; import polymod.Polymod; +@:nullSafety class PolymodErrorHandler { /** @@ -47,7 +48,7 @@ class PolymodErrorHandler logError(error.message); // Last word is the class name. - var className:String = error.message.split(' ').pop(); + var className:Null = error.message.split(' ').pop(); var msg:String = 'Import error in ${error.origin}'; msg += '\nCould not import unknown class ${className}'; msg += '\nCheck to ensure the class exists and is spelled correctly.'; diff --git a/source/funkin/modding/PolymodHandler.hx b/source/funkin/modding/PolymodHandler.hx index d6a548e0b..91dc4adcd 100644 --- a/source/funkin/modding/PolymodHandler.hx +++ b/source/funkin/modding/PolymodHandler.hx @@ -25,6 +25,7 @@ import polymod.Polymod; /** * A class for interacting with Polymod, the atomic modding framework for Haxe. */ +@:nullSafety class PolymodHandler { /** diff --git a/source/funkin/modding/base/Object.hx b/source/funkin/modding/base/Object.hx index 1484f9882..5337f311f 100644 --- a/source/funkin/modding/base/Object.hx +++ b/source/funkin/modding/base/Object.hx @@ -3,11 +3,13 @@ package funkin.modding.base; /** * An empty base class meant to be extended by scripts. */ - -class Object { +@:nullSafety +class Object +{ public function new() {} - public function toString():String { + public function toString():String + { return "(Object)"; } } diff --git a/source/funkin/modding/events/ScriptEvent.hx b/source/funkin/modding/events/ScriptEvent.hx index 6710e4138..153795bf1 100644 --- a/source/funkin/modding/events/ScriptEvent.hx +++ b/source/funkin/modding/events/ScriptEvent.hx @@ -15,6 +15,7 @@ import openfl.events.KeyboardEvent; * This is a base class for all events that are issued to scripted classes. * It can be used to identify the type of event called, store data, and cancel event propagation. */ +@:nullSafety class ScriptEvent { /** @@ -255,7 +256,8 @@ class HoldNoteScriptEvent extends NoteScriptEvent */ public var doesNotesplash:Bool = false; - public function new(type:ScriptEventType, holdNote:SustainTrail, healthChange:Float, score:Int, isComboBreak:Bool, comboCount:Int = 0, cancelable:Bool = false):Void + public function new(type:ScriptEventType, holdNote:SustainTrail, healthChange:Float, score:Int, isComboBreak:Bool, comboCount:Int = 0, + cancelable:Bool = false):Void { super(type, null, healthChange, comboCount, true); this.holdNote = holdNote; diff --git a/source/funkin/modding/events/ScriptEventDispatcher.hx b/source/funkin/modding/events/ScriptEventDispatcher.hx index 7d6e3992f..4333da59d 100644 --- a/source/funkin/modding/events/ScriptEventDispatcher.hx +++ b/source/funkin/modding/events/ScriptEventDispatcher.hx @@ -6,6 +6,7 @@ import funkin.modding.IScriptedClass; /** * Utility functions to assist with handling scripted classes. */ +@:nullSafety class ScriptEventDispatcher { /** diff --git a/source/funkin/modding/events/ScriptEventType.hx b/source/funkin/modding/events/ScriptEventType.hx index 02de0dc1a..b8f93d086 100644 --- a/source/funkin/modding/events/ScriptEventType.hx +++ b/source/funkin/modding/events/ScriptEventType.hx @@ -1,5 +1,6 @@ package funkin.modding.events; +@:nullSafety enum abstract ScriptEventType(String) from String to String { /** diff --git a/source/funkin/modding/module/Module.hx b/source/funkin/modding/module/Module.hx index 2638b82e2..c04084f87 100644 --- a/source/funkin/modding/module/Module.hx +++ b/source/funkin/modding/module/Module.hx @@ -8,6 +8,7 @@ import funkin.modding.events.ScriptEvent; * A module is a scripted class which receives all events without requiring a specific context. * You may have the module active at all times, or only when another script enables it. */ +@:nullSafety class Module implements IPlayStateScriptedClass implements IStateChangingScriptedClass { /** @@ -28,7 +29,7 @@ class Module implements IPlayStateScriptedClass implements IStateChangingScripte * * Priority 1 is processed before Priority 1000, etc. */ - public var priority(default, set):Int; + public var priority(default, set):Int = 1000; function set_priority(value:Int):Int { diff --git a/source/funkin/modding/module/ModuleHandler.hx b/source/funkin/modding/module/ModuleHandler.hx index 6c60b0f8c..e4e0ab7d3 100644 --- a/source/funkin/modding/module/ModuleHandler.hx +++ b/source/funkin/modding/module/ModuleHandler.hx @@ -10,6 +10,7 @@ import funkin.modding.module.ScriptedModule; /** * Utility functions for loading and manipulating active modules. */ +@:nullSafety class ModuleHandler { static final moduleCache:Map = new Map(); @@ -74,11 +75,15 @@ class ModuleHandler * Given two module IDs, sort them by priority. * @return 1 or -1 depending on which module has a higher priority. */ - static function sortByPriority(a:String, b:String) + static function sortByPriority(a:String, b:String):Int { - var aModule:Module = moduleCache.get(a); - var bModule:Module = moduleCache.get(b); + var aModule:Null = getModule(a); + var bModule:Null = getModule(b); + if (aModule == null || bModule == null) + { + return 0; + } if (aModule.priority != bModule.priority) { return aModule.priority - bModule.priority; @@ -89,14 +94,14 @@ class ModuleHandler } } - public static function getModule(moduleId:String):Module + public static function getModule(moduleId:String):Null { return moduleCache.get(moduleId); } public static function activateModule(moduleId:String):Void { - var module:Module = getModule(moduleId); + var module:Null = getModule(moduleId); if (module != null) { module.active = true; @@ -105,7 +110,7 @@ class ModuleHandler public static function deactivateModule(moduleId:String):Void { - var module:Module = getModule(moduleId); + var module:Null = getModule(moduleId); if (module != null) { module.active = false; @@ -136,7 +141,7 @@ class ModuleHandler { for (moduleId in modulePriorityOrder) { - var module:Module = moduleCache.get(moduleId); + var module:Null = moduleCache.get(moduleId); // The module needs to be active to receive events. if (module != null && module.active) {