AuthMe 3.4

This commit is contained in:
Xephi
2014-06-13 05:56:59 +02:00
parent ff9ec22041
commit 2638007ada
52 changed files with 504 additions and 383 deletions
+15 -1
View File
@@ -26,6 +26,7 @@ public class PlayerAuth {
this.lastLogin = lastLogin;
this.email = email;
this.realName = realName;
}
public PlayerAuth(String nickname, double x, double y, double z, String world) {
@@ -34,6 +35,8 @@ public class PlayerAuth {
this.y = y;
this.z = z;
this.world = world;
this.lastLogin = System.currentTimeMillis();
}
public PlayerAuth(String nickname, String hash, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) {
@@ -47,6 +50,7 @@ public class PlayerAuth {
this.world = world;
this.email = email;
this.realName = 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) {
@@ -62,6 +66,7 @@ public class PlayerAuth {
this.groupId = groupId;
this.email = email;
this.realName = realName;
}
public PlayerAuth(String nickname, String hash, String salt, int groupId , String ip, long lastLogin, String realName) {
@@ -72,6 +77,7 @@ public class PlayerAuth {
this.salt = salt;
this.groupId = groupId;
this.realName = realName;
}
public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, String realName) {
@@ -81,6 +87,7 @@ public class PlayerAuth {
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) {
@@ -101,6 +108,14 @@ public class PlayerAuth {
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;
}
public String getIp() {
@@ -218,5 +233,4 @@ public class PlayerAuth {
public String getRealname() {
return realName;
}
}
+96 -82
View File
@@ -10,11 +10,14 @@ import java.util.Scanner;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import fr.xephi.authme.AuthMe;
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()) {
@@ -127,25 +130,25 @@ public class FileCache {
final File file = new File("cache/" + playername
+ ".cache");
ItemStack[] stacki = new ItemStack[36];
ItemStack[] stacka = new ItemStack[4];
String group = null;
boolean op = false;
boolean flying = false;
if (!file.exists()) {
return new DataFileCache(stacki, stacka);
}
ItemStack[] stacki = new ItemStack[36];
ItemStack[] stacka = new ItemStack[4];
String group = null;
boolean op = false;
boolean flying = false;
if (!file.exists()) {
return new DataFileCache(stacki, stacka);
}
Scanner reader = null;
try {
reader = new Scanner(file);
Scanner reader = null;
try {
reader = new Scanner(file);
int i = 0;
int a = 0;
while (reader.hasNextLine()) {
String line = reader.nextLine();
int i = 0;
int a = 0;
while (reader.hasNextLine()) {
String line = reader.nextLine();
if (!line.contains(":")) {
if (!line.contains(":")) {
// the fist line represent the player group, operator status and flying status
final String[] playerInfo = line.split(";");
group = playerInfo[0];
@@ -154,77 +157,88 @@ public class FileCache {
op = true;
} else op = false;
if (playerInfo.length > 2) {
if (Integer.parseInt(playerInfo[2]) == 1)
flying = true;
else flying = false;
if (Integer.parseInt(playerInfo[2]) == 1)
flying = true;
else flying = false;
}
continue;
}
}
if (!line.startsWith("i") && !line.startsWith("w")) {
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(":");
if (!line.startsWith("i") && !line.startsWith("w")) {
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++;
}
}
if (!name.isEmpty())
stacki[i].getItemMeta().setDisplayName(name);
if (!lores.isEmpty()) {
List<String> loreList = new ArrayList<String>();
for (String s : lores.split("%newline%")) {
loreList.add(s);
}
stacki[i].getItemMeta().setLore(loreList);
}
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++;
}
}
if (!name.isEmpty())
stacka[a].getItemMeta().setDisplayName(name);
if (!lores.isEmpty()) {
List<String> loreList = new ArrayList<String>();
for (String s : lores.split("%newline%")) {
loreList.add(s);
}
stacka[a].getItemMeta().setLore(loreList);
}
a++;
}
}
} catch (final Exception e) {
e.printStackTrace();
} finally {
if (reader != null) {
reader.close();
}
}
return new DataFileCache(stacki, stacka, group, op, flying);
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) {
e.printStackTrace();
} finally {
if (reader != null) {
reader.close();
}
}
return new DataFileCache(stacki, stacka, group, op, flying);
}
public void removeCache(String playername) {