Code Refactor - Whitespace Refactor
This commit is contained in:
+73
-53
@@ -19,7 +19,8 @@ public class PlayerAuth {
|
||||
private String email = "your@email.com";
|
||||
private String realName = "";
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin, String email, String realName) {
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin,
|
||||
String email, String realName) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
@@ -29,7 +30,8 @@ public class PlayerAuth {
|
||||
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, double x, double y, double z, String world) {
|
||||
public PlayerAuth(String nickname, double x, double y, double z,
|
||||
String world) {
|
||||
this.nickname = nickname;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -39,7 +41,9 @@ public class PlayerAuth {
|
||||
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) {
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin,
|
||||
double x, double y, double z, String world, String email,
|
||||
String realName) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
@@ -53,7 +57,9 @@ public class PlayerAuth {
|
||||
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String salt, int groupId, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) {
|
||||
public PlayerAuth(String nickname, String hash, String salt, int groupId,
|
||||
String ip, long lastLogin, double x, double y, double z,
|
||||
String world, String email, String realName) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
@@ -69,28 +75,32 @@ public class PlayerAuth {
|
||||
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String salt, int groupId , String ip, long lastLogin, String realName) {
|
||||
public PlayerAuth(String nickname, String hash, String salt, int groupId,
|
||||
String ip, long lastLogin, String realName) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
this.lastLogin = lastLogin;
|
||||
this.lastLogin = lastLogin;
|
||||
this.salt = salt;
|
||||
this.groupId = groupId;
|
||||
this.realName = realName;
|
||||
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, String realName) {
|
||||
public PlayerAuth(String nickname, String hash, String salt, String ip,
|
||||
long lastLogin, String realName) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
this.lastLogin = lastLogin;
|
||||
this.lastLogin = lastLogin;
|
||||
this.salt = salt;
|
||||
this.realName = realName;
|
||||
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) {
|
||||
public PlayerAuth(String nickname, String hash, String salt, String ip,
|
||||
long lastLogin, double x, double y, double z, String world,
|
||||
String email, String realName) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
@@ -105,23 +115,22 @@ public class PlayerAuth {
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String ip, long lastLogin) {
|
||||
this.nickname = nickname;
|
||||
this.ip = ip;
|
||||
this.lastLogin = lastLogin;
|
||||
this.nickname = nickname;
|
||||
this.ip = ip;
|
||||
this.lastLogin = lastLogin;
|
||||
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin) {
|
||||
this.nickname = nickname;
|
||||
this.ip = ip;
|
||||
this.lastLogin = lastLogin;
|
||||
this.hash = hash;
|
||||
this.nickname = nickname;
|
||||
this.ip = ip;
|
||||
this.lastLogin = lastLogin;
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
if (ip == null || ip.isEmpty())
|
||||
ip = "127.0.0.1";
|
||||
return ip;
|
||||
public String getIp() {
|
||||
if (ip == null || ip.isEmpty()) ip = "127.0.0.1";
|
||||
return ip;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
@@ -129,17 +138,18 @@ public class PlayerAuth {
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
if (Settings.getPasswordHash == HashAlgorithm.MD5VB) {
|
||||
if(salt != null && !salt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.MD5VB) {
|
||||
vBhash = "$MD5vb$"+salt+"$"+hash;
|
||||
if (Settings.getPasswordHash == HashAlgorithm.MD5VB) {
|
||||
if (salt != null && !salt.isEmpty()
|
||||
&& Settings.getPasswordHash == HashAlgorithm.MD5VB) {
|
||||
vBhash = "$MD5vb$" + salt + "$" + hash;
|
||||
return vBhash;
|
||||
}
|
||||
}
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
public String getSalt() {
|
||||
return this.salt;
|
||||
return this.salt;
|
||||
}
|
||||
|
||||
public int getGroupId() {
|
||||
@@ -149,31 +159,37 @@ public class PlayerAuth {
|
||||
public double getQuitLocX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getQuitLocY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getQuitLocZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setQuitLocX(double d) {
|
||||
this.x = d;
|
||||
}
|
||||
|
||||
public void setQuitLocY(double d) {
|
||||
this.y = d;
|
||||
}
|
||||
|
||||
public void setQuitLocZ(double d) {
|
||||
this.z = d;
|
||||
}
|
||||
}
|
||||
|
||||
public long getLastLogin() {
|
||||
try {
|
||||
if (Long.valueOf(lastLogin) == null)
|
||||
lastLogin = 0L;
|
||||
} catch (NullPointerException e) {
|
||||
lastLogin = 0L;
|
||||
}
|
||||
try {
|
||||
if (Long.valueOf(lastLogin) == null) lastLogin = 0L;
|
||||
} catch (NullPointerException e) {
|
||||
lastLogin = 0L;
|
||||
}
|
||||
return lastLogin;
|
||||
}
|
||||
|
||||
@@ -190,11 +206,11 @@ public class PlayerAuth {
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public void setSalt(String salt) {
|
||||
this.salt = salt;
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,34 +219,38 @@ public class PlayerAuth {
|
||||
return false;
|
||||
}
|
||||
PlayerAuth other = (PlayerAuth) obj;
|
||||
return other.getIp().equals(this.ip) && other.getNickname().equals(this.nickname);
|
||||
return other.getIp().equals(this.ip)
|
||||
&& other.getNickname().equals(this.nickname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = 7;
|
||||
hashCode = 71 * hashCode + (this.nickname != null ? this.nickname.hashCode() : 0);
|
||||
hashCode = 71 * hashCode
|
||||
+ (this.nickname != null ? this.nickname.hashCode() : 0);
|
||||
hashCode = 71 * hashCode + (this.ip != null ? this.ip.hashCode() : 0);
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
public void setWorld(String world) {
|
||||
this.world = world;
|
||||
}
|
||||
public void setWorld(String world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public String getWorld() {
|
||||
return world;
|
||||
}
|
||||
public String getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String s = "Player : " + nickname + " ! IP : " + ip + " ! LastLogin : " + lastLogin + " ! LastPosition : " + x + "," + y + "," + z + "," + world
|
||||
+ " ! Email : " + email + " ! Hash : " + hash + " ! Salt : " + salt + " ! RealName : " + realName;
|
||||
return s;
|
||||
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
String s = "Player : " + nickname + " ! IP : " + ip + " ! LastLogin : "
|
||||
+ lastLogin + " ! LastPosition : " + x + "," + y + "," + z
|
||||
+ "," + world + " ! Email : " + email + " ! Hash : " + hash
|
||||
+ " ! Salt : " + salt + " ! RealName : " + realName;
|
||||
return s;
|
||||
|
||||
public String getRealname() {
|
||||
return realName;
|
||||
}
|
||||
}
|
||||
|
||||
public String getRealname() {
|
||||
return realName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class PlayerCache {
|
||||
}
|
||||
|
||||
public int getLogged() {
|
||||
return cache.size();
|
||||
return cache.size();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+32
-31
@@ -4,42 +4,43 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class DataFileCache {
|
||||
|
||||
private ItemStack[] inventory;
|
||||
private ItemStack[] armor;
|
||||
private String group;
|
||||
private boolean operator;
|
||||
private boolean flying;
|
||||
private ItemStack[] inventory;
|
||||
private ItemStack[] armor;
|
||||
private String group;
|
||||
private boolean operator;
|
||||
private boolean flying;
|
||||
|
||||
public DataFileCache(ItemStack[] inventory, ItemStack[] armor){
|
||||
this.inventory = inventory;
|
||||
this.armor = armor;
|
||||
}
|
||||
public DataFileCache(ItemStack[] inventory, ItemStack[] armor) {
|
||||
this.inventory = inventory;
|
||||
this.armor = armor;
|
||||
}
|
||||
|
||||
public DataFileCache(ItemStack[] inventory, ItemStack[] armor, String group, boolean operator, boolean flying){
|
||||
this.inventory = inventory;
|
||||
this.armor = armor;
|
||||
this.group = group;
|
||||
this.operator = operator;
|
||||
this.flying = flying;
|
||||
}
|
||||
public DataFileCache(ItemStack[] inventory, ItemStack[] armor,
|
||||
String group, boolean operator, boolean flying) {
|
||||
this.inventory = inventory;
|
||||
this.armor = armor;
|
||||
this.group = group;
|
||||
this.operator = operator;
|
||||
this.flying = flying;
|
||||
}
|
||||
|
||||
public ItemStack[] getInventory(){
|
||||
return inventory;
|
||||
}
|
||||
public ItemStack[] getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public ItemStack[] getArmour(){
|
||||
return armor;
|
||||
}
|
||||
public ItemStack[] getArmour() {
|
||||
return armor;
|
||||
}
|
||||
|
||||
public String getGroup(){
|
||||
return group;
|
||||
}
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public boolean getOperator(){
|
||||
return operator;
|
||||
}
|
||||
public boolean getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public boolean isFlying(){
|
||||
return flying;
|
||||
}
|
||||
public boolean isFlying() {
|
||||
return flying;
|
||||
}
|
||||
}
|
||||
|
||||
+154
-145
@@ -18,117 +18,122 @@ import fr.xephi.authme.api.API;
|
||||
public class FileCache {
|
||||
|
||||
private AuthMe plugin = AuthMe.getInstance();
|
||||
public FileCache() {
|
||||
final File folder = new File("cache");
|
||||
if (!folder.exists()) {
|
||||
folder.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
public void createCache(String playername, DataFileCache playerData, String group, boolean operator, boolean flying) {
|
||||
final File file = new File("cache/" + playername
|
||||
+ ".cache");
|
||||
public FileCache() {
|
||||
final File folder = new File("cache");
|
||||
if (!folder.exists()) {
|
||||
folder.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
if (file.exists()) {
|
||||
return;
|
||||
}
|
||||
public void createCache(String playername, DataFileCache playerData,
|
||||
String group, boolean operator, boolean flying) {
|
||||
final File file = new File("cache/" + playername + ".cache");
|
||||
|
||||
FileWriter writer = null;
|
||||
try {
|
||||
file.createNewFile();
|
||||
if (file.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
writer = new FileWriter(file);
|
||||
FileWriter writer = null;
|
||||
try {
|
||||
file.createNewFile();
|
||||
|
||||
String s = group+";";
|
||||
if (operator)
|
||||
s = s + "1";
|
||||
else s = s + "0";
|
||||
writer = new FileWriter(file);
|
||||
|
||||
// line format Group|OperatorStatus|isFlying
|
||||
if(flying)
|
||||
writer.write(s+";1" + API.newline);
|
||||
else writer.write(s+";0" + API.newline);
|
||||
writer.flush();
|
||||
String s = group + ";";
|
||||
if (operator) s = s + "1";
|
||||
else s = s + "0";
|
||||
|
||||
ItemStack[] invstack = playerData.getInventory();
|
||||
// line format Group|OperatorStatus|isFlying
|
||||
if (flying) writer.write(s + ";1" + API.newline);
|
||||
else writer.write(s + ";0" + API.newline);
|
||||
writer.flush();
|
||||
|
||||
for (int i = 0; i < invstack.length; i++) {
|
||||
ItemStack[] invstack = playerData.getInventory();
|
||||
|
||||
String itemid = "AIR";
|
||||
int amount = 0;
|
||||
int durability = 0;
|
||||
String enchList = "";
|
||||
String name = "";
|
||||
String lores = "";
|
||||
if (invstack[i] != null) {
|
||||
itemid = invstack[i].getType().name();
|
||||
amount = invstack[i].getAmount();
|
||||
durability = invstack[i].getDurability();
|
||||
for(Enchantment e : invstack[i].getEnchantments().keySet()) {
|
||||
enchList = enchList.concat(e.getName()+":"+invstack[i].getEnchantmentLevel(e)+":");
|
||||
}
|
||||
if (enchList.length() > 1)
|
||||
enchList = enchList.substring(0, enchList.length() - 1);
|
||||
if (invstack[i].hasItemMeta()) {
|
||||
if (invstack[i].getItemMeta().hasDisplayName()) {
|
||||
name = invstack[i].getItemMeta().getDisplayName();
|
||||
}
|
||||
if (invstack[i].getItemMeta().hasLore()) {
|
||||
for (String lore : invstack[i].getItemMeta().getLore()) {
|
||||
lores = lore + "%newline%";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String writeItem = "i" + ":" + itemid + ":" + amount + ":"
|
||||
+ durability + ":"+ enchList + ";" + name + "\\*" + lores + "\r\n";
|
||||
writer.write(writeItem);
|
||||
writer.flush();
|
||||
}
|
||||
for (int i = 0; i < invstack.length; i++) {
|
||||
|
||||
ItemStack[] armorstack = playerData.getArmour();
|
||||
String itemid = "AIR";
|
||||
int amount = 0;
|
||||
int durability = 0;
|
||||
String enchList = "";
|
||||
String name = "";
|
||||
String lores = "";
|
||||
if (invstack[i] != null) {
|
||||
itemid = invstack[i].getType().name();
|
||||
amount = invstack[i].getAmount();
|
||||
durability = invstack[i].getDurability();
|
||||
for (Enchantment e : invstack[i].getEnchantments().keySet()) {
|
||||
enchList = enchList.concat(e.getName() + ":"
|
||||
+ invstack[i].getEnchantmentLevel(e) + ":");
|
||||
}
|
||||
if (enchList.length() > 1) enchList = enchList.substring(0,
|
||||
enchList.length() - 1);
|
||||
if (invstack[i].hasItemMeta()) {
|
||||
if (invstack[i].getItemMeta().hasDisplayName()) {
|
||||
name = invstack[i].getItemMeta().getDisplayName();
|
||||
}
|
||||
if (invstack[i].getItemMeta().hasLore()) {
|
||||
for (String lore : invstack[i].getItemMeta()
|
||||
.getLore()) {
|
||||
lores = lore + "%newline%";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String writeItem = "i" + ":" + itemid + ":" + amount + ":"
|
||||
+ durability + ":" + enchList + ";" + name + "\\*"
|
||||
+ lores + "\r\n";
|
||||
writer.write(writeItem);
|
||||
writer.flush();
|
||||
}
|
||||
|
||||
for (int i = 0; i < armorstack.length; i++) {
|
||||
String itemid = "AIR";
|
||||
int amount = 0;
|
||||
int durability = 0;
|
||||
String enchList = "";
|
||||
String name = "";
|
||||
String lores = "";
|
||||
if (armorstack[i] != null) {
|
||||
itemid = armorstack[i].getType().name();
|
||||
amount = armorstack[i].getAmount();
|
||||
durability = armorstack[i].getDurability();
|
||||
for(Enchantment e : armorstack[i].getEnchantments().keySet()) {
|
||||
enchList = enchList.concat(e.getName()+":"+armorstack[i].getEnchantmentLevel(e)+":");
|
||||
}
|
||||
if (enchList.length() > 1)
|
||||
enchList = enchList.substring(0, enchList.length() - 1);
|
||||
if (armorstack[i].hasItemMeta()) {
|
||||
if (armorstack[i].getItemMeta().hasDisplayName()) {
|
||||
name = armorstack[i].getItemMeta().getDisplayName();
|
||||
}
|
||||
if (armorstack[i].getItemMeta().hasLore()) {
|
||||
for (String lore : armorstack[i].getItemMeta().getLore()) {
|
||||
lores = lore + "%newline%";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String writeItem = "w" + ":" + itemid + ":" + amount + ":"
|
||||
+ durability + ":"+ enchList + ";" + name + "\\*" + lores + "\r\n";
|
||||
writer.write(writeItem);
|
||||
writer.flush();
|
||||
}
|
||||
writer.close();
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
ItemStack[] armorstack = playerData.getArmour();
|
||||
|
||||
public DataFileCache readCache(String playername) {
|
||||
final File file = new File("cache/" + playername
|
||||
+ ".cache");
|
||||
for (int i = 0; i < armorstack.length; i++) {
|
||||
String itemid = "AIR";
|
||||
int amount = 0;
|
||||
int durability = 0;
|
||||
String enchList = "";
|
||||
String name = "";
|
||||
String lores = "";
|
||||
if (armorstack[i] != null) {
|
||||
itemid = armorstack[i].getType().name();
|
||||
amount = armorstack[i].getAmount();
|
||||
durability = armorstack[i].getDurability();
|
||||
for (Enchantment e : armorstack[i].getEnchantments()
|
||||
.keySet()) {
|
||||
enchList = enchList.concat(e.getName() + ":"
|
||||
+ armorstack[i].getEnchantmentLevel(e) + ":");
|
||||
}
|
||||
if (enchList.length() > 1) enchList = enchList.substring(0,
|
||||
enchList.length() - 1);
|
||||
if (armorstack[i].hasItemMeta()) {
|
||||
if (armorstack[i].getItemMeta().hasDisplayName()) {
|
||||
name = armorstack[i].getItemMeta().getDisplayName();
|
||||
}
|
||||
if (armorstack[i].getItemMeta().hasLore()) {
|
||||
for (String lore : armorstack[i].getItemMeta()
|
||||
.getLore()) {
|
||||
lores = lore + "%newline%";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String writeItem = "w" + ":" + itemid + ":" + amount + ":"
|
||||
+ durability + ":" + enchList + ";" + name + "\\*"
|
||||
+ lores + "\r\n";
|
||||
writer.write(writeItem);
|
||||
writer.flush();
|
||||
}
|
||||
writer.close();
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public DataFileCache readCache(String playername) {
|
||||
final File file = new File("cache/" + playername + ".cache");
|
||||
|
||||
ItemStack[] stacki = new ItemStack[36];
|
||||
ItemStack[] stacka = new ItemStack[4];
|
||||
@@ -149,20 +154,20 @@ public class FileCache {
|
||||
String line = reader.nextLine();
|
||||
|
||||
if (!line.contains(":")) {
|
||||
// the fist line represent the player group, operator status and flying status
|
||||
final String[] playerInfo = line.split(";");
|
||||
group = playerInfo[0];
|
||||
// the fist line represent the player group, operator status
|
||||
// and flying status
|
||||
final String[] playerInfo = line.split(";");
|
||||
group = playerInfo[0];
|
||||
|
||||
if (Integer.parseInt(playerInfo[1]) == 1) {
|
||||
op = true;
|
||||
} else op = false;
|
||||
if (playerInfo.length > 2) {
|
||||
if (Integer.parseInt(playerInfo[2]) == 1)
|
||||
flying = true;
|
||||
else flying = false;
|
||||
}
|
||||
if (Integer.parseInt(playerInfo[1]) == 1) {
|
||||
op = true;
|
||||
} else op = false;
|
||||
if (playerInfo.length > 2) {
|
||||
if (Integer.parseInt(playerInfo[2]) == 1) flying = true;
|
||||
else flying = false;
|
||||
}
|
||||
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!line.startsWith("i") && !line.startsWith("w")) {
|
||||
@@ -179,18 +184,22 @@ public class FileCache {
|
||||
line = line.split(";")[0];
|
||||
}
|
||||
final String[] in = line.split(":");
|
||||
// can enchant item? size ofstring in file - 4 all / 2 = number of enchant
|
||||
// can enchant item? size ofstring in file - 4 all / 2 = number
|
||||
// of enchant
|
||||
if (in[0].equals("i")) {
|
||||
stacki[i] = new ItemStack(Material.getMaterial(in[1]),
|
||||
Integer.parseInt(in[2]), Short.parseShort((in[3])));
|
||||
if(in.length > 4 && !in[4].isEmpty()) {
|
||||
for(int k=4;k<in.length-1;k++) {
|
||||
stacki[i].addUnsafeEnchantment(Enchantment.getByName(in[k]) ,Integer.parseInt(in[k+1]));
|
||||
Integer.parseInt(in[2]), Short.parseShort((in[3])));
|
||||
if (in.length > 4 && !in[4].isEmpty()) {
|
||||
for (int k = 4; k < in.length - 1; k++) {
|
||||
stacki[i].addUnsafeEnchantment(
|
||||
Enchantment.getByName(in[k]),
|
||||
Integer.parseInt(in[k + 1]));
|
||||
k++;
|
||||
}
|
||||
}
|
||||
try {
|
||||
ItemMeta meta = plugin.getServer().getItemFactory().getItemMeta(stacki[i].getType());
|
||||
ItemMeta meta = plugin.getServer().getItemFactory()
|
||||
.getItemMeta(stacki[i].getType());
|
||||
if (!name.isEmpty()) {
|
||||
meta.setDisplayName(name);
|
||||
}
|
||||
@@ -201,23 +210,25 @@ public class FileCache {
|
||||
}
|
||||
meta.setLore(loreList);
|
||||
}
|
||||
if (meta != null)
|
||||
stacki[i].setItemMeta(meta);
|
||||
} catch (Exception e) {}
|
||||
if (meta != null) stacki[i].setItemMeta(meta);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
i++;
|
||||
} else {
|
||||
stacka[a] = new ItemStack(Material.getMaterial(in[1]),
|
||||
Integer.parseInt(in[2]), Short.parseShort((in[3])));
|
||||
if(in.length > 4 && !in[4].isEmpty()) {
|
||||
for(int k=4;k<in.length-1;k++) {
|
||||
stacka[a].addUnsafeEnchantment(Enchantment.getByName(in[k]) ,Integer.parseInt(in[k+1]));
|
||||
if (in.length > 4 && !in[4].isEmpty()) {
|
||||
for (int k = 4; k < in.length - 1; k++) {
|
||||
stacka[a].addUnsafeEnchantment(
|
||||
Enchantment.getByName(in[k]),
|
||||
Integer.parseInt(in[k + 1]));
|
||||
k++;
|
||||
}
|
||||
}
|
||||
try {
|
||||
ItemMeta meta = plugin.getServer().getItemFactory().getItemMeta(stacka[a].getType());
|
||||
if (!name.isEmpty())
|
||||
meta.setDisplayName(name);
|
||||
ItemMeta meta = plugin.getServer().getItemFactory()
|
||||
.getItemMeta(stacka[a].getType());
|
||||
if (!name.isEmpty()) meta.setDisplayName(name);
|
||||
if (!lores.isEmpty()) {
|
||||
List<String> loreList = new ArrayList<String>();
|
||||
for (String s : lores.split("%newline%")) {
|
||||
@@ -225,9 +236,9 @@ public class FileCache {
|
||||
}
|
||||
meta.setLore(loreList);
|
||||
}
|
||||
if (meta != null)
|
||||
stacki[i].setItemMeta(meta);
|
||||
} catch (Exception e) {}
|
||||
if (meta != null) stacki[i].setItemMeta(meta);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
a++;
|
||||
}
|
||||
}
|
||||
@@ -239,25 +250,23 @@ public class FileCache {
|
||||
}
|
||||
}
|
||||
return new DataFileCache(stacki, stacka, group, op, flying);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeCache(String playername) {
|
||||
final File file = new File("cache/" + playername
|
||||
+ ".cache");
|
||||
public void removeCache(String playername) {
|
||||
final File file = new File("cache/" + playername + ".cache");
|
||||
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean doesCacheExist(String playername) {
|
||||
final File file = new File("cache/" + playername
|
||||
+ ".cache");
|
||||
public boolean doesCacheExist(String playername) {
|
||||
final File file = new File("cache/" + playername + ".cache");
|
||||
|
||||
if (file.exists()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (file.exists()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+57
-51
@@ -15,7 +15,6 @@ import fr.xephi.authme.events.ResetInventoryEvent;
|
||||
import fr.xephi.authme.events.StoreInventoryEvent;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
|
||||
public class LimboCache {
|
||||
|
||||
private static LimboCache singleton = null;
|
||||
@@ -24,7 +23,7 @@ public class LimboCache {
|
||||
public AuthMe plugin;
|
||||
|
||||
private LimboCache(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
this.plugin = plugin;
|
||||
this.cache = new HashMap<String, LimboPlayer>();
|
||||
}
|
||||
|
||||
@@ -39,63 +38,70 @@ public class LimboCache {
|
||||
boolean flying;
|
||||
|
||||
if (playerData.doesCacheExist(name)) {
|
||||
StoreInventoryEvent event = new StoreInventoryEvent(player, playerData);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled() && event.getInventory() != null && event.getArmor() != null) {
|
||||
inv = event.getInventory();
|
||||
arm = event.getArmor();
|
||||
} else {
|
||||
inv = null;
|
||||
arm = null;
|
||||
}
|
||||
playerGroup = playerData.readCache(name).getGroup();
|
||||
operator = playerData.readCache(name).getOperator();
|
||||
flying = playerData.readCache(name).isFlying();
|
||||
StoreInventoryEvent event = new StoreInventoryEvent(player,
|
||||
playerData);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled() && event.getInventory() != null
|
||||
&& event.getArmor() != null) {
|
||||
inv = event.getInventory();
|
||||
arm = event.getArmor();
|
||||
} else {
|
||||
inv = null;
|
||||
arm = null;
|
||||
}
|
||||
playerGroup = playerData.readCache(name).getGroup();
|
||||
operator = playerData.readCache(name).getOperator();
|
||||
flying = playerData.readCache(name).isFlying();
|
||||
} else {
|
||||
StoreInventoryEvent event = new StoreInventoryEvent(player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled() && event.getInventory() != null && event.getArmor() != null) {
|
||||
inv = event.getInventory();
|
||||
arm = event.getArmor();
|
||||
} else {
|
||||
inv = null;
|
||||
arm = null;
|
||||
}
|
||||
if(player.isOp())
|
||||
operator = true;
|
||||
StoreInventoryEvent event = new StoreInventoryEvent(player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled() && event.getInventory() != null
|
||||
&& event.getArmor() != null) {
|
||||
inv = event.getInventory();
|
||||
arm = event.getArmor();
|
||||
} else {
|
||||
inv = null;
|
||||
arm = null;
|
||||
}
|
||||
if (player.isOp()) operator = true;
|
||||
else operator = false;
|
||||
if(player.isFlying())
|
||||
flying = true;
|
||||
if (player.isFlying()) flying = true;
|
||||
else flying = false;
|
||||
if (plugin.permission != null) {
|
||||
try {
|
||||
playerGroup = plugin.permission.getPrimaryGroup(player);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
ConsoleLogger.showError("Your permission system (" + plugin.permission.getName() + ") do not support Group system with that config... unhook!");
|
||||
plugin.permission = null;
|
||||
}
|
||||
try {
|
||||
playerGroup = plugin.permission.getPrimaryGroup(player);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
ConsoleLogger
|
||||
.showError("Your permission system ("
|
||||
+ plugin.permission.getName()
|
||||
+ ") do not support Group system with that config... unhook!");
|
||||
plugin.permission = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Settings.isForceSurvivalModeEnabled) {
|
||||
if(Settings.isResetInventoryIfCreative && player.getGameMode() == GameMode.CREATIVE ) {
|
||||
ResetInventoryEvent event = new ResetInventoryEvent(player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
player.getInventory().clear();
|
||||
player.sendMessage("Your inventory has been cleaned!");
|
||||
}
|
||||
if (Settings.isForceSurvivalModeEnabled) {
|
||||
if (Settings.isResetInventoryIfCreative
|
||||
&& player.getGameMode() == GameMode.CREATIVE) {
|
||||
ResetInventoryEvent event = new ResetInventoryEvent(player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
player.getInventory().clear();
|
||||
player.sendMessage("Your inventory has been cleaned!");
|
||||
}
|
||||
}
|
||||
gameMode = GameMode.SURVIVAL;
|
||||
}
|
||||
if(player.isDead()) {
|
||||
loc = plugin.getSpawnLocation(player);
|
||||
if (player.isDead()) {
|
||||
loc = plugin.getSpawnLocation(player);
|
||||
}
|
||||
cache.put(player.getName().toLowerCase(), new LimboPlayer(name, loc, inv, arm, gameMode, operator, playerGroup, flying));
|
||||
cache.put(player.getName().toLowerCase(), new LimboPlayer(name, loc,
|
||||
inv, arm, gameMode, operator, playerGroup, flying));
|
||||
}
|
||||
|
||||
public void addLimboPlayer(Player player, String group) {
|
||||
cache.put(player.getName().toLowerCase(), new LimboPlayer(player.getName().toLowerCase(), group));
|
||||
cache.put(player.getName().toLowerCase(), new LimboPlayer(player
|
||||
.getName().toLowerCase(), group));
|
||||
}
|
||||
|
||||
public void deleteLimboPlayer(String name) {
|
||||
@@ -117,11 +123,11 @@ public class LimboCache {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
public void updateLimboPlayer(Player player) {
|
||||
if (this.hasLimboPlayer(player.getName().toLowerCase())) {
|
||||
this.deleteLimboPlayer(player.getName().toLowerCase());
|
||||
}
|
||||
this.addLimboPlayer(player);
|
||||
}
|
||||
public void updateLimboPlayer(Player player) {
|
||||
if (this.hasLimboPlayer(player.getName().toLowerCase())) {
|
||||
this.deleteLimboPlayer(player.getName().toLowerCase());
|
||||
}
|
||||
this.addLimboPlayer(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+22
-19
@@ -17,7 +17,9 @@ public class LimboPlayer {
|
||||
private String group = "";
|
||||
private boolean flying = false;
|
||||
|
||||
public LimboPlayer(String name, Location loc, ItemStack[] inventory, ItemStack[] armour, GameMode gameMode, boolean operator, String group, boolean flying) {
|
||||
public LimboPlayer(String name, Location loc, ItemStack[] inventory,
|
||||
ItemStack[] armour, GameMode gameMode, boolean operator,
|
||||
String group, boolean flying) {
|
||||
this.name = name;
|
||||
this.loc = loc;
|
||||
this.inventory = inventory;
|
||||
@@ -28,7 +30,8 @@ public class LimboPlayer {
|
||||
this.flying = flying;
|
||||
}
|
||||
|
||||
public LimboPlayer(String name, Location loc, GameMode gameMode, boolean operator, String group, boolean flying) {
|
||||
public LimboPlayer(String name, Location loc, GameMode gameMode,
|
||||
boolean operator, String group, boolean flying) {
|
||||
this.name = name;
|
||||
this.loc = loc;
|
||||
this.gameMode = gameMode;
|
||||
@@ -59,11 +62,11 @@ public class LimboPlayer {
|
||||
}
|
||||
|
||||
public void setArmour(ItemStack[] armour) {
|
||||
this.armour = armour;
|
||||
this.armour = armour;
|
||||
}
|
||||
|
||||
public void setInventory(ItemStack[] inventory) {
|
||||
this.inventory = inventory;
|
||||
this.inventory = inventory;
|
||||
}
|
||||
|
||||
public GameMode getGameMode() {
|
||||
@@ -78,24 +81,24 @@ public class LimboPlayer {
|
||||
return group;
|
||||
}
|
||||
|
||||
public void setTimeoutTaskId(int i) {
|
||||
this.timeoutTaskId = i;
|
||||
}
|
||||
public void setTimeoutTaskId(int i) {
|
||||
this.timeoutTaskId = i;
|
||||
}
|
||||
|
||||
public int getTimeoutTaskId() {
|
||||
return timeoutTaskId;
|
||||
}
|
||||
public int getTimeoutTaskId() {
|
||||
return timeoutTaskId;
|
||||
}
|
||||
|
||||
public void setMessageTaskId(int messageTaskId) {
|
||||
this.messageTaskId = messageTaskId;
|
||||
}
|
||||
public void setMessageTaskId(int messageTaskId) {
|
||||
this.messageTaskId = messageTaskId;
|
||||
}
|
||||
|
||||
public int getMessageTaskId() {
|
||||
return messageTaskId;
|
||||
}
|
||||
public int getMessageTaskId() {
|
||||
return messageTaskId;
|
||||
}
|
||||
|
||||
public boolean isFlying() {
|
||||
return flying;
|
||||
}
|
||||
public boolean isFlying() {
|
||||
return flying;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user