Skip to content

Commit

Permalink
Compare strings with .equals
Browse files Browse the repository at this point in the history
  • Loading branch information
Samistine committed Oct 19, 2015
1 parent 2dd081d commit 94c4da3
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ private void setupBasics() {
if (NCPAPIProvider.getNoCheatPlusAPI() == null) {
NCPAPIProvider.setNoCheatPlusAPI(this);
}
if (ServerVersion.getMinecraftVersion() == ServerVersion.UNKNOWN_VERSION) {
if (ServerVersion.getMinecraftVersion().equals(ServerVersion.UNKNOWN_VERSION)) {
BukkitVersion.init();
}
if (!ConfigManager.isInitialized()) {
Expand Down

1 comment on commit 94c4da3

@asofold
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to only use ServerVersion.UNKNOWN_VERSION, in order to be able to compare for identity of objects (at least internally).

The actual change that would be necessary to ensure this is always the case, would be to replace the given server version in ServerVersion.setMinecraftVersion by ServerVersion.UNKNOWN_VERSION in case it equals it, to ensure there can never be an equaling string that is not identical, internally.

If ever higher performance is needed, one should switch to a class instance for ServerVersion, storing the integer parts directly, to avoid string parsing, but this is meant to be done during setup. Given non-critical performance, we could easily change it to equals, but then again i think it's best to provide static methods to test if the version is unknown (and possibly the select and compare parts too).

So i'd say, either switch to changing ServerVersion (and all calls to it), or remove this commit from this PR for now. Alternatives are also making a new PR, or a ticket on BukkitDev (then i have to implement it :p).

Please sign in to comment.