Fix some minor configuration issues #1344

This commit is contained in:
Gabriele C 2017-10-02 08:43:20 +02:00
parent d95e5adc39
commit 3d08e1bae5
5 changed files with 34 additions and 12 deletions

View File

@ -169,8 +169,10 @@ public class PlayerListener implements Listener {
String customJoinMessage = settings.getProperty(RegistrationSettings.CUSTOM_JOIN_MESSAGE);
if (!customJoinMessage.isEmpty()) {
event.setJoinMessage(customJoinMessage.replace("{PLAYERNAME}", player.getName())
.replace("{DISPLAYNAME}", player.getDisplayName()));
event.setJoinMessage(customJoinMessage
.replace("{PLAYERNAME}", player.getName())
.replace("{DISPLAYNAME}", player.getDisplayName())
.replace("{PLAYERLISTNAME}", player.getPlayerListName()));
}
if (!settings.getProperty(RegistrationSettings.DELAY_JOIN_MESSAGE)) {

View File

@ -15,6 +15,7 @@ import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.PluginHookService;
import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.settings.WelcomeMessageConfiguration;
import fr.xephi.authme.settings.commandconfig.CommandManager;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.PluginSettings;
@ -68,6 +69,9 @@ public class AsynchronousJoin implements AsynchronousProcess {
@Inject
private ValidationService validationService;
@Inject
private WelcomeMessageConfiguration welcomeMessageConfiguration;
AsynchronousJoin() {
}
@ -126,6 +130,8 @@ public class AsynchronousJoin implements AsynchronousProcess {
return;
}
} else if (!service.getProperty(RegistrationSettings.FORCE)) {
welcomeMessageConfiguration.sendWelcomeMessage(player);
// Skip if registration is optional
return;
}

View File

@ -19,7 +19,6 @@ import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import javax.inject.Inject;
import java.util.List;
import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN;
@ -91,14 +90,7 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
player.saveData();
// Login is done, display welcome message
List<String> welcomeMessage = welcomeMessageConfiguration.getWelcomeMessage(player);
if (commonService.getProperty(RegistrationSettings.USE_WELCOME_MESSAGE)) {
if (commonService.getProperty(RegistrationSettings.BROADCAST_WELCOME_MESSAGE)) {
welcomeMessage.forEach(bukkitService::broadcastMessage);
} else {
welcomeMessage.forEach(player::sendMessage);
}
}
welcomeMessageConfiguration.sendWelcomeMessage(player);
// Login is now finished; we can force all commands
commandManager.runCommandsOnLogin(player);

View File

@ -5,7 +5,9 @@ import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.initialization.Reloadable;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.GeoIpService;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.util.PlayerUtils;
import fr.xephi.authme.util.lazytags.Tag;
import fr.xephi.authme.util.lazytags.TagReplacer;
@ -47,6 +49,9 @@ public class WelcomeMessageConfiguration implements Reloadable {
@Inject
private PlayerCache playerCache;
@Inject
private CommonService service;
/** List of all supported tags for the welcome message. */
private final List<Tag<Player>> availableTags = Arrays.asList(
createTag("&", () -> String.valueOf(ChatColor.COLOR_CHAR)),
@ -79,6 +84,22 @@ public class WelcomeMessageConfiguration implements Reloadable {
return messageSupplier.getAdaptedMessages(player);
}
/**
* Sends the welcome message accordingly to the configuration
*
* @param player the player for whom the welcome message should be prepared
*/
public void sendWelcomeMessage(Player player) {
List<String> welcomeMessage = getWelcomeMessage(player);
if (service.getProperty(RegistrationSettings.USE_WELCOME_MESSAGE)) {
if (service.getProperty(RegistrationSettings.BROADCAST_WELCOME_MESSAGE)) {
welcomeMessage.forEach(bukkitService::broadcastMessage);
} else {
welcomeMessage.forEach(player::sendMessage);
}
}
}
/**
* @return the lines of the welcome message file
*/

View File

@ -80,7 +80,8 @@ public final class RegistrationSettings implements SettingsHolder {
"keep empty to use the original one.",
"Available variables:",
"{PLAYERNAME}: the player name (no colors)",
"{DISPLAYNAME}: the player name (with colors)"})
"{DISPLAYNAME}: the player display name (with colors)",
"{PLAYERLISTNAME}: the player list name (with colors)"})
public static final Property<String> CUSTOM_JOIN_MESSAGE =
newProperty("settings.customJoinMessage", "");