mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-26 20:26:01 +01:00
Fix Item unstacking, disable customAttributes by default
This commit is contained in:
parent
9ba90bfb97
commit
514d5bfe6e
@ -23,6 +23,7 @@ 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.api.API;
|
import fr.xephi.authme.api.API;
|
||||||
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
|
||||||
public class FileCache {
|
public class FileCache {
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ public class FileCache {
|
|||||||
String group, boolean operator, boolean flying) {
|
String group, boolean operator, boolean flying) {
|
||||||
String path = "";
|
String path = "";
|
||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
path = player.getUniqueId().toString();
|
path = player.getUniqueId().toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -104,19 +105,21 @@ 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 {
|
if (Settings.customAttributes) {
|
||||||
Attributes attributes = new Attributes(item);
|
try {
|
||||||
if (attributes != null)
|
Attributes attributes = new Attributes(item);
|
||||||
while (attributes.values().iterator().hasNext()) {
|
if (attributes != null)
|
||||||
Attribute a = attributes.values().iterator().next();
|
while (attributes.values().iterator().hasNext()) {
|
||||||
if (a != null) {
|
Attribute a = attributes.values().iterator().next();
|
||||||
if (a.getName() != null && a.getAttributeType() != null
|
if (a != null) {
|
||||||
&& a.getOperation() != null && a.getUUID() != null)
|
if (a.getName() != null && a.getAttributeType() != 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");
|
||||||
}
|
}
|
||||||
@ -159,19 +162,20 @@ 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 {
|
if (Settings.customAttributes) {
|
||||||
Attributes attributes = new Attributes(item);
|
try {
|
||||||
if (attributes != null)
|
Attributes attributes = new Attributes(item);
|
||||||
while (attributes.values().iterator().hasNext()) {
|
if (attributes != null)
|
||||||
Attribute a = attributes.values().iterator().next();
|
while (attributes.values().iterator().hasNext()) {
|
||||||
if (a != null) {
|
Attribute a = attributes.values().iterator().next();
|
||||||
if (a.getName() != null && a.getAttributeType() != null
|
if (a != null) {
|
||||||
&& a.getOperation() != null && a.getUUID() != null
|
if (a.getName() != null && a.getAttributeType() != null && a.getOperation() != null && a.getUUID() != null && a.getAttributeType().getMinecraftId() != null)
|
||||||
&& a.getAttributeType().getMinecraftId() != 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);
|
||||||
}
|
}
|
||||||
@ -216,7 +220,8 @@ public class FileCache {
|
|||||||
String line = reader.nextLine();
|
String line = reader.nextLine();
|
||||||
|
|
||||||
if (!line.contains(":")) {
|
if (!line.contains(":")) {
|
||||||
// the fist line represent the player group, operator
|
// the fist line represent the player group,
|
||||||
|
// operator
|
||||||
// status
|
// status
|
||||||
// and flying status
|
// and flying status
|
||||||
final String[] playerInfo = line.split(";");
|
final String[] playerInfo = line.split(";");
|
||||||
@ -388,22 +393,25 @@ public class FileCache {
|
|||||||
line = line.substring(8);
|
line = line.substring(8);
|
||||||
item.addEnchantment(Enchantment.getByName(line.split(":")[0]), Integer.parseInt(line.split(":")[1]));
|
item.addEnchantment(Enchantment.getByName(line.split(":")[0]), Integer.parseInt(line.split(":")[1]));
|
||||||
}
|
}
|
||||||
if (line.startsWith("attribute=")) {
|
if (Settings.customAttributes)
|
||||||
if (attributes == null)
|
{
|
||||||
attributes = new Attributes(item);
|
if (line.startsWith("attribute=")) {
|
||||||
try {
|
if (attributes == null)
|
||||||
line = line.substring(10);
|
attributes = new Attributes(item);
|
||||||
String[] args = line.split(";");
|
try {
|
||||||
if (args.length != 5)
|
line = line.substring(10);
|
||||||
continue;
|
String[] args = line.split(";");
|
||||||
String name = args[0];
|
if (args.length != 5)
|
||||||
AttributeType type = AttributeType.fromId(args[1]);
|
continue;
|
||||||
double amount = Double.parseDouble(args[2]);
|
String name = args[0];
|
||||||
Operation operation = Operation.fromId(Integer.parseInt(args[3]));
|
AttributeType type = AttributeType.fromId(args[1]);
|
||||||
UUID uuid = UUID.fromString(args[4]);
|
double amount = Double.parseDouble(args[2]);
|
||||||
Attribute attribute = new Attribute(new Builder(amount, operation, type, name, uuid));
|
Operation operation = Operation.fromId(Integer.parseInt(args[3]));
|
||||||
attributes.add(attribute);
|
UUID uuid = UUID.fromString(args[4]);
|
||||||
} catch (Exception e) {
|
Attribute attribute = new Attribute(new Builder(amount, operation, type, name, uuid));
|
||||||
|
attributes.add(attribute);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
@ -412,8 +420,7 @@ public class FileCache {
|
|||||||
reader.close();
|
reader.close();
|
||||||
if (attributes != null)
|
if (attributes != null)
|
||||||
inv[i] = attributes.getStack();
|
inv[i] = attributes.getStack();
|
||||||
else
|
else inv[i] = item;
|
||||||
inv[i] = item;
|
|
||||||
}
|
}
|
||||||
for (int i = 0; i < armours.length; i++) {
|
for (int i = 0; i < armours.length; i++) {
|
||||||
reader = new Scanner(new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "armours" + File.separator + i + ".cache"));
|
reader = new Scanner(new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "armours" + File.separator + i + ".cache"));
|
||||||
@ -461,22 +468,25 @@ public class FileCache {
|
|||||||
line = line.substring(8);
|
line = line.substring(8);
|
||||||
item.addEnchantment(Enchantment.getByName(line.split(":")[0]), Integer.parseInt(line.split(":")[1]));
|
item.addEnchantment(Enchantment.getByName(line.split(":")[0]), Integer.parseInt(line.split(":")[1]));
|
||||||
}
|
}
|
||||||
if (line.startsWith("attribute=")) {
|
if (Settings.customAttributes)
|
||||||
if (attributes == null)
|
{
|
||||||
attributes = new Attributes(item);
|
if (line.startsWith("attribute=")) {
|
||||||
try {
|
if (attributes == null)
|
||||||
line = line.substring(10);
|
attributes = new Attributes(item);
|
||||||
String[] args = line.split(";");
|
try {
|
||||||
if (args.length != 5)
|
line = line.substring(10);
|
||||||
continue;
|
String[] args = line.split(";");
|
||||||
String name = args[0];
|
if (args.length != 5)
|
||||||
AttributeType type = AttributeType.fromId(args[1]);
|
continue;
|
||||||
double amount = Double.parseDouble(args[2]);
|
String name = args[0];
|
||||||
Operation operation = Operation.fromId(Integer.parseInt(args[3]));
|
AttributeType type = AttributeType.fromId(args[1]);
|
||||||
UUID uuid = UUID.fromString(args[4]);
|
double amount = Double.parseDouble(args[2]);
|
||||||
Attribute attribute = new Attribute(new Builder(amount, operation, type, name, uuid));
|
Operation operation = Operation.fromId(Integer.parseInt(args[3]));
|
||||||
attributes.add(attribute);
|
UUID uuid = UUID.fromString(args[4]);
|
||||||
} catch (Exception e) {
|
Attribute attribute = new Attribute(new Builder(amount, operation, type, name, uuid));
|
||||||
|
attributes.add(attribute);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
@ -485,12 +495,11 @@ public class FileCache {
|
|||||||
reader.close();
|
reader.close();
|
||||||
if (attributes != null)
|
if (attributes != null)
|
||||||
armours[i] = attributes.getStack();
|
armours[i] = attributes.getStack();
|
||||||
else
|
else armours[i] = item;
|
||||||
armours[i] = item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming...");
|
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();
|
||||||
@ -498,8 +507,8 @@ public class FileCache {
|
|||||||
return new DataFileCache(inv, armours, group, op, flying);
|
return new DataFileCache(inv, armours, group, op, flying);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming...");
|
ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming...");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,7 +540,7 @@ public class FileCache {
|
|||||||
} else file.delete();
|
} else file.delete();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ConsoleLogger.showError("File cannot be removed correctly :/");
|
ConsoleLogger.showError("File cannot be removed correctly :/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ public final class Settings extends YamlConfiguration {
|
|||||||
purgePermissions, enableProtection, enableAntiBot, recallEmail,
|
purgePermissions, enableProtection, enableAntiBot, recallEmail,
|
||||||
useWelcomeMessage, broadcastWelcomeMessage, forceRegKick,
|
useWelcomeMessage, broadcastWelcomeMessage, forceRegKick,
|
||||||
forceRegLogin, checkVeryGames, delayJoinMessage, noTeleport,
|
forceRegLogin, checkVeryGames, delayJoinMessage, noTeleport,
|
||||||
applyBlindEffect;
|
applyBlindEffect, customAttributes;
|
||||||
|
|
||||||
public static String getNickRegex, getUnloggedinGroup, getMySQLHost,
|
public static String getNickRegex, getUnloggedinGroup, getMySQLHost,
|
||||||
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
|
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
|
||||||
@ -270,6 +270,7 @@ public final class Settings extends YamlConfiguration {
|
|||||||
emailWhitelist = configFile.getStringList("Email.emailWhitelisted");
|
emailWhitelist = configFile.getStringList("Email.emailWhitelisted");
|
||||||
forceRegisterCommands = (List<String>) configFile.getList("settings.forceRegisterCommands", new ArrayList<String>());
|
forceRegisterCommands = (List<String>) configFile.getList("settings.forceRegisterCommands", new ArrayList<String>());
|
||||||
forceRegisterCommandsAsConsole = (List<String>) configFile.getList("settings.forceRegisterCommandsAsConsole", new ArrayList<String>());
|
forceRegisterCommandsAsConsole = (List<String>) configFile.getList("settings.forceRegisterCommandsAsConsole", new ArrayList<String>());
|
||||||
|
customAttributes = configFile.getBoolean("Hooks.customAttributes");
|
||||||
|
|
||||||
// Load the welcome message
|
// Load the welcome message
|
||||||
getWelcomeMessage(plugin);
|
getWelcomeMessage(plugin);
|
||||||
@ -437,6 +438,7 @@ public final class Settings extends YamlConfiguration {
|
|||||||
emailWhitelist = configFile.getStringList("Email.emailWhitelisted");
|
emailWhitelist = configFile.getStringList("Email.emailWhitelisted");
|
||||||
forceRegisterCommands = (List<String>) configFile.getList("settings.forceRegisterCommands", new ArrayList<String>());
|
forceRegisterCommands = (List<String>) configFile.getList("settings.forceRegisterCommands", new ArrayList<String>());
|
||||||
forceRegisterCommandsAsConsole = (List<String>) configFile.getList("settings.forceRegisterCommandsAsConsole", new ArrayList<String>());
|
forceRegisterCommandsAsConsole = (List<String>) configFile.getList("settings.forceRegisterCommandsAsConsole", new ArrayList<String>());
|
||||||
|
customAttributes = configFile.getBoolean("Hooks.customAttributes");
|
||||||
|
|
||||||
// Reload the welcome message
|
// Reload the welcome message
|
||||||
getWelcomeMessage(AuthMe.getInstance());
|
getWelcomeMessage(AuthMe.getInstance());
|
||||||
@ -579,6 +581,11 @@ public final class Settings extends YamlConfiguration {
|
|||||||
set("settings.forceRegisterCommandsAsConsole", new ArrayList<String>());
|
set("settings.forceRegisterCommandsAsConsole", new ArrayList<String>());
|
||||||
changes = true;
|
changes = true;
|
||||||
}
|
}
|
||||||
|
if (!contains("Hooks.customAttributes"))
|
||||||
|
{
|
||||||
|
set("Hooks.customAttributes", false);
|
||||||
|
changes = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (changes) {
|
if (changes) {
|
||||||
plugin.getLogger().warning("Merge new Config Options - I'm not an error, please don't report me");
|
plugin.getLogger().warning("Merge new Config Options - I'm not an error, please don't report me");
|
||||||
|
@ -381,6 +381,8 @@ Hooks:
|
|||||||
disableSocialSpy: true
|
disableSocialSpy: true
|
||||||
# Do we need to force /motd Essentials command on join ?
|
# Do we need to force /motd Essentials command on join ?
|
||||||
useEssentialsMotd: false
|
useEssentialsMotd: false
|
||||||
|
# Do we need to cache custom Attributes ?
|
||||||
|
customAttributes: false
|
||||||
Performances:
|
Performances:
|
||||||
# HIGHLY recommended to use this! This will increase database performance
|
# HIGHLY recommended to use this! This will increase database performance
|
||||||
# Default is true, change it to false if you experience issues
|
# Default is true, change it to false if you experience issues
|
||||||
|
Loading…
Reference in New Issue
Block a user