mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-09-19 02:11:55 +02:00
Some Fix on FileCache
This commit is contained in:
parent
44bbd30fd2
commit
5548004fd0
@ -21,6 +21,7 @@ import com.comphenix.attribute.Attributes.AttributeType;
|
|||||||
import com.comphenix.attribute.Attributes.Operation;
|
import com.comphenix.attribute.Attributes.Operation;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.api.API;
|
import fr.xephi.authme.api.API;
|
||||||
|
|
||||||
public class FileCache {
|
public class FileCache {
|
||||||
@ -101,19 +102,19 @@ public class FileCache {
|
|||||||
for (Enchantment ench : item.getEnchantments().keySet()) {
|
for (Enchantment ench : item.getEnchantments().keySet()) {
|
||||||
writer.write("enchant=" + ench.getName() + ":" + item.getEnchantments().get(ench) + API.newline);
|
writer.write("enchant=" + ench.getName() + ":" + item.getEnchantments().get(ench) + API.newline);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
Attributes attributes = new Attributes(item);
|
Attributes attributes = new Attributes(item);
|
||||||
if (attributes != null)
|
if (attributes != null)
|
||||||
while (attributes.values().iterator().hasNext()) {
|
while (attributes.values().iterator().hasNext()) {
|
||||||
Attribute a = attributes.values().iterator().next();
|
Attribute a = attributes.values().iterator().next();
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
try {
|
|
||||||
if (a.getName() != null && a.getAttributeType() != null
|
if (a.getName() != null && a.getAttributeType() != null
|
||||||
&& a.getOperation() != null && a.getUUID() != null)
|
&& a.getOperation() != null && a.getUUID() != null)
|
||||||
writer.write("attribute=" + a.getName() + ";" + a.getAttributeType().getMinecraftId() + ";" + a.getAmount() + ";" + a.getOperation().getId() + ";" + a.getUUID().toString());
|
writer.write("attribute=" + a.getName() + ";" + a.getAttributeType().getMinecraftId() + ";" + a.getAmount() + ";" + a.getOperation().getId() + ";" + a.getUUID().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
} catch (Error e) {}
|
} catch (Error e) {}
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
writer.write("AIR");
|
writer.write("AIR");
|
||||||
}
|
}
|
||||||
@ -155,25 +156,25 @@ public class FileCache {
|
|||||||
for (Enchantment ench : item.getEnchantments().keySet()) {
|
for (Enchantment ench : item.getEnchantments().keySet()) {
|
||||||
writer.write("enchant=" + ench.getName() + ":" + item.getEnchantments().get(ench) + API.newline);
|
writer.write("enchant=" + ench.getName() + ":" + item.getEnchantments().get(ench) + API.newline);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
Attributes attributes = new Attributes(item);
|
Attributes attributes = new Attributes(item);
|
||||||
if (attributes != null)
|
if (attributes != null)
|
||||||
while (attributes.values().iterator().hasNext()) {
|
while (attributes.values().iterator().hasNext()) {
|
||||||
Attribute a = attributes.values().iterator().next();
|
Attribute a = attributes.values().iterator().next();
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
try {
|
|
||||||
if (a.getName() != null && a.getAttributeType() != null
|
if (a.getName() != null && a.getAttributeType() != null
|
||||||
&& a.getOperation() != null && a.getUUID() != null)
|
&& a.getOperation() != null && a.getUUID() != null)
|
||||||
writer.write("attribute=" + a.getName() + ";" + a.getAttributeType().getMinecraftId() + ";" + a.getAmount() + ";" + a.getOperation().getId() + ";" + a.getUUID().toString());
|
writer.write("attribute=" + a.getName() + ";" + a.getAttributeType().getMinecraftId() + ";" + a.getAmount() + ";" + a.getOperation().getId() + ";" + a.getUUID().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
writer.write("AIR" + API.newline);
|
writer.write("AIR" + API.newline);
|
||||||
}
|
}
|
||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
ConsoleLogger.showError("Some error on creating file cache...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,6 +187,7 @@ public class FileCache {
|
|||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
path = player.getName();
|
path = player.getName();
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
File file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + ".playerdatas.cache");
|
File file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + ".playerdatas.cache");
|
||||||
String playername = player.getName().toLowerCase();
|
String playername = player.getName().toLowerCase();
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
@ -297,7 +299,7 @@ public class FileCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
ConsoleLogger.showError("Error on creating a file cache for " + player.getName() + ", maybe wipe inventory...");
|
||||||
} finally {
|
} finally {
|
||||||
if (reader != null) {
|
if (reader != null) {
|
||||||
reader.close();
|
reader.close();
|
||||||
@ -484,14 +486,17 @@ public class FileCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming...");
|
||||||
} finally {
|
} finally {
|
||||||
if (reader != null)
|
if (reader != null)
|
||||||
reader.close();
|
reader.close();
|
||||||
}
|
}
|
||||||
return new DataFileCache(inv, armours, group, op, flying);
|
return new DataFileCache(inv, armours, group, op, flying);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming...");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCache(Player player) {
|
public void removeCache(Player player) {
|
||||||
@ -503,11 +508,11 @@ public class FileCache {
|
|||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
path = player.getName();
|
path = player.getName();
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
File file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path);
|
File file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file = new File("cache/" + player.getName().toLowerCase() + ".cache");
|
file = new File("cache/" + player.getName().toLowerCase() + ".cache");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
for (File f : file.listFiles()) {
|
for (File f : file.listFiles()) {
|
||||||
@ -521,6 +526,9 @@ public class FileCache {
|
|||||||
file.delete();
|
file.delete();
|
||||||
} else file.delete();
|
} else file.delete();
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
ConsoleLogger.showError("File cannot be removed correctly :/");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean doesCacheExist(Player player) {
|
public boolean doesCacheExist(Player player) {
|
||||||
|
@ -651,8 +651,13 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
placePlayerSafely(player, spawnLoc);
|
placePlayerSafely(player, spawnLoc);
|
||||||
LimboCache.getInstance().updateLimboPlayer(player);
|
LimboCache.getInstance().updateLimboPlayer(player);
|
||||||
|
try {
|
||||||
DataFileCache dataFile = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(), LimboCache.getInstance().getLimboPlayer(name).getArmour());
|
DataFileCache dataFile = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(), LimboCache.getInstance().getLimboPlayer(name).getArmour());
|
||||||
playerBackup.createCache(player, dataFile, LimboCache.getInstance().getLimboPlayer(name).getGroup(), LimboCache.getInstance().getLimboPlayer(name).getOperator(), LimboCache.getInstance().getLimboPlayer(name).isFlying());
|
playerBackup.createCache(player, dataFile, LimboCache.getInstance().getLimboPlayer(name).getGroup(), LimboCache.getInstance().getLimboPlayer(name).getOperator(), LimboCache.getInstance().getLimboPlayer(name).isFlying());
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
ConsoleLogger.showError("Error on creating an inventory cache for " + name + ", maybe inventory wipe in preparation...");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
|
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
|
||||||
causeByAuthMe.put(name, true);
|
causeByAuthMe.put(name, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user