meta
This commit is contained in:
parent
8bd6618481
commit
9c42be39d8
@ -22,9 +22,9 @@ 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.ConsoleLogger;
|
||||||
|
import fr.xephi.authme.Utils;
|
||||||
import fr.xephi.authme.api.API;
|
import fr.xephi.authme.api.API;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.Utils;
|
|
||||||
|
|
||||||
public class FileCache {
|
public class FileCache {
|
||||||
|
|
||||||
@ -217,108 +217,93 @@ public class FileCache {
|
|||||||
boolean op = false;
|
boolean op = false;
|
||||||
boolean flying = false;
|
boolean flying = false;
|
||||||
|
|
||||||
Scanner reader = null;
|
Scanner reader = new Scanner(file);
|
||||||
try {
|
|
||||||
reader = new Scanner(file);
|
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int a = 0;
|
int a = 0;
|
||||||
while (reader.hasNextLine()) {
|
while (reader.hasNextLine()) {
|
||||||
String line = reader.nextLine();
|
String line = reader.nextLine();
|
||||||
|
|
||||||
if (!line.contains(":")) {
|
if (!line.contains(":")) {
|
||||||
// the fist line represent the player group,
|
// the fist line represent the player group,
|
||||||
// operator
|
// operator
|
||||||
// status
|
// status
|
||||||
// and flying status
|
// and flying status
|
||||||
final String[] playerInfo = line.split(";");
|
final String[] playerInfo = line.split(";");
|
||||||
group = playerInfo[0];
|
group = playerInfo[0];
|
||||||
|
|
||||||
if (Integer.parseInt(playerInfo[1]) == 1) {
|
if (Integer.parseInt(playerInfo[1]) == 1) {
|
||||||
op = true;
|
op = true;
|
||||||
} else op = false;
|
} else op = false;
|
||||||
if (playerInfo.length > 2) {
|
if (playerInfo.length > 2) {
|
||||||
if (Integer.parseInt(playerInfo[2]) == 1)
|
if (Integer.parseInt(playerInfo[2]) == 1)
|
||||||
flying = true;
|
flying = true;
|
||||||
else flying = false;
|
else flying = false;
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!line.startsWith("i") && !line.startsWith("w")) {
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String lores = "";
|
|
||||||
String name = "";
|
|
||||||
if (line.split("\\*").length > 1) {
|
|
||||||
lores = line.split("\\*")[1];
|
|
||||||
line = line.split("\\*")[0];
|
|
||||||
}
|
|
||||||
if (line.split(";").length > 1) {
|
|
||||||
name = line.split(";")[1];
|
|
||||||
line = line.split(";")[0];
|
|
||||||
}
|
|
||||||
final String[] in = line.split(":");
|
|
||||||
// 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]));
|
|
||||||
k++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
ItemMeta meta = plugin.getServer().getItemFactory().getItemMeta(stacki[i].getType());
|
|
||||||
if (!name.isEmpty()) {
|
|
||||||
meta.setDisplayName(name);
|
|
||||||
}
|
|
||||||
if (!lores.isEmpty()) {
|
|
||||||
List<String> loreList = new ArrayList<String>();
|
|
||||||
for (String s : lores.split("%newline%")) {
|
|
||||||
loreList.add(s);
|
|
||||||
}
|
|
||||||
meta.setLore(loreList);
|
|
||||||
}
|
|
||||||
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]));
|
|
||||||
k++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
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%")) {
|
|
||||||
loreList.add(s);
|
|
||||||
}
|
|
||||||
meta.setLore(loreList);
|
|
||||||
}
|
|
||||||
if (meta != null)
|
|
||||||
stacki[i].setItemMeta(meta);
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
a++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
|
||||||
ConsoleLogger.showError("Error on creating a file cache for " + player.getName() + ", maybe wipe inventory...");
|
if (!line.startsWith("i") && !line.startsWith("w")) {
|
||||||
} finally {
|
continue;
|
||||||
if (reader != null) {
|
}
|
||||||
reader.close();
|
String lores = "";
|
||||||
|
String name = "";
|
||||||
|
if (line.split("\\*").length > 1) {
|
||||||
|
lores = line.split("\\*")[1];
|
||||||
|
line = line.split("\\*")[0];
|
||||||
|
}
|
||||||
|
if (line.split(";").length > 1) {
|
||||||
|
name = line.split(";")[1];
|
||||||
|
line = line.split(";")[0];
|
||||||
|
}
|
||||||
|
final String[] in = line.split(":");
|
||||||
|
// 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]));
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ItemMeta meta = stacki[i].getItemMeta();
|
||||||
|
if (!name.isEmpty()) {
|
||||||
|
meta.setDisplayName(name);
|
||||||
|
}
|
||||||
|
if (!lores.isEmpty()) {
|
||||||
|
List<String> loreList = new ArrayList<String>();
|
||||||
|
for (String s : lores.split("%newline%")) {
|
||||||
|
loreList.add(s);
|
||||||
|
}
|
||||||
|
meta.setLore(loreList);
|
||||||
|
}
|
||||||
|
if (meta != null)
|
||||||
|
stacki[i].setItemMeta(meta);
|
||||||
|
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]));
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ItemMeta meta = stacka[a].getItemMeta();
|
||||||
|
if (!name.isEmpty())
|
||||||
|
meta.setDisplayName(name);
|
||||||
|
if (!lores.isEmpty()) {
|
||||||
|
List<String> loreList = new ArrayList<String>();
|
||||||
|
for (String s : lores.split("%newline%")) {
|
||||||
|
loreList.add(s);
|
||||||
|
}
|
||||||
|
meta.setLore(loreList);
|
||||||
|
}
|
||||||
|
if (meta != null)
|
||||||
|
stacki[i].setItemMeta(meta);
|
||||||
|
a++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new DataFileCache(stacki, stacka, group, op, flying);
|
return new DataFileCache(stacki, stacka, group, op, flying);
|
||||||
@ -548,7 +533,7 @@ public class FileCache {
|
|||||||
file.delete();
|
file.delete();
|
||||||
} else {
|
} else {
|
||||||
file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + player.getName().toLowerCase() + ".cache");
|
file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + player.getName().toLowerCase() + ".cache");
|
||||||
if(file.isFile()){
|
if (file.isFile()) {
|
||||||
file.delete();
|
file.delete();
|
||||||
} else {
|
} else {
|
||||||
ConsoleLogger.showError("Failed to remove" + player.getName() + "cache, it doesn't exist!");
|
ConsoleLogger.showError("Failed to remove" + player.getName() + "cache, it doesn't exist!");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user