Add forceRegisterCommand to force a command after a /register (passwords

only)
This commit is contained in:
Xephi 2014-08-27 06:14:49 +02:00
parent e869eae036
commit 0d8ce9e3d8
3 changed files with 24 additions and 3 deletions

View File

@ -35,13 +35,16 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
this.plugin = plugin;
}
protected void forceCommands(Player player) {
for (String command : Settings.forceCommands) {
protected void forceCommands() {
for (String command : Settings.forceRegisterCommands) {
try {
player.performCommand(command.replace("%p", player.getName()));
} catch (Exception e) {
}
}
for (String command : Settings.forceRegisterCommandsAsConsole) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command.replace("%p", player.getName()));
}
}
protected void forceLogin(Player player) {
@ -144,7 +147,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
}
// Register is now finish , we can force all commands
forceCommands(player);
forceCommands();
}
}

View File

@ -38,6 +38,8 @@ public final class Settings extends YamlConfiguration {
public static List<String> countriesBlacklist = null;
public static List<String> forceCommands = null;
public static List<String> forceCommandsAsConsole = null;
public static List<String> forceRegisterCommands = null;
public static List<String> forceRegisterCommandsAsConsole = null;
private AuthMe plugin;
private final File file;
public static DataSourceType getDataSource;
@ -265,6 +267,8 @@ public final class Settings extends YamlConfiguration {
applyBlindEffect = configFile.getBoolean("settings.applyBlindEffect", false);
emailBlacklist = configFile.getStringList("Email.emailBlacklisted");
emailWhitelist = configFile.getStringList("Email.emailWhitelisted");
forceRegisterCommands = (List<String>) configFile.getList("settings.forceRegisterCommands", new ArrayList<String>());
forceRegisterCommandsAsConsole = (List<String>) configFile.getList("settings.forceRegisterCommandsAsConsole", new ArrayList<String>());
// Load the welcome message
getWelcomeMessage(plugin);
@ -430,6 +434,8 @@ public final class Settings extends YamlConfiguration {
applyBlindEffect = configFile.getBoolean("settings.applyBlindEffect", false);
emailBlacklist = configFile.getStringList("Email.emailBlacklisted");
emailWhitelist = configFile.getStringList("Email.emailWhitelisted");
forceRegisterCommands = (List<String>) configFile.getList("settings.forceRegisterCommands", new ArrayList<String>());
forceRegisterCommandsAsConsole = (List<String>) configFile.getList("settings.forceRegisterCommandsAsConsole", new ArrayList<String>());
// Reload the welcome message
getWelcomeMessage(AuthMe.getInstance());
@ -564,6 +570,14 @@ public final class Settings extends YamlConfiguration {
set("Email.emailWhitelisted", new ArrayList<String>());
changes = true;
}
if (!contains("settings.forceRegisterCommands")) {
set("settings.forceRegisterCommands", new ArrayList<String>());
changes = true;
}
if (!contains("settings.forceRegisterCommandsAsConsole")) {
set("settings.forceRegisterCommandsAsConsole", new ArrayList<String>());
changes = true;
}
if (changes) {
plugin.getLogger().warning("Merge new Config Options - I'm not an error, please don't report me");

View File

@ -250,6 +250,10 @@ settings:
forceCommands: []
# Force these commands after /login as a server console, without any '/', use %p for replace with player name
forceCommandsAsConsole: []
# Force these commands after /register, without any '/', use %p for replace with player name
forceRegisterCommands: []
# Force these commands after /register as a server console, without any '/', use %p for replace with player name
forceRegisterCommandsAsConsole: []
# Do we need to display the welcome message (welcome.txt) after a register or a login?
# You can use colors in this welcome.txt + some replaced strings :
# {PLAYER} : player name, {ONLINE} : display number of online players, {MAXPLAYERS} : display server slots,