Minor code householding

- Fix Javadoc errors reported during Jenkins build
- Use Guava methods in NewSetting where possible
This commit is contained in:
ljacqu 2016-05-28 07:56:26 +02:00
parent eee06dad50
commit b48e080324
4 changed files with 20 additions and 22 deletions

View File

@ -26,10 +26,8 @@ public class CommandHandler {
private final CommandService commandService; private final CommandService commandService;
private final PermissionsManager permissionsManager; private final PermissionsManager permissionsManager;
/** /*
* Create a command handler. * Constructor.
*
* @param commandService The CommandService instance
*/ */
@Inject @Inject
public CommandHandler(CommandService commandService, PermissionsManager permissionsManager) { public CommandHandler(CommandService commandService, PermissionsManager permissionsManager) {

View File

@ -31,8 +31,9 @@ public class LoginEvent extends CustomEvent {
} }
/** /**
* Ensures compatibility with plugins like GuiRules.
* *
* @return * @return true
* @deprecated this will always return true because this event is only called if it was successful * @deprecated this will always return true because this event is only called if it was successful
*/ */
@Deprecated @Deprecated

View File

@ -69,6 +69,7 @@ public class PermissionsManager implements PermissionsService {
* Constructor. * Constructor.
* *
* @param server Server instance * @param server Server instance
* @param pluginManager Bukkit plugin manager
*/ */
@Inject @Inject
public PermissionsManager(Server server, PluginManager pluginManager) { public PermissionsManager(Server server, PluginManager pluginManager) {

View File

@ -1,6 +1,8 @@
package fr.xephi.authme.settings; package fr.xephi.authme.settings;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import com.google.common.io.Files; import com.google.common.io.Files;
import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.settings.domain.Property; import fr.xephi.authme.settings.domain.Property;
@ -121,10 +123,20 @@ public class NewSetting {
return "/messages/messages_en.yml"; return "/messages/messages_en.yml";
} }
/**
* Return the text to use in email registrations.
*
* @return The email message
*/
public String getEmailMessage() { public String getEmailMessage() {
return emailMessage; return emailMessage;
} }
/**
* Return the lines to output after an in-game registration.
*
* @return The welcome message
*/
public List<String> getWelcomeMessage() { public List<String> getWelcomeMessage() {
return welcomeMessage; return welcomeMessage;
} }
@ -206,7 +218,7 @@ public class NewSetting {
private <T> String toYaml(Property<T> property, int indent, Yaml simpleYaml, Yaml singleQuoteYaml) { private <T> String toYaml(Property<T> property, int indent, Yaml simpleYaml, Yaml singleQuoteYaml) {
String representation = property.toYaml(configuration, simpleYaml, singleQuoteYaml); String representation = property.toYaml(configuration, simpleYaml, singleQuoteYaml);
return join("\n" + indent(indent), representation.split("\\n")); return Joiner.on("\n" + indent(indent)).join(representation.split("\\n"));
} }
private File buildMessagesFile() { private File buildMessagesFile() {
@ -251,7 +263,7 @@ public class NewSetting {
final Charset charset = Charset.forName("UTF-8"); final Charset charset = Charset.forName("UTF-8");
if (copyFileFromResource(emailFile, "email.html")) { if (copyFileFromResource(emailFile, "email.html")) {
try { try {
return StringUtils.join("\n", Files.readLines(emailFile, charset)); return Files.toString(emailFile, charset);
} catch (IOException e) { } catch (IOException e) {
ConsoleLogger.logException("Failed to read file '" + emailFile.getPath() + "':", e); ConsoleLogger.logException("Failed to read file '" + emailFile.getPath() + "':", e);
} }
@ -269,23 +281,9 @@ public class NewSetting {
return new Yaml(options); return new Yaml(options);
} }
private static String join(String delimiter, String[] items) {
StringBuilder sb = new StringBuilder();
String delim = "";
for (String item : items) {
sb.append(delim).append(item);
delim = delimiter;
}
return sb.toString();
}
private static String indent(int level) { private static String indent(int level) {
// We use an indentation of 4 spaces // We use an indentation of 4 spaces
StringBuilder sb = new StringBuilder(level * 4); return Strings.repeat(" ", level * 4);
for (int i = 0; i < level; ++i) {
sb.append(" ");
}
return sb.toString();
} }
} }