yellowstonegames / SquidLib

Useful tools for roguelike, role-playing, strategy, and other grid-based games in Java. Feedback is welcome!
Other
448 stars 46 forks source link

Suggestion : Improvement of String.equals("xxx") #201

Closed o0lwj0o closed 5 years ago

o0lwj0o commented 5 years ago

Hi, I have found some usage of “String.equals("xxx")” in your project. For excmple terms[t].equals(";") ,it will get nullpointexception if terms[t] ==null. The problem can be fixed by repalced with ";".equals(terms[t]) or Objects.equals(terms[t],";").

PS: https://github.com/SquidPony/SquidLib/blob/master/squidlib-util/src/main/java/squidpony/MonsterGen.java | 109/118/125/133/140

tommyettinger commented 5 years ago

Thanks for reporting! I wrote that MonsterGen class quite a while ago and haven't looked much at it since; I'll try and see if I'm using non-null-safe String equality checks anywhere else as well. This should be a quick fix.