Some minor improvements from static analysis

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot
2017-11-07 17:28:28 +11:00
parent 2a82e16c61
commit 417599c2ab
15 changed files with 44 additions and 56 deletions

View File

@@ -5,8 +5,6 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.apache.commons.lang.StringUtils;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.help.HelpTopic;
/**
* Lacking an alternative, the help system will create instances of
@@ -28,7 +26,7 @@ public class GenericCommandHelpTopic extends HelpTopic {
}
// The short text is the first line of the description
int i = command.getDescription().indexOf("\n");
int i = command.getDescription().indexOf('\n');
if (i > 1) {
shortText = command.getDescription().substring(0, i - 1);
} else {
@@ -36,7 +34,7 @@ public class GenericCommandHelpTopic extends HelpTopic {
}
// Build full text
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append(ChatColor.GOLD);
sb.append("Description: ");

View File

@@ -1,7 +1,5 @@
package org.bukkit.help;
import org.bukkit.help.HelpTopic;
import java.util.Comparator;
/**
@@ -11,18 +9,18 @@ import java.util.Comparator;
* slash come after topics that don't.
*/
public class HelpTopicComparator implements Comparator<HelpTopic> {
// Singleton implementations
private static final TopicNameComparator tnc = new TopicNameComparator();
public static TopicNameComparator topicNameComparatorInstance() {
return tnc;
}
private static final HelpTopicComparator htc = new HelpTopicComparator();
public static HelpTopicComparator helpTopicComparatorInstance() {
return htc;
}
private HelpTopicComparator() {}
public int compare(HelpTopic lhs, HelpTopic rhs) {
@@ -31,11 +29,11 @@ public class HelpTopicComparator implements Comparator<HelpTopic> {
public static class TopicNameComparator implements Comparator<String> {
private TopicNameComparator(){}
public int compare(String lhs, String rhs) {
boolean lhsStartSlash = lhs.startsWith("/");
boolean rhsStartSlash = rhs.startsWith("/");
if (lhsStartSlash && !rhsStartSlash) {
return 1;
} else if (!lhsStartSlash && rhsStartSlash) {