1
0
mirror of https://github.com/moparisthebest/xAuth synced 2024-12-22 07:08:51 -05:00

1. Accounts/Session are now reloaded from the database when a player joins the server to take external changes into effect

2. Allowed commands configuration (guest.allowed-commands)
3. Inventory protection now stores items and armor in the database to prevent item loss
4. register.error.disabled message fixed
This commit is contained in:
Zach Iverson 2011-06-24 17:00:12 -04:00
parent 79d5332e1d
commit 581609eede
16 changed files with 280 additions and 69 deletions

View File

@ -3,7 +3,7 @@ package com.cypherx.xauth;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
//import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
@ -80,7 +80,7 @@ public class Util {
return sb.toString();
}
public static boolean getOnlineMode() {
/*public static boolean getOnlineMode() {
BufferedReader br = null;
String value = null;
String line;
@ -99,7 +99,7 @@ public class Util {
}
return Boolean.parseBoolean(value);
}
}*/
public static boolean isValidName(Player player) {
String playerName = player.getName().toLowerCase();
@ -199,4 +199,13 @@ public class Util {
public static Timestamp getNow() {
return new Timestamp(System.currentTimeMillis());
}
public static int[] stringToInt(String[] strArray) {
int[] intArray = new int[strArray.length];
for (int i = 0; i < strArray.length; i++)
intArray[i] = Integer.parseInt(strArray[i]);
return intArray;
}
}

View File

@ -23,7 +23,7 @@ public class ChangePasswordCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player)sender;
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(player.getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayer(player.getName());
if (!xAuthSettings.pwAllowChange) {
xAuthMessages.send("cpwErrDisabled", player);

View File

@ -22,7 +22,7 @@ public class LoginCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player)sender;
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(player.getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayer(player.getName());
if (args.length < 1) {
xAuthMessages.send("loginUsage", player);

View File

@ -19,7 +19,7 @@ public class LogoutCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player)sender;
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(player.getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayer(player.getName());
if (!xPlayer.hasSession()) {
xAuthMessages.send("logoutErrLogged", player);

View File

@ -23,7 +23,7 @@ public class RegisterCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player)sender;
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(player.getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayer(player.getName());
if (!xAuthSettings.regEnabled) {
xAuthMessages.send("regErrDisabled", player);

View File

@ -72,7 +72,7 @@ public class xAuthCommand implements CommandExecutor {
String targetName = args[1];
String password = args[2];
String email = (args.length > 3 ? args[3] : null);
xAuthPlayer xPlayer = dataManager.getPlayerByName(targetName);
xAuthPlayer xPlayer = dataManager.getPlayer(targetName);
if (xPlayer.isRegistered()) {
xAuthMessages.send("admnRegRegistered", player, xPlayer.getPlayer());
@ -94,7 +94,7 @@ public class xAuthCommand implements CommandExecutor {
String targetName = args[1];
String password = args[2];
String email = (args.length > 3 ? args[3] : null);
xAuthPlayer xPlayer = dataManager.getPlayerByName(targetName);
xAuthPlayer xPlayer = dataManager.getPlayer(targetName);
if (xPlayer.isRegistered()) {
xAuthLog.info(targetName + " is already registered!");
@ -124,7 +124,7 @@ public class xAuthCommand implements CommandExecutor {
}
String targetName = args[1];
xAuthPlayer xPlayer = dataManager.getPlayerByName(targetName);
xAuthPlayer xPlayer = dataManager.getPlayer(targetName);
if (!xPlayer.isRegistered()) {
xAuthMessages.send("admnCpwRegistered", player, xPlayer.getPlayer());
@ -144,7 +144,7 @@ public class xAuthCommand implements CommandExecutor {
}
String targetName = args[1];
xAuthPlayer xPlayer = dataManager.getPlayerByName(targetName);
xAuthPlayer xPlayer = dataManager.getPlayer(targetName);
if (!xPlayer.isRegistered()) {
xAuthLog.info("This player is not registered!");
@ -174,7 +174,7 @@ public class xAuthCommand implements CommandExecutor {
}
String targetName = args[1];
xAuthPlayer xPlayer = dataManager.getPlayerByName(targetName);
xAuthPlayer xPlayer = dataManager.getPlayer(targetName);
if (!xPlayer.hasSession()) {
xAuthMessages.send("admnLogoutLogged", player, xPlayer.getPlayer());
@ -194,7 +194,7 @@ public class xAuthCommand implements CommandExecutor {
}
String targetName = args[1];
xAuthPlayer xPlayer = dataManager.getPlayerByName(targetName);
xAuthPlayer xPlayer = dataManager.getPlayer(targetName);
if (!xPlayer.hasSession()) {
xAuthLog.info(targetName + " is not logged in!");
@ -224,7 +224,7 @@ public class xAuthCommand implements CommandExecutor {
}
String targetName = args[1];
xAuthPlayer xPlayer = dataManager.getPlayerByName(targetName);
xAuthPlayer xPlayer = dataManager.getPlayer(targetName);
if (!xPlayer.isRegistered()) {
xAuthMessages.send("admnUnregRegistered", player, xPlayer.getPlayer());
@ -248,7 +248,7 @@ public class xAuthCommand implements CommandExecutor {
}
String targetName = args[1];
xAuthPlayer xPlayer = dataManager.getPlayerByName(targetName);
xAuthPlayer xPlayer = dataManager.getPlayer(targetName);
if (!xPlayer.isRegistered()) {
xAuthLog.info(targetName + " is not registered!");

View File

@ -9,10 +9,14 @@ import java.sql.Statement;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.cypherx.xauth.Account;
import com.cypherx.xauth.Session;
import com.cypherx.xauth.StrikeBan;
import com.cypherx.xauth.TeleLocation;
import com.cypherx.xauth.Util;
import com.cypherx.xauth.xAuth;
import com.cypherx.xauth.xAuthLog;
import com.cypherx.xauth.xAuthPlayer;
@ -148,12 +152,136 @@ public class DataManager {
"PRIMARY KEY(`host`)" +
")"
);
stmt.execute(
"CREATE TABLE IF NOT EXISTS `inventory` (" +
"`playername` VARCHAR(255) NOT NULL," +
"`itemid` TEXT NOT NULL," +
"`amount` TEXT NOT NULL," +
"`durability` TEXT NOT NULL," +
"PRIMARY KEY (`playername`)" +
")"
);
} catch (SQLException e) {
xAuthLog.severe("Could not check/create database tables!", e);
}
}
public xAuthPlayer getPlayerByName(String playerName) {
public void insertInventory(xAuthPlayer xPlayer) {
try {
prepStmt = connection.prepareStatement(
"SELECT *" +
" FROM `" + xAuthSettings.tblInventory + "`" +
" WHERE `playername` = ?"
);
prepStmt.setString(1, xPlayer.getPlayerName());
rs = prepStmt.executeQuery();
if (rs.next())
return;
} catch (SQLException e) {
xAuthLog.severe("Could not check inventory for player: " + xPlayer.getPlayerName(), e);
}
PlayerInventory inv = xPlayer.getPlayer().getInventory();
StringBuilder sbItems = new StringBuilder();
StringBuilder sbAmount = new StringBuilder();
StringBuilder sbDurability = new StringBuilder();
for (ItemStack item : inv.getContents()) {
int itemid = 0;
int amount = 0;
short durability = 0;
if (item != null) {
itemid = item.getTypeId();
amount = item.getAmount();
durability = item.getDurability();
}
sbItems.append(itemid + ",");
sbAmount.append(amount + ",");
sbDurability.append(durability + ",");
}
for (ItemStack item : inv.getArmorContents()) {
int itemid = 0;
int amount = 0;
short durability = 0;
if (item != null) {
itemid = item.getTypeId();
amount = item.getAmount();
durability = item.getDurability();
}
sbItems.append(itemid + ",");
sbAmount.append(amount + ",");
sbDurability.append(durability + ",");
}
sbItems.deleteCharAt(sbItems.lastIndexOf(","));
sbAmount.deleteCharAt(sbAmount.lastIndexOf(","));
sbDurability.deleteCharAt(sbDurability.lastIndexOf(","));
try {
prepStmt = connection.prepareStatement(
"INSERT INTO `" + xAuthSettings.tblInventory + "`" +
" VALUES" +
"(?, ?, ?, ?)"
);
prepStmt.setString(1, xPlayer.getPlayerName());
prepStmt.setString(2, sbItems.toString());
prepStmt.setString(3, sbAmount.toString());
prepStmt.setString(4, sbDurability.toString());
prepStmt.executeUpdate();
} catch (SQLException e) {
xAuthLog.severe("Could not insert inventory for player: " + xPlayer.getPlayerName(), e);
}
}
public ItemStack[] getInventory(xAuthPlayer xPlayer) {
try {
prepStmt = connection.prepareStatement(
"SELECT *" +
" FROM `" + xAuthSettings.tblInventory + "`" +
" WHERE `playername` = ?"
);
prepStmt.setString(1, xPlayer.getPlayerName());
rs = prepStmt.executeQuery();
if (rs.next()) {
int[] itemid = Util.stringToInt(rs.getString("itemid").split(","));
int[] amount = Util.stringToInt(rs.getString("amount").split(","));
int[] durability = Util.stringToInt(rs.getString("durability").split(","));
ItemStack[] inv = new ItemStack[itemid.length];
for (int i = 0; i < inv.length; i++)
inv[i] = new ItemStack(itemid[i], amount[i], (short)durability[i]);
return inv;
}
} catch (SQLException e) {
xAuthLog.severe("Could not load inventory for player: " + xPlayer.getPlayerName(), e);
}
return null;
}
public void deleteInventory(xAuthPlayer xPlayer) {
try {
prepStmt = connection.prepareStatement(
"DELETE FROM `" + xAuthSettings.tblInventory + "`" +
" WHERE `playername` = ?"
);
prepStmt.setString(1, xPlayer.getPlayerName());
prepStmt.executeUpdate();
} catch (SQLException e) {
xAuthLog.severe("Could not delete inventory for player: " + xPlayer.getPlayerName(), e);
}
}
public xAuthPlayer getPlayer(String playerName) {
String lowPlayerName = playerName.toLowerCase();
if (playerCache.containsKey(lowPlayerName))
@ -167,6 +295,20 @@ public class DataManager {
return xPlayer;
}
public xAuthPlayer getPlayerJoin(String playerName) {
String lowPlayerName = playerName.toLowerCase();
if (playerCache.containsKey(lowPlayerName))
return reloadPlayer(playerCache.get(lowPlayerName));
xAuthPlayer xPlayer = getPlayerFromDb(playerName);
if (xPlayer == null)
xPlayer = new xAuthPlayer(playerName);
playerCache.put(lowPlayerName, xPlayer);
return xPlayer;
}
public xAuthPlayer getPlayerFromDb(String playerName) {
xAuthPlayer xPlayer = null;
@ -190,6 +332,29 @@ public class DataManager {
return xPlayer;
}
public xAuthPlayer reloadPlayer(xAuthPlayer xPlayer) {
try {
prepStmt = connection.prepareStatement(
"SELECT a.*, s.*" +
" FROM `" + xAuthSettings.tblAccount + "` a" +
" LEFT JOIN `" + xAuthSettings.tblSession + "` s" +
" ON a.id = s.accountid" +
" WHERE `playername` = ?"
);
prepStmt.setString(1, xPlayer.getPlayerName());
rs = prepStmt.executeQuery();
if (rs.next()) {
xPlayer.setAccount(buildAccount(rs));
xPlayer.setSession(buildSession(rs));
}
} catch (SQLException e) {
xAuthLog.severe("Could not reload player: " + xPlayer.getPlayerName(), e);
}
return xPlayer;
}
public int getActive(String playerName) {
try {
prepStmt = connection.prepareStatement(

View File

@ -26,7 +26,7 @@ public class xAuthBlockListener extends BlockListener {
if (event.isCancelled())
return;
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(event.getPlayer().getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayer(event.getPlayer().getName());
//if (!xAuthSettings.rstrBreak && !xPlayer.isRegistered())
//return;
@ -43,7 +43,7 @@ public class xAuthBlockListener extends BlockListener {
if (event.isCancelled())
return;
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(event.getPlayer().getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayer(event.getPlayer().getName());
//if (!xAuthSettings.rstrPlace && !xPlayer.isRegistered())
//return;

View File

@ -31,7 +31,7 @@ public class xAuthEntityListener extends EntityListener {
Entity entity = event.getEntity();
if (entity instanceof Player && ((Player)entity).isOnline()) { // player taking damage
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(((Player)entity).getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayer(((Player)entity).getName());
//if (!xAuthSettings.rstrDmgTaken && !xPlayer.isRegistered())
//return;
@ -46,7 +46,7 @@ public class xAuthEntityListener extends EntityListener {
Entity damager = edbeEvent.getDamager();
if (damager instanceof Player) {
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(((Player)damager).getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayer(((Player)damager).getName());
//if (!xAuthSettings.rstrDmgGiven && !xPlayer.isRegistered())
//return;
@ -67,7 +67,7 @@ public class xAuthEntityListener extends EntityListener {
Entity target = event.getTarget();
if (target instanceof Player) {
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(((Player)target).getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayer(((Player)target).getName());
//if (!xAuthSettings.rstrMobTarget && !xPlayer.isRegistered())
//return;

View File

@ -1,6 +1,5 @@
package com.cypherx.xauth.listeners;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
@ -55,7 +54,7 @@ public class xAuthPlayerListener extends PlayerListener {
public void onPlayerJoin(PlayerJoinEvent event) {
final Player player = event.getPlayer();
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(player.getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerJoin(player.getName());
boolean isRegistered = xPlayer.isRegistered();
if (!xPlayer.isAuthenticated() && (isRegistered || (!isRegistered && xPlayer.mustRegister()))) {
@ -89,7 +88,7 @@ public class xAuthPlayerListener extends PlayerListener {
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(player.getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayer(player.getName());
if (xPlayer.isGuest())
plugin.removeGuest(xPlayer);
@ -104,7 +103,7 @@ public class xAuthPlayerListener extends PlayerListener {
if (event.isCancelled())
return;
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(event.getPlayer().getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayer(event.getPlayer().getName());
//if (!xAuthSettings.rstrChat && !xPlayer.isRegistered())
//return;
@ -121,15 +120,17 @@ public class xAuthPlayerListener extends PlayerListener {
if (event.isCancelled())
return;
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(event.getPlayer().getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayer(event.getPlayer().getName());
//if (!xAuthSettings.rstrCommands && !xPlayer.isRegistered())
//return;
if (xPlayer.isGuest()) {
String command = event.getMessage().split(" ")[0];
String command = event.getMessage().split(" ")[0].replaceFirst("/", "");
if (xAuthSettings.allowedCmds.contains(command))
return;
if (!command.equals("/register") && !command.equals("/login") && !command.equals("/l")) {
if (xPlayer.canNotify())
xPlayer.sendIllegalActionNotice();
@ -137,13 +138,12 @@ public class xAuthPlayerListener extends PlayerListener {
event.setCancelled(true);
}
}
}
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.isCancelled())
return;
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(event.getPlayer().getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayer(event.getPlayer().getName());
//if (!xAuthSettings.rstrInteract && !xPlayer.isRegistered())
//return;
@ -154,7 +154,6 @@ public class xAuthPlayerListener extends PlayerListener {
if (action == Action.LEFT_CLICK_BLOCK) {
if (type == Material.NOTE_BLOCK
//|| type == Material.TNT
|| type == Material.WOODEN_DOOR
|| type == Material.LEVER
|| type == Material.IRON_DOOR
@ -189,10 +188,6 @@ public class xAuthPlayerListener extends PlayerListener {
event.setCancelled(true);
}
}
/*xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(event.getPlayer().getName());
if (xPlayer.isGuest())
event.setCancelled(true);*/
}
public void onPlayerMove(PlayerMoveEvent event) {
@ -200,21 +195,22 @@ public class xAuthPlayerListener extends PlayerListener {
return;
Player player = event.getPlayer();
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(player.getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayer(player.getName());
//if (!xAuthSettings.rstrMovement && !xPlayer.isRegistered())
//return;
if (xPlayer.isGuest()) {
Location loc = plugin.getLocationToTeleport(player.getWorld());
player.teleport(loc);
event.setFrom(loc);
event.setTo(loc);
//Location loc = plugin.getLocationToTeleport(player.getWorld());
//player.teleport(loc);
//event.setFrom(loc);
event.setTo(plugin.getLocationToTeleport(player.getWorld()));
if (xPlayer.canNotify())
xPlayer.sendIllegalActionNotice();
event.setCancelled(true);
//event.setCancelled(true);
}
}
@ -222,7 +218,7 @@ public class xAuthPlayerListener extends PlayerListener {
if (event.isCancelled())
return;
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(event.getPlayer().getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayer(event.getPlayer().getName());
//if (!xAuthSettings.rstrPickup && !xPlayer.isRegistered())
//return;

View File

@ -29,7 +29,7 @@ public class xAuth extends JavaPlugin {
Player[] players = getServer().getOnlinePlayers();
if (players.length > 0) {
for (Player player : players) {
xAuthPlayer xPlayer = dataManager.getPlayerByName(player.getName());
xAuthPlayer xPlayer = dataManager.getPlayer(player.getName());
if (xPlayer.isGuest())
removeGuest(xPlayer);
}
@ -52,7 +52,8 @@ public class xAuth extends JavaPlugin {
xAuthSettings.setup(dataFolder);
xAuthMessages.setup(dataFolder);
if (xAuthSettings.autoDisable && Util.getOnlineMode()) {
// Util.getOnlineMode() -> getServer().getOnlineMode()
if (xAuthSettings.autoDisable && getServer().getOnlineMode()) {
xAuthLog.warning("Disabling - Server is running in online-mode");
getServer().getPluginManager().disablePlugin(this);
return;
@ -125,7 +126,7 @@ public class xAuth extends JavaPlugin {
private void handleReload(Player[] players) {
for (Player player : players) {
xAuthPlayer xPlayer = dataManager.getPlayerByName(player.getName());
xAuthPlayer xPlayer = dataManager.getPlayerJoin(player.getName());
boolean isRegistered = xPlayer.isRegistered();
if (!xPlayer.isAuthenticated() && (isRegistered || (!isRegistered && xPlayer.mustRegister()))) {
@ -167,8 +168,9 @@ public class xAuth extends JavaPlugin {
Player player = xPlayer.getPlayer();
PlayerInventory playerInv = player.getInventory();
xPlayer.setInventory(playerInv.getContents());
xPlayer.setArmor(playerInv.getArmorContents());
dataManager.insertInventory(xPlayer);
//xPlayer.setInventory(playerInv.getContents());
//xPlayer.setArmor(playerInv.getArmorContents());
playerInv.clear();
playerInv.setHelmet(null);
playerInv.setChestplate(null);
@ -179,15 +181,41 @@ public class xAuth extends JavaPlugin {
if (player.getHealth() > 0)
xPlayer.setLocation(player.getLocation());
Location loc = getLocationToTeleport(player.getWorld());
player.teleport(loc);
player.teleport(getLocationToTeleport(player.getWorld()));
}
public void restore(xAuthPlayer xPlayer) {
Player player = xPlayer.getPlayer();
PlayerInventory playerInv = player.getInventory();
ItemStack[] inv = xPlayer.getInventory();
ItemStack[] inv = dataManager.getInventory(xPlayer);
ItemStack[] items = new ItemStack[inv.length - 4];
ItemStack[] armor = new ItemStack[4];
for (int i = 0; i < inv.length - 4; i++)
items[i] = inv[i];
//Backpack fix
if (playerInv.getSize() > items.length) {
ItemStack[] newItems = new ItemStack[playerInv.getSize()];
for(int i = 0; i < items.length; i++)
newItems[i] = items[i];
items = newItems;
}
//end Backpack fix
armor[0] = inv[inv.length - 4];
armor[1] = inv[inv.length - 3];
armor[2] = inv[inv.length - 2];
armor[3] = inv[inv.length - 1];
playerInv.setContents(items);
playerInv.setArmorContents(armor);
dataManager.deleteInventory(xPlayer);
/*ItemStack[] inv = xPlayer.getInventory();
//Backpack fix
if (playerInv.getSize() > inv.length) {
ItemStack[] newInv = new ItemStack[playerInv.getSize()];
@ -200,7 +228,7 @@ public class xAuth extends JavaPlugin {
//end Backpack fix
playerInv.setContents(inv);
playerInv.setArmorContents(xPlayer.getArmor());
playerInv.setArmorContents(xPlayer.getArmor());*/
if (xPlayer.getLocation() != null)
xPlayer.getPlayer().teleport(xPlayer.getLocation());

View File

@ -106,7 +106,7 @@ public class xAuthMessages {
regUsage = getString("register.usage", regUsage);
regSuccess = getString("register.success", regSuccess);
regErrDisabled = getString("register.error.disable", regErrDisabled);
regErrDisabled = getString("register.error.disabled", regErrDisabled);
regErrRegistered = getString("register.error.registered", regErrRegistered);
regErrMultiple = getString("register.error.multiple", regErrMultiple);
regErrPassword = getString("register.error.password", regErrPassword);

View File

@ -5,7 +5,7 @@ import java.sql.Timestamp;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
//import org.bukkit.inventory.ItemStack;
public class xAuthPlayer {
private String playerName;
@ -13,8 +13,8 @@ public class xAuthPlayer {
private Session session;
private boolean guest = false;
private Location location;
private ItemStack[] inventory;
private ItemStack[] armor;
//private ItemStack[] inventory;
//private ItemStack[] armor;
private Timestamp lastNotifyTime;
private int strikes = 0;
private int timeoutTaskId;
@ -127,7 +127,7 @@ public class xAuthPlayer {
return location;
}
public void setInventory(ItemStack[] inventory) {
/*public void setInventory(ItemStack[] inventory) {
this.inventory = inventory;
}
@ -141,7 +141,7 @@ public class xAuthPlayer {
public ItemStack[] getArmor() {
return armor;
}
}*/
public void setLastNotifyTime(Timestamp lastNotifyTime) {
this.lastNotifyTime = lastNotifyTime;

View File

@ -1,6 +1,8 @@
package com.cypherx.xauth;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import org.bukkit.util.config.Configuration;
@ -24,6 +26,7 @@ public class xAuthSettings {
public static String tblSession = "sessions";
public static String tblStrike = "strike_bans";
public static String tblLocation = "tele_locations";
public static String tblInventory = "inventory";
/*public static String colAccId = "id";
public static String colAccPlayerName = "playername";
public static String colAccPassword = "password";
@ -58,6 +61,7 @@ public class xAuthSettings {
// guest
public static int guestTimeout = 300;
public static int notifyCooldown = 5;
public static List<String> allowedCmds = Arrays.asList(new String[]{"register", "login", "l"});
// session
public static int sessionLength = 3600;
@ -84,7 +88,7 @@ public class xAuthSettings {
/*
* REMEMBER TO CHANGE VERSION AFTER MODIFYING DEFAULT SETTINGS
*/
public static int version = 1;
public static int version = 2;
public static void setup(File dataFolder) {
file = new File(dataFolder, "config.yml");
@ -114,6 +118,7 @@ public class xAuthSettings {
tblSession = getString("mysql.tables.session", tblSession);
tblStrike = getString("mysql.tables.strike", tblStrike);
tblLocation = getString("mysql.tables.location", tblLocation);
tblInventory = getString("mysql.tables.inventory", tblInventory);
/*colAccId = getString("mysql.columns.account.id", colAccId);
colAccPlayerName = getString("mysql.columns.account.playername", colAccPlayerName);
colAccPassword = getString("mysql.columns.account.password", colAccPassword);
@ -144,6 +149,7 @@ public class xAuthSettings {
guestTimeout = getInt("guest.timeout", guestTimeout);
notifyCooldown = getInt("guest.notify-cooldown", notifyCooldown);
allowedCmds = getStrList("guest.allowed-commands", allowedCmds);
sessionLength = getInt("session.length", sessionLength);
verifyIp = getBool("session.verifyip", verifyIp);
@ -177,6 +183,10 @@ public class xAuthSettings {
return config.getBoolean(key, def);
}
private static List<String> getStrList(String key, List<String> def) {
return config.getStringList(key, def);
}
private static void update() {
if (version > getInt("version", version)) {
xAuthLog.info("Updating file: config.yml");

View File

@ -29,6 +29,7 @@ mysql:
session: [tblSession]
strike: [tblStrike]
location: [tblLocation]
inventory: [tblInventory]
registration:
# Enable/disable new registrations
@ -74,6 +75,8 @@ guest:
timeout: [guestTimeout]
# Amount of time, in seconds, between "You must be logged in.." messages
notify-cooldown: [notifyCooldown]
# Commands that players who are not registered or logged in may execute
allowed-commands: [allowedCmds]
session:
# Amount of time, in seconds, that a session will remain valid

View File

@ -1,6 +1,6 @@
name: xAuth
main: com.cypherx.xauth.xAuth
version: 2.0b2
version: 2.0b3
description: Offline-Mode Security Suite
author: CypherX
commands: