mirror of
https://github.com/moparisthebest/xAuth
synced 2024-12-22 15:18:52 -05:00
MultiInv compatibility *seems* to be fixed, revision of entire Settings class, illegal action notify limit fixed, multiple other small fixes/edits
This commit is contained in:
parent
525fee6d5e
commit
7a24b5cae0
@ -5,12 +5,10 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
|
|
||||||
import com.cypherx.xauth.Settings.Keys;
|
|
||||||
|
|
||||||
public class CommandHandler
|
public class CommandHandler
|
||||||
{
|
{
|
||||||
private final xAuth plugin;
|
private final xAuth plugin;
|
||||||
PluginDescriptionFile pdfFile;
|
private final PluginDescriptionFile pdfFile;
|
||||||
|
|
||||||
public CommandHandler(final xAuth instance)
|
public CommandHandler(final xAuth instance)
|
||||||
{
|
{
|
||||||
@ -24,25 +22,18 @@ public class CommandHandler
|
|||||||
{
|
{
|
||||||
if (args.length != 1)
|
if (args.length != 1)
|
||||||
player.sendMessage(xAuth.strings.getString("register.usage"));
|
player.sendMessage(xAuth.strings.getString("register.usage"));
|
||||||
//player.sendMessage(ChatColor.RED + "Correct Usage: /register <password>");
|
else if (!xAuth.settings.getBool("registration.enabled"))
|
||||||
else if (!xAuth.settings.getBool(Keys.REG_ENABLED))
|
|
||||||
player.sendMessage(xAuth.strings.getString("register.err.disabled"));
|
player.sendMessage(xAuth.strings.getString("register.err.disabled"));
|
||||||
//player.sendMessage(ChatColor.RED + "Registrations are currently disabled.");
|
|
||||||
else if (plugin.isRegistered(player.getName()))
|
else if (plugin.isRegistered(player.getName()))
|
||||||
player.sendMessage(xAuth.strings.getString("register.err.registered"));
|
player.sendMessage(xAuth.strings.getString("register.err.registered"));
|
||||||
//player.sendMessage(ChatColor.RED + "You are already registered.");
|
else if (args[0].length() < xAuth.settings.getInt("registration.pw-min-length"))
|
||||||
else if (args[0].length() < xAuth.settings.getInt(Keys.PW_MIN_LENGTH))
|
player.sendMessage(xAuth.strings.getString("register.err.password", xAuth.settings.getInt("registration.pw-min-length")));
|
||||||
//player.sendMessage(xAuth.strings.get(Strings.Keys.REG_ERR_REGISTERED, xAuth.settings.getInt(Keys.PW_MIN_LENGTH)));
|
|
||||||
player.sendMessage(xAuth.strings.getString("register.err.password", xAuth.settings.getInt(Keys.PW_MIN_LENGTH)));
|
|
||||||
//player.sendMessage(ChatColor.RED + "Your password must contain " + xAuth.settings.getInt(Keys.PW_MIN_LENGTH) + " or more characters.");
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
plugin.addAuth(player.getName(), args[0]);
|
plugin.addAuth(player.getName(), args[0]);
|
||||||
plugin.login(player);
|
plugin.login(player);
|
||||||
player.sendMessage(xAuth.strings.getString("register.success1"));
|
player.sendMessage(xAuth.strings.getString("register.success1"));
|
||||||
player.sendMessage(xAuth.strings.getString("register.success2", args[0]));
|
player.sendMessage(xAuth.strings.getString("register.success2", args[0]));
|
||||||
//player.sendMessage(ChatColor.GREEN + "You have successfully registered!");
|
|
||||||
//player.sendMessage(ChatColor.GREEN + "Your password is: " + ChatColor.WHITE + args[0]);
|
|
||||||
System.out.println("[" + pdfFile.getName() + "] Player '" + player.getName() + "' has registered");
|
System.out.println("[" + pdfFile.getName() + "] Player '" + player.getName() + "' has registered");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,10 +65,10 @@ public class CommandHandler
|
|||||||
{
|
{
|
||||||
if (!plugin.sessionExists(player.getName()))
|
if (!plugin.sessionExists(player.getName()))
|
||||||
player.sendMessage(ChatColor.RED + "You must login before changing your password!");
|
player.sendMessage(ChatColor.RED + "You must login before changing your password!");
|
||||||
else if (!xAuth.settings.getBool(Keys.ALLOW_CHANGEPW))
|
else if (!xAuth.settings.getBool("misc.allow-changepw"))
|
||||||
player.sendMessage(ChatColor.RED + "Password changes are currently disabled.");
|
player.sendMessage(ChatColor.RED + "Password changes are currently disabled.");
|
||||||
else if (args[0].length() < xAuth.settings.getInt(Keys.PW_MIN_LENGTH))
|
else if (args[0].length() < xAuth.settings.getInt("registration.pw-min-length"))
|
||||||
player.sendMessage(ChatColor.RED + "Your password must contain " + xAuth.settings.getInt(Keys.PW_MIN_LENGTH) + " or more characters.");
|
player.sendMessage(ChatColor.RED + "Your password must contain " + xAuth.settings.getInt("registration.pw-min-length") + " or more characters.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
plugin.changePass(player.getName(), args[0]);
|
plugin.changePass(player.getName(), args[0]);
|
||||||
@ -107,10 +98,10 @@ public class CommandHandler
|
|||||||
player.sendMessage(ChatColor.RED + "Correct Usage: /changepw <newpassword>");
|
player.sendMessage(ChatColor.RED + "Correct Usage: /changepw <newpassword>");
|
||||||
else if (!plugin.sessionExists(player.getName()))
|
else if (!plugin.sessionExists(player.getName()))
|
||||||
player.sendMessage(ChatColor.RED + "You must login before changing your password!");
|
player.sendMessage(ChatColor.RED + "You must login before changing your password!");
|
||||||
else if (!xAuth.settings.getBool(Keys.ALLOW_CHANGEPW))
|
else if (!xAuth.settings.getBool("misc.allow-changepw"))
|
||||||
player.sendMessage(ChatColor.RED + "Password changes are currently disabled.");
|
player.sendMessage(ChatColor.RED + "Password changes are currently disabled.");
|
||||||
else if (args[0].length() < xAuth.settings.getInt(Keys.PW_MIN_LENGTH))
|
else if (args[0].length() < xAuth.settings.getInt("registration.pw-min-length"))
|
||||||
player.sendMessage(ChatColor.RED + "Your password must contain " + xAuth.settings.getInt(Keys.PW_MIN_LENGTH) + " or more characters.");
|
player.sendMessage(ChatColor.RED + "Your password must contain " + xAuth.settings.getInt("registration.pw-min-length") + " or more characters.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
plugin.changePass(player.getName(), args[0]);
|
plugin.changePass(player.getName(), args[0]);
|
||||||
@ -159,8 +150,8 @@ public class CommandHandler
|
|||||||
player.sendMessage(ChatColor.RED + "You aren't allow to toggle that!");
|
player.sendMessage(ChatColor.RED + "You aren't allow to toggle that!");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Boolean b = xAuth.settings.getBool(Keys.REG_ENABLED);
|
Boolean b = xAuth.settings.getBool("registration.enabled");
|
||||||
xAuth.settings.update(Keys.REG_ENABLED, (b ? false : true));
|
xAuth.settings.updateValue("registration.enabled", (b ? false : true));
|
||||||
player.sendMessage(ChatColor.YELLOW + "[" + pdfFile.getName() + "] Registrations are now " + (b ? "disabled." : "enabled."));
|
player.sendMessage(ChatColor.YELLOW + "[" + pdfFile.getName() + "] Registrations are now " + (b ? "disabled." : "enabled."));
|
||||||
System.out.println("[" + pdfFile.getName() + "] " + player.getName() + " has " + (b ? "disabled" : "enabled") + " registrations");
|
System.out.println("[" + pdfFile.getName() + "] " + player.getName() + " has " + (b ? "disabled" : "enabled") + " registrations");
|
||||||
}
|
}
|
||||||
@ -172,8 +163,8 @@ public class CommandHandler
|
|||||||
player.sendMessage(ChatColor.RED + "You aren't allow to toggle that!");
|
player.sendMessage(ChatColor.RED + "You aren't allow to toggle that!");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Boolean b = xAuth.settings.getBool(Keys.ALLOW_CHANGEPW);
|
Boolean b = xAuth.settings.getBool("misc.allow-changepw");
|
||||||
xAuth.settings.update(Keys.ALLOW_CHANGEPW, (b ? false : true));
|
xAuth.settings.updateValue("misc.allow-changepw", (b ? false : true));
|
||||||
player.sendMessage(ChatColor.YELLOW + "[" + pdfFile.getName() + "] Password changes are now " + (b ? "disabled." : "enabled."));
|
player.sendMessage(ChatColor.YELLOW + "[" + pdfFile.getName() + "] Password changes are now " + (b ? "disabled." : "enabled."));
|
||||||
System.out.println("[" + pdfFile.getName() + "] " + player.getName() + " has " + (b ? "disabled" : "enabled") + " password changes");
|
System.out.println("[" + pdfFile.getName() + "] " + player.getName() + " has " + (b ? "disabled" : "enabled") + " password changes");
|
||||||
}
|
}
|
||||||
@ -184,8 +175,8 @@ public class CommandHandler
|
|||||||
player.sendMessage(ChatColor.RED + "You aren't allow to toggle that!");
|
player.sendMessage(ChatColor.RED + "You aren't allow to toggle that!");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Boolean b = xAuth.settings.getBool(Keys.AUTOSAVE);
|
Boolean b = xAuth.settings.getBool("misc.autosave");
|
||||||
xAuth.settings.update(Keys.AUTOSAVE, (b ? false : true));
|
xAuth.settings.updateValue("misc.autosave", (b ? false : true));
|
||||||
player.sendMessage(ChatColor.YELLOW + "[" + pdfFile.getName() + "] Autosaving of account modifications is now " + (b ? "disabled." : "enabled."));
|
player.sendMessage(ChatColor.YELLOW + "[" + pdfFile.getName() + "] Autosaving of account modifications is now " + (b ? "disabled." : "enabled."));
|
||||||
System.out.println("[" + pdfFile.getName() + "] " + player.getName() + " has " + (b ? "disabled" : "enabled") + " autosave");
|
System.out.println("[" + pdfFile.getName() + "] " + player.getName() + " has " + (b ? "disabled" : "enabled") + " autosave");
|
||||||
}
|
}
|
||||||
@ -242,20 +233,20 @@ public class CommandHandler
|
|||||||
System.out.println("Correct Usage: /toggle <reg|changepw|autosave>");
|
System.out.println("Correct Usage: /toggle <reg|changepw|autosave>");
|
||||||
else if (args[0].equalsIgnoreCase("reg"))
|
else if (args[0].equalsIgnoreCase("reg"))
|
||||||
{
|
{
|
||||||
Boolean b = xAuth.settings.getBool(Keys.REG_ENABLED);
|
Boolean b = xAuth.settings.getBool("registration.enabled");
|
||||||
xAuth.settings.update(Keys.REG_ENABLED, (b ? false : true));
|
xAuth.settings.updateValue("registration.enabled", (b ? false : true));
|
||||||
System.out.println("[" + pdfFile.getName() + "] Registrations are now " + (b ? "disabled" : "enabled"));
|
System.out.println("[" + pdfFile.getName() + "] Registrations are now " + (b ? "disabled" : "enabled"));
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("changepw"))
|
else if (args[0].equalsIgnoreCase("changepw"))
|
||||||
{
|
{
|
||||||
Boolean b = xAuth.settings.getBool(Keys.ALLOW_CHANGEPW);
|
Boolean b = xAuth.settings.getBool("misc.allow-changepw");
|
||||||
xAuth.settings.update(Keys.ALLOW_CHANGEPW, (b ? false : true));
|
xAuth.settings.updateValue("misc.allow-changepw", (b ? false : true));
|
||||||
System.out.println("[" + pdfFile.getName() + "] Password changes are now " + (b ? "disabled" : "enabled"));
|
System.out.println("[" + pdfFile.getName() + "] Password changes are now " + (b ? "disabled" : "enabled"));
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("autosave"))
|
else if (args[0].equalsIgnoreCase("autosave"))
|
||||||
{
|
{
|
||||||
Boolean b = xAuth.settings.getBool(Keys.AUTOSAVE);
|
Boolean b = xAuth.settings.getBool("misc.autosave");
|
||||||
xAuth.settings.update(Keys.AUTOSAVE, (b ? false : true));
|
xAuth.settings.updateValue("misc.autosave", (b ? false : true));
|
||||||
System.out.println("[" + pdfFile.getName() + "] Autosaving of account modifications is now " + (b ? "disabled" : "enabled"));
|
System.out.println("[" + pdfFile.getName() + "] Autosaving of account modifications is now " + (b ? "disabled" : "enabled"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.cypherx.xauth;
|
package com.cypherx.xauth;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@ -9,89 +8,79 @@ import org.bukkit.util.config.Configuration;
|
|||||||
|
|
||||||
public class Settings
|
public class Settings
|
||||||
{
|
{
|
||||||
interface Keys
|
private static String[] keys =
|
||||||
{
|
{
|
||||||
public static final String REG_ENABLED = "registration.enabled";
|
"registration.enabled",
|
||||||
public static final String ALLOW_CHANGE_PW = "misc.allow-change-pw";//old allow-changepw
|
"misc.allow-changepw",
|
||||||
public static final String ALLOW_CHANGEPW = "misc.allow-changepw";//new allow-changepw
|
"misc.autosave",
|
||||||
public static final String SAVE_ON_CHANGE = "misc.save-on-change";//old autosave
|
"session.timeout",
|
||||||
public static final String AUTOSAVE = "misc.autosave";//new autosave
|
"notify.limit",
|
||||||
public static final String SESSION_TIMEOUT = "session.timeout";
|
"registration.pw-min-length",
|
||||||
public static final String NOTIFY_LIMIT = "notify.limit";
|
"misc.allowed-cmds"
|
||||||
public static final String PW_MIN_LENGTH = "registration.pw-min-length";
|
};
|
||||||
public static final String ALLOWED_CMDS = "misc.allowed-cmds";
|
|
||||||
}
|
private static final String[][] keyUpdates =
|
||||||
|
{
|
||||||
|
{"misc.allow-change-pw", "misc.allow-changepw"},
|
||||||
|
{"misc.save-on-change", "misc.autosave"}
|
||||||
|
};
|
||||||
|
|
||||||
private static Configuration config;
|
private static Configuration config;
|
||||||
|
private static final ConcurrentHashMap<String, Object> defaults = new ConcurrentHashMap<String, Object>();
|
||||||
private static final ConcurrentHashMap<String, Object> settings = new ConcurrentHashMap<String, Object>();
|
private static final ConcurrentHashMap<String, Object> settings = new ConcurrentHashMap<String, Object>();
|
||||||
|
|
||||||
public Settings (File file)
|
public Settings(File file)
|
||||||
{
|
{
|
||||||
config = new Configuration(file);
|
config = new Configuration(file);
|
||||||
|
config.load();
|
||||||
|
fillDefaults();
|
||||||
|
|
||||||
|
if (file.exists() && keyUpdates.length > 0)
|
||||||
|
updateKeys();
|
||||||
|
|
||||||
load();
|
load();
|
||||||
|
config.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillDefaults()
|
||||||
|
{
|
||||||
|
defaults.put("registration.enabled", true);
|
||||||
|
defaults.put("registration.pw-min-length", 3);
|
||||||
|
defaults.put("session.timeout", 3600);
|
||||||
|
defaults.put("notify.limit", 5);
|
||||||
|
defaults.put("misc.allow-changepw", true);
|
||||||
|
defaults.put("misc.allowed-cmds", new String[]{"/register", "/login"});
|
||||||
|
defaults.put("misc.autosave", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateKeys()
|
||||||
|
{
|
||||||
|
String fromKey, toKey;
|
||||||
|
Object holder;
|
||||||
|
for (String[] update : keyUpdates)
|
||||||
|
{
|
||||||
|
fromKey = update[0];
|
||||||
|
if (config.getProperty(fromKey) != null)
|
||||||
|
{
|
||||||
|
toKey = update[1];
|
||||||
|
holder = config.getProperty(fromKey);
|
||||||
|
config.removeProperty(fromKey);
|
||||||
|
config.setProperty(toKey, holder);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load()
|
public void load()
|
||||||
{
|
{
|
||||||
config.load();
|
for (String key : keys)
|
||||||
|
|
||||||
//Booleans
|
|
||||||
String key = Keys.REG_ENABLED;
|
|
||||||
if (config.getProperty(key) == null)
|
|
||||||
config.setProperty(key, true);
|
|
||||||
settings.put(key, config.getBoolean(key, true));
|
|
||||||
|
|
||||||
key = Keys.ALLOW_CHANGE_PW;
|
|
||||||
if (config.getProperty(key) != null)
|
|
||||||
{
|
{
|
||||||
settings.put(key, config.getBoolean(key, true));
|
if (config.getProperty(key) == null)
|
||||||
config.removeProperty(key);
|
config.setProperty(key, defaults.get(key));
|
||||||
|
settings.put(key, config.getProperty(key));
|
||||||
}
|
}
|
||||||
key = Keys.ALLOW_CHANGEPW;
|
|
||||||
if (config.getProperty(key) == null)
|
|
||||||
config.setProperty(key, getBool(Keys.ALLOW_CHANGE_PW) == null ? true : getBool(Keys.ALLOW_CHANGE_PW));
|
|
||||||
settings.put(key, config.getBoolean(key, true));
|
|
||||||
|
|
||||||
key = Keys.SAVE_ON_CHANGE;
|
|
||||||
if (config.getProperty(key) != null)
|
|
||||||
{
|
|
||||||
settings.put(key, config.getBoolean(key, true));
|
|
||||||
config.removeProperty(key);
|
|
||||||
}
|
|
||||||
key = Keys.AUTOSAVE;
|
|
||||||
if (config.getProperty(key) == null)
|
|
||||||
config.setProperty(key, getBool(Keys.SAVE_ON_CHANGE) == null ? true : getBool(Keys.SAVE_ON_CHANGE));
|
|
||||||
settings.put(key, config.getBoolean(key, true));
|
|
||||||
//end Booleans
|
|
||||||
|
|
||||||
//Integers
|
|
||||||
key = Keys.SESSION_TIMEOUT;
|
|
||||||
if (config.getProperty(key) == null)
|
|
||||||
config.setProperty(key, 3600);
|
|
||||||
settings.put(key, config.getInt(key, 3600));
|
|
||||||
|
|
||||||
key = Keys.NOTIFY_LIMIT;
|
|
||||||
if (config.getProperty(key) == null)
|
|
||||||
config.setProperty(key, 5);
|
|
||||||
settings.put(key, config.getInt(key, 5));
|
|
||||||
|
|
||||||
key = Keys.PW_MIN_LENGTH;
|
|
||||||
if (config.getProperty(key) == null)
|
|
||||||
config.setProperty(key, 3);
|
|
||||||
settings.put(key, config.getInt(key, 3));
|
|
||||||
//end Integers
|
|
||||||
|
|
||||||
//String Arrays
|
|
||||||
key = Keys.ALLOWED_CMDS;
|
|
||||||
if (config.getProperty(key) == null)
|
|
||||||
config.setProperty(key, Arrays.asList(new String[] {"/register", "/login"}));
|
|
||||||
settings.put(key, config.getStringList(key, Arrays.asList(new String[] {"/register", "/login"})));
|
|
||||||
//end String Arrays
|
|
||||||
|
|
||||||
config.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(String key, Object value)
|
public void updateValue(String key, Object value)
|
||||||
{
|
{
|
||||||
settings.replace(key, value);
|
settings.replace(key, value);
|
||||||
config.setProperty(key, value);
|
config.setProperty(key, value);
|
||||||
@ -109,7 +98,7 @@ public class Settings
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public List<String> getStrArr(String key)
|
public List<String> getStrList(String key)
|
||||||
{
|
{
|
||||||
return (List<String>)settings.get(key);
|
return (List<String>)settings.get(key);
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,7 @@ public class Strings
|
|||||||
"register.success2"
|
"register.success2"
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final String[][] keyUpdates =
|
private static final String[][] keyUpdates = {};
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
private static Configuration config;
|
private static Configuration config;
|
||||||
private static final ConcurrentHashMap<String, String> defaults = new ConcurrentHashMap<String, String>();
|
private static final ConcurrentHashMap<String, String> defaults = new ConcurrentHashMap<String, String>();
|
||||||
|
@ -25,7 +25,6 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
import com.cypherx.xauth.Settings.Keys;
|
|
||||||
import com.nijiko.permissions.PermissionHandler;
|
import com.nijiko.permissions.PermissionHandler;
|
||||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||||
|
|
||||||
@ -40,6 +39,7 @@ public class xAuth extends JavaPlugin
|
|||||||
private final xAuthBlockListener blockListener = new xAuthBlockListener(this);
|
private final xAuthBlockListener blockListener = new xAuthBlockListener(this);
|
||||||
private final xAuthEntityListener entityListener = new xAuthEntityListener(this);
|
private final xAuthEntityListener entityListener = new xAuthEntityListener(this);
|
||||||
private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
|
private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
|
||||||
|
private static PluginDescriptionFile pdfFile;
|
||||||
|
|
||||||
private static final String DIR = "plugins/xAuth/";
|
private static final String DIR = "plugins/xAuth/";
|
||||||
private static final String CONFIG_FILE = "config.yml";
|
private static final String CONFIG_FILE = "config.yml";
|
||||||
@ -61,6 +61,8 @@ public class xAuth extends JavaPlugin
|
|||||||
|
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
|
pdfFile = this.getDescription();
|
||||||
|
|
||||||
/*Whirlpool w = new Whirlpool();
|
/*Whirlpool w = new Whirlpool();
|
||||||
byte[] digest = new byte[Whirlpool.DIGESTBYTES];
|
byte[] digest = new byte[Whirlpool.DIGESTBYTES];
|
||||||
w.NESSIEinit();
|
w.NESSIEinit();
|
||||||
@ -68,7 +70,6 @@ public class xAuth extends JavaPlugin
|
|||||||
w.NESSIEfinalize(digest);
|
w.NESSIEfinalize(digest);
|
||||||
System.out.println(Whirlpool.display(digest));*/
|
System.out.println(Whirlpool.display(digest));*/
|
||||||
|
|
||||||
PluginDescriptionFile pdfFile = this.getDescription();
|
|
||||||
PropertyManager props = new PropertyManager(new File("server.properties"));
|
PropertyManager props = new PropertyManager(new File("server.properties"));
|
||||||
if (props.a("online-mode", true))
|
if (props.a("online-mode", true))
|
||||||
{
|
{
|
||||||
@ -119,7 +120,7 @@ public class xAuth extends JavaPlugin
|
|||||||
pm.registerEvent(Event.Type.PLAYER_ITEM, playerListener, Event.Priority.Highest, this);
|
pm.registerEvent(Event.Type.PLAYER_ITEM, playerListener, Event.Priority.Highest, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Event.Priority.Highest, this);
|
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Event.Priority.Highest, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Event.Priority.Highest, this);
|
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Event.Priority.Highest, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Event.Priority.Highest, this);
|
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Event.Priority.Lowest, this);
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Highest, this);
|
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Highest, this);
|
||||||
//pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Highest, this);
|
//pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Highest, this);
|
||||||
@ -129,7 +130,6 @@ public class xAuth extends JavaPlugin
|
|||||||
pm.registerEvent(Event.Type.ENTITY_DAMAGED, entityListener, Priority.Highest, this);
|
pm.registerEvent(Event.Type.ENTITY_DAMAGED, entityListener, Priority.Highest, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_TARGET, entityListener, Priority.Highest, this);
|
pm.registerEvent(Event.Type.ENTITY_TARGET, entityListener, Priority.Highest, this);
|
||||||
|
|
||||||
//PluginDescriptionFile pdfFile = this.getDescription();
|
|
||||||
System.out.println("[" + pdfFile.getName() + "]" + " v" + pdfFile.getVersion() + " Enabled!");
|
System.out.println("[" + pdfFile.getName() + "]" + " v" + pdfFile.getVersion() + " Enabled!");
|
||||||
|
|
||||||
//autosave stuff
|
//autosave stuff
|
||||||
@ -138,7 +138,6 @@ public class xAuth extends JavaPlugin
|
|||||||
|
|
||||||
public void getAuths()
|
public void getAuths()
|
||||||
{
|
{
|
||||||
PluginDescriptionFile pdfFile = this.getDescription();
|
|
||||||
System.out.println("[" + pdfFile.getName() + "] Loading player accounts..");
|
System.out.println("[" + pdfFile.getName() + "] Loading player accounts..");
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -174,7 +173,6 @@ public class xAuth extends JavaPlugin
|
|||||||
if (fullyEnabled)
|
if (fullyEnabled)
|
||||||
updateAuthFile();
|
updateAuthFile();
|
||||||
|
|
||||||
PluginDescriptionFile pdfFile = this.getDescription();
|
|
||||||
System.out.println("[" + pdfFile.getName() + "]" + " v" + pdfFile.getVersion() + " Disabled");
|
System.out.println("[" + pdfFile.getName() + "]" + " v" + pdfFile.getVersion() + " Disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +197,7 @@ public class xAuth extends JavaPlugin
|
|||||||
String hash = md5(pass);
|
String hash = md5(pass);
|
||||||
auths.put(pName.toLowerCase(), pName.toLowerCase() + ":" + hash);
|
auths.put(pName.toLowerCase(), pName.toLowerCase() + ":" + hash);
|
||||||
|
|
||||||
if (settings.getBool(Keys.AUTOSAVE))
|
if (settings.getBool("misc.autosave"))
|
||||||
updateAuthFile();
|
updateAuthFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +216,7 @@ public class xAuth extends JavaPlugin
|
|||||||
auths.remove(pName.toLowerCase());
|
auths.remove(pName.toLowerCase());
|
||||||
auths.put(pName.toLowerCase(), pName.toLowerCase() + ":" + hash);
|
auths.put(pName.toLowerCase(), pName.toLowerCase() + ":" + hash);
|
||||||
|
|
||||||
if (settings.getBool(Keys.AUTOSAVE))
|
if (settings.getBool("misc.autosave"))
|
||||||
updateAuthFile();
|
updateAuthFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +228,7 @@ public class xAuth extends JavaPlugin
|
|||||||
if (sessionExists(pName))
|
if (sessionExists(pName))
|
||||||
removeSession(pName);
|
removeSession(pName);
|
||||||
|
|
||||||
if (settings.getBool(Keys.AUTOSAVE))
|
if (settings.getBool("misc.autosave"))
|
||||||
updateAuthFile();
|
updateAuthFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +274,7 @@ public class xAuth extends JavaPlugin
|
|||||||
{
|
{
|
||||||
Session session = sessions.get(pName.toLowerCase());
|
Session session = sessions.get(pName.toLowerCase());
|
||||||
|
|
||||||
if (session.isExpired(new Date(session.getLoginTime() + (settings.getInt(Keys.SESSION_TIMEOUT) * 1000))))
|
if (session.isExpired(new Date(session.getLoginTime() + (settings.getInt("session.timeout") * 1000))))
|
||||||
removeSession(pName);
|
removeSession(pName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -297,7 +295,7 @@ public class xAuth extends JavaPlugin
|
|||||||
|
|
||||||
public Boolean isCmdAllowed(String cmd)
|
public Boolean isCmdAllowed(String cmd)
|
||||||
{
|
{
|
||||||
if (settings.getStrArr(Keys.ALLOWED_CMDS).contains(cmd))
|
if (settings.getStrList("misc.allowed-cmds").contains(cmd))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -308,7 +306,7 @@ public class xAuth extends JavaPlugin
|
|||||||
if (lastNotifyTimes.get(player) == null)
|
if (lastNotifyTimes.get(player) == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Date nextNotifyTime = new Date(lastNotifyTimes.get(player).getTime() + (settings.getInt(Keys.NOTIFY_LIMIT) * 1000));
|
Date nextNotifyTime = new Date(lastNotifyTimes.get(player).getTime() + (settings.getInt("notify.limit") * 1000));
|
||||||
if (nextNotifyTime.compareTo(new Date()) < 0)
|
if (nextNotifyTime.compareTo(new Date()) < 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -323,9 +321,8 @@ public class xAuth extends JavaPlugin
|
|||||||
|
|
||||||
public void updateNotifyTime(Player player, Date date)
|
public void updateNotifyTime(Player player, Date date)
|
||||||
{
|
{
|
||||||
lastNotifyTimes.replace(player, date);
|
lastNotifyTimes.remove(player);
|
||||||
//lastNotifyTimes.remove(player);
|
lastNotifyTimes.put(player, date);
|
||||||
//lastNotifyTimes.put(player, date);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//INVENTORY FUNCTIONS
|
//INVENTORY FUNCTIONS
|
||||||
@ -395,7 +392,7 @@ public class xAuth extends JavaPlugin
|
|||||||
public Boolean isSessionValid(Player player)
|
public Boolean isSessionValid(Player player)
|
||||||
{
|
{
|
||||||
Session session = sessions.get(player.getName().toLowerCase());
|
Session session = sessions.get(player.getName().toLowerCase());
|
||||||
if (session.isExpired(new Date(session.getLoginTime() + (settings.getInt(Keys.SESSION_TIMEOUT) * 1000))))
|
if (session.isExpired(new Date(session.getLoginTime() + (settings.getInt("session.timeout") * 1000))))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!session.isValidAddr(player.getAddress().getAddress().getHostAddress()))
|
if (!session.isValidAddr(player.getAddress().getAddress().getHostAddress()))
|
||||||
@ -414,7 +411,6 @@ public class xAuth extends JavaPlugin
|
|||||||
//MISC FUNCTIONS
|
//MISC FUNCTIONS
|
||||||
private void setupPermissions()
|
private void setupPermissions()
|
||||||
{
|
{
|
||||||
PluginDescriptionFile pdfFile = this.getDescription();
|
|
||||||
Plugin test = this.getServer().getPluginManager().getPlugin("Permissions");
|
Plugin test = this.getServer().getPluginManager().getPlugin("Permissions");
|
||||||
|
|
||||||
if (xAuth.Permissions == null)
|
if (xAuth.Permissions == null)
|
||||||
@ -465,7 +461,6 @@ public class xAuth extends JavaPlugin
|
|||||||
|
|
||||||
public void reload()
|
public void reload()
|
||||||
{
|
{
|
||||||
PluginDescriptionFile pdfFile = this.getDescription();
|
|
||||||
updateAuthFile();
|
updateAuthFile();
|
||||||
settings = new Settings(new File(DIR + CONFIG_FILE));
|
settings = new Settings(new File(DIR + CONFIG_FILE));
|
||||||
strings = new Strings(new File(DIR + STRINGS_FILE));
|
strings = new Strings(new File(DIR + STRINGS_FILE));
|
||||||
|
@ -4,20 +4,25 @@ version: 1.1.4
|
|||||||
|
|
||||||
commands:
|
commands:
|
||||||
register:
|
register:
|
||||||
description:
|
description: Register your player name
|
||||||
usage:
|
usage: /register <password>
|
||||||
login:
|
login:
|
||||||
description:
|
description: Authenticate yourself
|
||||||
usage:
|
usage: /login <password>
|
||||||
changepw:
|
changepw:
|
||||||
description:
|
description: Change your or another players password
|
||||||
usage:
|
usage: |
|
||||||
|
/changepw <password>
|
||||||
|
/changepw <player> <password>
|
||||||
unregister:
|
unregister:
|
||||||
description:
|
description: Remove a players registration
|
||||||
usage:
|
usage: /unregister <player>
|
||||||
authreload:
|
authreload:
|
||||||
description:
|
description: Reload the account, configuration, and string files
|
||||||
usage:
|
usage: /authreload
|
||||||
toggle:
|
toggle:
|
||||||
description:
|
description: Toggle various commands on/off
|
||||||
usage:
|
usage: |
|
||||||
|
/toggle reg
|
||||||
|
/toggle changepw
|
||||||
|
/toggle autosave
|
Loading…
Reference in New Issue
Block a user