Fix useWelcomeMessage + implement broadcast conf
This commit is contained in:
@@ -433,8 +433,13 @@ public class AuthMe extends JavaPlugin {
|
||||
ess = null;
|
||||
}
|
||||
if (this.getServer().getPluginManager().getPlugin("EssentialsSpawn") != null && this.getServer().getPluginManager().getPlugin("EssentialsSpawn").isEnabled()) {
|
||||
this.essentialsSpawn = new EssSpawn().getLocation();
|
||||
ConsoleLogger.info("Hook with EssentialsSpawn plugin");
|
||||
try {
|
||||
essentialsSpawn = new EssSpawn().getLocation();
|
||||
ConsoleLogger.info("Hook with EssentialsSpawn plugin");
|
||||
} catch (Exception e) {
|
||||
essentialsSpawn = null;
|
||||
ConsoleLogger.showError("Error while reading /plugins/Essentials/spawn.yml file ");
|
||||
}
|
||||
} else {
|
||||
ess = null;
|
||||
}
|
||||
|
||||
@@ -418,10 +418,18 @@ public class Management extends Thread {
|
||||
// The Loginevent now fires (as intended) after everything is processed
|
||||
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
|
||||
player.saveData();
|
||||
|
||||
|
||||
// Login is finish, display welcome message
|
||||
for (String s : Settings.welcomeMsg)
|
||||
player.sendMessage(plugin.replaceAllInfos(s, player));
|
||||
if(Settings.useWelcomeMessage)
|
||||
if(Settings.broadcastWelcomeMessage) {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
Bukkit.getServer().broadcastMessage(s);
|
||||
}
|
||||
} else {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
player.sendMessage(plugin.replaceAllInfos(s, player));
|
||||
}
|
||||
}
|
||||
|
||||
// Login is now finish , we can force all commands
|
||||
forceCommands();
|
||||
|
||||
@@ -262,8 +262,16 @@ public class RegisterCommand implements CommandExecutor {
|
||||
player.saveData();
|
||||
|
||||
// Register is finish and player is logged, display welcome message
|
||||
for (String s : Settings.welcomeMsg)
|
||||
player.sendMessage(plugin.replaceAllInfos(s, player));
|
||||
if(Settings.useWelcomeMessage)
|
||||
if(Settings.broadcastWelcomeMessage) {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
Bukkit.getServer().broadcastMessage(s);
|
||||
}
|
||||
} else {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
player.sendMessage(plugin.replaceAllInfos(s, player));
|
||||
}
|
||||
}
|
||||
|
||||
// Register is now finish , we can force all commands
|
||||
forceCommands(player);
|
||||
|
||||
@@ -26,6 +26,7 @@ public class EssSpawn extends CustomConfiguration {
|
||||
|
||||
public Location getLocation() {
|
||||
try {
|
||||
if (!this.contains("spawns.default.world")) return null;
|
||||
if (this.getString("spawns.default.world").isEmpty() || this.getString("spawns.default.world") == "") return null;
|
||||
Location location = new Location(Bukkit.getWorld(this.getString("spawns.default.world")), this.getDouble("spawns.default.x"), this.getDouble("spawns.default.y"), this.getDouble("spawns.default.z"), Float.parseFloat(this.getString("spawns.default.yaw")), Float.parseFloat(this.getString("spawns.default.pitch")));
|
||||
return location;
|
||||
|
||||
@@ -58,7 +58,8 @@ public final class Settings extends YamlConfiguration {
|
||||
useCaptcha, emailRegistration, multiverse, notifications, chestshop, bungee, banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange,
|
||||
disableSocialSpy, useMultiThreading, forceOnlyAfterLogin, useEssentialsMotd,
|
||||
usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative,
|
||||
purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage;
|
||||
purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
||||
broadcastWelcomeMessage;
|
||||
|
||||
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
|
||||
getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
|
||||
@@ -233,6 +234,7 @@ public void loadConfigOptions() {
|
||||
useWelcomeMessage = configFile.getBoolean("settings.useWelcomeMessage", true);
|
||||
unsafePasswords = (List<String>) configFile.getList("settings.security.unsafePasswords", new ArrayList<String>());
|
||||
countriesBlacklist = (List<String>) configFile.getList("Protection.countriesBlacklist", new ArrayList<String>());
|
||||
broadcastWelcomeMessage = configFile.getBoolean("settings.broadcastWelcomeMessage", false);
|
||||
|
||||
// Load the welcome message
|
||||
getWelcomeMessage(plugin);
|
||||
@@ -383,6 +385,7 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
|
||||
useWelcomeMessage = configFile.getBoolean("settings.useWelcomeMessage", true);
|
||||
unsafePasswords = (List<String>) configFile.getList("settings.security.unsafePasswords", new ArrayList<String>());
|
||||
countriesBlacklist = (List<String>) configFile.getList("Protection.countriesBlacklist", new ArrayList<String>());
|
||||
broadcastWelcomeMessage = configFile.getBoolean("settings.broadcastWelcomeMessage", false);
|
||||
|
||||
// Reload the welcome message
|
||||
getWelcomeMessage(AuthMe.getInstance());
|
||||
@@ -516,6 +519,8 @@ public void mergeConfig() {
|
||||
countriesBlacklist.add("A1");
|
||||
set("Protection.countriesBlacklist", countriesBlacklist);
|
||||
}
|
||||
if(!contains("settings.broadcastWelcomeMessage"))
|
||||
set("settings.broadcastWelcomeMessage", false);
|
||||
|
||||
plugin.getLogger().warning("Merge new Config Options if needed..");
|
||||
plugin.getLogger().warning("Please check your config.yml file!");
|
||||
@@ -696,6 +701,10 @@ public void mergeConfig() {
|
||||
}
|
||||
|
||||
private static void getWelcomeMessage(AuthMe plugin) {
|
||||
welcomeMsg = new ArrayList<String>();
|
||||
if(!useWelcomeMessage) {
|
||||
return;
|
||||
}
|
||||
if (!(new File(plugin.getDataFolder() + File.separator + "welcome.txt").exists())) {
|
||||
try {
|
||||
FileWriter fw = new FileWriter(plugin.getDataFolder() + File.separator + "welcome.txt", true);
|
||||
@@ -708,20 +717,18 @@ public void mergeConfig() {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
List<String> msg = new ArrayList<String>();
|
||||
try {
|
||||
FileReader fr = new FileReader(plugin.getDataFolder() + File.separator + "welcome.txt");
|
||||
BufferedReader br = new BufferedReader(fr);
|
||||
String line = "";
|
||||
while((line = br.readLine()) != null) {
|
||||
msg.add(line);
|
||||
welcomeMsg.add(line);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
welcomeMsg = msg;
|
||||
}
|
||||
|
||||
public enum messagesLang {
|
||||
|
||||
Reference in New Issue
Block a user