Update 3.3.4

//Changes 3.3.4://
* Add an isLogged column in mySQL
* Add a maxLoginPerIp
* Add a maxJoinPerIp
* Add a way to force kick after register
* Add a way to force login after register
* Update session correctly
* Fix Change Email command
* Fix some perm problems
* Fix some problems with email sending
* Remove some dead code
* Add a way to control spawn priority, by default , in order, it is :
authme,essentials,multiverse,default
This commit is contained in:
Xephi
2014-03-08 00:16:14 +01:00
parent 4e7e9e6cb4
commit b659d8968e
33 changed files with 817 additions and 354 deletions
@@ -1,10 +1,16 @@
package fr.xephi.authme.settings;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.Charset;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -58,8 +64,24 @@ public class CustomConfiguration extends YamlConfiguration{
public boolean loadRessource(File file) {
boolean out = true;
if (!file.exists()) {
InputStream fis = getClass().getResourceAsStream("/" + file.getName());
FileOutputStream fos = null;
try {
InputStream fis = getClass().getResourceAsStream("/" + file.getName());
BufferedReader reader = new BufferedReader(new InputStreamReader(fis, Charset.forName("UTF-8").newDecoder()));
String str;
Writer writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(file), Charset.forName("UTF-8").newEncoder()));
while ((str = reader.readLine()) != null) {
writer.append(str).append("\r\n");
}
writer.flush();
writer.close();
reader.close();
fis.close();
} catch (Exception e) {
Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Failed to load config from JAR");
out = false;
}
/*FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
byte[] buf = new byte[1024];
@@ -81,7 +103,8 @@ public class CustomConfiguration extends YamlConfiguration{
} catch (Exception e) {
}
}
}*/
}
return out;
}
}
}
@@ -1,25 +1,28 @@
package fr.xephi.authme.settings;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
/**
*
* @author Xephi59
*/
public class PlayersLogs extends CustomConfiguration {
private static PlayersLogs pllog = null;
public static List<String> players;
public List<String> players;
@SuppressWarnings("unchecked")
public PlayersLogs() {
super(new File("./plugins/AuthMe/players.yml"));
pllog = this;
load();
save();
players = (List<String>) this.getList("players");
players = this.getStringList("players");
}
public void clear() {
set("players", new ArrayList<String>());
save();
}
public static PlayersLogs getInstance() {
@@ -28,13 +31,22 @@ public class PlayersLogs extends CustomConfiguration {
}
return pllog;
}
public void addPlayer(Player player) {
List<String> players = this.getStringList("players");
if (!players.contains(player.getName())) {
players.add(player.getName());
this.set("players", players);
public void addPlayer(String user) {
players = this.getStringList("players");
if (!players.contains(user.toLowerCase())) {
players.add(user.toLowerCase());
set("players", players);
save();
}
}
public void removePlayer(String user) {
players = this.getStringList("players");
if (players.contains(user.toLowerCase())) {
players.remove(user.toLowerCase());
set("players", players);
save();
}
}
}
@@ -59,7 +59,7 @@ public final class Settings extends YamlConfiguration {
disableSocialSpy, useMultiThreading, forceOnlyAfterLogin, useEssentialsMotd,
usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative,
purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
broadcastWelcomeMessage;
broadcastWelcomeMessage, forceRegKick, forceRegLogin;
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
@@ -68,12 +68,12 @@ public final class Settings extends YamlConfiguration {
getcUnrestrictedName, getRegisteredGroup, messagesLanguage, getMySQLlastlocX, getMySQLlastlocY, getMySQLlastlocZ,
rakamakUsers, rakamakUsersIp, getmailAccount, getmailPassword, getmailSMTP, getMySQLColumnId, getmailSenderName,
getMailSubject, getMailText, getMySQLlastlocWorld, defaultWorld,
getPhpbbPrefix, getWordPressPrefix;
getPhpbbPrefix, getWordPressPrefix, getMySQLColumnLogged, spawnPriority;
public static int getWarnMessageInterval, getSessionTimeout, getRegistrationTimeout, getMaxNickLength,
getMinNickLength, getPasswordMinLen, getMovementRadius, getmaxRegPerIp, getNonActivatedGroup,
passwordMaxLength, getRecoveryPassLength, getMailPort, maxLoginTry, captchaLength, saltLength, getmaxRegPerEmail,
bCryptLog2Rounds, getPhpbbGroup, antiBotSensibility, antiBotDuration, delayRecall;
bCryptLog2Rounds, getPhpbbGroup, antiBotSensibility, antiBotDuration, delayRecall, getMaxLoginPerIp, getMaxJoinPerIp;
protected static YamlConfiguration configFile;
@@ -235,6 +235,12 @@ public void loadConfigOptions() {
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);
forceRegKick = configFile.getBoolean("settings.registration.forceKickAfterRegister", false);
forceRegLogin = configFile.getBoolean("settings.registration.forceLoginAfterRegister", false);
getMySQLColumnLogged = configFile.getString("DataSource.mySQLColumnLogged","isLogged");
spawnPriority = configFile.getString("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
// Load the welcome message
getWelcomeMessage(plugin);
@@ -386,6 +392,12 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
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);
forceRegKick = configFile.getBoolean("settings.registration.forceKickAfterRegister", false);
forceRegLogin = configFile.getBoolean("settings.registration.forceLoginAfterRegister", false);
getMySQLColumnLogged = configFile.getString("DataSource.mySQLColumnLogged","isLogged");
spawnPriority = configFile.getString("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
// Reload the welcome message
getWelcomeMessage(AuthMe.getInstance());
@@ -525,6 +537,18 @@ public void mergeConfig() {
}
if(!contains("settings.broadcastWelcomeMessage"))
set("settings.broadcastWelcomeMessage", false);
if(!contains("settings.registration.forceKickAfterRegister"))
set("settings.registration.forceKickAfterRegister", false);
if(!contains("settings.registration.forceLoginAfterRegister"))
set("settings.registration.forceLoginAfterRegister", false);
if(!contains("DataSource.mySQLColumnLogged"))
set("DataSource.mySQLColumnLogged", "isLogged");
if(!contains("settings.restrictions.spawnPriority"))
set("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
if(!contains("settings.restrictions.maxLoginPerIp"))
set("settings.restrictions.maxLoginPerIp", 0);
if(!contains("settings.restrictions.maxJoinPerIp"))
set("settings.restrictions.maxJoinPerIp", 0);
plugin.getLogger().warning("Merge new Config Options if needed..");
plugin.getLogger().warning("Please check your config.yml file!");
@@ -728,6 +752,7 @@ public void mergeConfig() {
while((line = br.readLine()) != null) {
welcomeMsg.add(line);
}
br.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {