This one has turned into a bit of a can worms. Just want to run my thinking past you before I leap in.
The symptom of an NPE in the RangeFilter constructor traces back to a Counter Global Key Command passing down a null instead of a map sourced from a call to getMap(). Your comment implies that this is the source of the bug.
However, getMap() == null is not necessarily an error. Any piece executing KeyCommands in a GamePiece palette or PieceDefiner (PieceSlot, CardSlot, Prototype or Place Marker definition) returns getMap() == null.
So potentially, every trait has to cope with getMap() == null.
Issue 1.
Some traits that should not be called offmap protect themselves from generating NPE’s by disabling themselves in myGetKeyCommand() if getMap() == null, preventing themselves from being activated off map.
Some newer traits that should disable themselves in this way do not. My feeling is that any KeyCommand that
a) Moves the piece
b) Issues KeyCommands to itself or other counters.
c) Issues HotKeys to other Vassal components
should be disabled when off map. Only KeyCommands that affect the look or internal state of the piece should be enabled.
Specifically, Trigger Action, Counter Global Key Command and Action Button are current enabled when offmap, but should not be.
This specific bug is being caused by a Counter Global Key Command with a Range Limitation being executed on an off-map counter.
Issue 2.
There are related bugs caused by Trigger Action running a series of KeyCommands against a counter on the map, but one of the earlier KeyCommands deletes the counter. Later KeyCommands are then applied against the counter, which now exists in the bit bucket, returning getMap() == null.
My feeling here is that TriggerAction should not issue any further KeyCommands if it finds its piece has been deleted.
The purpose of allowing KeyCommands to be issued to offmap pieces in Editor mode is to change the internal state of that piece and have that state ‘stick’ and be available in new pieces pulled from the Game Palette. Triggers, Action Buttons and Global Key Commands do not directly change the state of the piece and are generally built to be executed while on a Map. It is asking for trouble to allow the m to be executed offmap.