Do not create a welcome.txt file when boolean is false (#1633)

* Update WelcomeMessageConfiguration.java

* Update WelcomeMessageConfiguration.java

* Fix compile error
This commit is contained in:
montlikadani 2018-10-09 02:21:21 +02:00 committed by Gabriele C
parent d1d51f5aca
commit 1d6729425f

View File

@ -74,6 +74,10 @@ public class WelcomeMessageConfiguration implements Reloadable {
@PostConstruct @PostConstruct
@Override @Override
public void reload() { public void reload() {
if (!(service.getProperty(RegistrationSettings.USE_WELCOME_MESSAGE))) {
return;
}
List<String> welcomeMessage = new ArrayList<>(); List<String> welcomeMessage = new ArrayList<>();
for (String line : readWelcomeFile()) { for (String line : readWelcomeFile()) {
welcomeMessage.add(ChatColor.translateAlternateColorCodes('&', line)); welcomeMessage.add(ChatColor.translateAlternateColorCodes('&', line));
@ -111,6 +115,10 @@ public class WelcomeMessageConfiguration implements Reloadable {
* @return the lines of the welcome message file * @return the lines of the welcome message file
*/ */
private List<String> readWelcomeFile() { private List<String> readWelcomeFile() {
if (!(service.getProperty(RegistrationSettings.USE_WELCOME_MESSAGE))) {
return Collections.emptyList();
}
File welcomeFile = new File(pluginFolder, "welcome.txt"); File welcomeFile = new File(pluginFolder, "welcome.txt");
if (copyFileFromResource(welcomeFile, "welcome.txt")) { if (copyFileFromResource(welcomeFile, "welcome.txt")) {
try { try {