1. Fixed a bunch of issues with disabling forced registration
2. Database connection will be reestablised if the previous connection is closed 3. Location protection can now be turned on/off 4. Cleaned up code
This commit is contained in:
parent
69aeb90688
commit
500a9ac0dd
|
@ -3,7 +3,6 @@ package com.cypherx.xauth;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
//import java.io.FileReader;
|
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -20,10 +19,6 @@ import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.avaje.ebean.validation.factory.EmailValidatorFactory;
|
import com.avaje.ebean.validation.factory.EmailValidatorFactory;
|
||||||
|
|
||||||
/*
|
|
||||||
* Miscellaneous methods
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class Util {
|
public class Util {
|
||||||
public static void writeConfig(File file, Class<?> c) {
|
public static void writeConfig(File file, Class<?> c) {
|
||||||
String fileName = file.getName();
|
String fileName = file.getName();
|
||||||
|
@ -80,27 +75,6 @@ public class Util {
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static boolean getOnlineMode() {
|
|
||||||
BufferedReader br = null;
|
|
||||||
String value = null;
|
|
||||||
String line;
|
|
||||||
|
|
||||||
try {
|
|
||||||
br = new BufferedReader(new FileReader("server.properties"));
|
|
||||||
while ((line = br.readLine()).indexOf("online-mode") == -1);
|
|
||||||
value = line.split("=")[1];
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (br != null)
|
|
||||||
br.close();
|
|
||||||
} catch (IOException e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Boolean.parseBoolean(value);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public static boolean isValidName(Player player) {
|
public static boolean isValidName(Player player) {
|
||||||
String playerName = player.getName().toLowerCase();
|
String playerName = player.getName().toLowerCase();
|
||||||
if (playerName.length() < xAuthSettings.filterMinLength)
|
if (playerName.length() < xAuthSettings.filterMinLength)
|
||||||
|
|
|
@ -235,6 +235,7 @@ public class xAuthCommand implements CommandExecutor {
|
||||||
|
|
||||||
Player target = xPlayer.getPlayer();
|
Player target = xPlayer.getPlayer();
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
|
if (xPlayer.mustRegister())
|
||||||
plugin.createGuest(xPlayer);
|
plugin.createGuest(xPlayer);
|
||||||
xAuthMessages.send("admnUnregSuccessTgt", target);
|
xAuthMessages.send("admnUnregSuccessTgt", target);
|
||||||
}
|
}
|
||||||
|
@ -259,6 +260,7 @@ public class xAuthCommand implements CommandExecutor {
|
||||||
|
|
||||||
Player target = xPlayer.getPlayer();
|
Player target = xPlayer.getPlayer();
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
|
if (xPlayer.mustRegister())
|
||||||
plugin.createGuest(xPlayer);
|
plugin.createGuest(xPlayer);
|
||||||
target.sendMessage("You have been unregistered and logged out!");
|
target.sendMessage("You have been unregistered and logged out!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,10 @@ public class DataManager {
|
||||||
private ConcurrentHashMap<String, TeleLocation> teleLocations = new ConcurrentHashMap<String, TeleLocation>();
|
private ConcurrentHashMap<String, TeleLocation> teleLocations = new ConcurrentHashMap<String, TeleLocation>();
|
||||||
|
|
||||||
public DataManager() {
|
public DataManager() {
|
||||||
|
connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void connect() {
|
||||||
if (xAuthSettings.datasource.equals("mysql"))
|
if (xAuthSettings.datasource.equals("mysql"))
|
||||||
connectMySQL();
|
connectMySQL();
|
||||||
else
|
else
|
||||||
|
@ -83,6 +87,9 @@ public class DataManager {
|
||||||
"WHERE NOW() > DATEADD('SECOND', " + xAuthSettings.sessionLength + ", `logintime`)";
|
"WHERE NOW() > DATEADD('SECOND', " + xAuthSettings.sessionLength + ", `logintime`)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
// delete expired sessions
|
// delete expired sessions
|
||||||
try {
|
try {
|
||||||
stmt.executeUpdate(sql);
|
stmt.executeUpdate(sql);
|
||||||
|
@ -91,22 +98,10 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printStats() {
|
|
||||||
try {
|
|
||||||
rs = stmt.executeQuery(
|
|
||||||
"SELECT" +
|
|
||||||
" (SELECT COUNT(*) FROM `" + xAuthSettings.tblAccount + "`) AS accounts," +
|
|
||||||
" (SELECT COUNT(*) FROM `" + xAuthSettings.tblSession + "`) AS sessions"
|
|
||||||
);
|
|
||||||
|
|
||||||
if (rs.next())
|
|
||||||
xAuthLog.info("Accounts: " + rs.getInt("accounts") + ", Sessions: " + rs.getInt("sessions"));
|
|
||||||
} catch (SQLException e) {
|
|
||||||
xAuthLog.severe("Could not fetch xAuth statistics!", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void createTables() {
|
public void createTables() {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
stmt.execute(
|
stmt.execute(
|
||||||
"CREATE TABLE IF NOT EXISTS `" + xAuthSettings.tblAccount + "` (" +
|
"CREATE TABLE IF NOT EXISTS `" + xAuthSettings.tblAccount + "` (" +
|
||||||
|
@ -167,7 +162,28 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void printStats() {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
|
try {
|
||||||
|
rs = stmt.executeQuery(
|
||||||
|
"SELECT" +
|
||||||
|
" (SELECT COUNT(*) FROM `" + xAuthSettings.tblAccount + "`) AS accounts," +
|
||||||
|
" (SELECT COUNT(*) FROM `" + xAuthSettings.tblSession + "`) AS sessions"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (rs.next())
|
||||||
|
xAuthLog.info("Accounts: " + rs.getInt("accounts") + ", Sessions: " + rs.getInt("sessions"));
|
||||||
|
} catch (SQLException e) {
|
||||||
|
xAuthLog.severe("Could not fetch xAuth statistics!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void insertInventory(xAuthPlayer xPlayer) {
|
public void insertInventory(xAuthPlayer xPlayer) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
prepStmt = connection.prepareStatement(
|
prepStmt = connection.prepareStatement(
|
||||||
"SELECT *" +
|
"SELECT *" +
|
||||||
|
@ -241,6 +257,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack[] getInventory(xAuthPlayer xPlayer) {
|
public ItemStack[] getInventory(xAuthPlayer xPlayer) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
prepStmt = connection.prepareStatement(
|
prepStmt = connection.prepareStatement(
|
||||||
"SELECT *" +
|
"SELECT *" +
|
||||||
|
@ -269,6 +288,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteInventory(xAuthPlayer xPlayer) {
|
public void deleteInventory(xAuthPlayer xPlayer) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
prepStmt = connection.prepareStatement(
|
prepStmt = connection.prepareStatement(
|
||||||
"DELETE FROM `" + xAuthSettings.tblInventory + "`" +
|
"DELETE FROM `" + xAuthSettings.tblInventory + "`" +
|
||||||
|
@ -310,6 +332,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public xAuthPlayer getPlayerFromDb(String playerName) {
|
public xAuthPlayer getPlayerFromDb(String playerName) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
xAuthPlayer xPlayer = null;
|
xAuthPlayer xPlayer = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -333,6 +358,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public xAuthPlayer reloadPlayer(xAuthPlayer xPlayer) {
|
public xAuthPlayer reloadPlayer(xAuthPlayer xPlayer) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
prepStmt = connection.prepareStatement(
|
prepStmt = connection.prepareStatement(
|
||||||
"SELECT a.*, s.*" +
|
"SELECT a.*, s.*" +
|
||||||
|
@ -356,6 +384,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getActive(String playerName) {
|
public int getActive(String playerName) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
prepStmt = connection.prepareStatement(
|
prepStmt = connection.prepareStatement(
|
||||||
"SELECT `active`" +
|
"SELECT `active`" +
|
||||||
|
@ -382,6 +413,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void insertAccount(Account account) {
|
protected void insertAccount(Account account) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
prepStmt = connection.prepareStatement(
|
prepStmt = connection.prepareStatement(
|
||||||
"INSERT INTO `" + xAuthSettings.tblAccount + "`" +
|
"INSERT INTO `" + xAuthSettings.tblAccount + "`" +
|
||||||
|
@ -408,6 +442,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertAccounts(List<Account> accounts) {
|
public void insertAccounts(List<Account> accounts) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
Account account;
|
Account account;
|
||||||
sb.append("INSERT INTO `" + xAuthSettings.tblAccount + "` (`playername`, `password`) VALUES");
|
sb.append("INSERT INTO `" + xAuthSettings.tblAccount + "` (`playername`, `password`) VALUES");
|
||||||
|
@ -431,6 +468,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateAccount(Account account) {
|
protected void updateAccount(Account account) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
prepStmt = connection.prepareStatement(
|
prepStmt = connection.prepareStatement(
|
||||||
"UPDATE `" + xAuthSettings.tblAccount + "`" +
|
"UPDATE `" + xAuthSettings.tblAccount + "`" +
|
||||||
|
@ -461,6 +501,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAccount(xAuthPlayer xPlayer) {
|
public void deleteAccount(xAuthPlayer xPlayer) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
Account account = xPlayer.getAccount();
|
Account account = xPlayer.getAccount();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -479,6 +522,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertSession(Session session) {
|
public void insertSession(Session session) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
prepStmt = connection.prepareStatement(
|
prepStmt = connection.prepareStatement(
|
||||||
"INSERT INTO `" + xAuthSettings.tblSession + "`" +
|
"INSERT INTO `" + xAuthSettings.tblSession + "`" +
|
||||||
|
@ -495,6 +541,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteSession(xAuthPlayer xPlayer) {
|
public void deleteSession(xAuthPlayer xPlayer) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
Session session = xPlayer.getSession();
|
Session session = xPlayer.getSession();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -512,7 +561,8 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadTeleLocations() {
|
public void loadTeleLocations() {
|
||||||
//List<TeleLocation> teleLocations = new ArrayList<TeleLocation>();
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
rs = stmt.executeQuery(
|
rs = stmt.executeQuery(
|
||||||
|
@ -529,16 +579,16 @@ public class DataManager {
|
||||||
teleLocation.setYaw(rs.getFloat("yaw"));
|
teleLocation.setYaw(rs.getFloat("yaw"));
|
||||||
teleLocation.setPitch(rs.getFloat("pitch"));
|
teleLocation.setPitch(rs.getFloat("pitch"));
|
||||||
teleLocations.put(teleLocation.getWorldName(), teleLocation);
|
teleLocations.put(teleLocation.getWorldName(), teleLocation);
|
||||||
//teleLocations.add(teleLocation);
|
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
xAuthLog.severe("Could not load TeleLocations from database!", e);
|
xAuthLog.severe("Could not load TeleLocations from database!", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//return teleLocations;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertTeleLocation(TeleLocation teleLocation) {
|
public void insertTeleLocation(TeleLocation teleLocation) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
prepStmt = connection.prepareStatement(
|
prepStmt = connection.prepareStatement(
|
||||||
"INSERT INTO `" + xAuthSettings.tblLocation + "`" +
|
"INSERT INTO `" + xAuthSettings.tblLocation + "`" +
|
||||||
|
@ -559,6 +609,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTeleLocation(TeleLocation teleLocation) {
|
public void updateTeleLocation(TeleLocation teleLocation) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
prepStmt = connection.prepareStatement(
|
prepStmt = connection.prepareStatement(
|
||||||
"UPDATE `" + xAuthSettings.tblLocation + "`" +
|
"UPDATE `" + xAuthSettings.tblLocation + "`" +
|
||||||
|
@ -583,6 +636,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteTeleLocation(TeleLocation teleLocation) {
|
public void deleteTeleLocation(TeleLocation teleLocation) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
prepStmt = connection.prepareStatement(
|
prepStmt = connection.prepareStatement(
|
||||||
"DELETE FROM `" + xAuthSettings.tblLocation + "`" +
|
"DELETE FROM `" + xAuthSettings.tblLocation + "`" +
|
||||||
|
@ -597,6 +653,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public StrikeBan loadStrikeBan(String host) {
|
public StrikeBan loadStrikeBan(String host) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
StrikeBan ban = null;
|
StrikeBan ban = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -622,6 +681,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertStrikeBan(StrikeBan ban) {
|
public void insertStrikeBan(StrikeBan ban) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
prepStmt = connection.prepareStatement(
|
prepStmt = connection.prepareStatement(
|
||||||
"INSERT INTO `" + xAuthSettings.tblStrike + "`" +
|
"INSERT INTO `" + xAuthSettings.tblStrike + "`" +
|
||||||
|
@ -639,6 +701,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteStrikeBan(StrikeBan ban) {
|
public void deleteStrikeBan(StrikeBan ban) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
stmt = connection.prepareStatement(
|
stmt = connection.prepareStatement(
|
||||||
"DELETE FROM `" + xAuthSettings.tblStrike + "`" +
|
"DELETE FROM `" + xAuthSettings.tblStrike + "`" +
|
||||||
|
@ -653,6 +718,9 @@ public class DataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHostUsed(String host) {
|
public boolean isHostUsed(String host) {
|
||||||
|
if (!isConnected())
|
||||||
|
connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
prepStmt = connection.prepareStatement(
|
prepStmt = connection.prepareStatement(
|
||||||
"SELECT `id`" +
|
"SELECT `id`" +
|
||||||
|
|
|
@ -201,16 +201,13 @@ public class xAuthPlayerListener extends PlayerListener {
|
||||||
//return;
|
//return;
|
||||||
|
|
||||||
if (xPlayer.isGuest()) {
|
if (xPlayer.isGuest()) {
|
||||||
//Location loc = plugin.getLocationToTeleport(player.getWorld());
|
if (xAuthSettings.protectLoc)
|
||||||
//player.teleport(loc);
|
|
||||||
|
|
||||||
//event.setFrom(loc);
|
|
||||||
event.setTo(plugin.getLocationToTeleport(player.getWorld()));
|
event.setTo(plugin.getLocationToTeleport(player.getWorld()));
|
||||||
|
else
|
||||||
|
event.setTo(xPlayer.getLocation());
|
||||||
|
|
||||||
if (xPlayer.canNotify())
|
if (xPlayer.canNotify())
|
||||||
xPlayer.sendIllegalActionNotice();
|
xPlayer.sendIllegalActionNotice();
|
||||||
|
|
||||||
//event.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,6 @@ public class xAuth extends JavaPlugin {
|
||||||
xAuthSettings.setup(dataFolder);
|
xAuthSettings.setup(dataFolder);
|
||||||
xAuthMessages.setup(dataFolder);
|
xAuthMessages.setup(dataFolder);
|
||||||
|
|
||||||
// Util.getOnlineMode() -> getServer().getOnlineMode()
|
|
||||||
if (xAuthSettings.autoDisable && getServer().getOnlineMode()) {
|
if (xAuthSettings.autoDisable && getServer().getOnlineMode()) {
|
||||||
xAuthLog.warning("Disabling - Server is running in online-mode");
|
xAuthLog.warning("Disabling - Server is running in online-mode");
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
|
@ -159,6 +158,9 @@ public class xAuth extends JavaPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeGuest(xAuthPlayer xPlayer) {
|
public void removeGuest(xAuthPlayer xPlayer) {
|
||||||
|
if (!xPlayer.isGuest())
|
||||||
|
return;
|
||||||
|
|
||||||
getServer().getScheduler().cancelTask(xPlayer.getTimeoutTaskId());
|
getServer().getScheduler().cancelTask(xPlayer.getTimeoutTaskId());
|
||||||
restore(xPlayer);
|
restore(xPlayer);
|
||||||
xPlayer.setGuest(false);
|
xPlayer.setGuest(false);
|
||||||
|
@ -169,8 +171,6 @@ public class xAuth extends JavaPlugin {
|
||||||
PlayerInventory playerInv = player.getInventory();
|
PlayerInventory playerInv = player.getInventory();
|
||||||
|
|
||||||
dataManager.insertInventory(xPlayer);
|
dataManager.insertInventory(xPlayer);
|
||||||
//xPlayer.setInventory(playerInv.getContents());
|
|
||||||
//xPlayer.setArmor(playerInv.getArmorContents());
|
|
||||||
playerInv.clear();
|
playerInv.clear();
|
||||||
playerInv.setHelmet(null);
|
playerInv.setHelmet(null);
|
||||||
playerInv.setChestplate(null);
|
playerInv.setChestplate(null);
|
||||||
|
@ -181,6 +181,7 @@ public class xAuth extends JavaPlugin {
|
||||||
if (player.getHealth() > 0)
|
if (player.getHealth() > 0)
|
||||||
xPlayer.setLocation(player.getLocation());
|
xPlayer.setLocation(player.getLocation());
|
||||||
|
|
||||||
|
if (xAuthSettings.protectLoc)
|
||||||
player.teleport(getLocationToTeleport(player.getWorld()));
|
player.teleport(getLocationToTeleport(player.getWorld()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,21 +216,6 @@ public class xAuth extends JavaPlugin {
|
||||||
playerInv.setArmorContents(armor);
|
playerInv.setArmorContents(armor);
|
||||||
dataManager.deleteInventory(xPlayer);
|
dataManager.deleteInventory(xPlayer);
|
||||||
|
|
||||||
/*ItemStack[] inv = xPlayer.getInventory();
|
|
||||||
//Backpack fix
|
|
||||||
if (playerInv.getSize() > inv.length) {
|
|
||||||
ItemStack[] newInv = new ItemStack[playerInv.getSize()];
|
|
||||||
|
|
||||||
for(int i = 0; i < inv.length; i++)
|
|
||||||
newInv[i] = inv[i];
|
|
||||||
|
|
||||||
inv = newInv;
|
|
||||||
}
|
|
||||||
//end Backpack fix
|
|
||||||
|
|
||||||
playerInv.setContents(inv);
|
|
||||||
playerInv.setArmorContents(xPlayer.getArmor());*/
|
|
||||||
|
|
||||||
if (xPlayer.getLocation() != null)
|
if (xPlayer.getLocation() != null)
|
||||||
xPlayer.getPlayer().teleport(xPlayer.getLocation());
|
xPlayer.getPlayer().teleport(xPlayer.getLocation());
|
||||||
player.saveData();
|
player.saveData();
|
||||||
|
@ -324,8 +310,6 @@ public class xAuth extends JavaPlugin {
|
||||||
public void reload() {
|
public void reload() {
|
||||||
xAuthSettings.setup(dataFolder);
|
xAuthSettings.setup(dataFolder);
|
||||||
xAuthMessages.setup(dataFolder);
|
xAuthMessages.setup(dataFolder);
|
||||||
//dataManager.close();
|
|
||||||
//dataManager = new DataManager();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataManager getDataManager() {
|
public DataManager getDataManager() {
|
||||||
|
|
|
@ -13,8 +13,6 @@ public class xAuthPlayer {
|
||||||
private Session session;
|
private Session session;
|
||||||
private boolean guest = false;
|
private boolean guest = false;
|
||||||
private Location location;
|
private Location location;
|
||||||
//private ItemStack[] inventory;
|
|
||||||
//private ItemStack[] armor;
|
|
||||||
private Timestamp lastNotifyTime;
|
private Timestamp lastNotifyTime;
|
||||||
private int strikes = 0;
|
private int strikes = 0;
|
||||||
private int timeoutTaskId;
|
private int timeoutTaskId;
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class xAuthSettings {
|
||||||
public static int guestTimeout = 300;
|
public static int guestTimeout = 300;
|
||||||
public static int notifyCooldown = 5;
|
public static int notifyCooldown = 5;
|
||||||
public static List<String> allowedCmds = Arrays.asList(new String[]{"register", "login", "l"});
|
public static List<String> allowedCmds = Arrays.asList(new String[]{"register", "login", "l"});
|
||||||
|
public static boolean protectLoc = true;
|
||||||
|
|
||||||
// session
|
// session
|
||||||
public static int sessionLength = 3600;
|
public static int sessionLength = 3600;
|
||||||
|
@ -88,7 +89,7 @@ public class xAuthSettings {
|
||||||
/*
|
/*
|
||||||
* REMEMBER TO CHANGE VERSION AFTER MODIFYING DEFAULT SETTINGS
|
* REMEMBER TO CHANGE VERSION AFTER MODIFYING DEFAULT SETTINGS
|
||||||
*/
|
*/
|
||||||
public static int version = 2;
|
public static int version = 3;
|
||||||
|
|
||||||
public static void setup(File dataFolder) {
|
public static void setup(File dataFolder) {
|
||||||
file = new File(dataFolder, "config.yml");
|
file = new File(dataFolder, "config.yml");
|
||||||
|
@ -150,6 +151,7 @@ public class xAuthSettings {
|
||||||
guestTimeout = getInt("guest.timeout", guestTimeout);
|
guestTimeout = getInt("guest.timeout", guestTimeout);
|
||||||
notifyCooldown = getInt("guest.notify-cooldown", notifyCooldown);
|
notifyCooldown = getInt("guest.notify-cooldown", notifyCooldown);
|
||||||
allowedCmds = getStrList("guest.allowed-commands", allowedCmds);
|
allowedCmds = getStrList("guest.allowed-commands", allowedCmds);
|
||||||
|
protectLoc = getBool("guest.protect-location", protectLoc);
|
||||||
|
|
||||||
sessionLength = getInt("session.length", sessionLength);
|
sessionLength = getInt("session.length", sessionLength);
|
||||||
verifyIp = getBool("session.verifyip", verifyIp);
|
verifyIp = getBool("session.verifyip", verifyIp);
|
||||||
|
|
|
@ -10,7 +10,7 @@ main:
|
||||||
auto-disable: [autoDisable]
|
auto-disable: [autoDisable]
|
||||||
# When set to true, if a player connects with the same name as someone who is
|
# When set to true, if a player connects with the same name as someone who is
|
||||||
# already online, the player connecting will be kicked instead of the online player
|
# already online, the player connecting will be kicked instead of the online player
|
||||||
reverse-enforce-single-session: true
|
reverse-enforce-single-session: [reverseESS]
|
||||||
|
|
||||||
mysql:
|
mysql:
|
||||||
# Location of the MySQL server. Can be either a host name or IP address
|
# Location of the MySQL server. Can be either a host name or IP address
|
||||||
|
@ -77,6 +77,8 @@ guest:
|
||||||
notify-cooldown: [notifyCooldown]
|
notify-cooldown: [notifyCooldown]
|
||||||
# Commands that players who are not registered or logged in may execute
|
# Commands that players who are not registered or logged in may execute
|
||||||
allowed-commands: [allowedCmds]
|
allowed-commands: [allowedCmds]
|
||||||
|
# Turn on/off location protection
|
||||||
|
protect-location: [protectLoc]
|
||||||
|
|
||||||
session:
|
session:
|
||||||
# Amount of time, in seconds, that a session will remain valid
|
# Amount of time, in seconds, that a session will remain valid
|
||||||
|
|
Loading…
Reference in New Issue