diff --git a/src/main/java/com/comphenix/attribute/AttributeStorage.java b/src/main/java/com/comphenix/attribute/AttributeStorage.java
index 55f4fced..2d9aa526 100644
--- a/src/main/java/com/comphenix/attribute/AttributeStorage.java
+++ b/src/main/java/com/comphenix/attribute/AttributeStorage.java
@@ -12,105 +12,125 @@ import com.google.common.base.Preconditions;
/**
* Store meta-data in an ItemStack as attributes.
+ *
* @author Kristian
*/
public class AttributeStorage {
+
private ItemStack target;
private final UUID uniqueKey;
-
+
private AttributeStorage(ItemStack target, UUID uniqueKey) {
this.target = Preconditions.checkNotNull(target, "target cannot be NULL");
this.uniqueKey = Preconditions.checkNotNull(uniqueKey, "uniqueKey cannot be NULL");
}
-
+
/**
* Construct a new attribute storage system.
*
* The key must be the same in order to retrieve the same data.
- * @param target - the item stack where the data will be stored.
- * @param uniqueKey - the unique key used to retrieve the correct data.
+ *
+ * @param target
+ * - the item stack where the data will be stored.
+ * @param uniqueKey
+ * - the unique key used to retrieve the correct data.
*/
public static AttributeStorage newTarget(ItemStack target, UUID uniqueKey) {
return new AttributeStorage(target, uniqueKey);
}
-
+
/**
* Retrieve the data stored in the item's attribute.
- * @param defaultValue - the default value to return if no data can be found.
+ *
+ * @param defaultValue
+ * - the default value to return if no data can be found.
* @return The stored data, or defaultValue if not found.
*/
public String getData(String defaultValue) {
Attribute current = getAttribute(new Attributes(target), uniqueKey);
return current != null ? current.getName() : defaultValue;
}
-
+
/**
* Determine if we are storing any data.
+ *
* @return TRUE if we are, FALSE otherwise.
*/
public boolean hasData() {
- return getAttribute(new Attributes(target), uniqueKey) != null;
+ return getAttribute(new Attributes(target), uniqueKey) != null;
}
-
+
/**
* Set the data stored in the attributes.
- * @param data - the data.
+ *
+ * @param data
+ * - the data.
*/
public void setData(String data) {
Attributes attributes = new Attributes(target);
Attribute current = getAttribute(attributes, uniqueKey);
if (current == null) {
- attributes.add(
- Attribute.newBuilder().
- name(data).
- amount(getBaseDamage(target)).
- uuid(uniqueKey).
- operation(Operation.ADD_NUMBER).
- type(AttributeType.GENERIC_ATTACK_DAMAGE).
- build()
- );
+ attributes.add(Attribute.newBuilder().name(data).amount(getBaseDamage(target)).uuid(uniqueKey).operation(Operation.ADD_NUMBER).type(AttributeType.GENERIC_ATTACK_DAMAGE).build());
} else {
current.setName(data);
}
this.target = attributes.getStack();
}
-
+
/**
* Retrieve the base damage of the given item.
- * @param stack - the stack.
+ *
+ * @param stack
+ * - the stack.
* @return The base damage.
*/
private int getBaseDamage(ItemStack stack) {
- // Yes - we have to hard code these values. Cannot use Operation.ADD_PERCENTAGE either.
- switch (stack.getType()) {
- case WOOD_SWORD: return 4;
- case GOLD_SWORD: return 4;
- case STONE_SWORD: return 5;
- case IRON_SWORD: return 6;
- case DIAMOND_SWORD: return 7;
-
- case WOOD_AXE: return 3;
- case GOLD_AXE: return 3;
- case STONE_AXE: return 4;
- case IRON_AXE: return 5;
- case DIAMOND_AXE: return 6;
- default: return 0;
- }
+ // Yes - we have to hard code these values. Cannot use
+ // Operation.ADD_PERCENTAGE either.
+ switch (stack.getType()) {
+ case WOOD_SWORD:
+ return 4;
+ case GOLD_SWORD:
+ return 4;
+ case STONE_SWORD:
+ return 5;
+ case IRON_SWORD:
+ return 6;
+ case DIAMOND_SWORD:
+ return 7;
+
+ case WOOD_AXE:
+ return 3;
+ case GOLD_AXE:
+ return 3;
+ case STONE_AXE:
+ return 4;
+ case IRON_AXE:
+ return 5;
+ case DIAMOND_AXE:
+ return 6;
+ default:
+ return 0;
+ }
}
-
+
/**
* Retrieve the target stack. May have been changed.
+ *
* @return The target stack.
*/
public ItemStack getTarget() {
return target;
}
-
+
/**
* Retrieve an attribute by UUID.
- * @param attributes - the attribute.
- * @param id - the UUID to search for.
+ *
+ * @param attributes
+ * - the attribute.
+ * @param id
+ * - the UUID to search for.
* @return The first attribute associated with this UUID, or NULL.
*/
private Attribute getAttribute(Attributes attributes, UUID id) {
@@ -121,4 +141,4 @@ public class AttributeStorage {
}
return null;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/comphenix/attribute/Attributes.java b/src/main/java/com/comphenix/attribute/Attributes.java
index 274b13cd..d11afe30 100644
--- a/src/main/java/com/comphenix/attribute/Attributes.java
+++ b/src/main/java/com/comphenix/attribute/Attributes.java
@@ -19,20 +19,22 @@ import com.google.common.collect.Iterators;
import com.google.common.collect.Maps;
public class Attributes {
+
public enum Operation {
ADD_NUMBER(0),
MULTIPLY_PERCENTAGE(1),
ADD_PERCENTAGE(2);
+
private int id;
-
+
private Operation(int id) {
this.id = id;
}
-
+
public int getId() {
return id;
}
-
+
public static Operation fromId(int id) {
// Linear scan is very fast for small N
for (Operation op : values()) {
@@ -43,56 +45,64 @@ public class Attributes {
throw new IllegalArgumentException("Corrupt operation ID " + id + " detected.");
}
}
-
+
public static class AttributeType {
+
private static ConcurrentMap LOOKUP = Maps.newConcurrentMap();
public static final AttributeType GENERIC_MAX_HEALTH = new AttributeType("generic.maxHealth").register();
public static final AttributeType GENERIC_FOLLOW_RANGE = new AttributeType("generic.followRange").register();
public static final AttributeType GENERIC_ATTACK_DAMAGE = new AttributeType("generic.attackDamage").register();
public static final AttributeType GENERIC_MOVEMENT_SPEED = new AttributeType("generic.movementSpeed").register();
public static final AttributeType GENERIC_KNOCKBACK_RESISTANCE = new AttributeType("generic.knockbackResistance").register();
-
+
private final String minecraftId;
-
+
/**
* Construct a new attribute type.
*
* Remember to {@link #register()} the type.
- * @param minecraftId - the ID of the type.
+ *
+ * @param minecraftId
+ * - the ID of the type.
*/
public AttributeType(String minecraftId) {
this.minecraftId = minecraftId;
}
-
+
/**
* Retrieve the associated minecraft ID.
+ *
* @return The associated ID.
*/
public String getMinecraftId() {
return minecraftId;
}
-
+
/**
* Register the type in the central registry.
+ *
* @return The registered type.
*/
- // Constructors should have no side-effects!
+ // Constructors should have no side-effects!
public AttributeType register() {
AttributeType old = LOOKUP.putIfAbsent(minecraftId, this);
return old != null ? old : this;
}
-
+
/**
* Retrieve the attribute type associated with a given ID.
- * @param minecraftId The ID to search for.
+ *
+ * @param minecraftId
+ * The ID to search for.
* @return The attribute type, or NULL if not found.
*/
public static AttributeType fromId(String minecraftId) {
return LOOKUP.get(minecraftId);
}
-
+
/**
* Retrieve every registered attribute type.
+ *
* @return Every type.
*/
public static Iterable values() {
@@ -101,6 +111,7 @@ public class Attributes {
}
public static class Attribute {
+
private NbtCompound data;
public Attribute(Builder builder) {
@@ -111,11 +122,11 @@ public class Attributes {
setName(builder.name);
setUUID(builder.uuid);
}
-
+
private Attribute(NbtCompound data) {
this.data = data;
}
-
+
public double getAmount() {
return data.getDouble("Amount", 0.0);
}
@@ -162,15 +173,18 @@ public class Attributes {
}
/**
- * Construct a new attribute builder with a random UUID and default operation of adding numbers.
+ * Construct a new attribute builder with a random UUID and default
+ * operation of adding numbers.
+ *
* @return The attribute builder.
*/
public static Builder newBuilder() {
return new Builder().uuid(UUID.randomUUID()).operation(Operation.ADD_NUMBER);
}
-
+
// Makes it easier to construct an attribute
public static class Builder {
+
private double amount;
private Operation operation = Operation.ADD_NUMBER;
private AttributeType type;
@@ -181,7 +195,8 @@ public class Attributes {
// Don't make this accessible
}
- public Builder(double amount, Operation operation, AttributeType type, String name, UUID uuid) {
+ public Builder(double amount, Operation operation,
+ AttributeType type, String name, UUID uuid) {
this.amount = amount;
this.operation = operation;
this.type = type;
@@ -193,139 +208,156 @@ public class Attributes {
this.amount = amount;
return this;
}
+
public Builder operation(Operation operation) {
this.operation = operation;
return this;
}
+
public Builder type(AttributeType type) {
this.type = type;
return this;
}
+
public Builder name(String name) {
this.name = name;
return this;
}
+
public Builder uuid(UUID uuid) {
this.uuid = uuid;
return this;
}
+
public Attribute build() {
return new Attribute(this);
}
}
}
-
+
// This may be modified
public ItemStack stack;
private NbtList attributes;
-
+
public Attributes(ItemStack stack) {
// Create a CraftItemStack (under the hood)
this.stack = NbtFactory.getCraftItemStack(stack);
loadAttributes(false);
}
-
+
/**
* Load the NBT list from the TAG compound.
- * @param createIfMissing - create the list if its missing.
+ *
+ * @param createIfMissing
+ * - create the list if its missing.
*/
private void loadAttributes(boolean createIfMissing) {
- if (this.attributes == null) {
+ if (this.attributes == null) {
NbtCompound nbt = NbtFactory.fromItemTag(this.stack);
this.attributes = nbt.getList("AttributeModifiers", createIfMissing);
- }
+ }
}
-
+
/**
* Remove the NBT list from the TAG compound.
*/
private void removeAttributes() {
- NbtCompound nbt = NbtFactory.fromItemTag(this.stack);
- nbt.remove("AttributeModifiers");
- this.attributes = null;
+ NbtCompound nbt = NbtFactory.fromItemTag(this.stack);
+ nbt.remove("AttributeModifiers");
+ this.attributes = null;
}
-
+
/**
* Retrieve the modified item stack.
+ *
* @return The modified item stack.
*/
public ItemStack getStack() {
return stack;
}
-
+
/**
* Retrieve the number of attributes.
+ *
* @return Number of attributes.
*/
public int size() {
return attributes != null ? attributes.size() : 0;
}
-
+
/**
* Add a new attribute to the list.
- * @param attribute - the new attribute.
+ *
+ * @param attribute
+ * - the new attribute.
*/
public void add(Attribute attribute) {
- Preconditions.checkNotNull(attribute.getName(), "must specify an attribute name.");
- loadAttributes(true);
+ Preconditions.checkNotNull(attribute.getName(), "must specify an attribute name.");
+ loadAttributes(true);
attributes.add(attribute.data);
}
-
+
/**
* Remove the first instance of the given attribute.
*
* The attribute will be removed using its UUID.
- * @param attribute - the attribute to remove.
+ *
+ * @param attribute
+ * - the attribute to remove.
* @return TRUE if the attribute was removed, FALSE otherwise.
*/
public boolean remove(Attribute attribute) {
- if (attributes == null)
- return false;
+ if (attributes == null)
+ return false;
UUID uuid = attribute.getUUID();
-
- for (Iterator it = values().iterator(); it.hasNext(); ) {
+
+ for (Iterator it = values().iterator(); it.hasNext();) {
if (Objects.equal(it.next().getUUID(), uuid)) {
it.remove();
-
+
// Last removed attribute?
if (size() == 0) {
- removeAttributes();
+ removeAttributes();
}
return true;
}
}
return false;
}
-
+
/**
* Remove every attribute.
*/
public void clear() {
- removeAttributes();
+ removeAttributes();
}
-
+
/**
* Retrieve the attribute at a given index.
- * @param index - the index to look up.
+ *
+ * @param index
+ * - the index to look up.
* @return The attribute at that index.
*/
public Attribute get(int index) {
- if (size() == 0)
- throw new IllegalStateException("Attribute list is empty.");
+ if (size() == 0)
+ throw new IllegalStateException("Attribute list is empty.");
return new Attribute((NbtCompound) attributes.get(index));
}
- // We can't make Attributes itself iterable without splitting it up into separate classes
- public Iterable values() {
+ // We can't make Attributes itself iterable without splitting it up into
+ // separate classes
+ public Iterable values() {
return new Iterable() {
+
@Override
public Iterator iterator() {
- // Handle the empty case
- if (size() == 0)
- return Collections.emptyList().iterator();
-
- return Iterators.transform(attributes.iterator(),
- new Function() {
+ // Handle the empty case
+ if (size() == 0)
+ return Collections. emptyList().iterator();
+
+ return Iterators.transform(attributes.iterator(), new Function() {
+
@Override
public Attribute apply(@Nullable Object element) {
return new Attribute((NbtCompound) element);
diff --git a/src/main/java/com/comphenix/attribute/NbtFactory.java b/src/main/java/com/comphenix/attribute/NbtFactory.java
index 6bd51a61..7fe03cb6 100644
--- a/src/main/java/com/comphenix/attribute/NbtFactory.java
+++ b/src/main/java/com/comphenix/attribute/NbtFactory.java
@@ -40,20 +40,22 @@ import com.google.common.io.InputSupplier;
import com.google.common.io.OutputSupplier;
import com.google.common.primitives.Primitives;
-public class NbtFactory {
+public class NbtFactory {
+
// Convert between NBT id and the equivalent class in java
private static final BiMap> NBT_CLASS = HashBiMap.create();
private static final BiMap NBT_ENUM = HashBiMap.create();
-
+
/**
* Whether or not to enable stream compression.
+ *
* @author Kristian
*/
public enum StreamOptions {
NO_COMPRESSION,
GZIP_COMPRESSION,
}
-
+
private enum NbtType {
TAG_END(0, Void.class),
TAG_BYTE(1, byte.class),
@@ -70,23 +72,22 @@ public class NbtFactory {
// Unique NBT id
public final int id;
-
+
private NbtType(int id, Class> type) {
this.id = id;
NBT_CLASS.put(id, type);
NBT_ENUM.put(id, this);
}
-
+
private String getFieldName() {
- if (this == TAG_COMPOUND)
+ if (this == TAG_COMPOUND)
return "map";
else if (this == TAG_LIST)
return "list";
- else
- return "data";
+ else return "data";
}
}
-
+
// The NBT base class
private Class> BASE_CLASS;
private Class> COMPOUND_CLASS;
@@ -101,151 +102,184 @@ public class NbtFactory {
private Class> CRAFT_STACK;
private Field CRAFT_HANDLE;
private Field STACK_TAG;
-
+
// Loading/saving compounds
private LoadCompoundMethod LOAD_COMPOUND;
private Method SAVE_COMPOUND;
-
+
// Shared instance
private static NbtFactory INSTANCE;
-
+
/**
* Represents a root NBT compound.
*
- * All changes to this map will be reflected in the underlying NBT compound. Values may only be one of the following:
+ * All changes to this map will be reflected in the underlying NBT compound.
+ * Values may only be one of the following:
*
- * Primitive types
- * {@link java.lang.String String}
- * {@link NbtList}
- * {@link NbtCompound}
+ * Primitive types
+ * {@link java.lang.String String}
+ * {@link NbtList}
+ * {@link NbtCompound}
*
*
* See also:
*
- * {@link NbtFactory#createCompound()}
- * {@link NbtFactory#fromCompound(Object)}
+ * {@link NbtFactory#createCompound()}
+ * {@link NbtFactory#fromCompound(Object)}
*
+ *
* @author Kristian
*/
public final class NbtCompound extends ConvertedMap {
+
private NbtCompound(Object handle) {
super(handle, getDataMap(handle));
}
// Simplifiying access to each value
public Byte getByte(String key, Byte defaultValue) {
- return containsKey(key) ? (Byte)get(key) : defaultValue;
+ return containsKey(key) ? (Byte) get(key) : defaultValue;
}
+
public Short getShort(String key, Short defaultValue) {
- return containsKey(key) ? (Short)get(key) : defaultValue;
+ return containsKey(key) ? (Short) get(key) : defaultValue;
}
+
public Integer getInteger(String key, Integer defaultValue) {
- return containsKey(key) ? (Integer)get(key) : defaultValue;
+ return containsKey(key) ? (Integer) get(key) : defaultValue;
}
+
public Long getLong(String key, Long defaultValue) {
- return containsKey(key) ? (Long)get(key) : defaultValue;
+ return containsKey(key) ? (Long) get(key) : defaultValue;
}
+
public Float getFloat(String key, Float defaultValue) {
- return containsKey(key) ? (Float)get(key) : defaultValue;
+ return containsKey(key) ? (Float) get(key) : defaultValue;
}
+
public Double getDouble(String key, Double defaultValue) {
- return containsKey(key) ? (Double)get(key) : defaultValue;
+ return containsKey(key) ? (Double) get(key) : defaultValue;
}
+
public String getString(String key, String defaultValue) {
- return containsKey(key) ? (String)get(key) : defaultValue;
+ return containsKey(key) ? (String) get(key) : defaultValue;
}
+
public byte[] getByteArray(String key, byte[] defaultValue) {
- return containsKey(key) ? (byte[])get(key) : defaultValue;
+ return containsKey(key) ? (byte[]) get(key) : defaultValue;
}
+
public int[] getIntegerArray(String key, int[] defaultValue) {
- return containsKey(key) ? (int[])get(key) : defaultValue;
+ return containsKey(key) ? (int[]) get(key) : defaultValue;
}
-
+
/**
* Retrieve the list by the given name.
- * @param key - the name of the list.
- * @param createNew - whether or not to create a new list if its missing.
+ *
+ * @param key
+ * - the name of the list.
+ * @param createNew
+ * - whether or not to create a new list if its missing.
* @return An existing list, a new list or NULL.
*/
public NbtList getList(String key, boolean createNew) {
NbtList list = (NbtList) get(key);
-
- if (list == null && createNew)
+
+ if (list == null && createNew)
put(key, list = createList());
return list;
}
-
+
/**
* Retrieve the map by the given name.
- * @param key - the name of the map.
- * @param createNew - whether or not to create a new map if its missing.
+ *
+ * @param key
+ * - the name of the map.
+ * @param createNew
+ * - whether or not to create a new map if its missing.
* @return An existing map, a new map or NULL.
*/
public NbtCompound getMap(String key, boolean createNew) {
return getMap(Arrays.asList(key), createNew);
}
+
// Done
-
+
/**
* Set the value of an entry at a given location.
*
- * Every element of the path (except the end) are assumed to be compounds, and will
- * be created if they are missing.
- * @param path - the path to the entry.
- * @param value - the new value of this entry.
+ * Every element of the path (except the end) are assumed to be
+ * compounds, and will be created if they are missing.
+ *
+ * @param path
+ * - the path to the entry.
+ * @param value
+ * - the new value of this entry.
* @return This compound, for chaining.
*/
public NbtCompound putPath(String path, Object value) {
List entries = getPathElements(path);
Map map = getMap(entries.subList(0, entries.size() - 1), true);
-
+
map.put(entries.get(entries.size() - 1), value);
return this;
}
-
+
/**
* Retrieve the value of a given entry in the tree.
*
- * Every element of the path (except the end) are assumed to be compounds. The
- * retrieval operation will be cancelled if any of them are missing.
- * @param path - path to the entry.
+ * Every element of the path (except the end) are assumed to be
+ * compounds. The retrieval operation will be cancelled if any of them
+ * are missing.
+ *
+ * @param path
+ * - path to the entry.
* @return The value, or NULL if not found.
*/
@SuppressWarnings("unchecked")
public T getPath(String path) {
List entries = getPathElements(path);
NbtCompound map = getMap(entries.subList(0, entries.size() - 1), false);
-
+
if (map != null) {
return (T) map.get(entries.get(entries.size() - 1));
}
return null;
}
-
+
/**
* Save the content of a NBT compound to a stream.
*
- * Use {@link Files#newOutputStreamSupplier(java.io.File)} to provide a stream supplier to a file.
- * @param stream - the output stream.
- * @param option - whether or not to compress the output.
- * @throws IOException If anything went wrong.
+ * Use {@link Files#newOutputStreamSupplier(java.io.File)} to provide a
+ * stream supplier to a file.
+ *
+ * @param stream
+ * - the output stream.
+ * @param option
+ * - whether or not to compress the output.
+ * @throws IOException
+ * If anything went wrong.
*/
- public void saveTo(OutputSupplier extends OutputStream> stream, StreamOptions option) throws IOException {
+ public void saveTo(OutputSupplier extends OutputStream> stream,
+ StreamOptions option) throws IOException {
saveStream(this, stream, option);
}
-
+
/**
* Retrieve a map from a given path.
- * @param path - path of compounds to look up.
- * @param createNew - whether or not to create new compounds on the way.
+ *
+ * @param path
+ * - path of compounds to look up.
+ * @param createNew
+ * - whether or not to create new compounds on the way.
* @return The map at this location.
*/
private NbtCompound getMap(Iterable path, boolean createNew) {
NbtCompound current = this;
-
+
for (String entry : path) {
NbtCompound child = (NbtCompound) current.get(entry);
-
+
if (child == null) {
if (!createNew)
return null;
@@ -255,46 +289,53 @@ public class NbtFactory {
}
return current;
}
-
+
/**
* Split the path into separate elements.
- * @param path - the path to split.
+ *
+ * @param path
+ * - the path to split.
* @return The elements.
*/
private List getPathElements(String path) {
return Lists.newArrayList(Splitter.on(".").omitEmptyStrings().split(path));
}
}
-
+
/**
- * Represents a root NBT list.
- * See also:
+ * Represents a root NBT list. See also:
*
- * {@link NbtFactory#createNbtList()}
- * {@link NbtFactory#fromList(Object)}
+ * {@link NbtFactory#createNbtList()}
+ * {@link NbtFactory#fromList(Object)}
*
+ *
* @author Kristian
*/
public final class NbtList extends ConvertedList {
+
private NbtList(Object handle) {
super(handle, getDataList(handle));
}
}
-
+
/**
* Represents an object that provides a view of a native NMS class.
+ *
* @author Kristian
*/
public static interface Wrapper {
+
/**
* Retrieve the underlying native NBT tag.
+ *
* @return The underlying NBT.
*/
public Object getHandle();
}
-
+
/**
* Retrieve or construct a shared NBT factory.
+ *
* @return The factory.
*/
private static NbtFactory get() {
@@ -302,147 +343,152 @@ public class NbtFactory {
INSTANCE = new NbtFactory();
return INSTANCE;
}
-
+
/**
- * Construct an instance of the NBT factory by deducing the class of NBTBase.
+ * Construct an instance of the NBT factory by deducing the class of
+ * NBTBase.
*/
private NbtFactory() {
if (BASE_CLASS == null) {
try {
- // Keep in mind that I do use hard-coded field names - but it's okay as long as we're dealing
- // with CraftBukkit or its derivatives. This does not work in MCPC+ however.
+ // Keep in mind that I do use hard-coded field names - but it's
+ // okay as long as we're dealing
+ // with CraftBukkit or its derivatives. This does not work in
+ // MCPC+ however.
ClassLoader loader = NbtFactory.class.getClassLoader();
-
+
String packageName = getPackageName();
Class> offlinePlayer = loader.loadClass(packageName + ".CraftOfflinePlayer");
-
+
// Prepare NBT
COMPOUND_CLASS = getMethod(0, Modifier.STATIC, offlinePlayer, "getData").getReturnType();
BASE_CLASS = COMPOUND_CLASS.getSuperclass();
NBT_GET_TYPE = getMethod(0, Modifier.STATIC, BASE_CLASS, "getTypeId");
NBT_CREATE_TAG = getMethod(Modifier.STATIC, 0, BASE_CLASS, "createTag", byte.class);
-
+
// Prepare CraftItemStack
CRAFT_STACK = loader.loadClass(packageName + ".inventory.CraftItemStack");
CRAFT_HANDLE = getField(null, CRAFT_STACK, "handle");
STACK_TAG = getField(null, CRAFT_HANDLE.getType(), "tag");
-
+
// Loading/saving
String nmsPackage = BASE_CLASS.getPackage().getName();
- initializeNMS(loader, nmsPackage);
-
- LOAD_COMPOUND = READ_LIMITER_CLASS != null ?
- new LoadMethodSkinUpdate(STREAM_TOOLS, READ_LIMITER_CLASS) :
- new LoadMethodWorldUpdate(STREAM_TOOLS);
+ initializeNMS(loader, nmsPackage);
+
+ LOAD_COMPOUND = READ_LIMITER_CLASS != null ? new LoadMethodSkinUpdate(STREAM_TOOLS, READ_LIMITER_CLASS) : new LoadMethodWorldUpdate(STREAM_TOOLS);
SAVE_COMPOUND = getMethod(Modifier.STATIC, 0, STREAM_TOOLS, null, BASE_CLASS, DataOutput.class);
-
+
} catch (ClassNotFoundException e) {
throw new IllegalStateException("Unable to find offline player.", e);
}
}
}
- private void initializeNMS(ClassLoader loader, String nmsPackage) {
- try {
- STREAM_TOOLS = loader.loadClass(nmsPackage + ".NBTCompressedStreamTools");
- READ_LIMITER_CLASS = loader.loadClass(nmsPackage + ".NBTReadLimiter");
- } catch (ClassNotFoundException e) {
- // Ignore - we will detect this later
- }
- }
-
+ private void initializeNMS(ClassLoader loader, String nmsPackage) {
+ try {
+ STREAM_TOOLS = loader.loadClass(nmsPackage + ".NBTCompressedStreamTools");
+ READ_LIMITER_CLASS = loader.loadClass(nmsPackage + ".NBTReadLimiter");
+ } catch (ClassNotFoundException e) {
+ // Ignore - we will detect this later
+ }
+ }
+
private String getPackageName() {
- Server server = Bukkit.getServer();
- String name = server != null ? server.getClass().getPackage().getName() : null;
-
- if (name != null && name.contains("craftbukkit")) {
- return name;
- } else {
- // Fallback
- return "org.bukkit.craftbukkit.v1_7_R3";
- }
- }
-
+ Server server = Bukkit.getServer();
+ String name = server != null ? server.getClass().getPackage().getName() : null;
+
+ if (name != null && name.contains("craftbukkit")) {
+ return name;
+ } else {
+ // Fallback
+ return "org.bukkit.craftbukkit.v1_7_R3";
+ }
+ }
+
@SuppressWarnings("unchecked")
private Map getDataMap(Object handle) {
- return (Map) getFieldValue(
- getDataField(NbtType.TAG_COMPOUND, handle), handle);
+ return (Map) getFieldValue(getDataField(NbtType.TAG_COMPOUND, handle), handle);
}
-
+
@SuppressWarnings("unchecked")
private List getDataList(Object handle) {
- return (List) getFieldValue(
- getDataField(NbtType.TAG_LIST, handle), handle);
+ return (List) getFieldValue(getDataField(NbtType.TAG_LIST, handle), handle);
}
-
+
/**
* Construct a new NBT list of an unspecified type.
+ *
* @return The NBT list.
*/
public static NbtList createList(Object... content) {
return createList(Arrays.asList(content));
}
-
+
/**
* Construct a new NBT list of an unspecified type.
+ *
* @return The NBT list.
*/
public static NbtList createList(Iterable extends Object> iterable) {
- NbtList list = get().new NbtList(
- INSTANCE.createNbtTag(NbtType.TAG_LIST, null)
- );
-
+ NbtList list = get().new NbtList(INSTANCE.createNbtTag(NbtType.TAG_LIST, null));
+
// Add the content as well
- for (Object obj : iterable)
+ for (Object obj : iterable)
list.add(obj);
return list;
}
-
+
/**
* Construct a new NBT compound.
*
* Use {@link NbtCompound#asMap()} to modify it.
+ *
* @return The NBT compound.
*/
public static NbtCompound createCompound() {
- return get().new NbtCompound(
- INSTANCE.createNbtTag(NbtType.TAG_COMPOUND, null)
- );
+ return get().new NbtCompound(INSTANCE.createNbtTag(NbtType.TAG_COMPOUND, null));
}
-
+
/**
* Construct a new NBT wrapper from a list.
- * @param nmsList - the NBT list.
+ *
+ * @param nmsList
+ * - the NBT list.
* @return The wrapper.
*/
public static NbtList fromList(Object nmsList) {
return get().new NbtList(nmsList);
}
-
+
/**
* Load the content of a file from a stream.
*
- * Use {@link Files#newInputStreamSupplier(java.io.File)} to provide a stream from a file.
- * @param stream - the stream supplier.
- * @param option - whether or not to decompress the input stream.
+ * Use {@link Files#newInputStreamSupplier(java.io.File)} to provide a
+ * stream from a file.
+ *
+ * @param stream
+ * - the stream supplier.
+ * @param option
+ * - whether or not to decompress the input stream.
* @return The decoded NBT compound.
- * @throws IOException If anything went wrong.
+ * @throws IOException
+ * If anything went wrong.
*/
- public static NbtCompound fromStream(InputSupplier extends InputStream> stream, StreamOptions option) throws IOException {
+ public static NbtCompound fromStream(
+ InputSupplier extends InputStream> stream, StreamOptions option)
+ throws IOException {
InputStream input = null;
DataInputStream data = null;
boolean suppress = true;
-
+
try {
input = stream.getInput();
- data = new DataInputStream(new BufferedInputStream(
- option == StreamOptions.GZIP_COMPRESSION ? new GZIPInputStream(input) : input
- ));
-
+ data = new DataInputStream(new BufferedInputStream(option == StreamOptions.GZIP_COMPRESSION ? new GZIPInputStream(input) : input));
+
NbtCompound result = fromCompound(get().LOAD_COMPOUND.loadNbt(data));
suppress = false;
return result;
-
+
} finally {
if (data != null)
Closeables.close(data, suppress);
@@ -450,30 +496,36 @@ public class NbtFactory {
Closeables.close(input, suppress);
}
}
-
+
/**
* Save the content of a NBT compound to a stream.
*
- * Use {@link Files#newOutputStreamSupplier(java.io.File)} to provide a stream supplier to a file.
- * @param source - the NBT compound to save.
- * @param stream - the stream.
- * @param option - whether or not to compress the output.
- * @throws IOException If anything went wrong.
+ * Use {@link Files#newOutputStreamSupplier(java.io.File)} to provide a
+ * stream supplier to a file.
+ *
+ * @param source
+ * - the NBT compound to save.
+ * @param stream
+ * - the stream.
+ * @param option
+ * - whether or not to compress the output.
+ * @throws IOException
+ * If anything went wrong.
*/
- public static void saveStream(NbtCompound source, OutputSupplier extends OutputStream> stream, StreamOptions option) throws IOException {
+ public static void saveStream(NbtCompound source,
+ OutputSupplier extends OutputStream> stream, StreamOptions option)
+ throws IOException {
OutputStream output = null;
DataOutputStream data = null;
boolean suppress = true;
-
+
try {
output = stream.getOutput();
- data = new DataOutputStream(
- option == StreamOptions.GZIP_COMPRESSION ? new GZIPOutputStream(output) : output
- );
-
+ data = new DataOutputStream(option == StreamOptions.GZIP_COMPRESSION ? new GZIPOutputStream(output) : output);
+
invokeMethod(get().SAVE_COMPOUND, null, source.getHandle(), data);
suppress = false;
-
+
} finally {
if (data != null)
Closeables.close(data, suppress);
@@ -481,10 +533,12 @@ public class NbtFactory {
Closeables.close(output, suppress);
}
}
-
+
/**
* Construct a new NBT wrapper from a compound.
- * @param nmsCompound - the NBT compund.
+ *
+ * @param nmsCompound
+ * - the NBT compund.
* @return The wrapper.
*/
public static NbtCompound fromCompound(Object nmsCompound) {
@@ -494,34 +548,40 @@ public class NbtFactory {
/**
* Set the NBT compound tag of a given item stack.
*
- * The item stack must be a wrapper for a CraftItemStack. Use
+ * The item stack must be a wrapper for a CraftItemStack. Use
* {@link MinecraftReflection#getBukkitItemStack(ItemStack)} if not.
- * @param stack - the item stack, cannot be air.
- * @param compound - the new NBT compound, or NULL to remove it.
- * @throws IllegalArgumentException If the stack is not a CraftItemStack, or it represents air.
+ *
+ * @param stack
+ * - the item stack, cannot be air.
+ * @param compound
+ * - the new NBT compound, or NULL to remove it.
+ * @throws IllegalArgumentException
+ * If the stack is not a CraftItemStack, or it represents air.
*/
public static void setItemTag(ItemStack stack, NbtCompound compound) {
checkItemStack(stack);
Object nms = getFieldValue(get().CRAFT_HANDLE, stack);
-
+
// Now update the tag compound
setFieldValue(get().STACK_TAG, nms, compound.getHandle());
}
/**
- * Construct a wrapper for an NBT tag stored (in memory) in an item stack. This is where
- * auxillary data such as enchanting, name and lore is stored. It does not include items
- * material, damage value or count.
+ * Construct a wrapper for an NBT tag stored (in memory) in an item stack.
+ * This is where auxillary data such as enchanting, name and lore is stored.
+ * It does not include items material, damage value or count.
*
* The item stack must be a wrapper for a CraftItemStack.
- * @param stack - the item stack.
+ *
+ * @param stack
+ * - the item stack.
* @return A wrapper for its NBT tag.
*/
public static NbtCompound fromItemTag(ItemStack stack) {
checkItemStack(stack);
Object nms = getFieldValue(get().CRAFT_HANDLE, stack);
Object tag = getFieldValue(get().STACK_TAG, nms);
-
+
// Create the tag if it doesn't exist
if (tag == null) {
NbtCompound compound = createCompound();
@@ -530,10 +590,12 @@ public class NbtFactory {
}
return fromCompound(tag);
}
-
+
/**
* Retrieve a CraftItemStack version of the stack.
- * @param stack - the stack to convert.
+ *
+ * @param stack
+ * - the stack to convert.
* @return The CraftItemStack version.
*/
public static ItemStack getCraftItemStack(ItemStack stack) {
@@ -549,10 +611,12 @@ public class NbtFactory {
throw new IllegalStateException("Unable to convert " + stack + " + to a CraftItemStack.");
}
}
-
+
/**
* Ensure that the given stack can store arbitrary NBT information.
- * @param stack - the stack to check.
+ *
+ * @param stack
+ * - the stack to check.
*/
private static void checkItemStack(ItemStack stack) {
if (stack == null)
@@ -562,35 +626,43 @@ public class NbtFactory {
if (stack.getType() == Material.AIR)
throw new IllegalArgumentException("ItemStacks representing air cannot store NMS information.");
}
-
+
/**
- * Convert wrapped List and Map objects into their respective NBT counterparts.
- * @param name - the name of the NBT element to create.
- * @param value - the value of the element to create. Can be a List or a Map.
+ * Convert wrapped List and Map objects into their respective NBT
+ * counterparts.
+ *
+ * @param name
+ * - the name of the NBT element to create.
+ * @param value
+ * - the value of the element to create. Can be a List or a Map.
* @return The NBT element.
*/
private Object unwrapValue(Object value) {
if (value == null)
return null;
-
+
if (value instanceof Wrapper) {
return ((Wrapper) value).getHandle();
-
+
} else if (value instanceof List) {
throw new IllegalArgumentException("Can only insert a WrappedList.");
} else if (value instanceof Map) {
throw new IllegalArgumentException("Can only insert a WrappedCompound.");
-
+
} else {
return createNbtTag(getPrimitiveType(value), value);
}
}
-
+
/**
- * Convert a given NBT element to a primitive wrapper or List/Map equivalent.
+ * Convert a given NBT element to a primitive wrapper or List/Map
+ * equivalent.
*
- * All changes to any mutable objects will be reflected in the underlying NBT element(s).
- * @param nms - the NBT element.
+ * All changes to any mutable objects will be reflected in the underlying
+ * NBT element(s).
+ *
+ * @param nms
+ * - the NBT element.
* @return The wrapper equivalent.
*/
private Object wrapNative(Object nms) {
@@ -599,7 +671,7 @@ public class NbtFactory {
if (BASE_CLASS.isAssignableFrom(nms.getClass())) {
final NbtType type = getNbtType(nms);
-
+
// Handle the different types
switch (type) {
case TAG_COMPOUND:
@@ -612,76 +684,89 @@ public class NbtFactory {
}
throw new IllegalArgumentException("Unexpected type: " + nms);
}
-
+
/**
* Construct a new NMS NBT tag initialized with the given value.
- * @param type - the NBT type.
- * @param value - the value, or NULL to keep the original value.
+ *
+ * @param type
+ * - the NBT type.
+ * @param value
+ * - the value, or NULL to keep the original value.
* @return The created tag.
*/
private Object createNbtTag(NbtType type, Object value) {
- Object tag = invokeMethod(NBT_CREATE_TAG, null, (byte)type.id);
+ Object tag = invokeMethod(NBT_CREATE_TAG, null, (byte) type.id);
if (value != null) {
setFieldValue(getDataField(type, tag), tag, value);
}
return tag;
}
-
+
/**
* Retrieve the field where the NBT class stores its value.
- * @param type - the NBT type.
- * @param nms - the NBT class instance.
+ *
+ * @param type
+ * - the NBT type.
+ * @param nms
+ * - the NBT class instance.
* @return The corresponding field.
*/
private Field getDataField(NbtType type, Object nms) {
- if (DATA_FIELD[type.id] == null)
+ if (DATA_FIELD[type.id] == null)
DATA_FIELD[type.id] = getField(nms, null, type.getFieldName());
return DATA_FIELD[type.id];
}
-
+
/**
* Retrieve the NBT type from a given NMS NBT tag.
- * @param nms - the native NBT tag.
+ *
+ * @param nms
+ * - the native NBT tag.
* @return The corresponding type.
*/
private NbtType getNbtType(Object nms) {
int type = (Byte) invokeMethod(NBT_GET_TYPE, nms);
return NBT_ENUM.get(type);
}
-
+
/**
* Retrieve the nearest NBT type for a given primitive type.
- * @param primitive - the primitive type.
+ *
+ * @param primitive
+ * - the primitive type.
* @return The corresponding type.
*/
private NbtType getPrimitiveType(Object primitive) {
- NbtType type = NBT_ENUM.get(NBT_CLASS.inverse().get(
- Primitives.unwrap(primitive.getClass())
- ));
-
+ NbtType type = NBT_ENUM.get(NBT_CLASS.inverse().get(Primitives.unwrap(primitive.getClass())));
+
// Display the illegal value at least
if (type == null)
- throw new IllegalArgumentException(String.format(
- "Illegal type: %s (%s)", primitive.getClass(), primitive));
+ throw new IllegalArgumentException(String.format("Illegal type: %s (%s)", primitive.getClass(), primitive));
return type;
}
/**
- * Invoke a method on the given target instance using the provided parameters.
- * @param method - the method to invoke.
- * @param target - the target.
- * @param params - the parameters to supply.
+ * Invoke a method on the given target instance using the provided
+ * parameters.
+ *
+ * @param method
+ * - the method to invoke.
+ * @param target
+ * - the target.
+ * @param params
+ * - the parameters to supply.
* @return The result of the method.
*/
- private static Object invokeMethod(Method method, Object target, Object... params) {
+ private static Object invokeMethod(Method method, Object target,
+ Object... params) {
try {
return method.invoke(target, params);
} catch (Exception e) {
throw new RuntimeException("Unable to invoke method " + method + " for " + target, e);
}
}
-
+
private static void setFieldValue(Field field, Object target, Object value) {
try {
field.set(target, value);
@@ -689,7 +774,7 @@ public class NbtFactory {
throw new RuntimeException("Unable to set " + field + " for " + target, e);
}
}
-
+
private static Object getFieldValue(Field field, Object target) {
try {
return field.get(target);
@@ -697,25 +782,31 @@ public class NbtFactory {
throw new RuntimeException("Unable to retrieve " + field + " for " + target, e);
}
}
-
+
/**
- * Search for the first publically and privately defined method of the given name and parameter count.
- * @param requireMod - modifiers that are required.
- * @param bannedMod - modifiers that are banned.
- * @param clazz - a class to start with.
- * @param methodName - the method name, or NULL to skip.
- * @param params - the expected parameters.
+ * Search for the first publically and privately defined method of the given
+ * name and parameter count.
+ *
+ * @param requireMod
+ * - modifiers that are required.
+ * @param bannedMod
+ * - modifiers that are banned.
+ * @param clazz
+ * - a class to start with.
+ * @param methodName
+ * - the method name, or NULL to skip.
+ * @param params
+ * - the expected parameters.
* @return The first method by this name.
- * @throws IllegalStateException If we cannot find this method.
+ * @throws IllegalStateException
+ * If we cannot find this method.
*/
- private static Method getMethod(int requireMod, int bannedMod, Class> clazz, String methodName, Class>... params) {
+ private static Method getMethod(int requireMod, int bannedMod,
+ Class> clazz, String methodName, Class>... params) {
for (Method method : clazz.getDeclaredMethods()) {
// Limitation: Doesn't handle overloads
- if ((method.getModifiers() & requireMod) == requireMod &&
- (method.getModifiers() & bannedMod) == 0 &&
- (methodName == null || method.getName().equals(methodName)) &&
- Arrays.equals(method.getParameterTypes(), params)) {
-
+ if ((method.getModifiers() & requireMod) == requireMod && (method.getModifiers() & bannedMod) == 0 && (methodName == null || method.getName().equals(methodName)) && Arrays.equals(method.getParameterTypes(), params)) {
+
method.setAccessible(true);
return method;
}
@@ -723,20 +814,27 @@ public class NbtFactory {
// Search in every superclass
if (clazz.getSuperclass() != null)
return getMethod(requireMod, bannedMod, clazz.getSuperclass(), methodName, params);
- throw new IllegalStateException(String.format(
- "Unable to find method %s (%s).", methodName, Arrays.asList(params)));
+ throw new IllegalStateException(String.format("Unable to find method %s (%s).", methodName, Arrays.asList(params)));
}
-
+
/**
- * Search for the first publically and privately defined field of the given name.
- * @param instance - an instance of the class with the field.
- * @param clazz - an optional class to start with, or NULL to deduce it from instance.
- * @param fieldName - the field name.
+ * Search for the first publically and privately defined field of the given
+ * name.
+ *
+ * @param instance
+ * - an instance of the class with the field.
+ * @param clazz
+ * - an optional class to start with, or NULL to deduce it from
+ * instance.
+ * @param fieldName
+ * - the field name.
* @return The first field by this name.
- * @throws IllegalStateException If we cannot find this field.
+ * @throws IllegalStateException
+ * If we cannot find this field.
*/
- private static Field getField(Object instance, Class> clazz, String fieldName) {
- if (clazz == null)
+ private static Field getField(Object instance, Class> clazz,
+ String fieldName) {
+ if (clazz == null)
clazz = instance.getClass();
// Ignore access rules
for (Field field : clazz.getDeclaredFields()) {
@@ -750,144 +848,150 @@ public class NbtFactory {
return getField(instance, clazz.getSuperclass(), fieldName);
throw new IllegalStateException("Unable to find field " + fieldName + " in " + instance);
}
-
+
/**
* Represents a class for caching wrappers.
+ *
* @author Kristian
*/
private final class CachedNativeWrapper {
+
// Don't recreate wrapper objects
private final ConcurrentMap cache = new MapMaker().weakKeys().makeMap();
-
+
public Object wrap(Object value) {
Object current = cache.get(value);
-
+
if (current == null) {
current = wrapNative(value);
-
+
// Only cache composite objects
- if (current instanceof ConvertedMap ||
- current instanceof ConvertedList) {
+ if (current instanceof ConvertedMap || current instanceof ConvertedList) {
cache.put(value, current);
}
}
return current;
}
}
-
+
/**
- * Represents a map that wraps another map and automatically
- * converts entries of its type and another exposed type.
+ * Represents a map that wraps another map and automatically converts
+ * entries of its type and another exposed type.
+ *
* @author Kristian
*/
- private class ConvertedMap extends AbstractMap implements Wrapper {
+ private class ConvertedMap extends AbstractMap implements
+ Wrapper {
+
private final Object handle;
private final Map original;
-
+
private final CachedNativeWrapper cache = new CachedNativeWrapper();
public ConvertedMap(Object handle, Map original) {
this.handle = handle;
this.original = original;
}
-
+
// For converting back and forth
protected Object wrapOutgoing(Object value) {
return cache.wrap(value);
}
+
protected Object unwrapIncoming(Object wrapped) {
return unwrapValue(wrapped);
}
-
+
// Modification
@Override
public Object put(String key, Object value) {
- return wrapOutgoing(original.put(
- (String) key,
- unwrapIncoming(value)
- ));
+ return wrapOutgoing(original.put((String) key, unwrapIncoming(value)));
}
-
+
// Performance
@Override
public Object get(Object key) {
return wrapOutgoing(original.get(key));
}
+
@Override
public Object remove(Object key) {
return wrapOutgoing(original.remove(key));
}
+
@Override
public boolean containsKey(Object key) {
return original.containsKey(key);
}
-
+
@Override
public Set> entrySet() {
- return new AbstractSet>() {
+ return new AbstractSet>() {
+
@Override
public boolean add(Entry e) {
String key = e.getKey();
Object value = e.getValue();
-
+
original.put(key, unwrapIncoming(value));
return true;
}
-
+
@Override
public int size() {
return original.size();
}
-
+
@Override
public Iterator> iterator() {
return ConvertedMap.this.iterator();
}
};
}
-
+
private Iterator> iterator() {
final Iterator> proxy = original.entrySet().iterator();
-
+
return new Iterator>() {
+
@Override
public boolean hasNext() {
return proxy.hasNext();
}
-
+
@Override
public Entry next() {
Entry entry = proxy.next();
-
- return new SimpleEntry(
- entry.getKey(), wrapOutgoing(entry.getValue())
- );
+
+ return new SimpleEntry(entry.getKey(), wrapOutgoing(entry.getValue()));
}
-
+
@Override
public void remove() {
proxy.remove();
}
};
}
-
+
@Override
public Object getHandle() {
return handle;
}
}
-
+
/**
- * Represents a list that wraps another list and converts elements
- * of its type and another exposed type.
+ * Represents a list that wraps another list and converts elements of its
+ * type and another exposed type.
+ *
* @author Kristian
*/
private class ConvertedList extends AbstractList implements Wrapper {
+
private final Object handle;
-
+
private final List original;
private final CachedNativeWrapper cache = new CachedNativeWrapper();
-
+
public ConvertedList(Object handle, List original) {
if (NBT_LIST_TYPE == null)
NBT_LIST_TYPE = getField(handle, null, "type");
@@ -898,106 +1002,119 @@ public class NbtFactory {
protected Object wrapOutgoing(Object value) {
return cache.wrap(value);
}
+
protected Object unwrapIncoming(Object wrapped) {
return unwrapValue(wrapped);
}
-
+
@Override
public Object get(int index) {
return wrapOutgoing(original.get(index));
}
+
@Override
public int size() {
return original.size();
}
+
@Override
public Object set(int index, Object element) {
- return wrapOutgoing(
- original.set(index, unwrapIncoming(element))
- );
+ return wrapOutgoing(original.set(index, unwrapIncoming(element)));
}
+
@Override
public void add(int index, Object element) {
Object nbt = unwrapIncoming(element);
-
+
// Set the list type if its the first element
- if (size() == 0)
- setFieldValue(NBT_LIST_TYPE, handle, (byte)getNbtType(nbt).id);
+ if (size() == 0)
+ setFieldValue(NBT_LIST_TYPE, handle, (byte) getNbtType(nbt).id);
original.add(index, nbt);
}
+
@Override
public Object remove(int index) {
return wrapOutgoing(original.remove(index));
}
+
@Override
public boolean remove(Object o) {
return original.remove(unwrapIncoming(o));
}
-
+
@Override
public Object getHandle() {
return handle;
}
}
-
+
/**
* Represents a method for loading an NBT compound.
+ *
* @author Kristian
*/
- private static abstract class LoadCompoundMethod {
- protected Method staticMethod;
-
- protected void setMethod(Method method) {
- this.staticMethod = method;
- this.staticMethod.setAccessible(true);
- }
-
- /**
- * Load an NBT compound from a given stream.
- * @param input - the input stream.
- * @return The loaded NBT compound.
- */
- public abstract Object loadNbt(DataInput input);
- }
-
- /**
- * Load an NBT compound from the NBTCompressedStreamTools static method in 1.7.2 - 1.7.5
- */
- private static class LoadMethodWorldUpdate extends LoadCompoundMethod {
- public LoadMethodWorldUpdate(Class> streamClass) {
- setMethod(getMethod(Modifier.STATIC, 0, streamClass, null, DataInput.class));
- }
-
- @Override
- public Object loadNbt(DataInput input) {
- return invokeMethod(staticMethod, null, input);
- }
- }
+ private static abstract class LoadCompoundMethod {
- /**
- * Load an NBT compound from the NBTCompressedStreamTools static method in 1.7.8
- */
- private static class LoadMethodSkinUpdate extends LoadCompoundMethod {
- private Object readLimiter;
-
- public LoadMethodSkinUpdate(Class> streamClass, Class> readLimiterClass) {
- setMethod(getMethod(Modifier.STATIC, 0, streamClass, null, DataInput.class, readLimiterClass));
-
- // Find the unlimited read limiter
- for (Field field : readLimiterClass.getDeclaredFields()) {
- if (readLimiterClass.isAssignableFrom(field.getType())) {
- try {
- readLimiter = field.get(null);
- } catch (Exception e) {
- throw new RuntimeException("Cannot retrieve read limiter.", e);
- }
- }
- }
- }
-
- @Override
- public Object loadNbt(DataInput input) {
- return invokeMethod(staticMethod, null, input, readLimiter);
- }
- }
-}
\ No newline at end of file
+ protected Method staticMethod;
+
+ protected void setMethod(Method method) {
+ this.staticMethod = method;
+ this.staticMethod.setAccessible(true);
+ }
+
+ /**
+ * Load an NBT compound from a given stream.
+ *
+ * @param input
+ * - the input stream.
+ * @return The loaded NBT compound.
+ */
+ public abstract Object loadNbt(DataInput input);
+ }
+
+ /**
+ * Load an NBT compound from the NBTCompressedStreamTools static method in
+ * 1.7.2 - 1.7.5
+ */
+ private static class LoadMethodWorldUpdate extends LoadCompoundMethod {
+
+ public LoadMethodWorldUpdate(Class> streamClass) {
+ setMethod(getMethod(Modifier.STATIC, 0, streamClass, null, DataInput.class));
+ }
+
+ @Override
+ public Object loadNbt(DataInput input) {
+ return invokeMethod(staticMethod, null, input);
+ }
+ }
+
+ /**
+ * Load an NBT compound from the NBTCompressedStreamTools static method in
+ * 1.7.8
+ */
+ private static class LoadMethodSkinUpdate extends LoadCompoundMethod {
+
+ private Object readLimiter;
+
+ public LoadMethodSkinUpdate(Class> streamClass,
+ Class> readLimiterClass) {
+ setMethod(getMethod(Modifier.STATIC, 0, streamClass, null, DataInput.class, readLimiterClass));
+
+ // Find the unlimited read limiter
+ for (Field field : readLimiterClass.getDeclaredFields()) {
+ if (readLimiterClass.isAssignableFrom(field.getType())) {
+ try {
+ readLimiter = field.get(null);
+ } catch (Exception e) {
+ throw new RuntimeException("Cannot retrieve read limiter.", e);
+ }
+ }
+ }
+ }
+
+ @Override
+ public Object loadNbt(DataInput input) {
+ return invokeMethod(staticMethod, null, input, readLimiter);
+ }
+ }
+}
diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java
index c1f7d088..6cb5f985 100644
--- a/src/main/java/fr/xephi/authme/AuthMe.java
+++ b/src/main/java/fr/xephi/authme/AuthMe.java
@@ -126,6 +126,7 @@ public class AuthMe extends JavaPlugin {
if (Settings.enableAntiBot) {
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
+
@Override
public void run() {
delayedAntiBot = false;
@@ -155,18 +156,15 @@ public class AuthMe extends JavaPlugin {
Class.forName("org.apache.logging.log4j.core.Filter");
setLog4JFilter();
} catch (ClassNotFoundException e) {
- ConsoleLogger
- .info("You're using Minecraft 1.6.x or older, Log4J support is disabled");
+ ConsoleLogger.info("You're using Minecraft 1.6.x or older, Log4J support is disabled");
} catch (NoClassDefFoundError e) {
- ConsoleLogger
- .info("You're using Minecraft 1.6.x or older, Log4J support is disabled");
+ ConsoleLogger.info("You're using Minecraft 1.6.x or older, Log4J support is disabled");
}
}
// Load MailApi
- if (!Settings.getmailAccount.isEmpty()
- && !Settings.getmailPassword.isEmpty()) mail = new SendMailSSL(
- this);
+ if (!Settings.getmailAccount.isEmpty() && !Settings.getmailPassword.isEmpty())
+ mail = new SendMailSSL(this);
// Check Citizens Version
citizensVersion();
@@ -191,7 +189,8 @@ public class AuthMe extends JavaPlugin {
*/
if (Settings.isBackupActivated && Settings.isBackupOnStart) {
Boolean Backup = new PerformBackup(this).DoBackup();
- if (Backup) ConsoleLogger.info("Backup Complete");
+ if (Backup)
+ ConsoleLogger.info("Backup Complete");
else ConsoleLogger.showError("Error while making Backup");
}
@@ -240,10 +239,8 @@ public class AuthMe extends JavaPlugin {
PluginManager pm = getServer().getPluginManager();
if (Settings.bungee) {
- Bukkit.getMessenger().registerOutgoingPluginChannel(this,
- "BungeeCord");
- Bukkit.getMessenger().registerIncomingPluginChannel(this,
- "BungeeCord", new BungeeCordMessage(this));
+ Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
+ Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCordMessage(this));
}
if (pm.isPluginEnabled("Spout")) {
pm.registerEvents(new AuthMeSpoutListener(database), this);
@@ -261,35 +258,32 @@ public class AuthMe extends JavaPlugin {
this.getCommand("authme").setExecutor(new AdminCommand(this, database));
this.getCommand("register").setExecutor(new RegisterCommand(this));
this.getCommand("login").setExecutor(new LoginCommand(this));
- this.getCommand("changepassword").setExecutor(
- new ChangePasswordCommand(database, this));
- this.getCommand("logout")
- .setExecutor(new LogoutCommand(this, database));
- this.getCommand("unregister").setExecutor(
- new UnregisterCommand(this, database));
+ this.getCommand("changepassword").setExecutor(new ChangePasswordCommand(database, this));
+ this.getCommand("logout").setExecutor(new LogoutCommand(this, database));
+ this.getCommand("unregister").setExecutor(new UnregisterCommand(this, database));
this.getCommand("passpartu").setExecutor(new PasspartuCommand(this));
this.getCommand("email").setExecutor(new EmailCommand(this, database));
this.getCommand("captcha").setExecutor(new CaptchaCommand(this));
- this.getCommand("converter").setExecutor(
- new ConverterCommand(this, database));
+ this.getCommand("converter").setExecutor(new ConverterCommand(this, database));
if (!Settings.isForceSingleSessionEnabled) {
- ConsoleLogger
- .showError("ATTENTION by disabling ForceSingleSession, your server protection is set to low");
+ ConsoleLogger.showError("ATTENTION by disabling ForceSingleSession, your server protection is set to low");
}
- if (Settings.reloadSupport) try {
- onReload();
- if (server.getOnlinePlayers().length < 1) {
- try {
- database.purgeLogged();
- } catch (NullPointerException npe) {
+ if (Settings.reloadSupport)
+ try {
+ onReload();
+ if (server.getOnlinePlayers().length < 1) {
+ try {
+ database.purgeLogged();
+ } catch (NullPointerException npe) {
+ }
}
+ } catch (NullPointerException ex) {
}
- } catch (NullPointerException ex) {
- }
- if (Settings.usePurge) autoPurge();
+ if (Settings.usePurge)
+ autoPurge();
// Download GeoIp.dat file
downloadGeoIp();
@@ -300,35 +294,28 @@ public class AuthMe extends JavaPlugin {
dataManager = new DataManager(this, database);
dataManager.start();
- ConsoleLogger.info("Authme " + this.getDescription().getVersion()
- + " enabled");
+ ConsoleLogger.info("Authme " + this.getDescription().getVersion() + " enabled");
}
private void setLog4JFilter() {
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
+
@Override
public void run() {
- org.apache.logging.log4j.core.Logger coreLogger = (org.apache.logging.log4j.core.Logger) LogManager
- .getRootLogger();
+ org.apache.logging.log4j.core.Logger coreLogger = (org.apache.logging.log4j.core.Logger) LogManager.getRootLogger();
coreLogger.addFilter(new Log4JFilter());
}
});
}
public void checkVault() {
- if (this.getServer().getPluginManager().getPlugin("Vault") != null
- && this.getServer().getPluginManager().getPlugin("Vault")
- .isEnabled()) {
- RegisteredServiceProvider permissionProvider = getServer()
- .getServicesManager().getRegistration(
- net.milkbowl.vault.permission.Permission.class);
+ if (this.getServer().getPluginManager().getPlugin("Vault") != null && this.getServer().getPluginManager().getPlugin("Vault").isEnabled()) {
+ RegisteredServiceProvider permissionProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
if (permissionProvider != null) {
permission = permissionProvider.getProvider();
- ConsoleLogger.info("Vault plugin detected, hook with "
- + permission.getName() + " system");
+ ConsoleLogger.info("Vault plugin detected, hook with " + permission.getName() + " system");
} else {
- ConsoleLogger
- .showError("Vault plugin is detected but not the permissions plugin!");
+ ConsoleLogger.showError("Vault plugin is detected but not the permissions plugin!");
}
} else {
permission = null;
@@ -340,9 +327,7 @@ public class AuthMe extends JavaPlugin {
this.ChestShop = 0;
return;
}
- if (this.getServer().getPluginManager().getPlugin("ChestShop") != null
- && this.getServer().getPluginManager().getPlugin("ChestShop")
- .isEnabled()) {
+ if (this.getServer().getPluginManager().getPlugin("ChestShop") != null && this.getServer().getPluginManager().getPlugin("ChestShop").isEnabled()) {
try {
String ver = com.Acrobot.ChestShop.ChestShop.getVersion();
try {
@@ -350,8 +335,7 @@ public class AuthMe extends JavaPlugin {
if (version >= 3.50) {
this.ChestShop = version;
} else {
- ConsoleLogger
- .showError("Please Update your ChestShop version!");
+ ConsoleLogger.showError("Please Update your ChestShop version!");
}
} catch (NumberFormatException nfe) {
try {
@@ -359,8 +343,7 @@ public class AuthMe extends JavaPlugin {
if (version >= 3.50) {
this.ChestShop = version;
} else {
- ConsoleLogger
- .showError("Please Update your ChestShop version!");
+ ConsoleLogger.showError("Please Update your ChestShop version!");
}
} catch (NumberFormatException nfee) {
}
@@ -377,14 +360,10 @@ public class AuthMe extends JavaPlugin {
multiverse = null;
return;
}
- if (this.getServer().getPluginManager().getPlugin("Multiverse-Core") != null
- && this.getServer().getPluginManager()
- .getPlugin("Multiverse-Core").isEnabled()) {
+ if (this.getServer().getPluginManager().getPlugin("Multiverse-Core") != null && this.getServer().getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
try {
- multiverse = (MultiverseCore) this.getServer()
- .getPluginManager().getPlugin("Multiverse-Core");
- ConsoleLogger
- .info("Hook with Multiverse-Core for SpawnLocations");
+ multiverse = (MultiverseCore) this.getServer().getPluginManager().getPlugin("Multiverse-Core");
+ ConsoleLogger.info("Hook with Multiverse-Core for SpawnLocations");
} catch (NullPointerException npe) {
multiverse = null;
} catch (ClassCastException cce) {
@@ -398,12 +377,9 @@ public class AuthMe extends JavaPlugin {
}
public void checkEssentials() {
- if (this.getServer().getPluginManager().getPlugin("Essentials") != null
- && this.getServer().getPluginManager().getPlugin("Essentials")
- .isEnabled()) {
+ if (this.getServer().getPluginManager().getPlugin("Essentials") != null && this.getServer().getPluginManager().getPlugin("Essentials").isEnabled()) {
try {
- ess = (Essentials) this.getServer().getPluginManager()
- .getPlugin("Essentials");
+ ess = (Essentials) this.getServer().getPluginManager().getPlugin("Essentials");
ConsoleLogger.info("Hook with Essentials plugin");
} catch (NullPointerException npe) {
ess = null;
@@ -415,16 +391,13 @@ public class AuthMe extends JavaPlugin {
} else {
ess = null;
}
- if (this.getServer().getPluginManager().getPlugin("EssentialsSpawn") != null
- && this.getServer().getPluginManager()
- .getPlugin("EssentialsSpawn").isEnabled()) {
+ if (this.getServer().getPluginManager().getPlugin("EssentialsSpawn") != null && this.getServer().getPluginManager().getPlugin("EssentialsSpawn").isEnabled()) {
try {
essentialsSpawn = new EssSpawn().getLocation();
ConsoleLogger.info("Hook with EssentialsSpawn plugin");
} catch (Exception e) {
essentialsSpawn = null;
- ConsoleLogger
- .showError("Error while reading /plugins/Essentials/spawn.yml file ");
+ ConsoleLogger.showError("Error while reading /plugins/Essentials/spawn.yml file ");
}
} else {
ess = null;
@@ -436,11 +409,8 @@ public class AuthMe extends JavaPlugin {
this.notifications = null;
return;
}
- if (this.getServer().getPluginManager().getPlugin("Notifications") != null
- && this.getServer().getPluginManager()
- .getPlugin("Notifications").isEnabled()) {
- this.notifications = (Notifications) this.getServer()
- .getPluginManager().getPlugin("Notifications");
+ if (this.getServer().getPluginManager().getPlugin("Notifications") != null && this.getServer().getPluginManager().getPlugin("Notifications").isEnabled()) {
+ this.notifications = (Notifications) this.getServer().getPluginManager().getPlugin("Notifications");
ConsoleLogger.info("Successfully hook with Notifications");
} else {
this.notifications = null;
@@ -448,9 +418,7 @@ public class AuthMe extends JavaPlugin {
}
public void combatTag() {
- if (this.getServer().getPluginManager().getPlugin("CombatTag") != null
- && this.getServer().getPluginManager().getPlugin("CombatTag")
- .isEnabled()) {
+ if (this.getServer().getPluginManager().getPlugin("CombatTag") != null && this.getServer().getPluginManager().getPlugin("CombatTag").isEnabled()) {
this.CombatTag = 1;
} else {
this.CombatTag = 0;
@@ -458,11 +426,8 @@ public class AuthMe extends JavaPlugin {
}
public void citizensVersion() {
- if (this.getServer().getPluginManager().getPlugin("Citizens") != null
- && this.getServer().getPluginManager().getPlugin("Citizens")
- .isEnabled()) {
- Citizens cit = (Citizens) this.getServer().getPluginManager()
- .getPlugin("Citizens");
+ if (this.getServer().getPluginManager().getPlugin("Citizens") != null && this.getServer().getPluginManager().getPlugin("Citizens").isEnabled()) {
+ Citizens cit = (Citizens) this.getServer().getPluginManager().getPlugin("Citizens");
String ver = cit.getDescription().getVersion();
String[] args = ver.split("\\.");
if (args[0].contains("1")) {
@@ -477,30 +442,32 @@ public class AuthMe extends JavaPlugin {
@Override
public void onDisable() {
- if (Bukkit.getOnlinePlayers().length != 0) for (Player player : Bukkit
- .getOnlinePlayers()) {
- this.savePlayer(player);
- }
+ if (Bukkit.getOnlinePlayers().length != 0)
+ for (Player player : Bukkit.getOnlinePlayers()) {
+ this.savePlayer(player);
+ }
if (database != null) {
database.close();
}
if (databaseThread != null) {
- if (databaseThread.isAlive()) databaseThread.interrupt();
+ if (databaseThread.isAlive())
+ databaseThread.interrupt();
}
if (dataManager != null) {
- if (dataManager.isAlive()) dataManager.interrupt();
+ if (dataManager.isAlive())
+ dataManager.interrupt();
}
if (Settings.isBackupActivated && Settings.isBackupOnStop) {
Boolean Backup = new PerformBackup(this).DoBackup();
- if (Backup) ConsoleLogger.info("Backup Complete");
+ if (Backup)
+ ConsoleLogger.info("Backup Complete");
else ConsoleLogger.showError("Error while making Backup");
}
- ConsoleLogger.info("Authme " + this.getDescription().getVersion()
- + " disabled");
+ ConsoleLogger.info("Authme " + this.getDescription().getVersion() + " disabled");
}
private void onReload() {
@@ -510,10 +477,9 @@ public class AuthMe extends JavaPlugin {
if (database.isLogged(player.getName().toLowerCase())) {
String name = player.getName().toLowerCase();
PlayerAuth pAuth = database.getAuth(name);
- if (pAuth == null) break;
- PlayerAuth auth = new PlayerAuth(name, pAuth.getHash(),
- pAuth.getIp(), new Date().getTime(),
- pAuth.getEmail(), player.getName());
+ if (pAuth == null)
+ break;
+ PlayerAuth auth = new PlayerAuth(name, pAuth.getHash(), pAuth.getIp(), new Date().getTime(), pAuth.getEmail(), player.getName());
database.updateSession(auth);
PlayerCache.getInstance().addPlayer(auth);
}
@@ -532,35 +498,28 @@ public class AuthMe extends JavaPlugin {
public void savePlayer(Player player) throws IllegalStateException,
NullPointerException {
try {
- if ((citizens.isNPC(player, this))
- || (Utils.getInstance().isUnrestricted(player))
- || (CombatTagComunicator.isNPC(player))) {
+ if ((citizens.isNPC(player, this)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) {
return;
}
} catch (Exception e) {
}
try {
String name = player.getName().toLowerCase();
- if (PlayerCache.getInstance().isAuthenticated(name)
- && !player.isDead() && Settings.isSaveQuitLocationEnabled) {
- final PlayerAuth auth = new PlayerAuth(player.getName()
- .toLowerCase(), player.getLocation().getX(), player
- .getLocation().getY(), player.getLocation().getZ(),
- player.getWorld().getName());
+ if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead() && Settings.isSaveQuitLocationEnabled) {
+ final PlayerAuth auth = new PlayerAuth(player.getName().toLowerCase(), player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ(), player.getWorld().getName());
database.updateQuitLoc(auth);
}
if (LimboCache.getInstance().hasLimboPlayer(name)) {
- LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(
- name);
+ LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
if (Settings.protectInventoryBeforeLogInEnabled.booleanValue()) {
player.getInventory().setArmorContents(limbo.getArmour());
player.getInventory().setContents(limbo.getInventory());
}
- if (!Settings.noTeleport) player.teleport(limbo.getLoc());
+ if (!Settings.noTeleport)
+ player.teleport(limbo.getLoc());
this.utils.addNormal(player, limbo.getGroup());
player.setOp(limbo.getOperator());
- this.plugin.getServer().getScheduler()
- .cancelTask(limbo.getTimeoutTaskId());
+ this.plugin.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
LimboCache.getInstance().deleteLimboPlayer(name);
if (this.playerBackup.doesCacheExist(player)) {
this.playerBackup.removeCache(player);
@@ -608,7 +567,8 @@ public class AuthMe extends JavaPlugin {
}
public boolean authmePermissible(Player player, String perm) {
- if (player.hasPermission(perm)) return true;
+ if (player.hasPermission(perm))
+ return true;
else if (permission != null) {
return permission.playerHas(player, perm);
}
@@ -616,7 +576,8 @@ public class AuthMe extends JavaPlugin {
}
public boolean authmePermissible(CommandSender sender, String perm) {
- if (sender.hasPermission(perm)) return true;
+ if (sender.hasPermission(perm))
+ return true;
else if (permission != null) {
return permission.has(sender, perm);
}
@@ -631,23 +592,24 @@ public class AuthMe extends JavaPlugin {
calendar.add(Calendar.DATE, -(Settings.purgeDelay));
long until = calendar.getTimeInMillis();
List cleared = this.database.autoPurgeDatabase(until);
- ConsoleLogger.info("AutoPurgeDatabase : " + cleared.size()
- + " accounts removed.");
- if (cleared.isEmpty()) return;
- if (Settings.purgeEssentialsFile && this.ess != null) dataManager
- .purgeEssentials(cleared);
- if (Settings.purgePlayerDat) dataManager.purgeDat(cleared);
- if (Settings.purgeLimitedCreative) dataManager
- .purgeLimitedCreative(cleared);
- if (Settings.purgeAntiXray) dataManager.purgeAntiXray(cleared);
+ ConsoleLogger.info("AutoPurgeDatabase : " + cleared.size() + " accounts removed.");
+ if (cleared.isEmpty())
+ return;
+ if (Settings.purgeEssentialsFile && this.ess != null)
+ dataManager.purgeEssentials(cleared);
+ if (Settings.purgePlayerDat)
+ dataManager.purgeDat(cleared);
+ if (Settings.purgeLimitedCreative)
+ dataManager.purgeLimitedCreative(cleared);
+ if (Settings.purgeAntiXray)
+ dataManager.purgeAntiXray(cleared);
}
public Location getSpawnLocation(Player player) {
World world = player.getWorld();
String[] spawnPriority = Settings.spawnPriority.split(",");
if (spawnPriority.length < 4) {
- ConsoleLogger
- .showError("Check your config for spawnPriority, you need to put all of 4 spawn priorities");
+ ConsoleLogger.showError("Check your config for spawnPriority, you need to put all of 4 spawn priorities");
ConsoleLogger.showError("Defaulting Spawn to world's one");
return world.getSpawnLocation();
}
@@ -655,14 +617,17 @@ public class AuthMe extends JavaPlugin {
int i = 3;
for (i = 3; i >= 0; i--) {
String s = spawnPriority[i];
- if (s.equalsIgnoreCase("default") && getDefaultSpawn(world) != null) spawnLoc = getDefaultSpawn(world);
- if (s.equalsIgnoreCase("multiverse")
- && getMultiverseSpawn(world) != null) spawnLoc = getMultiverseSpawn(world);
- if (s.equalsIgnoreCase("essentials")
- && getEssentialsSpawn() != null) spawnLoc = getEssentialsSpawn();
- if (s.equalsIgnoreCase("authme") && getAuthMeSpawn(player) != null) spawnLoc = getAuthMeSpawn(player);
+ if (s.equalsIgnoreCase("default") && getDefaultSpawn(world) != null)
+ spawnLoc = getDefaultSpawn(world);
+ if (s.equalsIgnoreCase("multiverse") && getMultiverseSpawn(world) != null)
+ spawnLoc = getMultiverseSpawn(world);
+ if (s.equalsIgnoreCase("essentials") && getEssentialsSpawn() != null)
+ spawnLoc = getEssentialsSpawn();
+ if (s.equalsIgnoreCase("authme") && getAuthMeSpawn(player) != null)
+ spawnLoc = getAuthMeSpawn(player);
}
- if (spawnLoc == null) spawnLoc = world.getSpawnLocation();
+ if (spawnLoc == null)
+ spawnLoc = world.getSpawnLocation();
return spawnLoc;
}
@@ -673,8 +638,7 @@ public class AuthMe extends JavaPlugin {
private Location getMultiverseSpawn(World world) {
if (multiverse != null && Settings.multiverse) {
try {
- return multiverse.getMVWorldManager().getMVWorld(world)
- .getSpawnLocation();
+ return multiverse.getMVWorldManager().getMVWorld(world).getSpawnLocation();
} catch (NullPointerException npe) {
} catch (ClassCastException cce) {
} catch (NoClassDefFoundError ncdfe) {
@@ -684,23 +648,21 @@ public class AuthMe extends JavaPlugin {
}
private Location getEssentialsSpawn() {
- if (essentialsSpawn != null) return essentialsSpawn;
+ if (essentialsSpawn != null)
+ return essentialsSpawn;
return null;
}
private Location getAuthMeSpawn(Player player) {
- if ((!database.isAuthAvailable(player.getName().toLowerCase()) || !player
- .hasPlayedBefore())
- && (Spawn.getInstance().getFirstSpawn() != null)) return Spawn
- .getInstance().getFirstSpawn();
- if (Spawn.getInstance().getSpawn() != null) return Spawn.getInstance()
- .getSpawn();
+ if ((!database.isAuthAvailable(player.getName().toLowerCase()) || !player.hasPlayedBefore()) && (Spawn.getInstance().getFirstSpawn() != null))
+ return Spawn.getInstance().getFirstSpawn();
+ if (Spawn.getInstance().getSpawn() != null)
+ return Spawn.getInstance().getSpawn();
return null;
}
public void downloadGeoIp() {
- ConsoleLogger
- .info("LICENSE : This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com");
+ ConsoleLogger.info("LICENSE : This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com");
File file = new File(getDataFolder(), "GeoIP.dat");
if (!file.exists()) {
try {
@@ -710,7 +672,8 @@ public class AuthMe extends JavaPlugin {
conn.setConnectTimeout(10000);
conn.connect();
InputStream input = conn.getInputStream();
- if (url.endsWith(".gz")) input = new GZIPInputStream(input);
+ if (url.endsWith(".gz"))
+ input = new GZIPInputStream(input);
OutputStream output = new FileOutputStream(file);
byte[] buffer = new byte[2048];
int length = input.read(buffer);
@@ -727,10 +690,11 @@ public class AuthMe extends JavaPlugin {
public String getCountryCode(String ip) {
try {
- if (ls == null) ls = new LookupService(new File(getDataFolder(),
- "GeoIP.dat"));
+ if (ls == null)
+ ls = new LookupService(new File(getDataFolder(), "GeoIP.dat"));
String code = ls.getCountry(ip).getCode();
- if (code != null && !code.isEmpty()) return code;
+ if (code != null && !code.isEmpty())
+ return code;
} catch (Exception e) {
}
return null;
@@ -738,10 +702,11 @@ public class AuthMe extends JavaPlugin {
public String getCountryName(String ip) {
try {
- if (ls == null) ls = new LookupService(new File(getDataFolder(),
- "GeoIP.dat"));
+ if (ls == null)
+ ls = new LookupService(new File(getDataFolder(), "GeoIP.dat"));
String code = ls.getCountry(ip).getName();
- if (code != null && !code.isEmpty()) return code;
+ if (code != null && !code.isEmpty())
+ return code;
} catch (Exception e) {
}
return null;
@@ -753,20 +718,21 @@ public class AuthMe extends JavaPlugin {
}
private void recallEmail() {
- if (!Settings.recallEmail) return;
+ if (!Settings.recallEmail)
+ return;
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
+
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.isOnline()) {
String name = player.getName().toLowerCase();
- if (database.isAuthAvailable(name)) if (PlayerCache
- .getInstance().isAuthenticated(name)) {
- String email = database.getAuth(name).getEmail();
- if (email == null || email.isEmpty()
- || email.equalsIgnoreCase("your@email.com")) m
- ._(player, "add_email");
- }
+ if (database.isAuthAvailable(name))
+ if (PlayerCache.getInstance().isAuthenticated(name)) {
+ String email = database.getAuth(name).getEmail();
+ if (email == null || email.isEmpty() || email.equalsIgnoreCase("your@email.com"))
+ m._(player, "add_email");
+ }
}
}
}
@@ -777,20 +743,14 @@ public class AuthMe extends JavaPlugin {
try {
message = message.replace("&", "\u00a7");
message = message.replace("{PLAYER}", player.getName());
- message = message.replace("{ONLINE}", ""
- + this.getServer().getOnlinePlayers().length);
- message = message.replace("{MAXPLAYERS}", ""
- + this.getServer().getMaxPlayers());
+ message = message.replace("{ONLINE}", "" + this.getServer().getOnlinePlayers().length);
+ message = message.replace("{MAXPLAYERS}", "" + this.getServer().getMaxPlayers());
message = message.replace("{IP}", getIP(player));
- message = message.replace("{LOGINS}", ""
- + PlayerCache.getInstance().getLogged());
+ message = message.replace("{LOGINS}", "" + PlayerCache.getInstance().getLogged());
message = message.replace("{WORLD}", player.getWorld().getName());
- message = message.replace("{SERVER}", this.getServer()
- .getServerName());
- message = message.replace("{VERSION}", this.getServer()
- .getBukkitVersion());
- message = message.replace("{COUNTRY}",
- this.getCountryName(getIP(player)));
+ message = message.replace("{SERVER}", this.getServer().getServerName());
+ message = message.replace("{VERSION}", this.getServer().getBukkitVersion());
+ message = message.replace("{COUNTRY}", this.getCountryName(getIP(player)));
} catch (Exception e) {
}
return message;
@@ -800,30 +760,34 @@ public class AuthMe extends JavaPlugin {
String name = player.getName().toLowerCase();
String ip = player.getAddress().getAddress().getHostAddress();
if (Settings.bungee) {
- if (realIp.containsKey(name)) ip = realIp.get(name);
+ if (realIp.containsKey(name))
+ ip = realIp.get(name);
}
- if (Settings.checkVeryGames) if (getVeryGamesIP(player) != null) ip = getVeryGamesIP(player);
+ if (Settings.checkVeryGames)
+ if (getVeryGamesIP(player) != null)
+ ip = getVeryGamesIP(player);
return ip;
}
public boolean isLoggedIp(String name, String ip) {
int count = 0;
for (Player player : this.getServer().getOnlinePlayers()) {
- if (ip.equalsIgnoreCase(getIP(player))
- && database.isLogged(player.getName().toLowerCase())
- && !player.getName().equalsIgnoreCase(name)) count++;
+ if (ip.equalsIgnoreCase(getIP(player)) && database.isLogged(player.getName().toLowerCase()) && !player.getName().equalsIgnoreCase(name))
+ count++;
}
- if (count >= Settings.getMaxLoginPerIp) return true;
+ if (count >= Settings.getMaxLoginPerIp)
+ return true;
return false;
}
public boolean hasJoinedIp(String name, String ip) {
int count = 0;
for (Player player : this.getServer().getOnlinePlayers()) {
- if (ip.equalsIgnoreCase(getIP(player))
- && !player.getName().equalsIgnoreCase(name)) count++;
+ if (ip.equalsIgnoreCase(getIP(player)) && !player.getName().equalsIgnoreCase(name))
+ count++;
}
- if (count >= Settings.getMaxJoinPerIp) return true;
+ if (count >= Settings.getMaxJoinPerIp)
+ return true;
return false;
}
@@ -836,17 +800,13 @@ public class AuthMe extends JavaPlugin {
public String getVeryGamesIP(Player player) {
String realIP = null;
String sUrl = vgUrl;
- sUrl = sUrl.replace("%IP%",
- player.getAddress().getAddress().getHostAddress()).replace(
- "%PORT%", "" + player.getAddress().getPort());
+ sUrl = sUrl.replace("%IP%", player.getAddress().getAddress().getHostAddress()).replace("%PORT%", "" + player.getAddress().getPort());
try {
URL url = new URL(sUrl);
URLConnection urlc = url.openConnection();
- BufferedReader in = new BufferedReader(new InputStreamReader(
- urlc.getInputStream()));
+ BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));
String inputLine = in.readLine();
- if (inputLine != null && !inputLine.isEmpty()
- && !inputLine.equalsIgnoreCase("error")) {
+ if (inputLine != null && !inputLine.isEmpty() && !inputLine.equalsIgnoreCase("error")) {
realIP = inputLine;
}
} catch (Exception e) {
diff --git a/src/main/java/fr/xephi/authme/ConsoleFilter.java b/src/main/java/fr/xephi/authme/ConsoleFilter.java
index dccad577..10ac38de 100644
--- a/src/main/java/fr/xephi/authme/ConsoleFilter.java
+++ b/src/main/java/fr/xephi/authme/ConsoleFilter.java
@@ -15,18 +15,13 @@ public class ConsoleFilter implements Filter {
@Override
public boolean isLoggable(LogRecord record) {
try {
- if (record == null || record.getMessage() == null) return true;
+ if (record == null || record.getMessage() == null)
+ return true;
String logM = record.getMessage().toLowerCase();
- if (!logM.contains("issued server command:")) return true;
- if (!logM.contains("/login ") && !logM.contains("/l ")
- && !logM.contains("/reg ")
- && !logM.contains("/changepassword ")
- && !logM.contains("/unregister ")
- && !logM.contains("/authme register ")
- && !logM.contains("/authme changepassword ")
- && !logM.contains("/authme reg ")
- && !logM.contains("/authme cp ")
- && !logM.contains("/register ")) return true;
+ if (!logM.contains("issued server command:"))
+ return true;
+ if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ") && !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ") && !logM.contains("/register "))
+ return true;
String playername = record.getMessage().split(" ")[0];
record.setMessage(playername + " issued an AuthMe command!");
return true;
diff --git a/src/main/java/fr/xephi/authme/ConsoleLogger.java b/src/main/java/fr/xephi/authme/ConsoleLogger.java
index 80d48a8d..3a73ab5c 100644
--- a/src/main/java/fr/xephi/authme/ConsoleLogger.java
+++ b/src/main/java/fr/xephi/authme/ConsoleLogger.java
@@ -21,18 +21,13 @@ public class ConsoleLogger {
log.info("[AuthMe] " + message);
if (Settings.useLogging) {
Calendar date = Calendar.getInstance();
- final String actually = "["
- + DateFormat.getDateInstance().format(date.getTime())
- + ", " + date.get(Calendar.HOUR_OF_DAY) + ":"
- + date.get(Calendar.MINUTE) + ":"
- + date.get(Calendar.SECOND) + "] " + message;
- Bukkit.getScheduler().runTaskAsynchronously(
- AuthMe.getInstance(), new Runnable() {
- @Override
- public void run() {
- writeLog(actually);
- }
- });
+ final String actually = "[" + DateFormat.getDateInstance().format(date.getTime()) + ", " + date.get(Calendar.HOUR_OF_DAY) + ":" + date.get(Calendar.MINUTE) + ":" + date.get(Calendar.SECOND) + "] " + message;
+ Bukkit.getScheduler().runTaskAsynchronously(AuthMe.getInstance(), new Runnable() {
+ @Override
+ public void run() {
+ writeLog(actually);
+ }
+ });
}
}
}
@@ -42,26 +37,20 @@ public class ConsoleLogger {
log.warning("[AuthMe] ERROR: " + message);
if (Settings.useLogging) {
Calendar date = Calendar.getInstance();
- final String actually = "["
- + DateFormat.getDateInstance().format(date.getTime())
- + ", " + date.get(Calendar.HOUR_OF_DAY) + ":"
- + date.get(Calendar.MINUTE) + ":"
- + date.get(Calendar.SECOND) + "] ERROR : " + message;
- Bukkit.getScheduler().runTaskAsynchronously(
- AuthMe.getInstance(), new Runnable() {
- @Override
- public void run() {
- writeLog(actually);
- }
- });
+ final String actually = "[" + DateFormat.getDateInstance().format(date.getTime()) + ", " + date.get(Calendar.HOUR_OF_DAY) + ":" + date.get(Calendar.MINUTE) + ":" + date.get(Calendar.SECOND) + "] ERROR : " + message;
+ Bukkit.getScheduler().runTaskAsynchronously(AuthMe.getInstance(), new Runnable() {
+ @Override
+ public void run() {
+ writeLog(actually);
+ }
+ });
}
}
}
public static void writeLog(String string) {
try {
- FileWriter fw = new FileWriter(AuthMe.getInstance().getDataFolder()
- + File.separator + "authme.log", true);
+ FileWriter fw = new FileWriter(AuthMe.getInstance().getDataFolder() + File.separator + "authme.log", true);
BufferedWriter w = new BufferedWriter(fw);
w.write(string);
w.newLine();
diff --git a/src/main/java/fr/xephi/authme/DataManager.java b/src/main/java/fr/xephi/authme/DataManager.java
index b595812e..4c9f18f1 100644
--- a/src/main/java/fr/xephi/authme/DataManager.java
+++ b/src/main/java/fr/xephi/authme/DataManager.java
@@ -25,9 +25,7 @@ public class DataManager extends Thread {
public OfflinePlayer getOfflinePlayer(String name) {
OfflinePlayer result = null;
try {
- if (org.bukkit.Bukkit.class.getMethod("getOfflinePlayer",
- new Class[] { String.class }).isAnnotationPresent(
- Deprecated.class)) {
+ if (org.bukkit.Bukkit.class.getMethod("getOfflinePlayer", new Class[] { String.class }).isAnnotationPresent(Deprecated.class)) {
for (OfflinePlayer op : Bukkit.getOfflinePlayers())
if (op.getName().equalsIgnoreCase(name)) {
result = op;
@@ -46,63 +44,52 @@ public class DataManager extends Thread {
int i = 0;
for (String name : cleared) {
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
- if (player == null) continue;
+ if (player == null)
+ continue;
String playerName = player.getName();
- File playerFile = new File("." + File.separator + "plugins"
- + File.separator + "AntiXRayData" + File.separator
- + "PlayerData" + File.separator + playerName);
+ File playerFile = new File("." + File.separator + "plugins" + File.separator + "AntiXRayData" + File.separator + "PlayerData" + File.separator + playerName);
if (playerFile.exists()) {
playerFile.delete();
i++;
}
}
- ConsoleLogger.info("AutoPurgeDatabase : Remove " + i
- + " AntiXRayData Files");
+ ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files");
}
public void purgeLimitedCreative(List cleared) {
int i = 0;
for (String name : cleared) {
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
- if (player == null) continue;
+ if (player == null)
+ continue;
String playerName = player.getName();
- File playerFile = new File("." + File.separator + "plugins"
- + File.separator + "LimitedCreative" + File.separator
- + "inventories" + File.separator + playerName + ".yml");
+ File playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + ".yml");
if (playerFile.exists()) {
playerFile.delete();
i++;
}
- playerFile = new File("." + File.separator + "plugins"
- + File.separator + "LimitedCreative" + File.separator
- + "inventories" + File.separator + playerName
- + "_creative.yml");
+ playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_creative.yml");
if (playerFile.exists()) {
playerFile.delete();
i++;
}
- playerFile = new File("." + File.separator + "plugins"
- + File.separator + "LimitedCreative" + File.separator
- + "inventories" + File.separator + playerName
- + "_adventure.yml");
+ playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_adventure.yml");
if (playerFile.exists()) {
playerFile.delete();
i++;
}
}
- ConsoleLogger.info("AutoPurgeDatabase : Remove " + i
- + " LimitedCreative Survival, Creative and Adventure files");
+ ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files");
}
public void purgeDat(List cleared) {
int i = 0;
for (String name : cleared) {
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
- if (player == null) continue;
+ if (player == null)
+ continue;
String playerName = player.getName();
- File playerFile = new File(plugin.getServer().getWorldContainer()
- + File.separator + Settings.defaultWorld + File.separator
- + "players" + File.separator + playerName + ".dat");
+ File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + playerName + ".dat");
if (playerFile.exists()) {
playerFile.delete();
i++;
@@ -114,15 +101,12 @@ public class DataManager extends Thread {
public void purgeEssentials(List cleared) {
int i = 0;
for (String name : cleared) {
- File playerFile = new File(plugin.ess.getDataFolder()
- + File.separator + "userdata" + File.separator + name
- + ".yml");
+ File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
if (playerFile.exists()) {
playerFile.delete();
i++;
}
}
- ConsoleLogger.info("AutoPurgeDatabase : Remove " + i
- + " EssentialsFiles");
+ ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
}
}
diff --git a/src/main/java/fr/xephi/authme/Log4JFilter.java b/src/main/java/fr/xephi/authme/Log4JFilter.java
index 58587521..dccaee6f 100644
--- a/src/main/java/fr/xephi/authme/Log4JFilter.java
+++ b/src/main/java/fr/xephi/authme/Log4JFilter.java
@@ -18,19 +18,13 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
@Override
public Result filter(LogEvent record) {
try {
- if (record == null || record.getMessage() == null) return Result.NEUTRAL;
- String logM = record.getMessage().getFormattedMessage()
- .toLowerCase();
- if (!logM.contains("issued server command:")) return Result.NEUTRAL;
- if (!logM.contains("/login ") && !logM.contains("/l ")
- && !logM.contains("/reg ")
- && !logM.contains("/changepassword ")
- && !logM.contains("/unregister ")
- && !logM.contains("/authme register ")
- && !logM.contains("/authme changepassword ")
- && !logM.contains("/authme reg ")
- && !logM.contains("/authme cp ")
- && !logM.contains("/register ")) return Result.NEUTRAL;
+ if (record == null || record.getMessage() == null)
+ return Result.NEUTRAL;
+ String logM = record.getMessage().getFormattedMessage().toLowerCase();
+ if (!logM.contains("issued server command:"))
+ return Result.NEUTRAL;
+ if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ") && !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ") && !logM.contains("/register "))
+ return Result.NEUTRAL;
return Result.DENY;
} catch (NullPointerException npe) {
return Result.NEUTRAL;
@@ -41,18 +35,13 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
public Result filter(Logger arg0, Level arg1, Marker arg2, String message,
Object... arg4) {
try {
- if (message == null) return Result.NEUTRAL;
+ if (message == null)
+ return Result.NEUTRAL;
String logM = message.toLowerCase();
- if (!logM.contains("issued server command:")) return Result.NEUTRAL;
- if (!logM.contains("/login ") && !logM.contains("/l ")
- && !logM.contains("/reg ")
- && !logM.contains("/changepassword ")
- && !logM.contains("/unregister ")
- && !logM.contains("/authme register ")
- && !logM.contains("/authme changepassword ")
- && !logM.contains("/authme reg ")
- && !logM.contains("/authme cp ")
- && !logM.contains("/register ")) return Result.NEUTRAL;
+ if (!logM.contains("issued server command:"))
+ return Result.NEUTRAL;
+ if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ") && !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ") && !logM.contains("/register "))
+ return Result.NEUTRAL;
return Result.DENY;
} catch (NullPointerException npe) {
return Result.NEUTRAL;
@@ -63,18 +52,13 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
public Result filter(Logger arg0, Level arg1, Marker arg2, Object message,
Throwable arg4) {
try {
- if (message == null) return Result.NEUTRAL;
+ if (message == null)
+ return Result.NEUTRAL;
String logM = message.toString().toLowerCase();
- if (!logM.contains("issued server command:")) return Result.NEUTRAL;
- if (!logM.contains("/login ") && !logM.contains("/l ")
- && !logM.contains("/reg ")
- && !logM.contains("/changepassword ")
- && !logM.contains("/unregister ")
- && !logM.contains("/authme register ")
- && !logM.contains("/authme changepassword ")
- && !logM.contains("/authme reg ")
- && !logM.contains("/authme cp ")
- && !logM.contains("/register ")) return Result.NEUTRAL;
+ if (!logM.contains("issued server command:"))
+ return Result.NEUTRAL;
+ if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ") && !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ") && !logM.contains("/register "))
+ return Result.NEUTRAL;
return Result.DENY;
} catch (NullPointerException npe) {
return Result.NEUTRAL;
@@ -85,18 +69,13 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
public Result filter(Logger arg0, Level arg1, Marker arg2, Message message,
Throwable arg4) {
try {
- if (message == null) return Result.NEUTRAL;
+ if (message == null)
+ return Result.NEUTRAL;
String logM = message.getFormattedMessage().toLowerCase();
- if (!logM.contains("issued server command:")) return Result.NEUTRAL;
- if (!logM.contains("/login ") && !logM.contains("/l ")
- && !logM.contains("/reg ")
- && !logM.contains("/changepassword ")
- && !logM.contains("/unregister ")
- && !logM.contains("/authme register ")
- && !logM.contains("/authme changepassword ")
- && !logM.contains("/authme reg ")
- && !logM.contains("/authme cp ")
- && !logM.contains("/register ")) return Result.NEUTRAL;
+ if (!logM.contains("issued server command:"))
+ return Result.NEUTRAL;
+ if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ") && !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ") && !logM.contains("/register "))
+ return Result.NEUTRAL;
return Result.DENY;
} catch (NullPointerException npe) {
return Result.NEUTRAL;
diff --git a/src/main/java/fr/xephi/authme/PerformBackup.java b/src/main/java/fr/xephi/authme/PerformBackup.java
index c5840075..fd41bf4d 100644
--- a/src/main/java/fr/xephi/authme/PerformBackup.java
+++ b/src/main/java/fr/xephi/authme/PerformBackup.java
@@ -23,8 +23,7 @@ public class PerformBackup {
private String tblname = Settings.getMySQLTablename;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH-mm");
String dateString = format.format(new Date());
- private String path = AuthMe.getInstance().getDataFolder()
- + "/backups/backup" + dateString;
+ private String path = AuthMe.getInstance().getDataFolder() + File.separator + "backups" + File.separator + "backup" + dateString;
private AuthMe instance;
public PerformBackup(AuthMe instance) {
@@ -49,15 +48,12 @@ public class PerformBackup {
}
private boolean MySqlBackup() {
- File dirBackup = new File(AuthMe.getInstance().getDataFolder()
- + "/backups");
+ File dirBackup = new File(AuthMe.getInstance().getDataFolder() + "/backups");
- if (!dirBackup.exists()) dirBackup.mkdir();
+ if (!dirBackup.exists())
+ dirBackup.mkdir();
if (checkWindows(Settings.backupWindowsPath)) {
- String executeCmd = Settings.backupWindowsPath
- + "\\bin\\mysqldump.exe -u " + dbUserName + " -p"
- + dbPassword + " " + dbName + " --tables " + tblname
- + " -r " + path + ".sql";
+ String executeCmd = Settings.backupWindowsPath + "\\bin\\mysqldump.exe -u " + dbUserName + " -p" + dbPassword + " " + dbName + " --tables " + tblname + " -r " + path + ".sql";
Process runtimeProcess;
try {
runtimeProcess = Runtime.getRuntime().exec(executeCmd);
@@ -72,9 +68,7 @@ public class PerformBackup {
ex.printStackTrace();
}
} else {
- String executeCmd = "mysqldump -u " + dbUserName + " -p"
- + dbPassword + " " + dbName + " --tables " + tblname
- + " -r " + path + ".sql";
+ String executeCmd = "mysqldump -u " + dbUserName + " -p" + dbPassword + " " + dbName + " --tables " + tblname + " -r " + path + ".sql";
Process runtimeProcess;
try {
runtimeProcess = Runtime.getRuntime().exec(executeCmd);
@@ -93,13 +87,13 @@ public class PerformBackup {
}
private boolean FileBackup(String backend) {
- File dirBackup = new File(AuthMe.getInstance().getDataFolder()
- + "/backups");
+ File dirBackup = new File(AuthMe.getInstance().getDataFolder() + "/backups");
- if (!dirBackup.exists()) dirBackup.mkdir();
+ if (!dirBackup.exists())
+ dirBackup.mkdir();
try {
- copy(new File("plugins/AuthMe/" + backend), new File(path + ".db"));
+ copy(new File("plugins" + File.separator + "AuthMe" + File.separator + backend), new File(path + ".db"));
return true;
} catch (Exception ex) {
@@ -118,8 +112,7 @@ public class PerformBackup {
if (new File(windowsPath + "\\bin\\mysqldump.exe").exists()) {
return true;
} else {
- ConsoleLogger
- .showError("Mysql Windows Path is incorrect please check it");
+ ConsoleLogger.showError("Mysql Windows Path is incorrect please check it");
return true;
}
} else return false;
diff --git a/src/main/java/fr/xephi/authme/SendMailSSL.java b/src/main/java/fr/xephi/authme/SendMailSSL.java
index 28d005bd..15159212 100644
--- a/src/main/java/fr/xephi/authme/SendMailSSL.java
+++ b/src/main/java/fr/xephi/authme/SendMailSSL.java
@@ -31,8 +31,7 @@ public class SendMailSSL {
public void main(final PlayerAuth auth, final String newPass) {
String sendername;
- if (Settings.getmailSenderName.isEmpty()
- || Settings.getmailSenderName == null) {
+ if (Settings.getmailSenderName.isEmpty() || Settings.getmailSenderName == null) {
sendername = Settings.getmailAccount;
} else {
sendername = Settings.getmailSenderName;
@@ -40,42 +39,36 @@ public class SendMailSSL {
Properties props = new Properties();
props.put("mail.smtp.host", Settings.getmailSMTP);
- props.put("mail.smtp.socketFactory.port",
- String.valueOf(Settings.getMailPort));
- props.put("mail.smtp.socketFactory.class",
- "javax.net.ssl.SSLSocketFactory");
+ props.put("mail.smtp.socketFactory.port", String.valueOf(Settings.getMailPort));
+ props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", String.valueOf(Settings.getMailPort));
- Session session = Session.getInstance(props,
- new javax.mail.Authenticator() {
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(
- Settings.getmailAccount,
- Settings.getmailPassword);
- }
- });
+ Session session = Session.getInstance(props, new javax.mail.Authenticator() {
+
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(Settings.getmailAccount, Settings.getmailPassword);
+ }
+ });
try {
final Message message = new MimeMessage(session);
try {
- message.setFrom(new InternetAddress(Settings.getmailAccount,
- sendername));
+ message.setFrom(new InternetAddress(Settings.getmailAccount, sendername));
} catch (UnsupportedEncodingException uee) {
message.setFrom(new InternetAddress(Settings.getmailAccount));
}
- message.setRecipients(Message.RecipientType.TO,
- InternetAddress.parse(auth.getEmail()));
+ message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(auth.getEmail()));
message.setSubject(Settings.getMailSubject);
message.setSentDate(new Date());
String text = Settings.getMailText;
text = text.replace("", auth.getNickname());
- text = text.replace("", plugin.getServer()
- .getServerName());
+ text = text.replace("", plugin.getServer().getServerName());
text = text.replace("", newPass);
message.setContent(text, "text/html");
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
+
@Override
public void run() {
try {
@@ -85,8 +78,8 @@ public class SendMailSSL {
}
}
});
- if (!Settings.noConsoleSpam) ConsoleLogger.info("Email sent to : "
- + auth.getNickname());
+ if (!Settings.noConsoleSpam)
+ ConsoleLogger.info("Email sent to : " + auth.getNickname());
} catch (MessagingException e) {
throw new RuntimeException(e);
}
diff --git a/src/main/java/fr/xephi/authme/Utils.java b/src/main/java/fr/xephi/authme/Utils.java
index 9b6fb97c..5faa89d2 100644
--- a/src/main/java/fr/xephi/authme/Utils.java
+++ b/src/main/java/fr/xephi/authme/Utils.java
@@ -19,6 +19,7 @@ import fr.xephi.authme.events.AuthMeTeleportEvent;
import fr.xephi.authme.settings.Settings;
public class Utils {
+
private String currentGroup;
private static Utils singleton;
int id;
@@ -33,16 +34,15 @@ public class Utils {
}
public void setGroup(String player, groupType group) {
- if (!Settings.isPermissionCheckEnabled) return;
- if (plugin.permission == null) return;
+ if (!Settings.isPermissionCheckEnabled)
+ return;
+ if (plugin.permission == null)
+ return;
try {
World world = null;
currentGroup = plugin.permission.getPrimaryGroup(world, player);
} catch (UnsupportedOperationException e) {
- ConsoleLogger
- .showError("Your permission system ("
- + plugin.permission.getName()
- + ") do not support Group system with that config... unhook!");
+ ConsoleLogger.showError("Your permission system (" + plugin.permission.getName() + ") do not support Group system with that config... unhook!");
plugin.permission = null;
return;
}
@@ -51,28 +51,27 @@ public class Utils {
switch (group) {
case UNREGISTERED: {
plugin.permission.playerRemoveGroup(world, name, currentGroup);
- plugin.permission.playerAddGroup(world, name,
- Settings.unRegisteredGroup);
+ plugin.permission.playerAddGroup(world, name, Settings.unRegisteredGroup);
break;
}
case REGISTERED: {
plugin.permission.playerRemoveGroup(world, name, currentGroup);
- plugin.permission.playerAddGroup(world, name,
- Settings.getRegisteredGroup);
+ plugin.permission.playerAddGroup(world, name, Settings.getRegisteredGroup);
break;
}
case NOTLOGGEDIN: {
- if (!useGroupSystem()) break;
+ if (!useGroupSystem())
+ break;
plugin.permission.playerRemoveGroup(world, name, currentGroup);
- plugin.permission.playerAddGroup(world, name,
- Settings.getUnloggedinGroup);
+ plugin.permission.playerAddGroup(world, name, Settings.getUnloggedinGroup);
break;
}
case LOGGEDIN: {
- if (!useGroupSystem()) break;
- LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(
- name.toLowerCase());
- if (limbo == null) break;
+ if (!useGroupSystem())
+ break;
+ LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name.toLowerCase());
+ if (limbo == null)
+ break;
String realGroup = limbo.getGroup();
plugin.permission.playerRemoveGroup(world, name, currentGroup);
plugin.permission.playerAddGroup(world, name, realGroup);
@@ -86,20 +85,15 @@ public class Utils {
if (!useGroupSystem()) {
return false;
}
- if (plugin.permission == null) return false;
+ if (plugin.permission == null)
+ return false;
World world = null;
try {
- if (plugin.permission.playerRemoveGroup(world, player.getName()
- .toString(), Settings.getUnloggedinGroup)
- && plugin.permission.playerAddGroup(world, player.getName()
- .toString(), group)) {
+ if (plugin.permission.playerRemoveGroup(world, player.getName().toString(), Settings.getUnloggedinGroup) && plugin.permission.playerAddGroup(world, player.getName().toString(), group)) {
return true;
}
} catch (UnsupportedOperationException e) {
- ConsoleLogger
- .showError("Your permission system ("
- + plugin.permission.getName()
- + ") do not support Group system with that config... unhook!");
+ ConsoleLogger.showError("Your permission system (" + plugin.permission.getName() + ") do not support Group system with that config... unhook!");
plugin.permission = null;
return false;
}
@@ -107,7 +101,8 @@ public class Utils {
}
public void hasPermOnJoin(Player player) {
- if (plugin.permission == null) return;
+ if (plugin.permission == null)
+ return;
Iterator iter = Settings.getJoinPermissions.iterator();
while (iter.hasNext()) {
String permission = iter.next();
@@ -118,10 +113,12 @@ public class Utils {
}
public boolean isUnrestricted(Player player) {
- if (!Settings.isAllowRestrictedIp) return false;
- if (Settings.getUnrestrictedName.isEmpty()
- || Settings.getUnrestrictedName == null) return false;
- if (Settings.getUnrestrictedName.contains(player.getName())) return true;
+ if (!Settings.isAllowRestrictedIp)
+ return false;
+ if (Settings.getUnrestrictedName.isEmpty() || Settings.getUnrestrictedName == null)
+ return false;
+ if (Settings.getUnrestrictedName.contains(player.getName()))
+ return true;
return false;
}
@@ -131,8 +128,8 @@ public class Utils {
}
private boolean useGroupSystem() {
- if (Settings.isPermissionCheckEnabled
- && !Settings.getUnloggedinGroup.isEmpty()) return true;
+ if (Settings.isPermissionCheckEnabled && !Settings.getUnloggedinGroup.isEmpty())
+ return true;
return false;
}
@@ -144,18 +141,20 @@ public class Utils {
} else {
theWorld = Bukkit.getWorld(w);
}
- if (theWorld == null) theWorld = pl.getWorld();
+ if (theWorld == null)
+ theWorld = pl.getWorld();
final World world = theWorld;
final Location locat = new Location(world, x, y, z);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+
@Override
public void run() {
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(pl, locat);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
- if (!tpEvent.getTo().getChunk().isLoaded()) tpEvent.getTo()
- .getChunk().load();
+ if (!tpEvent.getTo().getChunk().isLoaded())
+ tpEvent.getTo().getChunk().load();
pl.teleport(tpEvent.getTo());
}
}
@@ -166,16 +165,16 @@ public class Utils {
* Random Token for passpartu
*/
public boolean obtainToken() {
- File file = new File("plugins/AuthMe/passpartu.token");
- if (file.exists()) file.delete();
+ File file = new File("plugins" + File.separator + "AuthMe" + File.separator + "passpartu.token");
+ if (file.exists())
+ file.delete();
FileWriter writer = null;
try {
file.createNewFile();
writer = new FileWriter(file);
String token = generateToken();
- writer.write(token + ":" + System.currentTimeMillis() / 1000
- + API.newline);
+ writer.write(token + ":" + System.currentTimeMillis() / 1000 + API.newline);
writer.flush();
ConsoleLogger.info("[AuthMe] Security passpartu token: " + token);
writer.close();
@@ -190,11 +189,13 @@ public class Utils {
* Read Token
*/
public boolean readToken(String inputToken) {
- File file = new File("plugins/AuthMe/passpartu.token");
+ File file = new File("plugins" + File.separator + "AuthMe" + File.separator + "passpartu.token");
- if (!file.exists()) return false;
+ if (!file.exists())
+ return false;
- if (inputToken.isEmpty()) return false;
+ if (inputToken.isEmpty())
+ return false;
Scanner reader = null;
try {
reader = new Scanner(file);
@@ -202,9 +203,7 @@ public class Utils {
final String line = reader.nextLine();
if (line.contains(":")) {
String[] tokenInfo = line.split(":");
- if (tokenInfo[0].equals(inputToken)
- && System.currentTimeMillis() / 1000 - 30 <= Integer
- .parseInt(tokenInfo[1])) {
+ if (tokenInfo[0].equals(inputToken) && System.currentTimeMillis() / 1000 - 30 <= Integer.parseInt(tokenInfo[1])) {
file.delete();
reader.close();
return true;
@@ -236,13 +235,15 @@ public class Utils {
* Used for force player GameMode
*/
public static void forceGM(Player player) {
- if (!AuthMe.getInstance().authmePermissible(player,
- "authme.bypassforcesurvival")) player
- .setGameMode(GameMode.SURVIVAL);
+ if (!AuthMe.getInstance().authmePermissible(player, "authme.bypassforcesurvival"))
+ player.setGameMode(GameMode.SURVIVAL);
}
public enum groupType {
- UNREGISTERED, REGISTERED, NOTLOGGEDIN, LOGGEDIN
+ UNREGISTERED,
+ REGISTERED,
+ NOTLOGGEDIN,
+ LOGGEDIN
}
}
diff --git a/src/main/java/fr/xephi/authme/api/API.java b/src/main/java/fr/xephi/authme/api/API.java
index 9917e0da..f733f7be 100644
--- a/src/main/java/fr/xephi/authme/api/API.java
+++ b/src/main/java/fr/xephi/authme/api/API.java
@@ -32,8 +32,7 @@ public class API {
* @return AuthMe instance
*/
public static AuthMe hookAuthMe() {
- Plugin plugin = Bukkit.getServer().getPluginManager()
- .getPlugin("AuthMe");
+ Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("AuthMe");
if (plugin == null || !(plugin instanceof AuthMe)) {
return null;
}
@@ -50,8 +49,7 @@ public class API {
* @return true if player is authenticate
*/
public static boolean isAuthenticated(Player player) {
- return PlayerCache.getInstance().isAuthenticated(
- player.getName().toLowerCase());
+ return PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase());
}
/**
@@ -61,7 +59,8 @@ public class API {
*/
@Deprecated
public boolean isaNPC(Player player) {
- if (instance.getCitizensCommunicator().isNPC(player, instance)) return true;
+ if (instance.getCitizensCommunicator().isNPC(player, instance))
+ return true;
return CombatTagComunicator.isNPC(player);
}
@@ -71,7 +70,8 @@ public class API {
* @return true if player is a npc
*/
public boolean isNPC(Player player) {
- if (instance.getCitizensCommunicator().isNPC(player, instance)) return true;
+ if (instance.getCitizensCommunicator().isNPC(player, instance))
+ return true;
return CombatTagComunicator.isNPC(player);
}
@@ -86,13 +86,10 @@ public class API {
public static Location getLastLocation(Player player) {
try {
- PlayerAuth auth = PlayerCache.getInstance().getAuth(
- player.getName().toLowerCase());
+ PlayerAuth auth = PlayerCache.getInstance().getAuth(player.getName().toLowerCase());
if (auth != null) {
- Location loc = new Location(Bukkit.getWorld(auth.getWorld()),
- auth.getQuitLocX(), auth.getQuitLocY(),
- auth.getQuitLocZ());
+ Location loc = new Location(Bukkit.getWorld(auth.getWorld()), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ());
return loc;
} else {
return null;
@@ -129,12 +126,12 @@ public class API {
*/
public static boolean checkPassword(String playerName,
String passwordToCheck) {
- if (!isRegistered(playerName)) return false;
+ if (!isRegistered(playerName))
+ return false;
String player = playerName.toLowerCase();
PlayerAuth auth = database.getAuth(player);
try {
- return PasswordSecurity.comparePasswordWithHash(passwordToCheck,
- auth.getHash(), playerName);
+ return PasswordSecurity.comparePasswordWithHash(passwordToCheck, auth.getHash(), playerName);
} catch (NoSuchAlgorithmException e) {
return false;
}
@@ -150,13 +147,11 @@ public class API {
public static boolean registerPlayer(String playerName, String password) {
try {
String name = playerName.toLowerCase();
- String hash = PasswordSecurity.getHash(Settings.getPasswordHash,
- password, name);
+ String hash = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
if (isRegistered(name)) {
return false;
}
- PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0,
- "your@email.com", getPlayerRealName(name));
+ PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0, "your@email.com", getPlayerRealName(name));
if (!database.saveAuth(auth)) {
return false;
}
@@ -174,9 +169,9 @@ public class API {
*/
public static String getPlayerRealName(String nickname) {
try {
- String realName = instance.dataManager.getOfflinePlayer(nickname)
- .getName();
- if (realName != null && !realName.isEmpty()) return realName;
+ String realName = instance.dataManager.getOfflinePlayer(nickname).getName();
+ if (realName != null && !realName.isEmpty())
+ return realName;
} catch (NullPointerException npe) {
}
return nickname;
diff --git a/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java b/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java
index 729cc2db..522f5c3b 100644
--- a/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java
+++ b/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java
@@ -129,7 +129,8 @@ public class PlayerAuth {
}
public String getIp() {
- if (ip == null || ip.isEmpty()) ip = "127.0.0.1";
+ if (ip == null || ip.isEmpty())
+ ip = "127.0.0.1";
return ip;
}
@@ -139,8 +140,7 @@ public class PlayerAuth {
public String getHash() {
if (Settings.getPasswordHash == HashAlgorithm.MD5VB) {
- if (salt != null && !salt.isEmpty()
- && Settings.getPasswordHash == HashAlgorithm.MD5VB) {
+ if (salt != null && !salt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.MD5VB) {
vBhash = "$MD5vb$" + salt + "$" + hash;
return vBhash;
}
@@ -186,7 +186,8 @@ public class PlayerAuth {
public long getLastLogin() {
try {
- if (Long.valueOf(lastLogin) == null) lastLogin = 0L;
+ if (Long.valueOf(lastLogin) == null)
+ lastLogin = 0L;
} catch (NullPointerException e) {
lastLogin = 0L;
}
@@ -219,15 +220,13 @@ 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;
}
@@ -242,10 +241,7 @@ public class PlayerAuth {
@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;
+ String s = "Player : " + nickname + " ! IP : " + ip + " ! LastLogin : " + lastLogin + " ! LastPosition : " + x + "," + y + "," + z + "," + world + " ! Email : " + email + " ! Hash : " + hash + " ! Salt : " + salt + " ! RealName : " + realName;
return s;
}
diff --git a/src/main/java/fr/xephi/authme/cache/backup/FileCache.java b/src/main/java/fr/xephi/authme/cache/backup/FileCache.java
index 17cff7a7..a513e8df 100644
--- a/src/main/java/fr/xephi/authme/cache/backup/FileCache.java
+++ b/src/main/java/fr/xephi/authme/cache/backup/FileCache.java
@@ -29,9 +29,9 @@ public class FileCache {
public FileCache(AuthMe plugin) {
this.plugin = plugin;
- final File file = new File(plugin.getDataFolder() + File.separator
- + "cache");
- if (!file.exists()) file.mkdir();
+ final File file = new File(plugin.getDataFolder() + File.separator + "cache");
+ if (!file.exists())
+ file.mkdir();
}
public void createCache(Player player, DataFileCache playerData,
@@ -44,8 +44,7 @@ public class FileCache {
} catch (Error e) {
path = player.getName();
}
- 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");
if (file.exists()) {
return;
@@ -61,16 +60,13 @@ public class FileCache {
writer.write(String.valueOf(flying) + API.newline);
writer.close();
- file = new File(plugin.getDataFolder() + File.separator + "cache"
- + File.separator + path + File.separator + "inventory");
+ file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "inventory");
file.mkdir();
ItemStack[] inv = playerData.getInventory();
for (int i = 0; i < inv.length; i++) {
ItemStack item = inv[i];
- file = new File(plugin.getDataFolder() + File.separator
- + "cache" + File.separator + path + File.separator
- + "inventory" + File.separator + i + ".cache");
+ file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "inventory" + File.separator + i + ".cache");
writer = new FileWriter(file);
writer.write(item.getType().name() + API.newline);
writer.write(item.getDurability() + API.newline);
@@ -78,8 +74,8 @@ public class FileCache {
writer.flush();
if (item.hasItemMeta()) {
ItemMeta meta = item.getItemMeta();
- if (meta.hasDisplayName()) writer.write("name="
- + meta.getDisplayName() + API.newline);
+ if (meta.hasDisplayName())
+ writer.write("name=" + meta.getDisplayName() + API.newline);
if (meta.hasLore()) {
String lores = "";
for (String lore : meta.getLore())
@@ -88,40 +84,33 @@ public class FileCache {
}
if (meta.hasEnchants()) {
for (Enchantment ench : meta.getEnchants().keySet()) {
- writer.write("metaenchant=" + ench.getName() + ":"
- + meta.getEnchants().get(ench)
- + API.newline);
+ writer.write("metaenchant=" + ench.getName() + ":" + meta.getEnchants().get(ench) + API.newline);
}
}
writer.flush();
}
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);
}
Attributes attributes = new Attributes(item);
if (attributes != null)
while (attributes.values().iterator().hasNext()) {
Attribute a = attributes.values().iterator().next();
if (a != 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());
}
}
writer.close();
}
- file = new File(plugin.getDataFolder() + File.separator + "cache"
- + File.separator + path + File.separator + "armours");
+ file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "armours");
file.mkdir();
ItemStack[] armors = playerData.getArmour();
for (int i = 0; i < armors.length; i++) {
ItemStack item = armors[i];
- file = new File(plugin.getDataFolder() + File.separator
- + "cache" + File.separator + path + File.separator
- + "armours" + File.separator + i + ".cache");
+ file = new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "armours" + File.separator + i + ".cache");
writer = new FileWriter(file);
if (item != null) {
writer.write(item.getType().name() + API.newline);
@@ -130,8 +119,8 @@ public class FileCache {
writer.flush();
if (item.hasItemMeta()) {
ItemMeta meta = item.getItemMeta();
- if (meta.hasDisplayName()) writer.write("name="
- + meta.getDisplayName() + API.newline);
+ if (meta.hasDisplayName())
+ writer.write("name=" + meta.getDisplayName() + API.newline);
if (meta.hasLore()) {
String lores = "";
for (String lore : meta.getLore())
@@ -141,17 +130,14 @@ public class FileCache {
writer.flush();
}
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);
}
Attributes attributes = new Attributes(item);
if (attributes != null)
while (attributes.values().iterator().hasNext()) {
Attribute a = attributes.values().iterator().next();
if (a != 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());
}
}
} else {
@@ -197,7 +183,8 @@ public class FileCache {
String line = reader.nextLine();
if (!line.contains(":")) {
- // the fist line represent the player group, operator status
+ // the fist line represent the player group, operator
+ // status
// and flying status
final String[] playerInfo = line.split(";");
group = playerInfo[0];
@@ -206,7 +193,8 @@ public class FileCache {
op = true;
} else op = false;
if (playerInfo.length > 2) {
- if (Integer.parseInt(playerInfo[2]) == 1) flying = true;
+ if (Integer.parseInt(playerInfo[2]) == 1)
+ flying = true;
else flying = false;
}
@@ -227,22 +215,19 @@ public class FileCache {
line = line.split(";")[0];
}
final String[] in = line.split(":");
- // can enchant item? size ofstring in file - 4 all / 2 = number
+ // 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])));
+ 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]));
+ 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);
}
@@ -253,25 +238,23 @@ public class FileCache {
}
meta.setLore(loreList);
}
- if (meta != null) stacki[i].setItemMeta(meta);
+ 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])));
+ 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]));
+ 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 loreList = new ArrayList();
for (String s : lores.split("%newline%")) {
@@ -279,7 +262,8 @@ public class FileCache {
}
meta.setLore(loreList);
}
- if (meta != null) stacki[i].setItemMeta(meta);
+ if (meta != null)
+ stacki[i].setItemMeta(meta);
} catch (Exception e) {
}
a++;
@@ -325,9 +309,8 @@ public class FileCache {
}
if (reader != null)
reader.close();
- for (int i = 0 ; i < inv.length; i++) {
- reader = new Scanner(new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path
- + File.separator + "inventory" + File.separator + i + ".cache"));
+ for (int i = 0; i < inv.length; i++) {
+ reader = new Scanner(new File(plugin.getDataFolder() + File.separator + "cache" + File.separator + path + File.separator + "inventory" + File.separator + i + ".cache"));
ItemStack item = new ItemStack(Material.AIR);
ItemMeta meta = null;
Attributes attributes = new Attributes(item);
@@ -350,7 +333,8 @@ public class FileCache {
case 4:
meta = Bukkit.getItemFactory().getItemMeta(item.getType());
break;
- default: break;
+ default:
+ break;
}
if (line.startsWith("name=")) {
line = line.substring(5);
@@ -375,7 +359,8 @@ public class FileCache {
try {
line = line.substring(10);
String[] args = line.split(";");
- if (args.length != 5) continue;
+ if (args.length != 5)
+ continue;
String name = args[0];
AttributeType type = AttributeType.fromId(args[1]);
double amount = Double.parseDouble(args[2]);
@@ -383,7 +368,8 @@ public class FileCache {
UUID uuid = UUID.fromString(args[4]);
Attribute attribute = new Attribute(new Builder(amount, operation, type, name, uuid));
attributes.add(attribute);
- } catch (Exception e) {}
+ } catch (Exception e) {
+ }
}
count++;
}
@@ -391,9 +377,8 @@ public class FileCache {
reader.close();
inv[i] = attributes.getStack();
}
- 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"));
+ 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"));
ItemStack item = new ItemStack(Material.AIR);
ItemMeta meta = null;
Attributes attributes = new Attributes(item);
@@ -416,7 +401,8 @@ public class FileCache {
case 4:
meta = Bukkit.getItemFactory().getItemMeta(item.getType());
break;
- default: break;
+ default:
+ break;
}
if (line.startsWith("name=")) {
line = line.substring(5);
@@ -441,7 +427,8 @@ public class FileCache {
try {
line = line.substring(10);
String[] args = line.split(";");
- if (args.length != 5) continue;
+ if (args.length != 5)
+ continue;
String name = args[0];
AttributeType type = AttributeType.fromId(args[1]);
double amount = Double.parseDouble(args[2]);
@@ -449,7 +436,8 @@ public class FileCache {
UUID uuid = UUID.fromString(args[4]);
Attribute attribute = new Attribute(new Builder(amount, operation, type, name, uuid));
attributes.add(attribute);
- } catch (Exception e) {}
+ } catch (Exception e) {
+ }
}
count++;
}
@@ -478,18 +466,17 @@ public class FileCache {
} catch (Error e) {
path = player.getName();
}
- 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()) {
- file = new File("cache/" + player.getName().toLowerCase()
- + ".cache");
+ file = new File("cache/" + player.getName().toLowerCase() + ".cache");
}
if (file.exists()) {
if (file.isDirectory()) {
for (File f : file.listFiles())
- if (f.isDirectory()) for (File a : f.listFiles())
- a.delete();
+ if (f.isDirectory())
+ for (File a : f.listFiles())
+ a.delete();
else f.delete();
} else file.delete();
}
@@ -504,11 +491,9 @@ public class FileCache {
} catch (Error e) {
path = player.getName();
}
- 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()) {
- file = new File("cache/" + player.getName().toLowerCase()
- + ".cache");
+ file = new File("cache/" + player.getName().toLowerCase() + ".cache");
}
if (file.exists()) {
diff --git a/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java b/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java
index c327db51..dd79b24b 100644
--- a/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java
+++ b/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java
@@ -39,11 +39,9 @@ public class LimboCache {
boolean flying;
if (playerData.doesCacheExist(player)) {
- StoreInventoryEvent event = new StoreInventoryEvent(player,
- playerData);
+ StoreInventoryEvent event = new StoreInventoryEvent(player, playerData);
Bukkit.getServer().getPluginManager().callEvent(event);
- if (!event.isCancelled() && event.getInventory() != null
- && event.getArmor() != null) {
+ if (!event.isCancelled() && event.getInventory() != null && event.getArmor() != null) {
inv = event.getInventory();
arm = event.getArmor();
} else {
@@ -56,34 +54,31 @@ public class LimboCache {
} else {
StoreInventoryEvent event = new StoreInventoryEvent(player);
Bukkit.getServer().getPluginManager().callEvent(event);
- if (!event.isCancelled() && event.getInventory() != null
- && event.getArmor() != null) {
+ 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;
+ 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!");
+ 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) {
+ if (Settings.isResetInventoryIfCreative && player.getGameMode() == GameMode.CREATIVE) {
ResetInventoryEvent event = new ResetInventoryEvent(player);
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
@@ -96,13 +91,11 @@ public class LimboCache {
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) {
diff --git a/src/main/java/fr/xephi/authme/commands/AdminCommand.java b/src/main/java/fr/xephi/authme/commands/AdminCommand.java
index 6f4f8a37..7549e8ca 100644
--- a/src/main/java/fr/xephi/authme/commands/AdminCommand.java
+++ b/src/main/java/fr/xephi/authme/commands/AdminCommand.java
@@ -76,32 +76,26 @@ public class AdminCommand implements CommandExecutor {
return true;
}
- if (!plugin.authmePermissible(sender,
- "authme.admin." + args[0].toLowerCase())) {
+ if (!plugin.authmePermissible(sender, "authme.admin." + args[0].toLowerCase())) {
m._(sender, "no_perm");
return true;
}
- if ((sender instanceof ConsoleCommandSender)
- && args[0].equalsIgnoreCase("passpartuToken")) {
+ if ((sender instanceof ConsoleCommandSender) && args[0].equalsIgnoreCase("passpartuToken")) {
if (args.length > 1) {
- System.out
- .println("[AuthMe] command usage: /authme passpartuToken");
+ System.out.println("[AuthMe] command usage: /authme passpartuToken");
return true;
}
if (Utils.getInstance().obtainToken()) {
- System.out
- .println("[AuthMe] You have 30s for insert this token ingame with /passpartu [token]");
+ System.out.println("[AuthMe] You have 30s for insert this token ingame with /passpartu [token]");
} else {
- System.out
- .println("[AuthMe] Security error on passpartu token, redo it. ");
+ System.out.println("[AuthMe] Security error on passpartu token, redo it. ");
}
return true;
}
if (args[0].equalsIgnoreCase("version")) {
- sender.sendMessage("AuthMe Version: "
- + AuthMe.getInstance().getDescription().getVersion());
+ sender.sendMessage("AuthMe Version: " + AuthMe.getInstance().getDescription().getVersion());
return true;
}
@@ -115,16 +109,15 @@ public class AdminCommand implements CommandExecutor {
calendar.add(Calendar.DATE, -(Integer.parseInt(args[1])));
long until = calendar.getTimeInMillis();
List purged = database.autoPurgeDatabase(until);
- sender.sendMessage("Deleted " + purged.size()
- + " user accounts");
- if (Settings.purgeEssentialsFile && plugin.ess != null) plugin.dataManager
- .purgeEssentials(purged);
- if (Settings.purgePlayerDat) plugin.dataManager
- .purgeDat(purged);
- if (Settings.purgeLimitedCreative) plugin.dataManager
- .purgeLimitedCreative(purged);
- if (Settings.purgeAntiXray) plugin.dataManager
- .purgeAntiXray(purged);
+ sender.sendMessage("Deleted " + purged.size() + " user accounts");
+ if (Settings.purgeEssentialsFile && plugin.ess != null)
+ plugin.dataManager.purgeEssentials(purged);
+ if (Settings.purgePlayerDat)
+ plugin.dataManager.purgeDat(purged);
+ if (Settings.purgeLimitedCreative)
+ plugin.dataManager.purgeLimitedCreative(purged);
+ if (Settings.purgeAntiXray)
+ plugin.dataManager.purgeAntiXray(purged);
return true;
} catch (NumberFormatException e) {
sender.sendMessage("Usage: /authme purge ");
@@ -132,9 +125,9 @@ public class AdminCommand implements CommandExecutor {
}
} else if (args[0].equalsIgnoreCase("reload")) {
database.reload();
- File newConfigFile = new File("plugins/AuthMe", "config.yml");
+ File newConfigFile = new File("plugins" + File.separator + "AuthMe", "config.yml");
if (!newConfigFile.exists()) {
- InputStream fis = getClass().getResourceAsStream("/config.yml");
+ InputStream fis = getClass().getResourceAsStream("" + File.separator + "config.yml");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(newConfigFile);
@@ -145,8 +138,7 @@ public class AdminCommand implements CommandExecutor {
fos.write(buf, 0, i);
}
} catch (Exception e) {
- Logger.getLogger(JavaPlugin.class.getName()).log(
- Level.SEVERE, "Failed to load config from JAR");
+ Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Failed to load config from JAR");
} finally {
try {
if (fis != null) {
@@ -159,8 +151,7 @@ public class AdminCommand implements CommandExecutor {
}
}
}
- YamlConfiguration newConfig = YamlConfiguration
- .loadConfiguration(newConfigFile);
+ YamlConfiguration newConfig = YamlConfiguration.loadConfiguration(newConfigFile);
Settings.reloadConfigOptions(newConfig);
m.reLoad();
s.reLoad();
@@ -176,16 +167,10 @@ public class AdminCommand implements CommandExecutor {
long lastLogin = player.getLastLogin();
Date d = new Date(lastLogin);
final long diff = System.currentTimeMillis() - lastLogin;
- final String msg = (int) (diff / 86400000) + " days "
- + (int) (diff / 3600000 % 24) + " hours "
- + (int) (diff / 60000 % 60) + " mins "
- + (int) (diff / 1000 % 60) + " secs.";
+ final String msg = (int) (diff / 86400000) + " days " + (int) (diff / 3600000 % 24) + " hours " + (int) (diff / 60000 % 60) + " mins " + (int) (diff / 1000 % 60) + " secs.";
String lastIP = player.getIp();
- sender.sendMessage("[AuthMe] " + args[1].toLowerCase()
- + " lastlogin : " + d.toString());
- sender.sendMessage("[AuthMe] The player : "
- + player.getNickname() + " is unlogged since "
- + msg);
+ sender.sendMessage("[AuthMe] " + args[1].toLowerCase() + " lastlogin : " + d.toString());
+ sender.sendMessage("[AuthMe] The player : " + player.getNickname() + " is unlogged since " + msg);
sender.sendMessage("[AuthMe] LastPlayer IP : " + lastIP);
} else {
m._(sender, "unknown_user");
@@ -204,104 +189,86 @@ public class AdminCommand implements CommandExecutor {
if (!args[1].contains(".")) {
final CommandSender fSender = sender;
final String[] arguments = args;
- Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
- new Runnable() {
- @Override
- public void run() {
- PlayerAuth pAuth = null;
- String message = "[AuthMe] ";
- try {
- pAuth = database.getAuth(arguments[1]
- .toLowerCase());
- } catch (NullPointerException npe) {
- fSender.sendMessage("[AuthMe] This player is unknown");
- return;
- }
- if (pAuth != null) {
- List accountList = database
- .getAllAuthsByName(pAuth);
- if (accountList.isEmpty()
- || accountList == null) {
- fSender.sendMessage("[AuthMe] This player is unknown");
- return;
- }
- if (accountList.size() == 1) {
- fSender.sendMessage("[AuthMe] "
- + arguments[1]
- + " is a single account player");
- return;
- }
- int i = 0;
- for (String account : accountList) {
- i++;
- message = message + account;
- if (i != accountList.size()) {
- message = message + ", ";
- } else {
- message = message + ".";
- }
- }
- fSender.sendMessage("[AuthMe] "
- + arguments[1]
- + " has "
- + String.valueOf(accountList.size())
- + " accounts");
- fSender.sendMessage(message);
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+
+ @Override
+ public void run() {
+ PlayerAuth pAuth = null;
+ String message = "[AuthMe] ";
+ try {
+ pAuth = database.getAuth(arguments[1].toLowerCase());
+ } catch (NullPointerException npe) {
+ fSender.sendMessage("[AuthMe] This player is unknown");
+ return;
+ }
+ if (pAuth != null) {
+ List accountList = database.getAllAuthsByName(pAuth);
+ if (accountList.isEmpty() || accountList == null) {
+ fSender.sendMessage("[AuthMe] This player is unknown");
+ return;
+ }
+ if (accountList.size() == 1) {
+ fSender.sendMessage("[AuthMe] " + arguments[1] + " is a single account player");
+ return;
+ }
+ int i = 0;
+ for (String account : accountList) {
+ i++;
+ message = message + account;
+ if (i != accountList.size()) {
+ message = message + ", ";
} else {
- fSender.sendMessage("[AuthMe] This player is unknown");
- return;
+ message = message + ".";
}
}
- });
+ fSender.sendMessage("[AuthMe] " + arguments[1] + " has " + String.valueOf(accountList.size()) + " accounts");
+ fSender.sendMessage(message);
+ } else {
+ fSender.sendMessage("[AuthMe] This player is unknown");
+ return;
+ }
+ }
+ });
return true;
} else {
final CommandSender fSender = sender;
final String[] arguments = args;
- Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
- new Runnable() {
- @Override
- public void run() {
- String message = "[AuthMe] ";
- if (arguments[1] != null) {
- List accountList = database
- .getAllAuthsByIp(arguments[1]);
- if (accountList.isEmpty()
- || accountList == null) {
- fSender.sendMessage("[AuthMe] Please put a valid IP");
- return;
- }
- if (accountList.size() == 1) {
- fSender.sendMessage("[AuthMe] "
- + arguments[1]
- + " is a single account player");
- return;
- }
- int i = 0;
- for (String account : accountList) {
- i++;
- message = message + account;
- if (i != accountList.size()) {
- message = message + ", ";
- } else {
- message = message + ".";
- }
- }
- fSender.sendMessage("[AuthMe] "
- + arguments[1]
- + " has "
- + String.valueOf(accountList.size())
- + " accounts");
- fSender.sendMessage(message);
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+
+ @Override
+ public void run() {
+ String message = "[AuthMe] ";
+ if (arguments[1] != null) {
+ List accountList = database.getAllAuthsByIp(arguments[1]);
+ if (accountList.isEmpty() || accountList == null) {
+ fSender.sendMessage("[AuthMe] Please put a valid IP");
+ return;
+ }
+ if (accountList.size() == 1) {
+ fSender.sendMessage("[AuthMe] " + arguments[1] + " is a single account player");
+ return;
+ }
+ int i = 0;
+ for (String account : accountList) {
+ i++;
+ message = message + account;
+ if (i != accountList.size()) {
+ message = message + ", ";
} else {
- fSender.sendMessage("[AuthMe] Please put a valid IP");
- return;
+ message = message + ".";
}
}
- });
+ fSender.sendMessage("[AuthMe] " + arguments[1] + " has " + String.valueOf(accountList.size()) + " accounts");
+ fSender.sendMessage(message);
+ } else {
+ fSender.sendMessage("[AuthMe] Please put a valid IP");
+ return;
+ }
+ }
+ });
return true;
}
- } else if (args[0].equalsIgnoreCase("register")
- || args[0].equalsIgnoreCase("reg")) {
+ } else if (args[0].equalsIgnoreCase("register") || args[0].equalsIgnoreCase("reg")) {
if (args.length != 3) {
sender.sendMessage("Usage: /authme register playername password");
return true;
@@ -312,13 +279,10 @@ public class AdminCommand implements CommandExecutor {
m._(sender, "user_regged");
return true;
}
- String hash = PasswordSecurity.getHash(
- Settings.getPasswordHash, args[2], name);
- PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0L,
- "your@email.com", API.getPlayerRealName(name));
- if (PasswordSecurity.userSalt.containsKey(name)
- && PasswordSecurity.userSalt.get(name) != null) auth
- .setSalt(PasswordSecurity.userSalt.get(name));
+ String hash = PasswordSecurity.getHash(Settings.getPasswordHash, args[2], name);
+ PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0L, "your@email.com", API.getPlayerRealName(name));
+ if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null)
+ auth.setSalt(PasswordSecurity.userSalt.get(name));
else auth.setSalt("");
if (!database.saveAuth(auth)) {
m._(sender, "error");
@@ -342,8 +306,7 @@ public class AdminCommand implements CommandExecutor {
m._(sender, "unknown_user");
return true;
}
- sender.sendMessage("[AuthMe] " + args[1] + " email : "
- + getAuth.getEmail());
+ sender.sendMessage("[AuthMe] " + args[1] + " email : " + getAuth.getEmail());
return true;
} else if (args[0].equalsIgnoreCase("chgemail")) {
if (args.length != 3) {
@@ -361,17 +324,15 @@ public class AdminCommand implements CommandExecutor {
m._(sender, "error");
return true;
}
- if (PlayerCache.getInstance().getAuth(playername) != null) PlayerCache
- .getInstance().updatePlayer(getAuth);
+ if (PlayerCache.getInstance().getAuth(playername) != null)
+ PlayerCache.getInstance().updatePlayer(getAuth);
return true;
} else if (args[0].equalsIgnoreCase("setspawn")) {
try {
if (sender instanceof Player) {
- if (Spawn.getInstance().setSpawn(
- ((Player) sender).getLocation())) sender
- .sendMessage("[AuthMe] Correctly define new spawn");
- else sender
- .sendMessage("[AuthMe] SetSpawn fail , please retry");
+ if (Spawn.getInstance().setSpawn(((Player) sender).getLocation()))
+ sender.sendMessage("[AuthMe] Correctly define new spawn");
+ else sender.sendMessage("[AuthMe] SetSpawn fail , please retry");
} else {
sender.sendMessage("[AuthMe] Please use that command in game");
}
@@ -382,11 +343,9 @@ public class AdminCommand implements CommandExecutor {
} else if (args[0].equalsIgnoreCase("setfirstspawn")) {
try {
if (sender instanceof Player) {
- if (Spawn.getInstance().setFirstSpawn(
- ((Player) sender).getLocation())) sender
- .sendMessage("[AuthMe] Correctly define new first spawn");
- else sender
- .sendMessage("[AuthMe] SetFirstSpawn fail , please retry");
+ if (Spawn.getInstance().setFirstSpawn(((Player) sender).getLocation()))
+ sender.sendMessage("[AuthMe] Correctly define new first spawn");
+ else sender.sendMessage("[AuthMe] SetFirstSpawn fail , please retry");
} else {
sender.sendMessage("[AuthMe] Please use that command in game");
}
@@ -399,34 +358,22 @@ public class AdminCommand implements CommandExecutor {
for (OfflinePlayer off : plugin.getServer().getBannedPlayers()) {
bannedPlayers.add(off.getName().toLowerCase());
}
- final List bP = bannedPlayers;
- if (database instanceof Thread) {
- database.purgeBanned(bP);
- } else {
- Bukkit.getScheduler().runTaskAsynchronously(plugin,
- new Runnable() {
- @Override
- public void run() {
- database.purgeBanned(bP);
- }
- });
- }
- if (Settings.purgeEssentialsFile && plugin.ess != null) plugin.dataManager
- .purgeEssentials(bannedPlayers);
- if (Settings.purgePlayerDat) plugin.dataManager
- .purgeDat(bannedPlayers);
- if (Settings.purgeLimitedCreative) plugin.dataManager
- .purgeLimitedCreative(bannedPlayers);
- if (Settings.purgeAntiXray) plugin.dataManager
- .purgeAntiXray(bannedPlayers);
+ database.purgeBanned(bannedPlayers);
+ if (Settings.purgeEssentialsFile && plugin.ess != null)
+ plugin.dataManager.purgeEssentials(bannedPlayers);
+ if (Settings.purgePlayerDat)
+ plugin.dataManager.purgeDat(bannedPlayers);
+ if (Settings.purgeLimitedCreative)
+ plugin.dataManager.purgeLimitedCreative(bannedPlayers);
+ if (Settings.purgeAntiXray)
+ plugin.dataManager.purgeAntiXray(bannedPlayers);
return true;
} else if (args[0].equalsIgnoreCase("spawn")) {
try {
if (sender instanceof Player) {
- if (Spawn.getInstance().getSpawn() != null) ((Player) sender)
- .teleport(Spawn.getInstance().getSpawn());
- else sender
- .sendMessage("[AuthMe] Spawn fail , please try to define the spawn");
+ if (Spawn.getInstance().getSpawn() != null)
+ ((Player) sender).teleport(Spawn.getInstance().getSpawn());
+ else sender.sendMessage("[AuthMe] Spawn fail , please try to define the spawn");
} else {
sender.sendMessage("[AuthMe] Please use that command in game");
}
@@ -437,10 +384,9 @@ public class AdminCommand implements CommandExecutor {
} else if (args[0].equalsIgnoreCase("firstspawn")) {
try {
if (sender instanceof Player) {
- if (Spawn.getInstance().getFirstSpawn() != null) ((Player) sender)
- .teleport(Spawn.getInstance().getFirstSpawn());
- else sender
- .sendMessage("[AuthMe] Spawn fail , please try to define the first spawn");
+ if (Spawn.getInstance().getFirstSpawn() != null)
+ ((Player) sender).teleport(Spawn.getInstance().getFirstSpawn());
+ else sender.sendMessage("[AuthMe] Spawn fail , please try to define the first spawn");
} else {
sender.sendMessage("[AuthMe] Please use that command in game");
}
@@ -448,16 +394,14 @@ public class AdminCommand implements CommandExecutor {
ConsoleLogger.showError(ex.getMessage());
}
return true;
- } else if (args[0].equalsIgnoreCase("changepassword")
- || args[0].equalsIgnoreCase("cp")) {
+ } else if (args[0].equalsIgnoreCase("changepassword") || args[0].equalsIgnoreCase("cp")) {
if (args.length != 3) {
sender.sendMessage("Usage: /authme changepassword playername newpassword");
return true;
}
try {
String name = args[1].toLowerCase();
- String hash = PasswordSecurity.getHash(
- Settings.getPasswordHash, args[2], name);
+ String hash = PasswordSecurity.getHash(Settings.getPasswordHash, args[2], name);
PlayerAuth auth = null;
if (PlayerCache.getInstance().isAuthenticated(name)) {
auth = PlayerCache.getInstance().getAuth(name);
@@ -484,9 +428,7 @@ public class AdminCommand implements CommandExecutor {
m._(sender, "error");
}
return true;
- } else if (args[0].equalsIgnoreCase("unregister")
- || args[0].equalsIgnoreCase("unreg")
- || args[0].equalsIgnoreCase("del")) {
+ } else if (args[0].equalsIgnoreCase("unregister") || args[0].equalsIgnoreCase("unreg") || args[0].equalsIgnoreCase("del")) {
if (args.length != 2) {
sender.sendMessage("Usage: /authme unregister playername");
return true;
@@ -505,13 +447,10 @@ public class AdminCommand implements CommandExecutor {
Utils.getInstance().setGroup(name, groupType.UNREGISTERED);
if (target != null) {
if (target.isOnline()) {
- if (Settings.isTeleportToSpawnEnabled
- && !Settings.noTeleport) {
+ if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location spawn = plugin.getSpawnLocation(target);
- SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(
- target, target.getLocation(), spawn, false);
- plugin.getServer().getPluginManager()
- .callEvent(tpEvent);
+ SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(target, target.getLocation(), spawn, false);
+ plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
target.teleport(tpEvent.getTo());
}
@@ -521,23 +460,12 @@ public class AdminCommand implements CommandExecutor {
int interval = Settings.getWarnMessageInterval;
BukkitScheduler sched = sender.getServer().getScheduler();
if (delay != 0) {
- int id = sched.scheduleSyncDelayedTask(plugin,
- new TimeoutTask(plugin, name), delay);
- LimboCache.getInstance().getLimboPlayer(name)
- .setTimeoutTaskId(id);
+ int id = sched.scheduleSyncDelayedTask(plugin, new TimeoutTask(plugin, name), delay);
+ LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
- LimboCache
- .getInstance()
- .getLimboPlayer(name)
- .setMessageTaskId(
- sched.scheduleSyncDelayedTask(
- plugin,
- new MessageTask(plugin, name, m
- ._("reg_msg"), interval)));
- if (Settings.applyBlindEffect) target
- .addPotionEffect(new PotionEffect(
- PotionEffectType.BLINDNESS,
- Settings.getRegistrationTimeout * 20, 2));
+ LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("reg_msg"), interval)));
+ if (Settings.applyBlindEffect)
+ target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
m._(target, "unregistered");
} else {
// Player isn't online, do nothing else
@@ -557,8 +485,7 @@ public class AdminCommand implements CommandExecutor {
String name = args[1].toLowerCase();
PlayerAuth auth = database.getAuth(name);
if (auth == null) {
- sender.sendMessage("The player " + name
- + " is not registered ");
+ sender.sendMessage("The player " + name + " is not registered ");
return true;
}
auth.setQuitLocX(0);
@@ -568,11 +495,10 @@ public class AdminCommand implements CommandExecutor {
database.updateQuitLoc(auth);
sender.sendMessage(name + " 's last pos location is now reset");
} catch (Exception e) {
- ConsoleLogger
- .showError("An error occured while trying to reset location or player do not exist, please see below: ");
+ ConsoleLogger.showError("An error occured while trying to reset location or player do not exist, please see below: ");
ConsoleLogger.showError(e.getMessage());
- if (sender instanceof Player) sender
- .sendMessage("An error occured while trying to reset location or player do not exist, please see logs");
+ if (sender instanceof Player)
+ sender.sendMessage("An error occured while trying to reset location or player do not exist, please see logs");
}
return true;
} else if (args[0].equalsIgnoreCase("switchantibot")) {
@@ -599,11 +525,8 @@ public class AdminCommand implements CommandExecutor {
}
if (Bukkit.getPlayer(args[1]) != null) {
Player player = Bukkit.getPlayer(args[1]);
- sender.sendMessage(player.getName() + " actual ip is : "
- + player.getAddress().getAddress().getHostAddress()
- + ":" + player.getAddress().getPort());
- sender.sendMessage(player.getName() + " real ip is : "
- + plugin.getIP(player));
+ sender.sendMessage(player.getName() + " actual ip is : " + player.getAddress().getAddress().getHostAddress() + ":" + player.getAddress().getPort());
+ sender.sendMessage(player.getName() + " real ip is : " + plugin.getIP(player));
return true;
} else {
sender.sendMessage("This player is not actually online");
@@ -625,8 +548,7 @@ public class AdminCommand implements CommandExecutor {
auth.setQuitLocZ(0D);
auth.setWorld("world");
database.updateQuitLoc(auth);
- sender.sendMessage("[AuthMe] Successfully reset position for "
- + auth.getNickname());
+ sender.sendMessage("[AuthMe] Successfully reset position for " + auth.getNickname());
return true;
} else {
sender.sendMessage("Usage: /authme reload|register playername password|changepassword playername password|unregister playername");
diff --git a/src/main/java/fr/xephi/authme/commands/CaptchaCommand.java b/src/main/java/fr/xephi/authme/commands/CaptchaCommand.java
index c8fc8dd3..9e58cc8f 100644
--- a/src/main/java/fr/xephi/authme/commands/CaptchaCommand.java
+++ b/src/main/java/fr/xephi/authme/commands/CaptchaCommand.java
@@ -61,8 +61,7 @@ public class CaptchaCommand implements CommandExecutor {
plugin.cap.remove(name);
plugin.cap.put(name, rdm.nextString());
for (String s : m._("wrong_captcha")) {
- player.sendMessage(s.replace("THE_CAPTCHA",
- plugin.cap.get(name)));
+ player.sendMessage(s.replace("THE_CAPTCHA", plugin.cap.get(name)));
}
return true;
}
diff --git a/src/main/java/fr/xephi/authme/commands/ChangePasswordCommand.java b/src/main/java/fr/xephi/authme/commands/ChangePasswordCommand.java
index 1cc7175b..e6fe61d1 100644
--- a/src/main/java/fr/xephi/authme/commands/ChangePasswordCommand.java
+++ b/src/main/java/fr/xephi/authme/commands/ChangePasswordCommand.java
@@ -54,16 +54,13 @@ public class ChangePasswordCommand implements CommandExecutor {
}
try {
- String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash,
- args[1], name);
+ String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, args[1], name);
- if (PasswordSecurity.comparePasswordWithHash(args[0], PlayerCache
- .getInstance().getAuth(name).getHash(), player.getName())) {
+ if (PasswordSecurity.comparePasswordWithHash(args[0], PlayerCache.getInstance().getAuth(name).getHash(), player.getName())) {
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
auth.setHash(hashnew);
- if (PasswordSecurity.userSalt.containsKey(name)
- && PasswordSecurity.userSalt.get(name) != null) auth
- .setSalt(PasswordSecurity.userSalt.get(name));
+ if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null)
+ auth.setSalt(PasswordSecurity.userSalt.get(name));
else auth.setSalt("");
if (!database.updatePassword(auth)) {
m._(player, "error");
@@ -74,9 +71,7 @@ public class ChangePasswordCommand implements CommandExecutor {
m._(player, "pwd_changed");
ConsoleLogger.info(player.getName() + " changed his password");
if (plugin.notifications != null) {
- plugin.notifications.showNotification(new Notification(
- "[AuthMe] " + player.getName()
- + " change his password!"));
+ plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " change his password!"));
}
} else {
m._(player, "wrong_pwd");
diff --git a/src/main/java/fr/xephi/authme/commands/ConverterCommand.java b/src/main/java/fr/xephi/authme/commands/ConverterCommand.java
index bdd93d86..5262f0aa 100644
--- a/src/main/java/fr/xephi/authme/commands/ConverterCommand.java
+++ b/src/main/java/fr/xephi/authme/commands/ConverterCommand.java
@@ -88,9 +88,13 @@ public class ConverterCommand implements CommandExecutor {
public enum ConvertType {
- ftsql("flattosql"), ftsqlite("flattosqlite"), xauth("xauth"), crazylogin(
- "crazylogin"), rakamak("rakamak"), royalauth("royalauth"), vauth(
- "vauth");
+ ftsql("flattosql"),
+ ftsqlite("flattosqlite"),
+ xauth("xauth"),
+ crazylogin("crazylogin"),
+ rakamak("rakamak"),
+ royalauth("royalauth"),
+ vauth("vauth");
String name;
diff --git a/src/main/java/fr/xephi/authme/commands/EmailCommand.java b/src/main/java/fr/xephi/authme/commands/EmailCommand.java
index 998952af..2e79018b 100644
--- a/src/main/java/fr/xephi/authme/commands/EmailCommand.java
+++ b/src/main/java/fr/xephi/authme/commands/EmailCommand.java
@@ -61,18 +61,14 @@ public class EmailCommand implements CommandExecutor {
return true;
}
if (Settings.getmaxRegPerEmail > 0) {
- if (!plugin.authmePermissible(sender, "authme.allow2accounts")
- && data.getAllAuthsByEmail(args[1]).size() >= Settings.getmaxRegPerEmail) {
+ if (!plugin.authmePermissible(sender, "authme.allow2accounts") && data.getAllAuthsByEmail(args[1]).size() >= Settings.getmaxRegPerEmail) {
m._(player, "max_reg");
return true;
}
}
- if (args[1].equals(args[2])
- && PlayerCache.getInstance().isAuthenticated(name)) {
+ if (args[1].equals(args[2]) && PlayerCache.getInstance().isAuthenticated(name)) {
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
- if (auth.getEmail() == null
- || (!auth.getEmail().equals("your@email.com") && !auth
- .getEmail().isEmpty())) {
+ if (auth.getEmail() == null || (!auth.getEmail().equals("your@email.com") && !auth.getEmail().isEmpty())) {
m._(player, "usage_email_change");
return true;
}
@@ -103,17 +99,14 @@ public class EmailCommand implements CommandExecutor {
return true;
}
if (Settings.getmaxRegPerEmail > 0) {
- if (!plugin.authmePermissible(sender, "authme.allow2accounts")
- && data.getAllAuthsByEmail(args[2]).size() >= Settings.getmaxRegPerEmail) {
+ if (!plugin.authmePermissible(sender, "authme.allow2accounts") && data.getAllAuthsByEmail(args[2]).size() >= Settings.getmaxRegPerEmail) {
m._(player, "max_reg");
return true;
}
}
if (PlayerCache.getInstance().isAuthenticated(name)) {
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
- if (auth.getEmail() == null
- || auth.getEmail().equals("your@email.com")
- || auth.getEmail().isEmpty()) {
+ if (auth.getEmail() == null || auth.getEmail().equals("your@email.com") || auth.getEmail().isEmpty()) {
m._(player, "usage_email_add");
return true;
}
@@ -158,11 +151,9 @@ public class EmailCommand implements CommandExecutor {
return true;
}
try {
- RandomString rand = new RandomString(
- Settings.getRecoveryPassLength);
+ RandomString rand = new RandomString(Settings.getRecoveryPassLength);
String thePass = rand.nextString();
- String hashnew = PasswordSecurity.getHash(
- Settings.getPasswordHash, thePass, name);
+ String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, thePass, name);
PlayerAuth auth = null;
if (PlayerCache.getInstance().isAuthenticated(name)) {
auth = PlayerCache.getInstance().getAuth(name);
@@ -172,16 +163,12 @@ public class EmailCommand implements CommandExecutor {
m._(player, "unknown_user");
return true;
}
- if (Settings.getmailAccount.equals("")
- || Settings.getmailAccount.isEmpty()) {
+ if (Settings.getmailAccount.equals("") || Settings.getmailAccount.isEmpty()) {
m._(player, "error");
return true;
}
- if (!args[1].equalsIgnoreCase(auth.getEmail())
- || args[1].equalsIgnoreCase("your@email.com")
- || auth.getEmail().equalsIgnoreCase(
- "your@email.com")) {
+ if (!args[1].equalsIgnoreCase(auth.getEmail()) || args[1].equalsIgnoreCase("your@email.com") || auth.getEmail().equalsIgnoreCase("your@email.com")) {
m._(player, "email_invalid");
return true;
}
@@ -191,14 +178,14 @@ public class EmailCommand implements CommandExecutor {
finalauth.setHash(hashnew);
data.updatePassword(auth);
} else {
- Bukkit.getScheduler().runTaskAsynchronously(plugin,
- new Runnable() {
- @Override
- public void run() {
- finalauth.setHash(finalhashnew);
- data.updatePassword(finalauth);
- }
- });
+ Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
+
+ @Override
+ public void run() {
+ finalauth.setHash(finalhashnew);
+ data.updatePassword(finalauth);
+ }
+ });
}
plugin.mail.main(auth, thePass);
m._(player, "email_send");
diff --git a/src/main/java/fr/xephi/authme/commands/LogoutCommand.java b/src/main/java/fr/xephi/authme/commands/LogoutCommand.java
index 24724d9e..83c4adf9 100644
--- a/src/main/java/fr/xephi/authme/commands/LogoutCommand.java
+++ b/src/main/java/fr/xephi/authme/commands/LogoutCommand.java
@@ -74,54 +74,46 @@ public class LogoutCommand implements CommandExecutor {
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location spawnLoc = plugin.getSpawnLocation(player);
- AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player,
- spawnLoc);
+ AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
- if (tpEvent.getTo() != null) player.teleport(tpEvent.getTo());
+ if (tpEvent.getTo() != null)
+ player.teleport(tpEvent.getTo());
}
}
- if (LimboCache.getInstance().hasLimboPlayer(name)) LimboCache
- .getInstance().deleteLimboPlayer(name);
+ if (LimboCache.getInstance().hasLimboPlayer(name))
+ LimboCache.getInstance().deleteLimboPlayer(name);
LimboCache.getInstance().addLimboPlayer(player);
utils.setGroup(player, groupType.NOTLOGGEDIN);
if (Settings.protectInventoryBeforeLogInEnabled) {
player.getInventory().clear();
// create cache file for handling lost of inventories on unlogged in
// status
- DataFileCache playerData = new DataFileCache(LimboCache
- .getInstance().getLimboPlayer(name).getInventory(),
- LimboCache.getInstance().getLimboPlayer(name).getArmour());
- playerBackup.createCache(player, playerData, LimboCache.getInstance()
- .getLimboPlayer(name).getGroup(), LimboCache.getInstance()
- .getLimboPlayer(name).getOperator(), LimboCache
- .getInstance().getLimboPlayer(name).isFlying());
+ DataFileCache playerData = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(), LimboCache.getInstance().getLimboPlayer(name).getArmour());
+ playerBackup.createCache(player, playerData, LimboCache.getInstance().getLimboPlayer(name).getGroup(), LimboCache.getInstance().getLimboPlayer(name).getOperator(), LimboCache.getInstance().getLimboPlayer(name).isFlying());
}
int delay = Settings.getRegistrationTimeout * 20;
int interval = Settings.getWarnMessageInterval;
BukkitScheduler sched = sender.getServer().getScheduler();
if (delay != 0) {
- int id = sched.scheduleSyncDelayedTask(plugin, new TimeoutTask(
- plugin, name), delay);
+ int id = sched.scheduleSyncDelayedTask(plugin, new TimeoutTask(plugin, name), delay);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
- int msgT = sched.scheduleSyncDelayedTask(plugin, new MessageTask(
- plugin, name, m._("login_msg"), interval));
+ int msgT = sched.scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("login_msg"), interval));
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
try {
- if (player.isInsideVehicle()) player.getVehicle().eject();
+ if (player.isInsideVehicle())
+ player.getVehicle().eject();
} catch (NullPointerException npe) {
}
- if (Settings.applyBlindEffect) player.addPotionEffect(new PotionEffect(
- PotionEffectType.BLINDNESS,
- Settings.getRegistrationTimeout * 20, 2));
+ if (Settings.applyBlindEffect)
+ player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
m._(player, "logout");
ConsoleLogger.info(player.getDisplayName() + " logged out");
if (plugin.notifications != null) {
- plugin.notifications.showNotification(new Notification("[AuthMe] "
- + player.getName() + " logged out!"));
+ plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " logged out!"));
}
return true;
}
diff --git a/src/main/java/fr/xephi/authme/commands/PasspartuCommand.java b/src/main/java/fr/xephi/authme/commands/PasspartuCommand.java
index 2b634dbd..51c3dc23 100644
--- a/src/main/java/fr/xephi/authme/commands/PasspartuCommand.java
+++ b/src/main/java/fr/xephi/authme/commands/PasspartuCommand.java
@@ -15,6 +15,7 @@ import fr.xephi.authme.settings.Messages;
* @author stefano
*/
public class PasspartuCommand implements CommandExecutor {
+
private Utils utils = Utils.getInstance();
public AuthMe plugin;
private Messages m = Messages.getInstance();
@@ -32,16 +33,14 @@ public class PasspartuCommand implements CommandExecutor {
return true;
}
- if (PlayerCache.getInstance().isAuthenticated(
- sender.getName().toLowerCase())) {
+ if (PlayerCache.getInstance().isAuthenticated(sender.getName().toLowerCase())) {
return true;
}
if ((sender instanceof Player) && args.length == 1) {
if (utils.readToken(args[0])) {
// bypass login!
- plugin.management.performLogin((Player) sender, "dontneed",
- true);
+ plugin.management.performLogin((Player) sender, "dontneed", true);
return true;
}
sender.sendMessage("Time is expired or Token is Wrong!");
diff --git a/src/main/java/fr/xephi/authme/commands/RegisterCommand.java b/src/main/java/fr/xephi/authme/commands/RegisterCommand.java
index 0c4e8480..9b489013 100644
--- a/src/main/java/fr/xephi/authme/commands/RegisterCommand.java
+++ b/src/main/java/fr/xephi/authme/commands/RegisterCommand.java
@@ -57,16 +57,15 @@ public class RegisterCommand implements CommandExecutor {
plugin.management.performRegister(player, thePass, email);
return true;
}
- if (args.length == 0
- || (Settings.getEnablePasswordVerifier && args.length < 2)) {
+ if (args.length == 0 || (Settings.getEnablePasswordVerifier && args.length < 2)) {
m._(player, "usage_reg");
return true;
}
- if (args.length > 1 && Settings.getEnablePasswordVerifier) if (!args[0]
- .equals(args[1])) {
- m._(player, "password_error");
- return true;
- }
+ if (args.length > 1 && Settings.getEnablePasswordVerifier)
+ if (!args[0].equals(args[1])) {
+ m._(player, "password_error");
+ return true;
+ }
plugin.management.performRegister(player, args[0], "");
return true;
}
diff --git a/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java b/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java
index b98dfd08..3d587639 100644
--- a/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java
+++ b/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java
@@ -67,20 +67,16 @@ public class UnregisterCommand implements CommandExecutor {
return true;
}
try {
- if (PasswordSecurity.comparePasswordWithHash(args[0], PlayerCache
- .getInstance().getAuth(name).getHash(), player.getName())) {
+ if (PasswordSecurity.comparePasswordWithHash(args[0], PlayerCache.getInstance().getAuth(name).getHash(), player.getName())) {
if (!database.removeAuth(name)) {
player.sendMessage("error");
return true;
}
if (Settings.isForcedRegistrationEnabled) {
- if (Settings.isTeleportToSpawnEnabled
- && !Settings.noTeleport) {
+ if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location spawn = plugin.getSpawnLocation(player);
- SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(
- player, player.getLocation(), spawn, false);
- plugin.getServer().getPluginManager()
- .callEvent(tpEvent);
+ SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
+ plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
player.teleport(tpEvent.getTo());
}
@@ -88,72 +84,48 @@ public class UnregisterCommand implements CommandExecutor {
player.getInventory().setContents(new ItemStack[36]);
player.getInventory().setArmorContents(new ItemStack[4]);
player.saveData();
- PlayerCache.getInstance().removePlayer(
- player.getName().toLowerCase());
- if (!Settings.getRegisteredGroup.isEmpty()) Utils
- .getInstance().setGroup(player,
- groupType.UNREGISTERED);
+ PlayerCache.getInstance().removePlayer(player.getName().toLowerCase());
+ if (!Settings.getRegisteredGroup.isEmpty())
+ Utils.getInstance().setGroup(player, groupType.UNREGISTERED);
LimboCache.getInstance().addLimboPlayer(player);
int delay = Settings.getRegistrationTimeout * 20;
int interval = Settings.getWarnMessageInterval;
BukkitScheduler sched = sender.getServer().getScheduler();
if (delay != 0) {
- int id = sched.scheduleSyncDelayedTask(plugin,
- new TimeoutTask(plugin, name), delay);
- LimboCache.getInstance().getLimboPlayer(name)
- .setTimeoutTaskId(id);
+ int id = sched.scheduleSyncDelayedTask(plugin, new TimeoutTask(plugin, name), delay);
+ LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
- LimboCache
- .getInstance()
- .getLimboPlayer(name)
- .setMessageTaskId(
- sched.scheduleSyncDelayedTask(
- plugin,
- new MessageTask(plugin, name, m
- ._("reg_msg"), interval)));
+ LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("reg_msg"), interval)));
m._(player, "unregistered");
- ConsoleLogger.info(player.getDisplayName()
- + " unregistered himself");
+ ConsoleLogger.info(player.getDisplayName() + " unregistered himself");
if (plugin.notifications != null) {
- plugin.notifications.showNotification(new Notification(
- "[AuthMe] " + player.getName()
- + " unregistered himself!"));
+ plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " unregistered himself!"));
}
return true;
}
if (!Settings.unRegisteredGroup.isEmpty()) {
- Utils.getInstance().setGroup(player,
- Utils.groupType.UNREGISTERED);
+ Utils.getInstance().setGroup(player, Utils.groupType.UNREGISTERED);
}
- PlayerCache.getInstance().removePlayer(
- player.getName().toLowerCase());
+ PlayerCache.getInstance().removePlayer(player.getName().toLowerCase());
// check if Player cache File Exist and delete it, preventing
// duplication of items
if (playerCache.doesCacheExist(player)) {
playerCache.removeCache(player);
}
- if (Settings.applyBlindEffect) player
- .addPotionEffect(new PotionEffect(
- PotionEffectType.BLINDNESS,
- Settings.getRegistrationTimeout * 20, 2));
+ if (Settings.applyBlindEffect)
+ player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
m._(player, "unregistered");
- ConsoleLogger.info(player.getDisplayName()
- + " unregistered himself");
+ ConsoleLogger.info(player.getDisplayName() + " unregistered himself");
if (plugin.notifications != null) {
- plugin.notifications.showNotification(new Notification(
- "[AuthMe] " + player.getName()
- + " unregistered himself!"));
+ plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " unregistered himself!"));
}
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location spawn = plugin.getSpawnLocation(player);
- SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player,
- player.getLocation(), spawn, false);
+ SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
- if (!tpEvent.getTo().getWorld()
- .getChunkAt(tpEvent.getTo()).isLoaded()) {
- tpEvent.getTo().getWorld()
- .getChunkAt(tpEvent.getTo()).load();
+ if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
+ tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
}
player.teleport(tpEvent.getTo());
}
diff --git a/src/main/java/fr/xephi/authme/converter/CrazyLoginConverter.java b/src/main/java/fr/xephi/authme/converter/CrazyLoginConverter.java
index 2d0ebd37..fdd8e34f 100644
--- a/src/main/java/fr/xephi/authme/converter/CrazyLoginConverter.java
+++ b/src/main/java/fr/xephi/authme/converter/CrazyLoginConverter.java
@@ -41,11 +41,9 @@ public class CrazyLoginConverter implements Converter {
public void run() {
fileName = Settings.crazyloginFileName;
try {
- source = new File(AuthMe.getInstance().getDataFolder()
- + File.separator + fileName);
+ source = new File(AuthMe.getInstance().getDataFolder() + File.separator + fileName);
if (!source.exists()) {
- sender.sendMessage("Error while trying to import datas, please put "
- + fileName + " in AuthMe folder!");
+ sender.sendMessage("Error while trying to import datas, please put " + fileName + " in AuthMe folder!");
return;
}
source.createNewFile();
@@ -55,14 +53,15 @@ public class CrazyLoginConverter implements Converter {
while ((line = users.readLine()) != null) {
if (line.contains("|")) {
String[] args = line.split("\\|");
- if (args.length < 2) continue;
- if (args[0].equalsIgnoreCase("name")) continue;
+ if (args.length < 2)
+ continue;
+ if (args[0].equalsIgnoreCase("name"))
+ continue;
String player = args[0].toLowerCase();
String psw = args[1];
try {
if (player != null && psw != null) {
- PlayerAuth auth = new PlayerAuth(player, psw,
- "127.0.0.1", System.currentTimeMillis());
+ PlayerAuth auth = new PlayerAuth(player, psw, "127.0.0.1", System.currentTimeMillis());
database.saveAuth(auth);
}
} catch (Exception e) {
@@ -70,8 +69,7 @@ public class CrazyLoginConverter implements Converter {
}
}
users.close();
- ConsoleLogger
- .info("CrazyLogin database has been imported correctly");
+ ConsoleLogger.info("CrazyLogin database has been imported correctly");
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
} catch (IOException ex) {
diff --git a/src/main/java/fr/xephi/authme/converter/FlatToSql.java b/src/main/java/fr/xephi/authme/converter/FlatToSql.java
index 6dc78b43..2c52ab66 100644
--- a/src/main/java/fr/xephi/authme/converter/FlatToSql.java
+++ b/src/main/java/fr/xephi/authme/converter/FlatToSql.java
@@ -51,78 +51,35 @@ public class FlatToSql implements Converter {
@Override
public void run() {
try {
- source = new File(AuthMe.getInstance().getDataFolder()
- + File.separator + "auths.db");
+ source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
source.createNewFile();
- output = new File(AuthMe.getInstance().getDataFolder()
- + File.separator + "authme.sql");
+ output = new File(AuthMe.getInstance().getDataFolder() + File.separator + "authme.sql");
BufferedReader br = null;
BufferedWriter sql = null;
br = new BufferedReader(new FileReader(source));
sql = new BufferedWriter(new FileWriter(output));
- String createDB = "CREATE TABLE IF NOT EXISTS " + tableName + " ("
- + columnID + " INTEGER AUTO_INCREMENT," + columnName
- + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword
- + " VARCHAR(255) NOT NULL," + columnIp
- + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1',"
- + columnLastLogin + " BIGINT NOT NULL DEFAULT '"
- + System.currentTimeMillis() + "'," + lastlocX
- + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY
- + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ
- + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld
- + " VARCHAR(255) DEFAULT 'world'," + columnEmail
- + " VARCHAR(255) DEFAULT 'your@email.com'," + columnLogged
- + " SMALLINT NOT NULL DEFAULT '0',"
- + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID
- + "));";
+ String createDB = "CREATE TABLE IF NOT EXISTS " + tableName + " (" + columnID + " INTEGER AUTO_INCREMENT," + columnName + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword + " VARCHAR(255) NOT NULL," + columnIp + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1'," + columnLastLogin + " BIGINT NOT NULL DEFAULT '" + System.currentTimeMillis() + "'," + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld + " VARCHAR(255) DEFAULT 'world'," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com'," + columnLogged + " SMALLINT NOT NULL DEFAULT '0'," + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));";
sql.write(createDB);
String line;
String newline;
while ((line = br.readLine()) != null) {
sql.newLine();
String[] args = line.split(":");
- if (args.length == 4) newline = "INSERT INTO " + tableName
- + "(" + columnName + "," + columnPassword + ","
- + columnIp + "," + columnLastLogin + "," + lastlocX
- + "," + lastlocY + "," + lastlocZ + "," + lastlocWorld
- + "," + columnEmail + "," + columnLogged
- + ") VALUES ('" + args[0] + "', '" + args[1] + "', '"
- + args[2] + "', " + args[3]
- + ", 0.0, 0.0, 0.0, 'world', 'your@email.com', 0);";
- else if (args.length == 7) newline = "INSERT INTO " + tableName
- + "(" + columnName + "," + columnPassword + ","
- + columnIp + "," + columnLastLogin + "," + lastlocX
- + "," + lastlocY + "," + lastlocZ + "," + lastlocWorld
- + "," + columnEmail + "," + columnLogged
- + ") VALUES ('" + args[0] + "', '" + args[1] + "', '"
- + args[2] + "', " + args[3] + ", " + args[4] + ", "
- + args[5] + ", " + args[6]
- + ", 'world', 'your@email.com', 0);";
- else if (args.length == 8) newline = "INSERT INTO " + tableName
- + "(" + columnName + "," + columnPassword + ","
- + columnIp + "," + columnLastLogin + "," + lastlocX
- + "," + lastlocY + "," + lastlocZ + "," + lastlocWorld
- + "," + columnEmail + "," + columnLogged
- + ") VALUES ('" + args[0] + "', '" + args[1] + "', '"
- + args[2] + "', " + args[3] + ", " + args[4] + ", "
- + args[5] + ", " + args[6] + ", '" + args[7]
- + "', 'your@email.com', 0);";
- else if (args.length == 9) newline = "INSERT INTO " + tableName
- + "(" + columnName + "," + columnPassword + ","
- + columnIp + "," + columnLastLogin + "," + lastlocX
- + "," + lastlocY + "," + lastlocZ + "," + lastlocWorld
- + "," + columnEmail + "," + columnLogged
- + ") VALUES ('" + args[0] + "', '" + args[1] + "', '"
- + args[2] + "', " + args[3] + ", " + args[4] + ", "
- + args[5] + ", " + args[6] + ", '" + args[7] + "', '"
- + args[8] + "', 0);";
+ if (args.length == 4)
+ newline = "INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + lastlocX + "," + lastlocY + "," + lastlocZ + "," + lastlocWorld + "," + columnEmail + "," + columnLogged + ") VALUES ('" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", 0.0, 0.0, 0.0, 'world', 'your@email.com', 0);";
+ else if (args.length == 7)
+ newline = "INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + lastlocX + "," + lastlocY + "," + lastlocZ + "," + lastlocWorld + "," + columnEmail + "," + columnLogged + ") VALUES ('" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", 'world', 'your@email.com', 0);";
+ else if (args.length == 8)
+ newline = "INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + lastlocX + "," + lastlocY + "," + lastlocZ + "," + lastlocWorld + "," + columnEmail + "," + columnLogged + ") VALUES ('" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", '" + args[7] + "', 'your@email.com', 0);";
+ else if (args.length == 9)
+ newline = "INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + lastlocX + "," + lastlocY + "," + lastlocZ + "," + lastlocWorld + "," + columnEmail + "," + columnLogged + ") VALUES ('" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", '" + args[7] + "', '" + args[8] + "', 0);";
else newline = "";
- if (newline != "") sql.write(newline);
+ if (newline != "")
+ sql.write(newline);
}
sql.close();
br.close();
- ConsoleLogger
- .info("The FlatFile has been converted to authme.sql file");
+ ConsoleLogger.info("The FlatFile has been converted to authme.sql file");
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
} catch (IOException ex) {
diff --git a/src/main/java/fr/xephi/authme/converter/FlatToSqlite.java b/src/main/java/fr/xephi/authme/converter/FlatToSqlite.java
index 715b4833..314896cc 100644
--- a/src/main/java/fr/xephi/authme/converter/FlatToSqlite.java
+++ b/src/main/java/fr/xephi/authme/converter/FlatToSqlite.java
@@ -56,24 +56,20 @@ public class FlatToSqlite implements Converter {
columnEmail = Settings.getMySQLColumnEmail;
columnID = Settings.getMySQLColumnId;
ConsoleLogger.info("Converting FlatFile to SQLite ...");
- if (new File(AuthMe.getInstance().getDataFolder() + File.separator
- + database + ".db").exists()) {
- sender.sendMessage("The Database " + database
- + ".db can't be created cause the file already exist");
+ if (new File(AuthMe.getInstance().getDataFolder() + File.separator + database + ".db").exists()) {
+ sender.sendMessage("The Database " + database + ".db can't be created cause the file already exist");
return;
}
try {
connect();
setup();
} catch (Exception e) {
- ConsoleLogger
- .showError("Problem while trying to convert to sqlite !");
+ ConsoleLogger.showError("Problem while trying to convert to sqlite !");
sender.sendMessage("Problem while trying to convert to sqlite !");
return;
}
try {
- source = new File(AuthMe.getInstance().getDataFolder()
- + File.separator + "auths.db");
+ source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
source.createNewFile();
BufferedReader br = new BufferedReader(new FileReader(source));
String line;
@@ -81,35 +77,23 @@ public class FlatToSqlite implements Converter {
String newline;
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
- if (args.length == 4) newline = "INSERT INTO " + tableName
- + " VALUES (" + i + ", '" + args[0] + "', '" + args[1]
- + "', '" + args[2] + "', " + args[3]
- + ", 0, 0, 0, 'world', 'your@email.com');";
- else if (args.length == 7) newline = "INSERT INTO " + tableName
- + " VALUES (" + i + ", '" + args[0] + "', '" + args[1]
- + "', '" + args[2] + "', " + args[3] + ", " + args[4]
- + ", " + args[5] + ", " + args[6]
- + ", 'world', 'your@email.com');";
- else if (args.length == 8) newline = "INSERT INTO " + tableName
- + " VALUES (" + i + ", '" + args[0] + "', '" + args[1]
- + "', '" + args[2] + "', " + args[3] + ", " + args[4]
- + ", " + args[5] + ", " + args[6] + ", '" + args[7]
- + "', 'your@email.com');";
- else if (args.length == 9) newline = "INSERT INTO " + tableName
- + " VALUES (" + i + ", '" + args[0] + "', '" + args[1]
- + "', '" + args[2] + "', " + args[3] + ", " + args[4]
- + ", " + args[5] + ", " + args[6] + ", '" + args[7]
- + "', '" + args[8] + "');";
+ if (args.length == 4)
+ newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", 0, 0, 0, 'world', 'your@email.com');";
+ else if (args.length == 7)
+ newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", 'world', 'your@email.com');";
+ else if (args.length == 8)
+ newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", '" + args[7] + "', 'your@email.com');";
+ else if (args.length == 9)
+ newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", '" + args[7] + "', '" + args[8] + "');";
else newline = "";
- if (newline != "") saveAuth(newline);
+ if (newline != "")
+ saveAuth(newline);
i = i + 1;
}
br.close();
- ConsoleLogger.info("The FlatFile has been converted to " + database
- + ".db file");
+ ConsoleLogger.info("The FlatFile has been converted to " + database + ".db file");
close();
- sender.sendMessage("The FlatFile has been converted to " + database
- + ".db file");
+ sender.sendMessage("The FlatFile has been converted to " + database + ".db file");
return;
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
@@ -124,8 +108,7 @@ public class FlatToSqlite implements Converter {
SQLException {
Class.forName("org.sqlite.JDBC");
ConsoleLogger.info("SQLite driver loaded");
- con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/"
- + database + ".db");
+ con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database + ".db");
}
private synchronized static void setup() throws SQLException {
@@ -133,63 +116,35 @@ public class FlatToSqlite implements Converter {
ResultSet rs = null;
try {
st = con.createStatement();
- st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " ("
- + columnID + " INTEGER AUTO_INCREMENT," + columnName
- + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword
- + " VARCHAR(255) NOT NULL," + columnIp
- + " VARCHAR(40) NOT NULL," + columnLastLogin + " BIGINT,"
- + lastlocX + " smallint(6) DEFAULT '0'," + lastlocY
- + " smallint(6) DEFAULT '0'," + lastlocZ
- + " smallint(6) DEFAULT '0'," + lastlocWorld
- + " VARCHAR(255) DEFAULT 'world'," + columnEmail
- + " VARCHAR(255) DEFAULT 'your@email.com',"
- + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID
- + "));");
- rs = con.getMetaData().getColumns(null, null, tableName,
- columnPassword);
+ st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " (" + columnID + " INTEGER AUTO_INCREMENT," + columnName + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword + " VARCHAR(255) NOT NULL," + columnIp + " VARCHAR(40) NOT NULL," + columnLastLogin + " BIGINT," + lastlocX + " smallint(6) DEFAULT '0'," + lastlocY + " smallint(6) DEFAULT '0'," + lastlocZ + " smallint(6) DEFAULT '0'," + lastlocWorld + " VARCHAR(255) DEFAULT 'world'," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com'," + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
+ rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + columnPassword + " VARCHAR(255) NOT NULL;");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnPassword + " VARCHAR(255) NOT NULL;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, columnIp);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + columnIp + " VARCHAR(40) NOT NULL;");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnIp + " VARCHAR(40) NOT NULL;");
}
rs.close();
- rs = con.getMetaData().getColumns(null, null, tableName,
- columnLastLogin);
+ rs = con.getMetaData().getColumns(null, null, tableName, columnLastLogin);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + columnLastLogin + " BIGINT;");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnLastLogin + " BIGINT;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + lastlocX + " smallint(6) NOT NULL DEFAULT '0'; "
- + "ALTER TABLE " + tableName + " ADD COLUMN "
- + lastlocY + " smallint(6) NOT NULL DEFAULT '0'; "
- + "ALTER TABLE " + tableName + " ADD COLUMN "
- + lastlocZ + " smallint(6) NOT NULL DEFAULT '0';");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocX + " smallint(6) NOT NULL DEFAULT '0'; " + "ALTER TABLE " + tableName + " ADD COLUMN " + lastlocY + " smallint(6) NOT NULL DEFAULT '0'; " + "ALTER TABLE " + tableName + " ADD COLUMN " + lastlocZ + " smallint(6) NOT NULL DEFAULT '0';");
}
rs.close();
- rs = con.getMetaData().getColumns(null, null, tableName,
- lastlocWorld);
+ rs = con.getMetaData().getColumns(null, null, tableName, lastlocWorld);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + lastlocWorld
- + " VARCHAR(255) NOT NULL DEFAULT 'world' AFTER "
- + lastlocZ + ";");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocWorld + " VARCHAR(255) NOT NULL DEFAULT 'world' AFTER " + lastlocZ + ";");
}
rs.close();
- rs = con.getMetaData().getColumns(null, null, tableName,
- columnEmail);
+ rs = con.getMetaData().getColumns(null, null, tableName, columnEmail);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + columnEmail
- + " VARCHAR(255) DEFAULT 'your@email.com';");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com';");
}
} finally {
close(rs);
diff --git a/src/main/java/fr/xephi/authme/converter/RakamakConverter.java b/src/main/java/fr/xephi/authme/converter/RakamakConverter.java
index f66b27ea..2d0c5a51 100644
--- a/src/main/java/fr/xephi/authme/converter/RakamakConverter.java
+++ b/src/main/java/fr/xephi/authme/converter/RakamakConverter.java
@@ -55,10 +55,8 @@ public class RakamakConverter implements Converter {
HashMap playerIP = new HashMap();
HashMap playerPSW = new HashMap();
try {
- source = new File(AuthMe.getInstance().getDataFolder()
- + File.separator + fileName);
- ipfiles = new File(AuthMe.getInstance().getDataFolder()
- + File.separator + ipFileName);
+ source = new File(AuthMe.getInstance().getDataFolder() + File.separator + fileName);
+ ipfiles = new File(AuthMe.getInstance().getDataFolder() + File.separator + ipFileName);
source.createNewFile();
ipfiles.createNewFile();
BufferedReader users = null;
@@ -80,8 +78,7 @@ public class RakamakConverter implements Converter {
if (line.contains("=")) {
String[] arguments = line.split("=");
try {
- playerPSW.put(arguments[0], PasswordSecurity.getHash(
- hash, arguments[1], arguments[0]));
+ playerPSW.put(arguments[0], PasswordSecurity.getHash(hash, arguments[1], arguments[0]));
} catch (NoSuchAlgorithmException e) {
ConsoleLogger.showError(e.getMessage());
}
@@ -97,10 +94,9 @@ public class RakamakConverter implements Converter {
} else {
ip = "127.0.0.1";
}
- PlayerAuth auth = new PlayerAuth(player, psw, ip,
- System.currentTimeMillis());
- if (PasswordSecurity.userSalt.containsKey(player)) auth
- .setSalt(PasswordSecurity.userSalt.get(player));
+ PlayerAuth auth = new PlayerAuth(player, psw, ip, System.currentTimeMillis());
+ if (PasswordSecurity.userSalt.containsKey(player))
+ auth.setSalt(PasswordSecurity.userSalt.get(player));
database.saveAuth(auth);
}
ConsoleLogger.info("Rakamak database has been imported correctly");
diff --git a/src/main/java/fr/xephi/authme/converter/RoyalAuthConverter.java b/src/main/java/fr/xephi/authme/converter/RoyalAuthConverter.java
index 6d5ed7ad..5ad9b985 100644
--- a/src/main/java/fr/xephi/authme/converter/RoyalAuthConverter.java
+++ b/src/main/java/fr/xephi/authme/converter/RoyalAuthConverter.java
@@ -25,19 +25,16 @@ public class RoyalAuthConverter implements Converter {
try {
String name = o.getName().toLowerCase();
String separator = File.separator;
- File file = new File("." + separator + "plugins" + separator
- + "RoyalAuth" + separator + "userdata" + separator
- + name + ".yml");
- if (data.isAuthAvailable(name)) continue;
- if (!file.exists()) continue;
+ File file = new File("." + separator + "plugins" + separator + "RoyalAuth" + separator + "userdata" + separator + name + ".yml");
+ if (data.isAuthAvailable(name))
+ continue;
+ if (!file.exists())
+ continue;
RoyalAuthYamlReader ra = new RoyalAuthYamlReader(file);
- PlayerAuth auth = new PlayerAuth(name, ra.getHash(),
- "127.0.0.1", ra.getLastLogin(), "your@email.com",
- o.getName());
+ PlayerAuth auth = new PlayerAuth(name, ra.getHash(), "127.0.0.1", ra.getLastLogin(), "your@email.com", o.getName());
data.saveAuth(auth);
} catch (Exception e) {
- ConsoleLogger.showError("Error while trying to import "
- + o.getName() + " RoyalAuth datas");
+ ConsoleLogger.showError("Error while trying to import " + o.getName() + " RoyalAuth datas");
}
}
}
diff --git a/src/main/java/fr/xephi/authme/converter/newxAuthToFlat.java b/src/main/java/fr/xephi/authme/converter/newxAuthToFlat.java
index e159deb9..eda99aa4 100644
--- a/src/main/java/fr/xephi/authme/converter/newxAuthToFlat.java
+++ b/src/main/java/fr/xephi/authme/converter/newxAuthToFlat.java
@@ -37,7 +37,7 @@ public class newxAuthToFlat {
sender.sendMessage("[AuthMe] xAuth plugin not found");
return false;
}
- if (!(new File("./plugins/xAuth/xAuth.h2.db").exists())) {
+ if (!(new File(instance.getDataFolder().getParent() + File.separator + "xAuth" + File.separator + "xAuth.h2.db").exists())) {
sender.sendMessage("[AuthMe] xAuth H2 database not found, checking for MySQL or SQLite data...");
}
List players = getXAuthPlayers();
@@ -51,8 +51,7 @@ public class newxAuthToFlat {
String pl = getIdPlayer(id);
String psw = getPassword(id);
if (psw != null && !psw.isEmpty() && pl != null) {
- PlayerAuth auth = new PlayerAuth(pl, psw, "198.18.0.1", 0,
- "your@email.com", API.getPlayerRealName(pl));
+ PlayerAuth auth = new PlayerAuth(pl, psw, "198.18.0.1", 0, "your@email.com", API.getPlayerRealName(pl));
database.saveAuth(auth);
}
}
@@ -65,19 +64,16 @@ public class newxAuthToFlat {
public String getIdPlayer(int id) {
String realPass = "";
- Connection conn = xAuth.getPlugin().getDatabaseController()
- .getConnection();
+ Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
try {
- String sql = String.format(
- "SELECT `playername` FROM `%s` WHERE `id` = ?",
- xAuth.getPlugin().getDatabaseController()
- .getTable(Table.ACCOUNT));
+ String sql = String.format("SELECT `playername` FROM `%s` WHERE `id` = ?", xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT));
ps = conn.prepareStatement(sql);
ps.setInt(1, id);
rs = ps.executeQuery();
- if (!rs.next()) return null;
+ if (!rs.next())
+ return null;
realPass = rs.getString("playername").toLowerCase();
} catch (SQLException e) {
xAuthLog.severe("Failed to retrieve name for account: " + id, e);
@@ -90,13 +86,11 @@ public class newxAuthToFlat {
public List getXAuthPlayers() {
List xP = new ArrayList();
- Connection conn = xAuth.getPlugin().getDatabaseController()
- .getConnection();
+ Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
try {
- String sql = String.format("SELECT * FROM `%s`", xAuth.getPlugin()
- .getDatabaseController().getTable(Table.ACCOUNT));
+ String sql = String.format("SELECT * FROM `%s`", xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT));
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
while (rs.next()) {
@@ -113,23 +107,19 @@ public class newxAuthToFlat {
public String getPassword(int accountId) {
String realPass = "";
- Connection conn = xAuth.getPlugin().getDatabaseController()
- .getConnection();
+ Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
try {
- String sql = String.format(
- "SELECT `password`, `pwtype` FROM `%s` WHERE `id` = ?",
- xAuth.getPlugin().getDatabaseController()
- .getTable(Table.ACCOUNT));
+ String sql = String.format("SELECT `password`, `pwtype` FROM `%s` WHERE `id` = ?", xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT));
ps = conn.prepareStatement(sql);
ps.setInt(1, accountId);
rs = ps.executeQuery();
- if (!rs.next()) return null;
+ if (!rs.next())
+ return null;
realPass = rs.getString("password");
} catch (SQLException e) {
- xAuthLog.severe("Failed to retrieve password hash for account: "
- + accountId, e);
+ xAuthLog.severe("Failed to retrieve password hash for account: " + accountId, e);
return null;
} finally {
xAuth.getPlugin().getDatabaseController().close(conn, ps, rs);
diff --git a/src/main/java/fr/xephi/authme/converter/oldxAuthToFlat.java b/src/main/java/fr/xephi/authme/converter/oldxAuthToFlat.java
index bbaa13ee..4eda6a8f 100644
--- a/src/main/java/fr/xephi/authme/converter/oldxAuthToFlat.java
+++ b/src/main/java/fr/xephi/authme/converter/oldxAuthToFlat.java
@@ -41,7 +41,7 @@ public class oldxAuthToFlat {
sender.sendMessage("[AuthMe] xAuth plugin not found");
return false;
}
- if (!(new File("./plugins/xAuth/xAuth.h2.db").exists())) {
+ if (!(new File(instance.getDataFolder().getParent() + File.separator + "xAuth" + File.separator + "xAuth.h2.db").exists())) {
sender.sendMessage("[AuthMe] xAuth H2 database not found, checking for MySQL or SQLite data...");
}
List players = getXAuthPlayers();
@@ -55,8 +55,7 @@ public class oldxAuthToFlat {
String pl = getIdPlayer(id);
String psw = getPassword(id);
if (psw != null && !psw.isEmpty() && pl != null) {
- PlayerAuth auth = new PlayerAuth(pl, psw, "198.18.0.1", 0,
- "your@email.com", API.getPlayerRealName(pl));
+ PlayerAuth auth = new PlayerAuth(pl, psw, "198.18.0.1", 0, "your@email.com", API.getPlayerRealName(pl));
database.saveAuth(auth);
}
}
@@ -69,19 +68,16 @@ public class oldxAuthToFlat {
public String getIdPlayer(int id) {
String realPass = "";
- Connection conn = xAuth.getPlugin().getDatabaseController()
- .getConnection();
+ Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
try {
- String sql = String.format(
- "SELECT `playername` FROM `%s` WHERE `id` = ?",
- xAuth.getPlugin().getDatabaseController()
- .getTable(Table.ACCOUNT));
+ String sql = String.format("SELECT `playername` FROM `%s` WHERE `id` = ?", xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT));
ps = conn.prepareStatement(sql);
ps.setInt(1, id);
rs = ps.executeQuery();
- if (!rs.next()) return null;
+ if (!rs.next())
+ return null;
realPass = rs.getString("playername").toLowerCase();
} catch (SQLException e) {
xAuthLog.severe("Failed to retrieve name for account: " + id, e);
@@ -94,13 +90,11 @@ public class oldxAuthToFlat {
public List getXAuthPlayers() {
List xP = new ArrayList();
- Connection conn = xAuth.getPlugin().getDatabaseController()
- .getConnection();
+ Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
try {
- String sql = String.format("SELECT * FROM `%s`", xAuth.getPlugin()
- .getDatabaseController().getTable(Table.ACCOUNT));
+ String sql = String.format("SELECT * FROM `%s`", xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT));
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
while (rs.next()) {
@@ -117,23 +111,19 @@ public class oldxAuthToFlat {
public String getPassword(int accountId) {
String realPass = "";
- Connection conn = xAuth.getPlugin().getDatabaseController()
- .getConnection();
+ Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
try {
- String sql = String.format(
- "SELECT `password`, `pwtype` FROM `%s` WHERE `id` = ?",
- xAuth.getPlugin().getDatabaseController()
- .getTable(Table.ACCOUNT));
+ String sql = String.format("SELECT `password`, `pwtype` FROM `%s` WHERE `id` = ?", xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT));
ps = conn.prepareStatement(sql);
ps.setInt(1, accountId);
rs = ps.executeQuery();
- if (!rs.next()) return null;
+ if (!rs.next())
+ return null;
realPass = rs.getString("password");
} catch (SQLException e) {
- xAuthLog.severe("Failed to retrieve password hash for account: "
- + accountId, e);
+ xAuthLog.severe("Failed to retrieve password hash for account: " + accountId, e);
return null;
} finally {
xAuth.getPlugin().getDatabaseController().close(conn, ps, rs);
diff --git a/src/main/java/fr/xephi/authme/converter/vAuthFileReader.java b/src/main/java/fr/xephi/authme/converter/vAuthFileReader.java
index fb39e2d2..35d55663 100644
--- a/src/main/java/fr/xephi/authme/converter/vAuthFileReader.java
+++ b/src/main/java/fr/xephi/authme/converter/vAuthFileReader.java
@@ -28,8 +28,7 @@ public class vAuthFileReader {
}
public void convert() throws IOException {
- final File file = new File(plugin.getDataFolder().getParent()
- + "/vAuth/passwords.yml");
+ final File file = new File(plugin.getDataFolder().getParent() + "" + File.separator + "vAuth" + File.separator + "passwords.yml");
Scanner scanner = null;
try {
scanner = new Scanner(file);
@@ -41,23 +40,20 @@ public class vAuthFileReader {
if (isUUIDinstance(password)) {
String pname = null;
try {
- pname = Bukkit.getOfflinePlayer(UUID.fromString(name))
- .getName();
+ pname = Bukkit.getOfflinePlayer(UUID.fromString(name)).getName();
} catch (Exception e) {
pname = getName(UUID.fromString(name));
} catch (NoSuchMethodError e) {
pname = getName(UUID.fromString(name));
}
- if (pname == null) continue;
- auth = new PlayerAuth(pname.toLowerCase(), password,
- "127.0.0.1", System.currentTimeMillis(),
- "your@email.com", pname);
+ if (pname == null)
+ continue;
+ auth = new PlayerAuth(pname.toLowerCase(), password, "127.0.0.1", System.currentTimeMillis(), "your@email.com", pname);
} else {
- auth = new PlayerAuth(name, password, "127.0.0.1",
- System.currentTimeMillis(), "your@email.com",
- API.getPlayerRealName(name));
+ auth = new PlayerAuth(name, password, "127.0.0.1", System.currentTimeMillis(), "your@email.com", API.getPlayerRealName(name));
}
- if (auth != null) database.saveAuth(auth);
+ if (auth != null)
+ database.saveAuth(auth);
}
} catch (Exception e) {
}
@@ -65,14 +61,16 @@ public class vAuthFileReader {
}
private boolean isUUIDinstance(String s) {
- if (String.valueOf(s.charAt(8)).equalsIgnoreCase("-")) return true;
+ if (String.valueOf(s.charAt(8)).equalsIgnoreCase("-"))
+ return true;
return true;
}
private String getName(UUID uuid) {
try {
for (OfflinePlayer op : Bukkit.getOfflinePlayers()) {
- if (op.getUniqueId().compareTo(uuid) == 0) return op.getName();
+ if (op.getUniqueId().compareTo(uuid) == 0)
+ return op.getName();
}
} catch (Exception e) {
}
diff --git a/src/main/java/fr/xephi/authme/converter/xAuthConverter.java b/src/main/java/fr/xephi/authme/converter/xAuthConverter.java
index 254a1aac..cdb8e764 100644
--- a/src/main/java/fr/xephi/authme/converter/xAuthConverter.java
+++ b/src/main/java/fr/xephi/authme/converter/xAuthConverter.java
@@ -22,14 +22,12 @@ public class xAuthConverter implements Converter {
public void run() {
try {
Class.forName("com.cypherx.xauth.xAuth");
- oldxAuthToFlat converter = new oldxAuthToFlat(plugin, database,
- sender);
+ oldxAuthToFlat converter = new oldxAuthToFlat(plugin, database, sender);
converter.convert();
} catch (ClassNotFoundException e) {
try {
Class.forName("de.luricos.bukkit.xAuth.xAuth");
- newxAuthToFlat converter = new newxAuthToFlat(plugin, database,
- sender);
+ newxAuthToFlat converter = new newxAuthToFlat(plugin, database, sender);
converter.convert();
} catch (ClassNotFoundException ce) {
sender.sendMessage("xAuth has not been found, please put xAuth.jar in your plugin folder and restart!");
diff --git a/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java b/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java
index 958ea8f7..8b0e6852 100644
--- a/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java
+++ b/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java
@@ -22,7 +22,8 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized boolean isAuthAvailable(String user) {
- if (cache.containsKey(user.toLowerCase())) return true;
+ if (cache.containsKey(user.toLowerCase()))
+ return true;
return source.isAuthAvailable(user.toLowerCase());
}
@@ -32,7 +33,8 @@ public class CacheDataSource implements DataSource {
return cache.get(user.toLowerCase());
} else {
PlayerAuth auth = source.getAuth(user.toLowerCase());
- if (auth != null) cache.put(user.toLowerCase(), auth);
+ if (auth != null)
+ cache.put(user.toLowerCase(), auth);
return auth;
}
}
@@ -49,8 +51,8 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized boolean updatePassword(PlayerAuth auth) {
if (source.updatePassword(auth)) {
- if (cache.containsKey(auth.getNickname().toLowerCase())) cache.get(
- auth.getNickname()).setHash(auth.getHash());
+ if (cache.containsKey(auth.getNickname().toLowerCase()))
+ cache.get(auth.getNickname()).setHash(auth.getHash());
return true;
}
return false;
@@ -147,8 +149,8 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized boolean updateEmail(PlayerAuth auth) {
if (source.updateEmail(auth)) {
- if (cache.containsKey(auth.getNickname().toLowerCase())) cache.get(
- auth.getNickname()).setEmail(auth.getEmail());
+ if (cache.containsKey(auth.getNickname().toLowerCase()))
+ cache.get(auth.getNickname()).setEmail(auth.getEmail());
return true;
}
return false;
@@ -157,8 +159,8 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized boolean updateSalt(PlayerAuth auth) {
if (source.updateSalt(auth)) {
- if (cache.containsKey(auth.getNickname().toLowerCase())) cache.get(
- auth.getNickname()).setSalt(auth.getSalt());
+ if (cache.containsKey(auth.getNickname().toLowerCase()))
+ cache.get(auth.getNickname()).setSalt(auth.getSalt());
return true;
}
return false;
diff --git a/src/main/java/fr/xephi/authme/datasource/DataSource.java b/src/main/java/fr/xephi/authme/datasource/DataSource.java
index 55a89ca0..df9c993c 100644
--- a/src/main/java/fr/xephi/authme/datasource/DataSource.java
+++ b/src/main/java/fr/xephi/authme/datasource/DataSource.java
@@ -8,7 +8,9 @@ public interface DataSource {
public enum DataSourceType {
- MYSQL, FILE, SQLITE
+ MYSQL,
+ FILE,
+ SQLITE
}
boolean isAuthAvailable(String user);
diff --git a/src/main/java/fr/xephi/authme/datasource/FlatFileThread.java b/src/main/java/fr/xephi/authme/datasource/FlatFileThread.java
index 2bf0923b..f27d9d63 100644
--- a/src/main/java/fr/xephi/authme/datasource/FlatFileThread.java
+++ b/src/main/java/fr/xephi/authme/datasource/FlatFileThread.java
@@ -42,8 +42,8 @@ public class FlatFileThread extends Thread implements DataSource {
ConsoleLogger.showError("Can't use FLAT FILE... SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
- if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
- .getPluginManager().disablePlugin(AuthMe.getInstance());
+ if (!Settings.isStopEnabled)
+ AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
}
}
@@ -85,11 +85,7 @@ public class FlatFileThread extends Thread implements DataSource {
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter(source, true));
- bw.write(auth.getNickname() + ":" + auth.getHash() + ":"
- + auth.getIp() + ":" + auth.getLastLogin() + ":"
- + auth.getQuitLocX() + ":" + auth.getQuitLocY() + ":"
- + auth.getQuitLocZ() + ":" + auth.getWorld() + ":"
- + auth.getEmail() + "\n");
+ bw.write(auth.getNickname() + ":" + auth.getHash() + ":" + auth.getIp() + ":" + auth.getLastLogin() + ":" + auth.getQuitLocX() + ":" + auth.getQuitLocY() + ":" + auth.getQuitLocZ() + ":" + auth.getWorld() + ":" + auth.getEmail() + "\n");
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
@@ -119,46 +115,23 @@ public class FlatFileThread extends Thread implements DataSource {
if (args[0].equals(auth.getNickname())) {
switch (args.length) {
case 4: {
- newAuth = new PlayerAuth(args[0], auth.getHash(),
- args[2], Long.parseLong(args[3]), 0, 0, 0,
- "world", "your@email.com",
- API.getPlayerRealName(args[0]));
+ newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), 0, 0, 0, "world", "your@email.com", API.getPlayerRealName(args[0]));
break;
}
case 7: {
- newAuth = new PlayerAuth(args[0], auth.getHash(),
- args[2], Long.parseLong(args[3]),
- Double.parseDouble(args[4]),
- Double.parseDouble(args[5]),
- Double.parseDouble(args[6]), "world",
- "your@email.com",
- API.getPlayerRealName(args[0]));
+ newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), "world", "your@email.com", API.getPlayerRealName(args[0]));
break;
}
case 8: {
- newAuth = new PlayerAuth(args[0], auth.getHash(),
- args[2], Long.parseLong(args[3]),
- Double.parseDouble(args[4]),
- Double.parseDouble(args[5]),
- Double.parseDouble(args[6]), args[7],
- "your@email.com",
- API.getPlayerRealName(args[0]));
+ newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], "your@email.com", API.getPlayerRealName(args[0]));
break;
}
case 9: {
- newAuth = new PlayerAuth(args[0], auth.getHash(),
- args[2], Long.parseLong(args[3]),
- Double.parseDouble(args[4]),
- Double.parseDouble(args[5]),
- Double.parseDouble(args[6]), args[7],
- args[8], API.getPlayerRealName(args[0]));
+ newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], args[8], API.getPlayerRealName(args[0]));
break;
}
default: {
- newAuth = new PlayerAuth(args[0], auth.getHash(),
- args[2], 0, 0, 0, 0, "world",
- "your@email.com",
- API.getPlayerRealName(args[0]));
+ newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], 0, 0, 0, 0, "world", "your@email.com", API.getPlayerRealName(args[0]));
break;
}
}
@@ -199,46 +172,23 @@ public class FlatFileThread extends Thread implements DataSource {
if (args[0].equals(auth.getNickname())) {
switch (args.length) {
case 4: {
- newAuth = new PlayerAuth(args[0], args[1],
- auth.getIp(), auth.getLastLogin(), 0, 0, 0,
- "world", "your@email.com",
- API.getPlayerRealName(args[0]));
+ newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world", "your@email.com", API.getPlayerRealName(args[0]));
break;
}
case 7: {
- newAuth = new PlayerAuth(args[0], args[1],
- auth.getIp(), auth.getLastLogin(),
- Double.parseDouble(args[4]),
- Double.parseDouble(args[5]),
- Double.parseDouble(args[6]), "world",
- "your@email.com",
- API.getPlayerRealName(args[0]));
+ newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), "world", "your@email.com", API.getPlayerRealName(args[0]));
break;
}
case 8: {
- newAuth = new PlayerAuth(args[0], args[1],
- auth.getIp(), auth.getLastLogin(),
- Double.parseDouble(args[4]),
- Double.parseDouble(args[5]),
- Double.parseDouble(args[6]), args[7],
- "your@email.com",
- API.getPlayerRealName(args[0]));
+ newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], "your@email.com", API.getPlayerRealName(args[0]));
break;
}
case 9: {
- newAuth = new PlayerAuth(args[0], args[1],
- auth.getIp(), auth.getLastLogin(),
- Double.parseDouble(args[4]),
- Double.parseDouble(args[5]),
- Double.parseDouble(args[6]), args[7],
- args[8], API.getPlayerRealName(args[0]));
+ newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], args[8], API.getPlayerRealName(args[0]));
break;
}
default: {
- newAuth = new PlayerAuth(args[0], args[1],
- auth.getIp(), auth.getLastLogin(), 0, 0, 0,
- "world", "your@email.com",
- API.getPlayerRealName(args[0]));
+ newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world", "your@email.com", API.getPlayerRealName(args[0]));
break;
}
}
@@ -277,11 +227,7 @@ public class FlatFileThread extends Thread implements DataSource {
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
if (args[0].equals(auth.getNickname())) {
- newAuth = new PlayerAuth(args[0], args[1], args[2],
- Long.parseLong(args[3]), auth.getQuitLocX(),
- auth.getQuitLocY(), auth.getQuitLocZ(),
- auth.getWorld(), auth.getEmail(),
- API.getPlayerRealName(args[0]));
+ newAuth = new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), auth.getEmail(), API.getPlayerRealName(args[0]));
break;
}
}
@@ -481,40 +427,17 @@ public class FlatFileThread extends Thread implements DataSource {
if (args[0].equals(user)) {
switch (args.length) {
case 2:
- return new PlayerAuth(args[0], args[1],
- "198.18.0.1", 0, "your@email.com",
- API.getPlayerRealName(args[0]));
+ return new PlayerAuth(args[0], args[1], "198.18.0.1", 0, "your@email.com", API.getPlayerRealName(args[0]));
case 3:
- return new PlayerAuth(args[0], args[1], args[2], 0,
- "your@email.com",
- API.getPlayerRealName(args[0]));
+ return new PlayerAuth(args[0], args[1], args[2], 0, "your@email.com", API.getPlayerRealName(args[0]));
case 4:
- return new PlayerAuth(args[0], args[1], args[2],
- Long.parseLong(args[3]), "your@email.com",
- API.getPlayerRealName(args[0]));
+ return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), "your@email.com", API.getPlayerRealName(args[0]));
case 7:
- return new PlayerAuth(args[0], args[1], args[2],
- Long.parseLong(args[3]),
- Double.parseDouble(args[4]),
- Double.parseDouble(args[5]),
- Double.parseDouble(args[6]),
- "unavailableworld", "your@email.com",
- API.getPlayerRealName(args[0]));
+ return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), "unavailableworld", "your@email.com", API.getPlayerRealName(args[0]));
case 8:
- return new PlayerAuth(args[0], args[1], args[2],
- Long.parseLong(args[3]),
- Double.parseDouble(args[4]),
- Double.parseDouble(args[5]),
- Double.parseDouble(args[6]), args[7],
- "your@email.com",
- API.getPlayerRealName(args[0]));
+ return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], "your@email.com", API.getPlayerRealName(args[0]));
case 9:
- return new PlayerAuth(args[0], args[1], args[2],
- Long.parseLong(args[3]),
- Double.parseDouble(args[4]),
- Double.parseDouble(args[5]),
- Double.parseDouble(args[6]), args[7],
- args[8], API.getPlayerRealName(args[0]));
+ return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], args[8], API.getPlayerRealName(args[0]));
}
}
}
@@ -556,12 +479,7 @@ public class FlatFileThread extends Thread implements DataSource {
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
if (args[0].equals(auth.getNickname())) {
- newAuth = new PlayerAuth(args[0], args[1], args[2],
- Long.parseLong(args[3]),
- Double.parseDouble(args[4]),
- Double.parseDouble(args[5]),
- Double.parseDouble(args[6]), args[7],
- auth.getEmail(), API.getPlayerRealName(args[0]));
+ newAuth = new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Double.parseDouble(args[4]), Double.parseDouble(args[5]), Double.parseDouble(args[6]), args[7], auth.getEmail(), API.getPlayerRealName(args[0]));
break;
}
}
diff --git a/src/main/java/fr/xephi/authme/datasource/MiniConnectionPoolManager.java b/src/main/java/fr/xephi/authme/datasource/MiniConnectionPoolManager.java
index 812e6725..5a557f19 100644
--- a/src/main/java/fr/xephi/authme/datasource/MiniConnectionPoolManager.java
+++ b/src/main/java/fr/xephi/authme/datasource/MiniConnectionPoolManager.java
@@ -69,6 +69,7 @@ public class MiniConnectionPoolManager {
* no free connection becomes available within timeout seconds.
*/
public static class TimeoutException extends RuntimeException {
+
private static final long serialVersionUID = 1;
public TimeoutException() {
@@ -168,8 +169,7 @@ public class MiniConnectionPoolManager {
// block.
synchronized (this) {
if (isDisposed) {
- throw new IllegalStateException(
- "Connection pool has been disposed.");
+ throw new IllegalStateException("Connection pool has been disposed.");
}
}
try {
@@ -177,8 +177,7 @@ public class MiniConnectionPoolManager {
throw new TimeoutException();
}
} catch (InterruptedException e) {
- throw new RuntimeException(
- "Interrupted while waiting for a database connection.", e);
+ throw new RuntimeException("Interrupted while waiting for a database connection.", e);
}
boolean ok = false;
try {
@@ -194,8 +193,7 @@ public class MiniConnectionPoolManager {
private synchronized Connection getConnection3() throws SQLException {
if (isDisposed) {
- throw new IllegalStateException(
- "Connection pool has been disposed.");
+ throw new IllegalStateException("Connection pool has been disposed.");
}
PooledConnection pconn;
if (!recycledConnections.isEmpty()) {
@@ -260,15 +258,12 @@ public class MiniConnectionPoolManager {
try {
Thread.sleep(250);
} catch (InterruptedException e) {
- throw new RuntimeException(
- "Interrupted while waiting for a valid database connection.",
- e);
+ throw new RuntimeException("Interrupted while waiting for a valid database connection.", e);
}
}
time = System.currentTimeMillis();
if (time >= timeoutTime) {
- throw new TimeoutException(
- "Timeout while waiting for a valid database connection.");
+ throw new TimeoutException("Timeout while waiting for a valid database connection.");
}
}
}
@@ -340,8 +335,7 @@ public class MiniConnectionPoolManager {
private synchronized void disposeConnection(PooledConnection pconn) {
pconn.removeConnectionEventListener(poolConnectionEventListener);
- if (!recycledConnections.remove(pconn)
- && pconn != connectionInTransition) {
+ if (!recycledConnections.remove(pconn) && pconn != connectionInTransition) {
// If the PooledConnection is not in the recycledConnections list
// and is not currently within a PooledConnection.getConnection()
// call,
@@ -390,6 +384,7 @@ public class MiniConnectionPoolManager {
private class PoolConnectionEventListener implements
ConnectionEventListener {
+
public void connectionClosed(ConnectionEvent event) {
PooledConnection pconn = (PooledConnection) event.getSource();
recycleConnection(pconn);
diff --git a/src/main/java/fr/xephi/authme/datasource/MySQLThread.java b/src/main/java/fr/xephi/authme/datasource/MySQLThread.java
index d87b61d8..839f0426 100644
--- a/src/main/java/fr/xephi/authme/datasource/MySQLThread.java
+++ b/src/main/java/fr/xephi/authme/datasource/MySQLThread.java
@@ -70,32 +70,29 @@ public class MySQLThread extends Thread implements DataSource {
} catch (ClassNotFoundException e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
- ConsoleLogger
- .showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
+ ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
- if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
- .getPluginManager().disablePlugin(AuthMe.getInstance());
+ if (!Settings.isStopEnabled)
+ AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
} catch (SQLException e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
- ConsoleLogger
- .showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
+ ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
- if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
- .getPluginManager().disablePlugin(AuthMe.getInstance());
+ if (!Settings.isStopEnabled)
+ AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
} catch (TimeoutException e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
- ConsoleLogger
- .showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
+ ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
- if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
- .getPluginManager().disablePlugin(AuthMe.getInstance());
+ if (!Settings.isStopEnabled)
+ AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
}
}
@@ -121,85 +118,45 @@ public class MySQLThread extends Thread implements DataSource {
try {
con = makeSureConnectionIsReady();
st = con.createStatement();
- st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " ("
- + columnID + " INTEGER AUTO_INCREMENT," + columnName
- + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword
- + " VARCHAR(255) NOT NULL," + columnIp
- + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1',"
- + columnLastLogin + " BIGINT NOT NULL DEFAULT '"
- + System.currentTimeMillis() + "'," + lastlocX
- + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY
- + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ
- + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld
- + " VARCHAR(255) DEFAULT 'world'," + columnEmail
- + " VARCHAR(255) DEFAULT 'your@email.com'," + columnLogged
- + " SMALLINT NOT NULL DEFAULT '0',"
- + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID
- + "));");
- rs = con.getMetaData().getColumns(null, null, tableName,
- columnPassword);
+ st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " (" + columnID + " INTEGER AUTO_INCREMENT," + columnName + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword + " VARCHAR(255) NOT NULL," + columnIp + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1'," + columnLastLogin + " BIGINT NOT NULL DEFAULT '" + System.currentTimeMillis() + "'," + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld + " VARCHAR(255) DEFAULT 'world'," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com'," + columnLogged + " SMALLINT NOT NULL DEFAULT '0'," + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
+ rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + columnPassword + " VARCHAR(255) NOT NULL;");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnPassword + " VARCHAR(255) NOT NULL;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, columnIp);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + columnIp + " VARCHAR(40) NOT NULL;");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnIp + " VARCHAR(40) NOT NULL;");
}
rs.close();
- rs = con.getMetaData().getColumns(null, null, tableName,
- columnLastLogin);
+ rs = con.getMetaData().getColumns(null, null, tableName, columnLastLogin);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + columnLastLogin + " BIGINT;");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnLastLogin + " BIGINT;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0' AFTER "
- + columnLastLogin + " , ADD " + lastlocY
- + " DOUBLE NOT NULL DEFAULT '0.0' AFTER " + lastlocX
- + " , ADD " + lastlocZ
- + " DOUBLE NOT NULL DEFAULT '0.0' AFTER " + lastlocY
- + ";");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0' AFTER " + columnLastLogin + " , ADD " + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0' AFTER " + lastlocX + " , ADD " + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0' AFTER " + lastlocY + ";");
}
rs.close();
- rs = con.getMetaData().getColumns(null, null, tableName,
- lastlocWorld);
+ rs = con.getMetaData().getColumns(null, null, tableName, lastlocWorld);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + lastlocWorld
- + " VARCHAR(255) NOT NULL DEFAULT 'world' AFTER "
- + lastlocZ + ";");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocWorld + " VARCHAR(255) NOT NULL DEFAULT 'world' AFTER " + lastlocZ + ";");
}
rs.close();
- rs = con.getMetaData().getColumns(null, null, tableName,
- columnEmail);
+ rs = con.getMetaData().getColumns(null, null, tableName, columnEmail);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + columnEmail
- + " VARCHAR(255) DEFAULT 'your@email.com' AFTER "
- + lastlocWorld + ";");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com' AFTER " + lastlocWorld + ";");
}
rs.close();
- rs = con.getMetaData().getColumns(null, null, tableName,
- columnLogged);
+ rs = con.getMetaData().getColumns(null, null, tableName, columnLogged);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + columnLogged
- + " SMALLINT NOT NULL DEFAULT '0' AFTER " + columnEmail
- + ";");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnLogged + " SMALLINT NOT NULL DEFAULT '0' AFTER " + columnEmail + ";");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
if (rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " MODIFY "
- + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0', MODIFY "
- + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0', MODIFY "
- + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0';");
+ st.executeUpdate("ALTER TABLE " + tableName + " MODIFY " + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0', MODIFY " + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0', MODIFY " + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0';");
}
} finally {
close(rs);
@@ -215,8 +172,7 @@ public class MySQLThread extends Thread implements DataSource {
ResultSet rs = null;
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
- + columnName + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
rs = pst.executeQuery();
@@ -243,61 +199,25 @@ public class MySQLThread extends Thread implements DataSource {
int id = -1;
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
- + columnName + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
- if (rs.getString(columnIp).isEmpty()
- && rs.getString(columnIp) != null) {
- pAuth = new PlayerAuth(rs.getString(columnName),
- rs.getString(columnPassword), "198.18.0.1",
- rs.getLong(columnLastLogin),
- rs.getDouble(lastlocX), rs.getDouble(lastlocY),
- rs.getDouble(lastlocZ), rs.getString(lastlocWorld),
- rs.getString(columnEmail), API.getPlayerRealName(rs
- .getString(columnName)));
+ if (rs.getString(columnIp).isEmpty() && rs.getString(columnIp) != null) {
+ pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "198.18.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
} else {
if (!columnSalt.isEmpty()) {
- if (!columnGroup.isEmpty()) pAuth = new PlayerAuth(
- rs.getString(columnName),
- rs.getString(columnPassword),
- rs.getString(columnSalt),
- rs.getInt(columnGroup), rs.getString(columnIp),
- rs.getLong(columnLastLogin),
- rs.getDouble(lastlocX), rs.getDouble(lastlocY),
- rs.getDouble(lastlocZ),
- rs.getString(lastlocWorld),
- rs.getString(columnEmail),
- API.getPlayerRealName(rs.getString(columnName)));
- else pAuth = new PlayerAuth(rs.getString(columnName),
- rs.getString(columnPassword),
- rs.getString(columnSalt),
- rs.getString(columnIp),
- rs.getLong(columnLastLogin),
- rs.getDouble(lastlocX), rs.getDouble(lastlocY),
- rs.getDouble(lastlocZ),
- rs.getString(lastlocWorld),
- rs.getString(columnEmail),
- API.getPlayerRealName(rs.getString(columnName)));
+ if (!columnGroup.isEmpty())
+ pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
+ else pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
} else {
- pAuth = new PlayerAuth(rs.getString(columnName),
- rs.getString(columnPassword),
- rs.getString(columnIp),
- rs.getLong(columnLastLogin),
- rs.getDouble(lastlocX), rs.getDouble(lastlocY),
- rs.getDouble(lastlocZ),
- rs.getString(lastlocWorld),
- rs.getString(columnEmail),
- API.getPlayerRealName(rs.getString(columnName)));
+ pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
}
}
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
rs.close();
- pst = con
- .prepareStatement("SELECT * FROM xf_user_authenticate WHERE "
- + columnID + "=?;");
+ pst = con.prepareStatement("SELECT * FROM xf_user_authenticate WHERE " + columnID + "=?;");
pst.setInt(1, id);
rs = pst.executeQuery();
if (rs.next()) {
@@ -329,21 +249,15 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
- if ((columnSalt == null || columnSalt.isEmpty())
- || (auth.getSalt() == null || auth.getSalt().isEmpty())) {
- pst = con.prepareStatement("INSERT INTO " + tableName + "("
- + columnName + "," + columnPassword + "," + columnIp
- + "," + columnLastLogin + ") VALUES (?,?,?,?);");
+ if ((columnSalt == null || columnSalt.isEmpty()) || (auth.getSalt() == null || auth.getSalt().isEmpty())) {
+ pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + ") VALUES (?,?,?,?);");
pst.setString(1, auth.getNickname());
pst.setString(2, auth.getHash());
pst.setString(3, auth.getIp());
pst.setLong(4, auth.getLastLogin());
pst.executeUpdate();
} else {
- pst = con.prepareStatement("INSERT INTO " + tableName + "("
- + columnName + "," + columnPassword + "," + columnIp
- + "," + columnLastLogin + "," + columnSalt
- + ") VALUES (?,?,?,?,?);");
+ pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnSalt + ") VALUES (?,?,?,?,?);");
pst.setString(1, auth.getNickname());
pst.setString(2, auth.getHash());
pst.setString(3, auth.getIp());
@@ -353,8 +267,7 @@ public class MySQLThread extends Thread implements DataSource {
}
if (!columnOthers.isEmpty()) {
for (String column : columnOthers) {
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + column + "=? WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + column + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getRealname());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
@@ -363,42 +276,32 @@ public class MySQLThread extends Thread implements DataSource {
if (Settings.getPasswordHash == HashAlgorithm.PHPBB) {
int id;
ResultSet rs = null;
- pst = con.prepareStatement("SELECT * FROM " + tableName
- + " WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, auth.getNickname());
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
// Insert player in phpbb_user_group
- pst = con
- .prepareStatement("INSERT INTO "
- + Settings.getPhpbbPrefix
- + "user_group (group_id, user_id, group_leader, user_pending) VALUES (?,?,?,?);");
+ pst = con.prepareStatement("INSERT INTO " + Settings.getPhpbbPrefix + "user_group (group_id, user_id, group_leader, user_pending) VALUES (?,?,?,?);");
pst.setInt(1, Settings.getPhpbbGroup);
pst.setInt(2, id);
pst.setInt(3, 0);
pst.setInt(4, 0);
pst.executeUpdate();
// Update player group in phpbb_users
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + tableName + ".group_id=? WHERE " + columnName
- + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + tableName + ".group_id=? WHERE " + columnName + "=?;");
pst.setInt(1, Settings.getPhpbbGroup);
pst.setString(2, auth.getNickname());
pst.executeUpdate();
// Get current time without ms
long time = System.currentTimeMillis() / 1000;
// Update user_regdate
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + tableName + ".user_regdate=? WHERE " + columnName
- + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + tableName + ".user_regdate=? WHERE " + columnName + "=?;");
pst.setLong(1, time);
pst.setString(2, auth.getNickname());
pst.executeUpdate();
// Update user_lastvisit
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + tableName + ".user_lastvisit=? WHERE "
- + columnName + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + tableName + ".user_lastvisit=? WHERE " + columnName + "=?;");
pst.setLong(1, time);
pst.setString(2, auth.getNickname());
pst.executeUpdate();
@@ -407,116 +310,79 @@ public class MySQLThread extends Thread implements DataSource {
if (Settings.getPasswordHash == HashAlgorithm.WORDPRESS) {
int id;
ResultSet rs = null;
- pst = con.prepareStatement("SELECT * FROM " + tableName
- + " WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, auth.getNickname());
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
// First Name
- pst = con
- .prepareStatement("INSERT INTO "
- + Settings.getWordPressPrefix
- + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
+ pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "first_name");
pst.setString(3, "");
pst.executeUpdate();
// Last Name
- pst = con
- .prepareStatement("INSERT INTO "
- + Settings.getWordPressPrefix
- + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
+ pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "last_name");
pst.setString(3, "");
pst.executeUpdate();
// Nick Name
- pst = con
- .prepareStatement("INSERT INTO "
- + Settings.getWordPressPrefix
- + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
+ pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "nickname");
pst.setString(3, auth.getNickname());
pst.executeUpdate();
// Description
- pst = con
- .prepareStatement("INSERT INTO "
- + Settings.getWordPressPrefix
- + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
+ pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "description");
pst.setString(3, "");
pst.executeUpdate();
// Rich_Editing
- pst = con
- .prepareStatement("INSERT INTO "
- + Settings.getWordPressPrefix
- + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
+ pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "rich_editing");
pst.setString(3, "true");
pst.executeUpdate();
// Comments_Shortcuts
- pst = con
- .prepareStatement("INSERT INTO "
- + Settings.getWordPressPrefix
- + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
+ pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "comment_shortcuts");
pst.setString(3, "false");
pst.executeUpdate();
// admin_color
- pst = con
- .prepareStatement("INSERT INTO "
- + Settings.getWordPressPrefix
- + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
+ pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "admin_color");
pst.setString(3, "fresh");
pst.executeUpdate();
// use_ssl
- pst = con
- .prepareStatement("INSERT INTO "
- + Settings.getWordPressPrefix
- + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
+ pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "use_ssl");
pst.setString(3, "0");
pst.executeUpdate();
// show_admin_bar_front
- pst = con
- .prepareStatement("INSERT INTO "
- + Settings.getWordPressPrefix
- + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
+ pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "show_admin_bar_front");
pst.setString(3, "true");
pst.executeUpdate();
// wp_capabilities
- pst = con
- .prepareStatement("INSERT INTO "
- + Settings.getWordPressPrefix
- + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
+ pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "wp_capabilities");
pst.setString(3, "a:1:{s:10:\"subscriber\";b:1;}");
pst.executeUpdate();
// wp_user_level
- pst = con
- .prepareStatement("INSERT INTO "
- + Settings.getWordPressPrefix
- + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
+ pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "wp_user_level");
pst.setString(3, "0");
pst.executeUpdate();
// default_password_nag
- pst = con
- .prepareStatement("INSERT INTO "
- + Settings.getWordPressPrefix
- + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
+ pst = con.prepareStatement("INSERT INTO " + Settings.getWordPressPrefix + "usermeta (user_id, meta_key, meta_value) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "default_password_nag");
pst.setString(3, "");
@@ -526,15 +392,13 @@ public class MySQLThread extends Thread implements DataSource {
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
int id;
ResultSet rs = null;
- pst = con.prepareStatement("SELECT * FROM " + tableName
- + " WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, auth.getNickname());
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
// Insert password in the correct table
- pst = con
- .prepareStatement("INSERT INTO xf_user_authenticate (user_id, scheme_class, data) VALUES (?,?,?);");
+ pst = con.prepareStatement("INSERT INTO xf_user_authenticate (user_id, scheme_class, data) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "XenForo_Authentication_Core12");
byte[] bytes = auth.getHash().getBytes();
@@ -563,33 +427,27 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + columnPassword + "=? WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnPassword + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getHash());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
int id;
ResultSet rs = null;
- pst = con.prepareStatement("SELECT * FROM " + tableName
- + " WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, auth.getNickname());
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
// Insert password in the correct table
- pst = con
- .prepareStatement("UPDATE xf_user_authenticate SET data=? WHERE "
- + columnID + "=?;");
+ pst = con.prepareStatement("UPDATE xf_user_authenticate SET data=? WHERE " + columnID + "=?;");
byte[] bytes = auth.getHash().getBytes();
Blob blob = con.createBlob();
blob.setBytes(1, bytes);
pst.setBlob(1, blob);
pst.setInt(2, id);
pst.executeUpdate();
- pst = con
- .prepareStatement("UPDATE xf_user_authenticate SET scheme_class=? WHERE "
- + columnID + "=?;");
+ pst = con.prepareStatement("UPDATE xf_user_authenticate SET scheme_class=? WHERE " + columnID + "=?;");
pst.setString(1, "XenForo_Authentication_Core12");
pst.setInt(2, id);
pst.executeUpdate();
@@ -614,9 +472,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + columnIp + "=?, " + columnLastLogin + "=? WHERE "
- + columnName + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getIp());
pst.setLong(2, auth.getLastLogin());
pst.setString(3, auth.getNickname());
@@ -640,8 +496,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE "
- + columnLastLogin + ";");
+ pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + ";");
pst.setLong(1, until);
return pst.executeUpdate();
} catch (SQLException ex) {
@@ -664,15 +519,13 @@ public class MySQLThread extends Thread implements DataSource {
List list = new ArrayList();
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
- + columnLastLogin + ";");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLastLogin + ";");
pst.setLong(1, until);
rs = pst.executeQuery();
while (rs.next()) {
list.add(rs.getString(columnName));
}
- pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE "
- + columnLastLogin + ";");
+ pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + ";");
pst.setLong(1, until);
pst.executeUpdate();
return list;
@@ -698,21 +551,17 @@ public class MySQLThread extends Thread implements DataSource {
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
int id;
ResultSet rs = null;
- pst = con.prepareStatement("SELECT * FROM " + tableName
- + " WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
// Remove data
- pst = con
- .prepareStatement("DELETE FROM xf_user_authenticate WHERE "
- + columnID + "=?;");
+ pst = con.prepareStatement("DELETE FROM xf_user_authenticate WHERE " + columnID + "=?;");
pst.setInt(1, id);
}
}
- pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE "
- + columnName + "=?;");
+ pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
pst.executeUpdate();
} catch (SQLException ex) {
@@ -734,9 +583,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + lastlocX + " =?, " + lastlocY + "=?, " + lastlocZ
- + "=?, " + lastlocWorld + "=? WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + lastlocX + " =?, " + lastlocY + "=?, " + lastlocZ + "=?, " + lastlocWorld + "=? WHERE " + columnName + "=?;");
pst.setDouble(1, auth.getQuitLocX());
pst.setDouble(2, auth.getQuitLocY());
pst.setDouble(3, auth.getQuitLocZ());
@@ -764,8 +611,7 @@ public class MySQLThread extends Thread implements DataSource {
int countIp = 0;
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
- + columnIp + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
pst.setString(1, ip);
rs = pst.executeQuery();
while (rs.next()) {
@@ -791,8 +637,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + columnEmail + " =? WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnEmail + " =? WHERE " + columnName + "=?;");
pst.setString(1, auth.getEmail());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
@@ -818,8 +663,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + columnSalt + " =? WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnSalt + " =? WHERE " + columnName + "=?;");
pst.setString(1, auth.getSalt());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
@@ -852,12 +696,11 @@ public class MySQLThread extends Thread implements DataSource {
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
- ConsoleLogger
- .showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
+ ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
- if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
- .getPluginManager().disablePlugin(AuthMe.getInstance());
+ if (!Settings.isStopEnabled)
+ AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
}
}
@@ -899,8 +742,7 @@ public class MySQLThread extends Thread implements DataSource {
List countIp = new ArrayList();
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
- + columnIp + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
pst.setString(1, auth.getIp());
rs = pst.executeQuery();
while (rs.next()) {
@@ -928,8 +770,7 @@ public class MySQLThread extends Thread implements DataSource {
List countIp = new ArrayList();
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
- + columnIp + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
pst.setString(1, ip);
rs = pst.executeQuery();
while (rs.next()) {
@@ -957,8 +798,7 @@ public class MySQLThread extends Thread implements DataSource {
List countEmail = new ArrayList();
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
- + columnEmail + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnEmail + "=?;");
pst.setString(1, email);
rs = pst.executeQuery();
while (rs.next()) {
@@ -985,8 +825,7 @@ public class MySQLThread extends Thread implements DataSource {
try {
for (String name : banned) {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("DELETE FROM " + tableName
- + " WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, name);
pst.executeUpdate();
}
@@ -1009,33 +848,32 @@ public class MySQLThread extends Thread implements DataSource {
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
- ConsoleLogger
- .showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
+ ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
- if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
- .getPluginManager().disablePlugin(AuthMe.getInstance());
+ if (!Settings.isStopEnabled)
+ AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
}
} catch (AssertionError ae) {
// Make sure assertionerror is caused by the connectionpoolmanager,
// else re-throw it
- if (!ae.getMessage().equalsIgnoreCase("AuthMeDatabaseError")) throw new AssertionError(
- ae.getMessage());
+ if (!ae.getMessage().equalsIgnoreCase("AuthMeDatabaseError"))
+ throw new AssertionError(ae.getMessage());
try {
con = null;
reconnect(false);
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
- ConsoleLogger
- .showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
+ ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
- if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
- .getPluginManager().disablePlugin(AuthMe.getInstance());
+ if (!Settings.isStopEnabled)
+ AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
}
}
- if (con == null) con = conPool.getValidConnection();
+ if (con == null)
+ con = conPool.getValidConnection();
return con;
}
@@ -1050,8 +888,8 @@ public class MySQLThread extends Thread implements DataSource {
dataSource.setUser(username);
dataSource.setPassword(password);
conPool = new MiniConnectionPoolManager(dataSource, 10);
- if (!reload) ConsoleLogger
- .info("ConnectionPool was unavailable... Reconnected!");
+ if (!reload)
+ ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");
}
@Override
@@ -1066,11 +904,11 @@ public class MySQLThread extends Thread implements DataSource {
ResultSet rs = null;
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
- + columnName + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
rs = pst.executeQuery();
- if (rs.next()) return (rs.getInt(columnLogged) == 1);
+ if (rs.next())
+ return (rs.getInt(columnLogged) == 1);
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
@@ -1091,8 +929,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + columnLogged + "=? WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnName + "=?;");
pst.setInt(1, 1);
pst.setString(2, user);
pst.executeUpdate();
@@ -1115,8 +952,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + columnLogged + "=? WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnName + "=?;");
pst.setInt(1, 0);
pst.setString(2, user);
pst.executeUpdate();
@@ -1139,8 +975,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
con = makeSureConnectionIsReady();
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + columnLogged + "=? WHERE " + columnLogged + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnLogged + "=?;");
pst.setInt(1, 0);
pst.setInt(2, 1);
pst.executeUpdate();
diff --git a/src/main/java/fr/xephi/authme/datasource/SQLiteThread.java b/src/main/java/fr/xephi/authme/datasource/SQLiteThread.java
index e5d44ac1..a1bdb71d 100644
--- a/src/main/java/fr/xephi/authme/datasource/SQLiteThread.java
+++ b/src/main/java/fr/xephi/authme/datasource/SQLiteThread.java
@@ -60,8 +60,8 @@ public class SQLiteThread extends Thread implements DataSource {
ConsoleLogger.showError("Can't use SQLITE... ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
- if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
- .getPluginManager().disablePlugin(AuthMe.getInstance());
+ if (!Settings.isStopEnabled)
+ AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
} catch (SQLException e) {
ConsoleLogger.showError(e.getMessage());
@@ -69,8 +69,8 @@ public class SQLiteThread extends Thread implements DataSource {
ConsoleLogger.showError("Can't use SQLITE... ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
- if (!Settings.isStopEnabled) AuthMe.getInstance().getServer()
- .getPluginManager().disablePlugin(AuthMe.getInstance());
+ if (!Settings.isStopEnabled)
+ AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
}
}
@@ -79,8 +79,7 @@ public class SQLiteThread extends Thread implements DataSource {
SQLException {
Class.forName("org.sqlite.JDBC");
ConsoleLogger.info("SQLite driver loaded");
- this.con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/"
- + database + ".db");
+ this.con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database + ".db");
}
@@ -89,62 +88,37 @@ public class SQLiteThread extends Thread implements DataSource {
ResultSet rs = null;
try {
st = con.createStatement();
- st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " ("
- + columnID + " INTEGER AUTO_INCREMENT," + columnName
- + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword
- + " VARCHAR(255) NOT NULL," + columnIp
- + " VARCHAR(40) NOT NULL," + columnLastLogin + " BIGINT,"
- + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY
- + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ
- + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld
- + " VARCHAR(255) DEFAULT 'world'," + columnEmail
- + " VARCHAR(255) DEFAULT 'your@email.com',"
- + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID
- + "));");
- rs = con.getMetaData().getColumns(null, null, tableName,
- columnPassword);
+ st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " (" + columnID + " INTEGER AUTO_INCREMENT," + columnName + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword + " VARCHAR(255) NOT NULL," + columnIp + " VARCHAR(40) NOT NULL," + columnLastLogin + " BIGINT," + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld + " VARCHAR(255) DEFAULT 'world'," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com'," + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
+ rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + columnPassword + " VARCHAR(255) NOT NULL;");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnPassword + " VARCHAR(255) NOT NULL;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, columnIp);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + columnIp + " VARCHAR(40) NOT NULL;");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnIp + " VARCHAR(40) NOT NULL;");
}
rs.close();
- rs = con.getMetaData().getColumns(null, null, tableName,
- columnLastLogin);
+ rs = con.getMetaData().getColumns(null, null, tableName, columnLastLogin);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + columnLastLogin + " BIGINT;");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnLastLogin + " BIGINT;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0';");
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0';");
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0';");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0';");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0';");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0';");
}
rs.close();
- rs = con.getMetaData().getColumns(null, null, tableName,
- lastlocWorld);
+ rs = con.getMetaData().getColumns(null, null, tableName, lastlocWorld);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + lastlocWorld
- + " VARCHAR(255) NOT NULL DEFAULT 'world';");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocWorld + " VARCHAR(255) NOT NULL DEFAULT 'world';");
}
rs.close();
- rs = con.getMetaData().getColumns(null, null, tableName,
- columnEmail);
+ rs = con.getMetaData().getColumns(null, null, tableName, columnEmail);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + columnEmail
- + " VARCHAR(255) DEFAULT 'your@email.com';");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com';");
}
} finally {
close(rs);
@@ -158,8 +132,7 @@ public class SQLiteThread extends Thread implements DataSource {
PreparedStatement pst = null;
ResultSet rs = null;
try {
- pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
- + columnName + "=?");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?");
pst.setString(1, user);
rs = pst.executeQuery();
return rs.next();
@@ -177,41 +150,17 @@ public class SQLiteThread extends Thread implements DataSource {
PreparedStatement pst = null;
ResultSet rs = null;
try {
- pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
- + columnName + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
rs = pst.executeQuery();
if (rs.next()) {
if (rs.getString(columnIp).isEmpty()) {
- return new PlayerAuth(rs.getString(columnName),
- rs.getString(columnPassword), "198.18.0.1",
- rs.getLong(columnLastLogin),
- rs.getDouble(lastlocX), rs.getDouble(lastlocY),
- rs.getDouble(lastlocZ), rs.getString(lastlocWorld),
- rs.getString(columnEmail), API.getPlayerRealName(rs
- .getString(columnName)));
+ return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "198.18.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
} else {
if (!columnSalt.isEmpty()) {
- return new PlayerAuth(rs.getString(columnName),
- rs.getString(columnPassword),
- rs.getString(columnSalt),
- rs.getInt(columnGroup), rs.getString(columnIp),
- rs.getLong(columnLastLogin),
- rs.getDouble(lastlocX), rs.getDouble(lastlocY),
- rs.getDouble(lastlocZ),
- rs.getString(lastlocWorld),
- rs.getString(columnEmail),
- API.getPlayerRealName(rs.getString(columnName)));
+ return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
} else {
- return new PlayerAuth(rs.getString(columnName),
- rs.getString(columnPassword),
- rs.getString(columnIp),
- rs.getLong(columnLastLogin),
- rs.getDouble(lastlocX), rs.getDouble(lastlocY),
- rs.getDouble(lastlocZ),
- rs.getString(lastlocWorld),
- rs.getString(columnEmail),
- API.getPlayerRealName(rs.getString(columnName)));
+ return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
}
}
} else {
@@ -231,19 +180,14 @@ public class SQLiteThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
if (columnSalt.isEmpty() && auth.getSalt().isEmpty()) {
- pst = con.prepareStatement("INSERT INTO " + tableName + "("
- + columnName + "," + columnPassword + "," + columnIp
- + "," + columnLastLogin + ") VALUES (?,?,?,?);");
+ pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + ") VALUES (?,?,?,?);");
pst.setString(1, auth.getNickname());
pst.setString(2, auth.getHash());
pst.setString(3, auth.getIp());
pst.setLong(4, auth.getLastLogin());
pst.executeUpdate();
} else {
- pst = con.prepareStatement("INSERT INTO " + tableName + "("
- + columnName + "," + columnPassword + "," + columnIp
- + "," + columnLastLogin + "," + columnSalt
- + ") VALUES (?,?,?,?,?);");
+ pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnSalt + ") VALUES (?,?,?,?,?);");
pst.setString(1, auth.getNickname());
pst.setString(2, auth.getHash());
pst.setString(3, auth.getIp());
@@ -264,8 +208,7 @@ public class SQLiteThread extends Thread implements DataSource {
public synchronized boolean updatePassword(PlayerAuth auth) {
PreparedStatement pst = null;
try {
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + columnPassword + "=? WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnPassword + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getHash());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
@@ -282,9 +225,7 @@ public class SQLiteThread extends Thread implements DataSource {
public boolean updateSession(PlayerAuth auth) {
PreparedStatement pst = null;
try {
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + columnIp + "=?, " + columnLastLogin + "=? WHERE "
- + columnName + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getIp());
pst.setLong(2, auth.getLastLogin());
pst.setString(3, auth.getNickname());
@@ -303,8 +244,7 @@ public class SQLiteThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
- pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE "
- + columnLastLogin + ";");
+ pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + ";");
pst.setLong(1, until);
return pst.executeUpdate();
} catch (SQLException ex) {
@@ -321,8 +261,7 @@ public class SQLiteThread extends Thread implements DataSource {
ResultSet rs = null;
List list = new ArrayList();
try {
- pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
- + columnLastLogin + ";");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnLastLogin + ";");
pst.setLong(1, until);
rs = pst.executeQuery();
while (rs.next()) {
@@ -342,8 +281,7 @@ public class SQLiteThread extends Thread implements DataSource {
public synchronized boolean removeAuth(String user) {
PreparedStatement pst = null;
try {
- pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE "
- + columnName + "=?;");
+ pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
pst.executeUpdate();
} catch (SQLException ex) {
@@ -359,9 +297,7 @@ public class SQLiteThread extends Thread implements DataSource {
public boolean updateQuitLoc(PlayerAuth auth) {
PreparedStatement pst = null;
try {
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + lastlocX + "=?, " + lastlocY + "=?, " + lastlocZ + "=?, "
- + lastlocWorld + "=? WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + lastlocX + "=?, " + lastlocY + "=?, " + lastlocZ + "=?, " + lastlocWorld + "=? WHERE " + columnName + "=?;");
pst.setDouble(1, auth.getQuitLocX());
pst.setDouble(2, auth.getQuitLocY());
pst.setDouble(3, auth.getQuitLocZ());
@@ -383,8 +319,7 @@ public class SQLiteThread extends Thread implements DataSource {
ResultSet rs = null;
int countIp = 0;
try {
- pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
- + columnIp + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
pst.setString(1, ip);
rs = pst.executeQuery();
while (rs.next()) {
@@ -404,8 +339,7 @@ public class SQLiteThread extends Thread implements DataSource {
public boolean updateEmail(PlayerAuth auth) {
PreparedStatement pst = null;
try {
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + columnEmail + "=? WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnEmail + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getEmail());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
@@ -425,8 +359,7 @@ public class SQLiteThread extends Thread implements DataSource {
}
PreparedStatement pst = null;
try {
- pst = con.prepareStatement("UPDATE " + tableName + " SET "
- + columnSalt + "=? WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnSalt + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getSalt());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
@@ -478,8 +411,7 @@ public class SQLiteThread extends Thread implements DataSource {
ResultSet rs = null;
List countIp = new ArrayList();
try {
- pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
- + columnIp + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
pst.setString(1, auth.getIp());
rs = pst.executeQuery();
while (rs.next()) {
@@ -506,8 +438,7 @@ public class SQLiteThread extends Thread implements DataSource {
ResultSet rs = null;
List countIp = new ArrayList();
try {
- pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
- + columnIp + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnIp + "=?;");
pst.setString(1, ip);
rs = pst.executeQuery();
while (rs.next()) {
@@ -534,8 +465,7 @@ public class SQLiteThread extends Thread implements DataSource {
ResultSet rs = null;
List countEmail = new ArrayList();
try {
- pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
- + columnEmail + "=?;");
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnEmail + "=?;");
pst.setString(1, email);
rs = pst.executeQuery();
while (rs.next()) {
@@ -561,8 +491,7 @@ public class SQLiteThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
for (String name : banned) {
- pst = con.prepareStatement("DELETE FROM " + tableName
- + " WHERE " + columnName + "=?;");
+ pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, name);
pst.executeUpdate();
}
diff --git a/src/main/java/fr/xephi/authme/events/AuthMeTeleportEvent.java b/src/main/java/fr/xephi/authme/events/AuthMeTeleportEvent.java
index c59b52c9..bd6aa60e 100644
--- a/src/main/java/fr/xephi/authme/events/AuthMeTeleportEvent.java
+++ b/src/main/java/fr/xephi/authme/events/AuthMeTeleportEvent.java
@@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
/**
*
- * This event is call when AuthMe try to teleport a player
+ * This event is call when AuthMe try to teleport a player
*
* @author Xephi59
*/
diff --git a/src/main/java/fr/xephi/authme/events/LoginEvent.java b/src/main/java/fr/xephi/authme/events/LoginEvent.java
index 8a265ada..bedbc55d 100644
--- a/src/main/java/fr/xephi/authme/events/LoginEvent.java
+++ b/src/main/java/fr/xephi/authme/events/LoginEvent.java
@@ -5,44 +5,44 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
-*
-* This event is called when a player login or register through AuthMe.
-* The boolean 'isLogin' will be false if, and only if, login/register failed.
-*
-* @author Xephi59
-*/
+ *
+ * This event is called when a player login or register through AuthMe. The
+ * boolean 'isLogin' will be false if, and only if, login/register failed.
+ *
+ * @author Xephi59
+ */
public class LoginEvent extends Event {
- private Player player;
- private boolean isLogin;
- private static final HandlerList handlers = new HandlerList();
+ private Player player;
+ private boolean isLogin;
+ private static final HandlerList handlers = new HandlerList();
- public LoginEvent(Player player, boolean isLogin) {
- this.player = player;
- this.isLogin = isLogin;
- }
+ public LoginEvent(Player player, boolean isLogin) {
+ this.player = player;
+ this.isLogin = isLogin;
+ }
- public Player getPlayer() {
- return this.player;
- }
+ public Player getPlayer() {
+ return this.player;
+ }
- public void setPlayer(Player player) {
- this.player = player;
- }
+ public void setPlayer(Player player) {
+ this.player = player;
+ }
- @Deprecated
- public void setLogin(boolean isLogin) {
- this.isLogin = isLogin;
- }
+ @Deprecated
+ public void setLogin(boolean isLogin) {
+ this.isLogin = isLogin;
+ }
- public boolean isLogin() {
- return isLogin;
- }
+ public boolean isLogin() {
+ return isLogin;
+ }
- @Override
- public HandlerList getHandlers() {
- return handlers;
- }
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
public static HandlerList getHandlerList() {
return handlers;
diff --git a/src/main/java/fr/xephi/authme/events/PasswordEncryptionEvent.java b/src/main/java/fr/xephi/authme/events/PasswordEncryptionEvent.java
index 7611746e..9f6ea007 100644
--- a/src/main/java/fr/xephi/authme/events/PasswordEncryptionEvent.java
+++ b/src/main/java/fr/xephi/authme/events/PasswordEncryptionEvent.java
@@ -6,8 +6,10 @@ import org.bukkit.event.HandlerList;
import fr.xephi.authme.security.crypts.EncryptionMethod;
/**
- * This event is called when we need to compare or get an hash password,
- * for set a custom EncryptionMethod
+ *
+ * This event is called when we need to compare or get an hash password, for set
+ * a custom EncryptionMethod
+ *
*
* @see fr.xephi.authme.security.crypts.EncryptionMethod
*
@@ -15,31 +17,31 @@ import fr.xephi.authme.security.crypts.EncryptionMethod;
*/
public class PasswordEncryptionEvent extends Event {
- private static final HandlerList handlers = new HandlerList();
- private EncryptionMethod method = null;
- private String playerName = "";
+ private static final HandlerList handlers = new HandlerList();
+ private EncryptionMethod method = null;
+ private String playerName = "";
- public PasswordEncryptionEvent(EncryptionMethod method, String playerName) {
- this.method = method;
- this.playerName = playerName;
- }
+ public PasswordEncryptionEvent(EncryptionMethod method, String playerName) {
+ this.method = method;
+ this.playerName = playerName;
+ }
- @Override
- public HandlerList getHandlers() {
- return handlers;
- }
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
- public void setMethod(EncryptionMethod method) {
- this.method = method;
- }
+ public void setMethod(EncryptionMethod method) {
+ this.method = method;
+ }
- public EncryptionMethod getMethod() {
- return method;
- }
+ public EncryptionMethod getMethod() {
+ return method;
+ }
- public String getPlayerName() {
- return playerName;
- }
+ public String getPlayerName() {
+ return playerName;
+ }
public static HandlerList getHandlerList() {
return handlers;
diff --git a/src/main/java/fr/xephi/authme/events/ProtectInventoryEvent.java b/src/main/java/fr/xephi/authme/events/ProtectInventoryEvent.java
index 8b23d5c9..eebf6f4a 100644
--- a/src/main/java/fr/xephi/authme/events/ProtectInventoryEvent.java
+++ b/src/main/java/fr/xephi/authme/events/ProtectInventoryEvent.java
@@ -5,8 +5,8 @@ import org.bukkit.inventory.ItemStack;
/**
*
- * This event is call just after store inventory into cache and will
- * empty the player inventory.
+ * This event is call just after store inventory into cache and will empty the
+ * player inventory.
*
* @author Xephi59
*/
diff --git a/src/main/java/fr/xephi/authme/events/RegisterTeleportEvent.java b/src/main/java/fr/xephi/authme/events/RegisterTeleportEvent.java
index 724b85e4..78470051 100644
--- a/src/main/java/fr/xephi/authme/events/RegisterTeleportEvent.java
+++ b/src/main/java/fr/xephi/authme/events/RegisterTeleportEvent.java
@@ -5,8 +5,8 @@ import org.bukkit.entity.Player;
/**
*
- * This event is call if, and only if, a player is teleported
- * just after a register.
+ * This event is call if, and only if, a player is teleported just after a
+ * register.
*
* @author Xephi59
*/
diff --git a/src/main/java/fr/xephi/authme/events/StoreInventoryEvent.java b/src/main/java/fr/xephi/authme/events/StoreInventoryEvent.java
index d61d40f3..16c076d8 100644
--- a/src/main/java/fr/xephi/authme/events/StoreInventoryEvent.java
+++ b/src/main/java/fr/xephi/authme/events/StoreInventoryEvent.java
@@ -25,10 +25,8 @@ public class StoreInventoryEvent extends CustomEvent {
public StoreInventoryEvent(Player player, FileCache fileCache) {
this.player = player;
- this.inventory = fileCache.readCache(player)
- .getInventory();
- this.armor = fileCache.readCache(player)
- .getArmour();
+ this.inventory = fileCache.readCache(player).getInventory();
+ this.armor = fileCache.readCache(player).getArmour();
}
public ItemStack[] getInventory() {
diff --git a/src/main/java/fr/xephi/authme/gui/Clickable.java b/src/main/java/fr/xephi/authme/gui/Clickable.java
index 943bee51..7ff30336 100644
--- a/src/main/java/fr/xephi/authme/gui/Clickable.java
+++ b/src/main/java/fr/xephi/authme/gui/Clickable.java
@@ -3,5 +3,6 @@ package fr.xephi.authme.gui;
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
public interface Clickable {
+
public void handleClick(ButtonClickEvent event);
}
diff --git a/src/main/java/fr/xephi/authme/gui/CustomButton.java b/src/main/java/fr/xephi/authme/gui/CustomButton.java
index ad9dfde5..06abf145 100644
--- a/src/main/java/fr/xephi/authme/gui/CustomButton.java
+++ b/src/main/java/fr/xephi/authme/gui/CustomButton.java
@@ -4,6 +4,7 @@ import org.getspout.spoutapi.event.screen.ButtonClickEvent;
import org.getspout.spoutapi.gui.GenericButton;
public class CustomButton extends GenericButton {
+
public Clickable handleRef = null;
public CustomButton(Clickable c) {
diff --git a/src/main/java/fr/xephi/authme/gui/screens/LoginScreen.java b/src/main/java/fr/xephi/authme/gui/screens/LoginScreen.java
index 3c787c32..5137670a 100644
--- a/src/main/java/fr/xephi/authme/gui/screens/LoginScreen.java
+++ b/src/main/java/fr/xephi/authme/gui/screens/LoginScreen.java
@@ -36,8 +36,7 @@ public class LoginScreen extends GenericPopup implements Clickable {
String exitMsg = spoutCfg.getString("LoginScreen.exit message");
String title = spoutCfg.getString("LoginScreen.title");
@SuppressWarnings("unchecked")
- List textlines = (List) spoutCfg
- .getList("LoginScreen.text");
+ List textlines = (List) spoutCfg.getList("LoginScreen.text");
public SpoutPlayer splayer;
public LoginScreen(SpoutPlayer player) {
@@ -50,33 +49,24 @@ public class LoginScreen extends GenericPopup implements Clickable {
int part = !(textlines.size() <= 5) ? 195 / objects : 20;
int h = 3 * part / 4, w = 8 * part;
titleLbl = new GenericLabel();
- titleLbl.setText(title).setTextColor(new Color(1.0F, 0, 0, 1.0F))
- .setAlign(WidgetAnchor.TOP_CENTER).setHeight(h).setWidth(w)
- .setX(maxWidth / 2).setY(25);
+ titleLbl.setText(title).setTextColor(new Color(1.0F, 0, 0, 1.0F)).setAlign(WidgetAnchor.TOP_CENTER).setHeight(h).setWidth(w).setX(maxWidth / 2).setY(25);
this.attachWidget(plugin, titleLbl);
int ystart = 25 + h + part / 2;
for (int x = 0; x < textlines.size(); x++) {
textLbl = new GenericLabel();
- textLbl.setText(textlines.get(x)).setAlign(WidgetAnchor.TOP_CENTER)
- .setHeight(h).setWidth(w).setX(maxWidth / 2)
- .setY(ystart + x * part);
+ textLbl.setText(textlines.get(x)).setAlign(WidgetAnchor.TOP_CENTER).setHeight(h).setWidth(w).setX(maxWidth / 2).setY(ystart + x * part);
this.attachWidget(plugin, textLbl);
}
passBox = new GenericTextField();
- passBox.setMaximumCharacters(18).setMaximumLines(1).setHeight(h - 2)
- .setWidth(w - 2).setY(220 - h - 2 * part);
+ passBox.setMaximumCharacters(18).setMaximumLines(1).setHeight(h - 2).setWidth(w - 2).setY(220 - h - 2 * part);
passBox.setPasswordField(true);
setXToMid(passBox);
this.attachWidget(plugin, passBox);
errorLbl = new GenericLabel();
- errorLbl.setText("").setTextColor(new Color(1.0F, 0, 0, 1.0F))
- .setHeight(h).setWidth(w)
- .setX(passBox.getX() + passBox.getWidth() + 2)
- .setY(passBox.getY());
+ errorLbl.setText("").setTextColor(new Color(1.0F, 0, 0, 1.0F)).setHeight(h).setWidth(w).setX(passBox.getX() + passBox.getWidth() + 2).setY(passBox.getY());
this.attachWidget(plugin, errorLbl);
loginBtn = new CustomButton(this);
- loginBtn.setText(loginTxt).setHeight(h).setWidth(w)
- .setY(220 - h - part);
+ loginBtn.setText(loginTxt).setHeight(h).setWidth(w).setY(220 - h - part);
setXToMid(loginBtn);
this.attachWidget(plugin, loginBtn);
exitBtn = new CustomButton(this);
@@ -90,7 +80,8 @@ public class LoginScreen extends GenericPopup implements Clickable {
public void handleClick(ButtonClickEvent event) {
Button b = event.getButton();
SpoutPlayer player = event.getPlayer();
- if (event.isCancelled() || event == null || event.getPlayer() == null) return;
+ if (event.isCancelled() || event == null || event.getPlayer() == null)
+ return;
if (b.equals(loginBtn)) {
plugin.management.performLogin(player, passBox.getText(), false);
} else if (b.equals(exitBtn)) {
diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeBlockListener.java b/src/main/java/fr/xephi/authme/listener/AuthMeBlockListener.java
index 47fbe261..a87b622e 100644
--- a/src/main/java/fr/xephi/authme/listener/AuthMeBlockListener.java
+++ b/src/main/java/fr/xephi/authme/listener/AuthMeBlockListener.java
@@ -60,8 +60,7 @@ public class AuthMeBlockListener implements Listener {
return;
}
- if (PlayerCache.getInstance().isAuthenticated(
- player.getName().toLowerCase())) {
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
return;
}
diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeEntityListener.java b/src/main/java/fr/xephi/authme/listener/AuthMeEntityListener.java
index 07711233..bfce845b 100644
--- a/src/main/java/fr/xephi/authme/listener/AuthMeEntityListener.java
+++ b/src/main/java/fr/xephi/authme/listener/AuthMeEntityListener.java
@@ -43,12 +43,14 @@ public class AuthMeEntityListener implements Listener {
return;
}
- if (instance.citizens.isNPC(entity, instance)) return;
+ if (instance.citizens.isNPC(entity, instance))
+ return;
Player player = (Player) entity;
String name = player.getName().toLowerCase();
- if (CombatTagComunicator.isNPC(player)) return;
+ if (CombatTagComunicator.isNPC(player))
+ return;
if (PlayerCache.getInstance().isAuthenticated(name)) {
return;
@@ -68,13 +70,15 @@ public class AuthMeEntityListener implements Listener {
if (event.isCancelled()) {
return;
}
- if (event.getTarget() == null) return;
+ if (event.getTarget() == null)
+ return;
Entity entity = event.getTarget();
if (!(entity instanceof Player)) {
return;
}
- if (instance.citizens.isNPC(entity, instance)) return;
+ if (instance.citizens.isNPC(entity, instance))
+ return;
Player player = (Player) entity;
String name = player.getName().toLowerCase();
@@ -103,7 +107,8 @@ public class AuthMeEntityListener implements Listener {
return;
}
- if (instance.citizens.isNPC(entity, instance)) return;
+ if (instance.citizens.isNPC(entity, instance))
+ return;
Player player = (Player) entity;
String name = player.getName().toLowerCase();
@@ -133,7 +138,8 @@ public class AuthMeEntityListener implements Listener {
return;
}
- if (instance.citizens.isNPC(entity, instance)) return;
+ if (instance.citizens.isNPC(entity, instance))
+ return;
Player player = (Player) entity;
String name = player.getName().toLowerCase();
@@ -164,15 +170,14 @@ public class AuthMeEntityListener implements Listener {
Player player = (Player) event.getEntity();
String name = player.getName().toLowerCase();
- if (Utils.getInstance().isUnrestricted(player)
- || CombatTagComunicator.isNPC(player)) {
+ if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return;
}
- if (instance.citizens.isNPC(player, instance)) return;
+ if (instance.citizens.isNPC(player, instance))
+ return;
- if (PlayerCache.getInstance().isAuthenticated(
- player.getName().toLowerCase())) {
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
return;
}
@@ -197,15 +202,14 @@ public class AuthMeEntityListener implements Listener {
Player player = (Player) event.getEntity();
String name = player.getName().toLowerCase();
- if (Utils.getInstance().isUnrestricted(player)
- || CombatTagComunicator.isNPC(player)) {
+ if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return;
}
- if (instance.citizens.isNPC(player, instance)) return;
+ if (instance.citizens.isNPC(player, instance))
+ return;
- if (PlayerCache.getInstance().isAuthenticated(
- player.getName().toLowerCase())) {
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
return;
}
diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java
index 5f4607e4..8094ab05 100644
--- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java
+++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java
@@ -82,29 +82,34 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
- if (event.isCancelled() || event.getPlayer() == null) return;
+ if (event.isCancelled() || event.getPlayer() == null)
+ return;
Player player = event.getPlayer();
String name = player.getName().toLowerCase();
- if (Utils.getInstance().isUnrestricted(player)) return;
+ if (Utils.getInstance().isUnrestricted(player))
+ return;
- if (PlayerCache.getInstance().isAuthenticated(name)) return;
+ if (PlayerCache.getInstance().isAuthenticated(name))
+ return;
- if (!data.isAuthAvailable(name)) if (!Settings.isForcedRegistrationEnabled) return;
+ if (!data.isAuthAvailable(name))
+ if (!Settings.isForcedRegistrationEnabled)
+ return;
String msg = event.getMessage();
// WorldEdit GUI Shit
- if (msg.equalsIgnoreCase("/worldedit cui")) return;
+ if (msg.equalsIgnoreCase("/worldedit cui"))
+ return;
String cmd = msg.split(" ")[0];
- if (cmd.equalsIgnoreCase("/login") || cmd.equalsIgnoreCase("/register")
- || cmd.equalsIgnoreCase("/passpartu")
- || cmd.equalsIgnoreCase("/l") || cmd.equalsIgnoreCase("/reg")
- || cmd.equalsIgnoreCase("/email")
- || cmd.equalsIgnoreCase("/captcha")) return;
- if (Settings.useEssentialsMotd && cmd.equalsIgnoreCase("/motd")) return;
- if (Settings.allowCommands.contains(cmd)) return;
+ if (cmd.equalsIgnoreCase("/login") || cmd.equalsIgnoreCase("/register") || cmd.equalsIgnoreCase("/passpartu") || cmd.equalsIgnoreCase("/l") || cmd.equalsIgnoreCase("/reg") || cmd.equalsIgnoreCase("/email") || cmd.equalsIgnoreCase("/captcha"))
+ return;
+ if (Settings.useEssentialsMotd && cmd.equalsIgnoreCase("/motd"))
+ return;
+ if (Settings.allowCommands.contains(cmd))
+ return;
event.setMessage("/notloggedin");
event.setCancelled(true);
@@ -112,14 +117,17 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerNormalChat(AsyncPlayerChatEvent event) {
- if (event.isCancelled() || event.getPlayer() == null) return;
+ if (event.isCancelled() || event.getPlayer() == null)
+ return;
final Player player = event.getPlayer();
final String name = player.getName().toLowerCase();
- if (Utils.getInstance().isUnrestricted(player)) return;
+ if (Utils.getInstance().isUnrestricted(player))
+ return;
- if (PlayerCache.getInstance().isAuthenticated(name)) return;
+ if (PlayerCache.getInstance().isAuthenticated(name))
+ return;
String cmd = event.getMessage().split(" ")[0];
@@ -146,14 +154,17 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerHighChat(AsyncPlayerChatEvent event) {
- if (event.isCancelled() || event.getPlayer() == null) return;
+ if (event.isCancelled() || event.getPlayer() == null)
+ return;
final Player player = event.getPlayer();
final String name = player.getName().toLowerCase();
- if (Utils.getInstance().isUnrestricted(player)) return;
+ if (Utils.getInstance().isUnrestricted(player))
+ return;
- if (PlayerCache.getInstance().isAuthenticated(name)) return;
+ if (PlayerCache.getInstance().isAuthenticated(name))
+ return;
String cmd = event.getMessage().split(" ")[0];
@@ -180,14 +191,17 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerChat(AsyncPlayerChatEvent event) {
- if (event.isCancelled() || event.getPlayer() == null) return;
+ if (event.isCancelled() || event.getPlayer() == null)
+ return;
final Player player = event.getPlayer();
final String name = player.getName().toLowerCase();
- if (Utils.getInstance().isUnrestricted(player)) return;
+ if (Utils.getInstance().isUnrestricted(player))
+ return;
- if (PlayerCache.getInstance().isAuthenticated(name)) return;
+ if (PlayerCache.getInstance().isAuthenticated(name))
+ return;
String cmd = event.getMessage().split(" ")[0];
@@ -214,14 +228,17 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerHighestChat(AsyncPlayerChatEvent event) {
- if (event.isCancelled() || event.getPlayer() == null) return;
+ if (event.isCancelled() || event.getPlayer() == null)
+ return;
final Player player = event.getPlayer();
final String name = player.getName().toLowerCase();
- if (Utils.getInstance().isUnrestricted(player)) return;
+ if (Utils.getInstance().isUnrestricted(player))
+ return;
- if (PlayerCache.getInstance().isAuthenticated(name)) return;
+ if (PlayerCache.getInstance().isAuthenticated(name))
+ return;
String cmd = event.getMessage().split(" ")[0];
@@ -248,14 +265,17 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerEarlyChat(AsyncPlayerChatEvent event) {
- if (event.isCancelled() || event.getPlayer() == null) return;
+ if (event.isCancelled() || event.getPlayer() == null)
+ return;
final Player player = event.getPlayer();
final String name = player.getName().toLowerCase();
- if (Utils.getInstance().isUnrestricted(player)) return;
+ if (Utils.getInstance().isUnrestricted(player))
+ return;
- if (PlayerCache.getInstance().isAuthenticated(name)) return;
+ if (PlayerCache.getInstance().isAuthenticated(name))
+ return;
String cmd = event.getMessage().split(" ")[0];
@@ -282,14 +302,17 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOW)
public void onPlayerLowChat(AsyncPlayerChatEvent event) {
- if (event.isCancelled() || event.getPlayer() == null) return;
+ if (event.isCancelled() || event.getPlayer() == null)
+ return;
final Player player = event.getPlayer();
final String name = player.getName().toLowerCase();
- if (Utils.getInstance().isUnrestricted(player)) return;
+ if (Utils.getInstance().isUnrestricted(player))
+ return;
- if (PlayerCache.getInstance().isAuthenticated(name)) return;
+ if (PlayerCache.getInstance().isAuthenticated(name))
+ return;
String cmd = event.getMessage().split(" ")[0];
@@ -321,9 +344,7 @@ public class AuthMePlayerListener implements Listener {
Player player = event.getPlayer();
String name = player.getName().toLowerCase();
- if (plugin.getCitizensCommunicator().isNPC(player, plugin)
- || Utils.getInstance().isUnrestricted(player)
- || CombatTagComunicator.isNPC(player)) {
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return;
}
@@ -363,74 +384,54 @@ public class AuthMePlayerListener implements Listener {
final Player player = event.getPlayer();
final String name = player.getName().toLowerCase();
- if (plugin.getCitizensCommunicator().isNPC(player, plugin)
- || Utils.getInstance().isUnrestricted(player)
- || CombatTagComunicator.isNPC(player)) {
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return;
}
if (!Settings.countriesBlacklist.isEmpty()) {
- String code = plugin.getCountryCode(event.getAddress()
- .getHostAddress());
- if (((code == null) || (Settings.countriesBlacklist.contains(code) && !API
- .isRegistered(name)))
- && !plugin
- .authmePermissible(player, "authme.bypassantibot")) {
- event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
- m._("country_banned")[0]);
+ String code = plugin.getCountryCode(event.getAddress().getHostAddress());
+ if (((code == null) || (Settings.countriesBlacklist.contains(code) && !API.isRegistered(name))) && !plugin.authmePermissible(player, "authme.bypassantibot")) {
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("country_banned")[0]);
return;
}
}
if (Settings.enableProtection && !Settings.countries.isEmpty()) {
- String code = plugin.getCountryCode(event.getAddress()
- .getHostAddress());
- if (((code == null) || (!Settings.countries.contains(code) && !API
- .isRegistered(name)))
- && !plugin
- .authmePermissible(player, "authme.bypassantibot")) {
- event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
- m._("country_banned")[0]);
+ String code = plugin.getCountryCode(event.getAddress().getHostAddress());
+ if (((code == null) || (!Settings.countries.contains(code) && !API.isRegistered(name))) && !plugin.authmePermissible(player, "authme.bypassantibot")) {
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("country_banned")[0]);
return;
}
}
if (Settings.isKickNonRegisteredEnabled) {
if (!data.isAuthAvailable(name)) {
- event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
- m._("reg_only")[0]);
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("reg_only")[0]);
return;
}
}
if (player.isOnline() && Settings.isForceSingleSessionEnabled) {
- event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
- m._("same_nick")[0]);
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("same_nick")[0]);
return;
}
- if (data.isAuthAvailable(name)
- && !LimboCache.getInstance().hasLimboPlayer(name)) {
+ if (data.isAuthAvailable(name) && !LimboCache.getInstance().hasLimboPlayer(name)) {
if (!Settings.isSessionsEnabled) {
} else if (PlayerCache.getInstance().isAuthenticated(name)) {
- if (!Settings.sessionExpireOnIpChange) if (LimboCache
- .getInstance().hasLimboPlayer(
- player.getName().toLowerCase())) {
- LimboCache.getInstance().deleteLimboPlayer(name);
- }
+ if (!Settings.sessionExpireOnIpChange)
+ if (LimboCache.getInstance().hasLimboPlayer(player.getName().toLowerCase())) {
+ LimboCache.getInstance().deleteLimboPlayer(name);
+ }
}
}
// Check if forceSingleSession is set to true, so kick player that has
// joined with same nick of online player
if (player.isOnline() && Settings.isForceSingleSessionEnabled) {
- LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(
- player.getName().toLowerCase());
- event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
- m._("same_nick")[0]);
- if (PlayerCache.getInstance().isAuthenticated(
- player.getName().toLowerCase())) {
+ LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("same_nick")[0]);
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
utils.addNormal(player, limbo.getGroup());
- LimboCache.getInstance().deleteLimboPlayer(
- player.getName().toLowerCase());
+ LimboCache.getInstance().deleteLimboPlayer(player.getName().toLowerCase());
}
return;
}
@@ -441,33 +442,27 @@ public class AuthMePlayerListener implements Listener {
if (name.length() > max || name.length() < min) {
- event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
- m._("name_len")[0]);
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("name_len")[0]);
return;
}
try {
if (!player.getName().matches(regex) || name.equals("Player")) {
try {
- event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
- m._("regex")[0].replace("REG_EX", regex));
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("regex")[0].replace("REG_EX", regex));
} catch (Exception exc) {
- event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
- "allowed char : " + regex);
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "allowed char : " + regex);
}
return;
}
} catch (PatternSyntaxException pse) {
if (regex == null || regex.isEmpty()) {
- event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
- "Your nickname do not match");
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your nickname do not match");
return;
}
try {
- event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
- m._("regex")[0].replace("REG_EX", regex));
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("regex")[0].replace("REG_EX", regex));
} catch (Exception exc) {
- event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
- "allowed char : " + regex);
+ event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "allowed char : " + regex);
}
return;
}
@@ -486,27 +481,26 @@ public class AuthMePlayerListener implements Listener {
}
return;
}
- if (event.getResult() != PlayerLoginEvent.Result.KICK_FULL) return;
- if (player.isBanned()) return;
+ if (event.getResult() != PlayerLoginEvent.Result.KICK_FULL)
+ return;
+ if (player.isBanned())
+ return;
if (!plugin.authmePermissible(player, "authme.vip")) {
event.disallow(Result.KICK_FULL, m._("kick_fullserver")[0]);
return;
}
- if (plugin.getServer().getOnlinePlayers().length > plugin.getServer()
- .getMaxPlayers()) {
+ if (plugin.getServer().getOnlinePlayers().length > plugin.getServer().getMaxPlayers()) {
event.allow();
return;
} else {
- final Player pl = plugin.generateKickPlayer(plugin.getServer()
- .getOnlinePlayers());
+ final Player pl = plugin.generateKickPlayer(plugin.getServer().getOnlinePlayers());
if (pl != null) {
pl.kickPlayer(m._("kick_forvip")[0]);
event.allow();
return;
} else {
- ConsoleLogger.info("The player " + player.getName()
- + " wants to join, but the server is full");
+ ConsoleLogger.info("The player " + player.getName() + " wants to join, but the server is full");
event.disallow(Result.KICK_FULL, m._("kick_fullserver")[0]);
return;
}
@@ -514,29 +508,31 @@ public class AuthMePlayerListener implements Listener {
}
private void checkAntiBotMod(final PlayerLoginEvent event) {
- if (plugin.delayedAntiBot || plugin.antibotMod) return;
- if (plugin.authmePermissible(event.getPlayer(), "authme.bypassantibot")) return;
+ if (plugin.delayedAntiBot || plugin.antibotMod)
+ return;
+ if (plugin.authmePermissible(event.getPlayer(), "authme.bypassantibot"))
+ return;
if (antibot.keySet().size() > Settings.antiBotSensibility) {
plugin.switchAntiBotMod(true);
for (String s : m._("antibot_auto_enabled"))
Bukkit.broadcastMessage(s);
- Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
- new Runnable() {
- @Override
- public void run() {
- if (plugin.antibotMod) {
- plugin.switchAntiBotMod(false);
- antibot.clear();
- for (String s : m._("antibot_auto_disabled"))
- Bukkit.broadcastMessage(s.replace("%m", ""
- + Settings.antiBotDuration));
- }
- }
- }, Settings.antiBotDuration * 1200);
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+
+ @Override
+ public void run() {
+ if (plugin.antibotMod) {
+ plugin.switchAntiBotMod(false);
+ antibot.clear();
+ for (String s : m._("antibot_auto_disabled"))
+ Bukkit.broadcastMessage(s.replace("%m", "" + Settings.antiBotDuration));
+ }
+ }
+ }, Settings.antiBotDuration * 1200);
return;
}
antibot.put(event.getPlayer().getName().toLowerCase(), event);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+
@Override
public void run() {
antibot.remove(event.getPlayer().getName().toLowerCase());
@@ -556,9 +552,7 @@ public class AuthMePlayerListener implements Listener {
gameMode.put(name, gm);
BukkitScheduler sched = plugin.getServer().getScheduler();
- if (plugin.getCitizensCommunicator().isNPC(player, plugin)
- || Utils.getInstance().isUnrestricted(player)
- || CombatTagComunicator.isNPC(player)) {
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return;
}
@@ -576,13 +570,11 @@ public class AuthMePlayerListener implements Listener {
player.setGameMode(gM);
this.causeByAuthMe = false;
player.kickPlayer("You are not the Owner of this account, please try another name!");
- if (Settings.banUnsafeIp) plugin.getServer().banIP(ip);
+ if (Settings.banUnsafeIp)
+ plugin.getServer().banIP(ip);
return;
}
- if (Settings.getMaxJoinPerIp > 0
- && !plugin.authmePermissible(player, "authme.allow2accounts")
- && !ip.equalsIgnoreCase("127.0.0.1")
- && !ip.equalsIgnoreCase("localhost")) {
+ if (Settings.getMaxJoinPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !ip.equalsIgnoreCase("127.0.0.1") && !ip.equalsIgnoreCase("localhost")) {
if (plugin.hasJoinedIp(player.getName(), ip)) {
player.kickPlayer("A player with the same IP is already in game!");
return;
@@ -594,10 +586,8 @@ public class AuthMePlayerListener implements Listener {
long timeout = Settings.getSessionTimeout * 60000;
long lastLogin = auth.getLastLogin();
long cur = new Date().getTime();
- if ((cur - lastLogin < timeout || timeout == 0)
- && !auth.getIp().equals("198.18.0.1")) {
- if (auth.getNickname().equalsIgnoreCase(name)
- && auth.getIp().equals(ip)) {
+ if ((cur - lastLogin < timeout || timeout == 0) && !auth.getIp().equals("198.18.0.1")) {
+ if (auth.getNickname().equalsIgnoreCase(name) && auth.getIp().equals(ip)) {
if (PlayerCache.getInstance().getAuth(name) != null) {
PlayerCache.getInstance().updatePlayer(auth);
} else {
@@ -607,8 +597,7 @@ public class AuthMePlayerListener implements Listener {
m._(player, "valid_session");
// Restore Permission Group
utils.setGroup(player, Utils.groupType.LOGGEDIN);
- plugin.getServer().getPluginManager()
- .callEvent(new SessionEvent(auth, true));
+ plugin.getServer().getPluginManager().callEvent(new SessionEvent(auth, true));
return;
} else if (!Settings.sessionExpireOnIpChange) {
GameMode gM = gameMode.get(name);
@@ -618,8 +607,7 @@ public class AuthMePlayerListener implements Listener {
player.kickPlayer(m._("unvalid_session")[0]);
return;
} else if (auth.getNickname().equalsIgnoreCase(name)) {
- if (Settings.isForceSurvivalModeEnabled
- && !Settings.forceOnlyAfterLogin) {
+ if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
this.causeByAuthMe = true;
Utils.forceGM(player);
this.causeByAuthMe = false;
@@ -642,38 +630,27 @@ public class AuthMePlayerListener implements Listener {
}
}
// isent in session or session was ended correctly
- if (Settings.isForceSurvivalModeEnabled
- && !Settings.forceOnlyAfterLogin) {
+ if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
this.causeByAuthMe = true;
Utils.forceGM(player);
this.causeByAuthMe = false;
}
- if (!Settings.noTeleport) if (Settings.isTeleportToSpawnEnabled
- || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds
- .contains(player.getWorld().getName()))) {
- SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player,
- player.getLocation(), spawnLoc, PlayerCache
- .getInstance().isAuthenticated(name));
- plugin.getServer().getPluginManager().callEvent(tpEvent);
- if (!tpEvent.isCancelled()) {
- if (player != null && player.isOnline()
- && tpEvent.getTo() != null) {
- player.teleport(tpEvent.getTo());
+ if (!Settings.noTeleport)
+ if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
+ SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
+ plugin.getServer().getPluginManager().callEvent(tpEvent);
+ if (!tpEvent.isCancelled()) {
+ if (player != null && player.isOnline() && tpEvent.getTo() != null) {
+ player.teleport(tpEvent.getTo());
+ }
}
}
- }
placePlayerSafely(player, spawnLoc);
LimboCache.getInstance().updateLimboPlayer(player);
- 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());
+ 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());
} else {
- if (Settings.isForceSurvivalModeEnabled
- && !Settings.forceOnlyAfterLogin) {
+ if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
this.causeByAuthMe = true;
Utils.forceGM(player);
this.causeByAuthMe = false;
@@ -681,20 +658,16 @@ public class AuthMePlayerListener implements Listener {
if (!Settings.unRegisteredGroup.isEmpty()) {
utils.setGroup(player, Utils.groupType.UNREGISTERED);
}
- if (!Settings.noTeleport) if (Settings.isTeleportToSpawnEnabled
- || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds
- .contains(player.getWorld().getName()))) {
- SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player,
- player.getLocation(), spawnLoc, PlayerCache
- .getInstance().isAuthenticated(name));
- plugin.getServer().getPluginManager().callEvent(tpEvent);
- if (!tpEvent.isCancelled()) {
- if (player != null && player.isOnline()
- && tpEvent.getTo() != null) {
- player.teleport(tpEvent.getTo());
+ if (!Settings.noTeleport)
+ if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
+ SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
+ plugin.getServer().getPluginManager().callEvent(tpEvent);
+ if (!tpEvent.isCancelled()) {
+ if (player != null && player.isOnline() && tpEvent.getTo() != null) {
+ player.teleport(tpEvent.getTo());
+ }
}
}
- }
if (!Settings.isForcedRegistrationEnabled) {
return;
}
@@ -702,59 +675,52 @@ public class AuthMePlayerListener implements Listener {
}
if (Settings.protectInventoryBeforeLogInEnabled) {
try {
- LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(
- player.getName().toLowerCase());
- ProtectInventoryEvent ev = new ProtectInventoryEvent(player,
- limbo.getInventory(), limbo.getArmour());
+ LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
+ ProtectInventoryEvent ev = new ProtectInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
plugin.getServer().getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
- if (!Settings.noConsoleSpam) ConsoleLogger
- .info("ProtectInventoryEvent has been cancelled for "
- + player.getName() + " ...");
+ if (!Settings.noConsoleSpam)
+ ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ...");
} else {
- API.setPlayerInventory(player, ev.getEmptyInventory(),
- ev.getEmptyArmor());
+ API.setPlayerInventory(player, ev.getEmptyInventory(), ev.getEmptyArmor());
}
} catch (NullPointerException ex) {
}
}
String[] msg;
if (Settings.emailRegistration) {
- msg = data.isAuthAvailable(name) ? m._("login_msg") : m
- ._("reg_email_msg");
+ msg = data.isAuthAvailable(name) ? m._("login_msg") : m._("reg_email_msg");
} else {
- msg = data.isAuthAvailable(name) ? m._("login_msg") : m
- ._("reg_msg");
+ msg = data.isAuthAvailable(name) ? m._("login_msg") : m._("reg_msg");
}
int time = Settings.getRegistrationTimeout * 20;
int msgInterval = Settings.getWarnMessageInterval;
if (time != 0) {
- int id = sched.scheduleSyncDelayedTask(plugin, new TimeoutTask(
- plugin, name), time);
- if (!LimboCache.getInstance().hasLimboPlayer(name)) LimboCache
- .getInstance().addLimboPlayer(player);
+ int id = sched.scheduleSyncDelayedTask(plugin, new TimeoutTask(plugin, name), time);
+ if (!LimboCache.getInstance().hasLimboPlayer(name))
+ LimboCache.getInstance().addLimboPlayer(player);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
- if (!LimboCache.getInstance().hasLimboPlayer(name)) LimboCache
- .getInstance().addLimboPlayer(player);
+ if (!LimboCache.getInstance().hasLimboPlayer(name))
+ LimboCache.getInstance().addLimboPlayer(player);
if (data.isAuthAvailable(name)) {
utils.setGroup(player, groupType.NOTLOGGEDIN);
} else {
utils.setGroup(player, groupType.UNREGISTERED);
}
- if (player.isOp()) player.setOp(false);
+ if (player.isOp())
+ player.setOp(false);
if (!Settings.isMovementAllowed) {
player.setAllowFlight(true);
player.setFlying(true);
}
- int msgT = sched.scheduleSyncDelayedTask(plugin, new MessageTask(
- plugin, name, msg, msgInterval));
+ int msgT = sched.scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, msg, msgInterval));
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
player.setNoDamageTicks(Settings.getRegistrationTimeout * 20);
- if (Settings.useEssentialsMotd) player.performCommand("motd");
- if (Settings.applyBlindEffect) player.addPotionEffect(new PotionEffect(
- PotionEffectType.BLINDNESS,
- Settings.getRegistrationTimeout * 20, 2));
+ if (Settings.useEssentialsMotd)
+ player.performCommand("motd");
+ if (Settings.applyBlindEffect)
+ player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
// Remove the join message while the player isn't logging in
if (Settings.enableProtection || Settings.delayJoinMessage) {
@@ -764,24 +730,18 @@ public class AuthMePlayerListener implements Listener {
}
private void placePlayerSafely(Player player, Location spawnLoc) {
- if (!Settings.noTeleport) return;
- if (Settings.isTeleportToSpawnEnabled
- || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds
- .contains(player.getWorld().getName()))) return;
+ if (!Settings.noTeleport)
+ return;
+ if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())))
+ return;
Block b = player.getLocation().getBlock();
- if (b.getType() == Material.PORTAL
- || b.getType() == Material.ENDER_PORTAL
- || b.getType() == Material.LAVA
- || b.getType() == Material.STATIONARY_LAVA) {
+ if (b.getType() == Material.PORTAL || b.getType() == Material.ENDER_PORTAL || b.getType() == Material.LAVA || b.getType() == Material.STATIONARY_LAVA) {
m._(player, "unsafe_spawn");
player.teleport(spawnLoc);
return;
}
Block c = player.getLocation().add(0D, 1D, 0D).getBlock();
- if (c.getType() == Material.PORTAL
- || c.getType() == Material.ENDER_PORTAL
- || c.getType() == Material.LAVA
- || c.getType() == Material.STATIONARY_LAVA) {
+ if (c.getType() == Material.PORTAL || c.getType() == Material.ENDER_PORTAL || c.getType() == Material.LAVA || c.getType() == Material.STATIONARY_LAVA) {
m._(player, "unsafe_spawn");
player.teleport(spawnLoc);
return;
@@ -798,56 +758,44 @@ public class AuthMePlayerListener implements Listener {
String name = player.getName().toLowerCase();
Location loc = player.getLocation();
- if (plugin.getCitizensCommunicator().isNPC(player, plugin)
- || Utils.getInstance().isUnrestricted(player)
- || CombatTagComunicator.isNPC(player)) {
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return;
}
String ip = plugin.getIP(player);
if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead()) {
- if (Settings.isSaveQuitLocationEnabled
- && data.isAuthAvailable(name)) {
- final PlayerAuth auth = new PlayerAuth(name, loc.getX(),
- loc.getY(), loc.getZ(), loc.getWorld().getName());
+ if (Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
+ final PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName());
try {
data.updateQuitLoc(auth);
} catch (NullPointerException npe) {
}
}
- PlayerAuth auth = new PlayerAuth(name, ip,
- System.currentTimeMillis());
+ PlayerAuth auth = new PlayerAuth(name, ip, System.currentTimeMillis());
data.updateSession(auth);
}
- if (data.getAuth(name) != null
- && !PlayerCache.getInstance().isAuthenticated(name)
- && Settings.enableProtection) event.setQuitMessage(null);
+ if (data.getAuth(name) != null && !PlayerCache.getInstance().isAuthenticated(name) && Settings.enableProtection)
+ event.setQuitMessage(null);
if (LimboCache.getInstance().hasLimboPlayer(name)) {
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
- if (Settings.protectInventoryBeforeLogInEnabled
- && player.hasPlayedBefore()) {
- RestoreInventoryEvent ev = new RestoreInventoryEvent(player,
- limbo.getInventory(), limbo.getArmour());
+ if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
+ RestoreInventoryEvent ev = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
plugin.getServer().getPluginManager().callEvent(ev);
if (!ev.isCancelled()) {
- API.setPlayerInventory(player, ev.getInventory(),
- ev.getArmor());
+ API.setPlayerInventory(player, ev.getInventory(), ev.getArmor());
}
}
utils.addNormal(player, limbo.getGroup());
player.setOp(limbo.getOperator());
- if (player.getGameMode() != GameMode.CREATIVE
- && !Settings.isMovementAllowed) {
+ if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
player.setAllowFlight(limbo.isFlying());
player.setFlying(limbo.isFlying());
}
- this.plugin.getServer().getScheduler()
- .cancelTask(limbo.getTimeoutTaskId());
- this.plugin.getServer().getScheduler()
- .cancelTask(limbo.getMessageTaskId());
+ this.plugin.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
+ this.plugin.getServer().getScheduler().cancelTask(limbo.getMessageTaskId());
LimboCache.getInstance().deleteLimboPlayer(name);
if (playerBackup.doesCacheExist(player)) {
playerBackup.removeCache(player);
@@ -859,7 +807,8 @@ public class AuthMePlayerListener implements Listener {
player.getVehicle().eject();
} catch (NullPointerException ex) {
}
- if (gameMode.containsKey(name)) gameMode.remove(name);
+ if (gameMode.containsKey(name))
+ gameMode.remove(name);
player.saveData();
}
@@ -875,15 +824,11 @@ public class AuthMePlayerListener implements Listener {
Player player = event.getPlayer();
Location loc = player.getLocation();
- if ((plugin.getCitizensCommunicator().isNPC(player, plugin))
- || (Utils.getInstance().isUnrestricted(player))
- || (CombatTagComunicator.isNPC(player))) {
+ if ((plugin.getCitizensCommunicator().isNPC(player, plugin)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) {
return;
}
- if ((Settings.isForceSingleSessionEnabled)
- && (event.getReason()
- .contains("You logged in from another location"))) {
+ if ((Settings.isForceSingleSessionEnabled) && (event.getReason().contains("You logged in from another location"))) {
event.setCancelled(true);
return;
}
@@ -891,65 +836,53 @@ public class AuthMePlayerListener implements Listener {
String name = player.getName().toLowerCase();
String ip = plugin.getIP(player);
- if ((PlayerCache.getInstance().isAuthenticated(name))
- && (!player.isDead())) {
- if ((Settings.isSaveQuitLocationEnabled)
- && data.isAuthAvailable(name)) {
- final PlayerAuth auth = new PlayerAuth(name, loc.getX(),
- loc.getY(), loc.getZ(), loc.getWorld().getName());
+ if ((PlayerCache.getInstance().isAuthenticated(name)) && (!player.isDead())) {
+ if ((Settings.isSaveQuitLocationEnabled) && data.isAuthAvailable(name)) {
+ final PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName());
try {
data.updateQuitLoc(auth);
} catch (NullPointerException npe) {
}
}
- PlayerAuth auth = new PlayerAuth(name, ip,
- System.currentTimeMillis());
+ PlayerAuth auth = new PlayerAuth(name, ip, System.currentTimeMillis());
data.updateSession(auth);
}
- if (data.getAuth(name) != null
- && !PlayerCache.getInstance().isAuthenticated(name)
- && Settings.enableProtection) event.setLeaveMessage(null);
+ if (data.getAuth(name) != null && !PlayerCache.getInstance().isAuthenticated(name) && Settings.enableProtection)
+ event.setLeaveMessage(null);
if (LimboCache.getInstance().hasLimboPlayer(name)) {
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
if (Settings.protectInventoryBeforeLogInEnabled) {
try {
- RestoreInventoryEvent ev = new RestoreInventoryEvent(
- player, limbo.getInventory(), limbo.getArmour());
+ RestoreInventoryEvent ev = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
plugin.getServer().getPluginManager().callEvent(ev);
if (!ev.isCancelled()) {
- API.setPlayerInventory(player, ev.getInventory(),
- ev.getArmor());
+ API.setPlayerInventory(player, ev.getInventory(), ev.getArmor());
}
} catch (NullPointerException npe) {
- ConsoleLogger.showError("Problem while restore " + name
- + " inventory after a kick");
+ ConsoleLogger.showError("Problem while restore " + name + " inventory after a kick");
}
}
- if (!Settings.noTeleport) try {
- AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player,
- limbo.getLoc());
- plugin.getServer().getPluginManager().callEvent(tpEvent);
- if (!tpEvent.isCancelled()) {
- if (player != null && player.isOnline()
- && tpEvent.getTo() != null) {
- player.teleport(tpEvent.getTo());
+ if (!Settings.noTeleport)
+ try {
+ AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
+ plugin.getServer().getPluginManager().callEvent(tpEvent);
+ if (!tpEvent.isCancelled()) {
+ if (player != null && player.isOnline() && tpEvent.getTo() != null) {
+ player.teleport(tpEvent.getTo());
+ }
}
+ } catch (NullPointerException npe) {
}
- } catch (NullPointerException npe) {
- }
this.utils.addNormal(player, limbo.getGroup());
player.setOp(limbo.getOperator());
- if (player.getGameMode() != GameMode.CREATIVE
- && !Settings.isMovementAllowed) {
+ if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
player.setAllowFlight(limbo.isFlying());
player.setFlying(limbo.isFlying());
}
- this.plugin.getServer().getScheduler()
- .cancelTask(limbo.getTimeoutTaskId());
- this.plugin.getServer().getScheduler()
- .cancelTask(limbo.getMessageTaskId());
+ this.plugin.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
+ this.plugin.getServer().getScheduler().cancelTask(limbo.getMessageTaskId());
LimboCache.getInstance().deleteLimboPlayer(name);
if (this.playerBackup.doesCacheExist(player)) {
this.playerBackup.removeCache(player);
@@ -957,7 +890,8 @@ public class AuthMePlayerListener implements Listener {
}
PlayerCache.getInstance().removePlayer(name);
data.setUnlogged(name);
- if (gameMode.containsKey(name)) gameMode.remove(name);
+ if (gameMode.containsKey(name))
+ gameMode.remove(name);
try {
player.getVehicle().eject();
} catch (NullPointerException ex) {
@@ -978,10 +912,10 @@ public class AuthMePlayerListener implements Listener {
return;
}
- if (plugin.getCitizensCommunicator().isNPC(player, plugin)) return;
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin))
+ return;
- if (PlayerCache.getInstance().isAuthenticated(
- player.getName().toLowerCase())) {
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
return;
}
@@ -996,7 +930,8 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerInteract(PlayerInteractEvent event) {
- if (event.isCancelled() || event.getPlayer() == null) return;
+ if (event.isCancelled() || event.getPlayer() == null)
+ return;
Player player = event.getPlayer();
String name = player.getName().toLowerCase();
@@ -1005,10 +940,10 @@ public class AuthMePlayerListener implements Listener {
return;
}
- if (plugin.getCitizensCommunicator().isNPC(player, plugin)) return;
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin))
+ return;
- if (PlayerCache.getInstance().isAuthenticated(
- player.getName().toLowerCase())) {
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
return;
}
@@ -1017,16 +952,16 @@ public class AuthMePlayerListener implements Listener {
return;
}
}
- if (event.getClickedBlock() != null
- && event.getClickedBlock().getType() != Material.AIR) event
- .setUseInteractedBlock(org.bukkit.event.Event.Result.DENY);
+ if (event.getClickedBlock() != null && event.getClickedBlock().getType() != Material.AIR)
+ event.setUseInteractedBlock(org.bukkit.event.Event.Result.DENY);
event.setUseItemInHand(org.bukkit.event.Event.Result.DENY);
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInventoryOpen(InventoryOpenEvent event) {
- if (event.isCancelled() || event.getPlayer() == null) return;
+ if (event.isCancelled() || event.getPlayer() == null)
+ return;
Player player = (Player) event.getPlayer();
String name = player.getName().toLowerCase();
@@ -1034,10 +969,10 @@ public class AuthMePlayerListener implements Listener {
return;
}
- if (plugin.getCitizensCommunicator().isNPC(player, plugin)) return;
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin))
+ return;
- if (PlayerCache.getInstance().isAuthenticated(
- player.getName().toLowerCase())) {
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
return;
}
@@ -1052,8 +987,10 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInventoryClick(InventoryClickEvent event) {
- if (event.isCancelled() || event.getWhoClicked() == null) return;
- if (!(event.getWhoClicked() instanceof Player)) return;
+ if (event.isCancelled() || event.getWhoClicked() == null)
+ return;
+ if (!(event.getWhoClicked() instanceof Player))
+ return;
Player player = (Player) event.getWhoClicked();
String name = player.getName().toLowerCase();
@@ -1061,10 +998,10 @@ public class AuthMePlayerListener implements Listener {
return;
}
- if (plugin.getCitizensCommunicator().isNPC(player, plugin)) return;
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin))
+ return;
- if (PlayerCache.getInstance().isAuthenticated(
- player.getName().toLowerCase())) {
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
return;
}
@@ -1086,14 +1023,11 @@ public class AuthMePlayerListener implements Listener {
Player player = event.getPlayer();
String name = player.getName().toLowerCase();
- if (plugin.getCitizensCommunicator().isNPC(player, plugin)
- || Utils.getInstance().isUnrestricted(player)
- || CombatTagComunicator.isNPC(player)) {
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return;
}
- if (PlayerCache.getInstance().isAuthenticated(
- player.getName().toLowerCase())) {
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
return;
}
@@ -1113,15 +1047,14 @@ public class AuthMePlayerListener implements Listener {
Player player = event.getPlayer();
String name = player.getName().toLowerCase();
- if (Utils.getInstance().isUnrestricted(player)
- || CombatTagComunicator.isNPC(player)) {
+ if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return;
}
- if (plugin.getCitizensCommunicator().isNPC(player, plugin)) return;
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin))
+ return;
- if (PlayerCache.getInstance().isAuthenticated(
- player.getName().toLowerCase())) {
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
return;
}
@@ -1145,8 +1078,7 @@ public class AuthMePlayerListener implements Listener {
return;
}
- if (PlayerCache.getInstance().isAuthenticated(
- player.getName().toLowerCase())) {
+ if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
return;
}
@@ -1188,19 +1120,22 @@ public class AuthMePlayerListener implements Listener {
Player player = event.getPlayer();
String name = player.getName().toLowerCase();
- if (Utils.getInstance().isUnrestricted(player)
- || CombatTagComunicator.isNPC(player)) return;
+ if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player))
+ return;
- if (plugin.getCitizensCommunicator().isNPC(player, plugin)) return;
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin))
+ return;
- if (PlayerCache.getInstance().isAuthenticated(name)) return;
+ if (PlayerCache.getInstance().isAuthenticated(name))
+ return;
- if (!data.isAuthAvailable(name)) if (!Settings.isForcedRegistrationEnabled) return;
+ if (!data.isAuthAvailable(name))
+ if (!Settings.isForcedRegistrationEnabled)
+ return;
Location spawn = plugin.getSpawnLocation(player);
if (Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
- final PlayerAuth auth = new PlayerAuth(name, spawn.getX(),
- spawn.getY(), spawn.getZ(), spawn.getWorld().getName());
+ final PlayerAuth auth = new PlayerAuth(name, spawn.getX(), spawn.getY(), spawn.getZ(), spawn.getWorld().getName());
try {
data.updateQuitLoc(auth);
} catch (NullPointerException npe) {
@@ -1211,26 +1146,35 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
- if (event.isCancelled()) return;
- if (event.getPlayer() == null || event == null) return;
- if (!Settings.isForceSurvivalModeEnabled) return;
+ if (event.isCancelled())
+ return;
+ if (event.getPlayer() == null || event == null)
+ return;
+ if (!Settings.isForceSurvivalModeEnabled)
+ return;
Player player = event.getPlayer();
- if (plugin.authmePermissible(player, "authme.bypassforcesurvival")) return;
+ if (plugin.authmePermissible(player, "authme.bypassforcesurvival"))
+ return;
String name = player.getName().toLowerCase();
- if (Utils.getInstance().isUnrestricted(player)
- || CombatTagComunicator.isNPC(player)) return;
+ if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player))
+ return;
- if (plugin.getCitizensCommunicator().isNPC(player, plugin)) return;
+ if (plugin.getCitizensCommunicator().isNPC(player, plugin))
+ return;
- if (PlayerCache.getInstance().isAuthenticated(name)) return;
+ if (PlayerCache.getInstance().isAuthenticated(name))
+ return;
- if (!data.isAuthAvailable(name)) if (!Settings.isForcedRegistrationEnabled) return;
+ if (!data.isAuthAvailable(name))
+ if (!Settings.isForcedRegistrationEnabled)
+ return;
- if (this.causeByAuthMe) return;
+ if (this.causeByAuthMe)
+ return;
event.setCancelled(true);
}
}
diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeServerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMeServerListener.java
index 29dbcf48..34970d9f 100644
--- a/src/main/java/fr/xephi/authme/listener/AuthMeServerListener.java
+++ b/src/main/java/fr/xephi/authme/listener/AuthMeServerListener.java
@@ -23,15 +23,15 @@ public class AuthMeServerListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onServerPing(ServerListPingEvent event) {
- if (!Settings.enableProtection) return;
- if (Settings.countries.isEmpty()) return;
+ if (!Settings.enableProtection)
+ return;
+ if (Settings.countries.isEmpty())
+ return;
if (!Settings.countriesBlacklist.isEmpty()) {
- if (Settings.countriesBlacklist.contains(plugin
- .getCountryCode(event.getAddress().getHostAddress()))) event
- .setMotd(m._("country_banned")[0]);
+ if (Settings.countriesBlacklist.contains(plugin.getCountryCode(event.getAddress().getHostAddress())))
+ event.setMotd(m._("country_banned")[0]);
}
- if (Settings.countries.contains(plugin.getCountryCode(event
- .getAddress().getHostAddress()))) {
+ if (Settings.countries.contains(plugin.getCountryCode(event.getAddress().getHostAddress()))) {
event.setMotd(plugin.getServer().getMotd());
} else {
event.setMotd(m._("country_banned")[0]);
@@ -74,24 +74,26 @@ public class AuthMeServerListener implements Listener {
}
if (pluginName.equalsIgnoreCase("Vault")) {
plugin.permission = null;
- ConsoleLogger
- .showError("Vault has been disabled, unhook permissions!");
+ ConsoleLogger.showError("Vault has been disabled, unhook permissions!");
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPluginEnable(PluginEnableEvent event) {
String pluginName = event.getPlugin().getName();
- if (pluginName.equalsIgnoreCase("Essentials")
- || pluginName.equalsIgnoreCase("EssentialsSpawn")) plugin
- .checkEssentials();
- if (pluginName.equalsIgnoreCase("Multiverse-Core")) plugin
- .checkMultiverse();
- if (pluginName.equalsIgnoreCase("Notifications")) plugin
- .checkNotifications();
- if (pluginName.equalsIgnoreCase("ChestShop")) plugin.checkChestShop();
- if (pluginName.equalsIgnoreCase("CombatTag")) plugin.combatTag();
- if (pluginName.equalsIgnoreCase("Citizens")) plugin.citizensVersion();
- if (pluginName.equalsIgnoreCase("Vault")) plugin.checkVault();
+ if (pluginName.equalsIgnoreCase("Essentials") || pluginName.equalsIgnoreCase("EssentialsSpawn"))
+ plugin.checkEssentials();
+ if (pluginName.equalsIgnoreCase("Multiverse-Core"))
+ plugin.checkMultiverse();
+ if (pluginName.equalsIgnoreCase("Notifications"))
+ plugin.checkNotifications();
+ if (pluginName.equalsIgnoreCase("ChestShop"))
+ plugin.checkChestShop();
+ if (pluginName.equalsIgnoreCase("CombatTag"))
+ plugin.combatTag();
+ if (pluginName.equalsIgnoreCase("Citizens"))
+ plugin.citizensVersion();
+ if (pluginName.equalsIgnoreCase("Vault"))
+ plugin.checkVault();
}
}
diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeSpoutListener.java b/src/main/java/fr/xephi/authme/listener/AuthMeSpoutListener.java
index fe29b711..0c0ec624 100644
--- a/src/main/java/fr/xephi/authme/listener/AuthMeSpoutListener.java
+++ b/src/main/java/fr/xephi/authme/listener/AuthMeSpoutListener.java
@@ -10,6 +10,7 @@ import fr.xephi.authme.gui.screens.LoginScreen;
import fr.xephi.authme.settings.SpoutCfg;
public class AuthMeSpoutListener implements Listener {
+
private DataSource data;
public AuthMeSpoutListener(DataSource data) {
@@ -19,11 +20,8 @@ public class AuthMeSpoutListener implements Listener {
@EventHandler
public void onSpoutCraftEnable(final SpoutCraftEnableEvent event) {
if (SpoutCfg.getInstance().getBoolean("LoginScreen.enabled")) {
- if (data.isAuthAvailable(event.getPlayer().getName().toLowerCase())
- && !PlayerCache.getInstance().isAuthenticated(
- event.getPlayer().getName().toLowerCase())) {
- event.getPlayer().getMainScreen()
- .attachPopupScreen(new LoginScreen(event.getPlayer()));
+ if (data.isAuthAvailable(event.getPlayer().getName().toLowerCase()) && !PlayerCache.getInstance().isAuthenticated(event.getPlayer().getName().toLowerCase())) {
+ event.getPlayer().getMainScreen().attachPopupScreen(new LoginScreen(event.getPlayer()));
}
}
}
diff --git a/src/main/java/fr/xephi/authme/plugin/manager/BungeeCordMessage.java b/src/main/java/fr/xephi/authme/plugin/manager/BungeeCordMessage.java
index f7ad284c..b1014077 100644
--- a/src/main/java/fr/xephi/authme/plugin/manager/BungeeCordMessage.java
+++ b/src/main/java/fr/xephi/authme/plugin/manager/BungeeCordMessage.java
@@ -24,8 +24,7 @@ public class BungeeCordMessage implements PluginMessageListener {
return;
}
try {
- final DataInputStream in = new DataInputStream(
- new ByteArrayInputStream(message));
+ final DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
String subchannel = in.readUTF();
if (subchannel.equals("IP")) { // We need only the IP channel
String ip = in.readUTF();
diff --git a/src/main/java/fr/xephi/authme/plugin/manager/CombatTagComunicator.java b/src/main/java/fr/xephi/authme/plugin/manager/CombatTagComunicator.java
index e16baf20..6416e6cc 100644
--- a/src/main/java/fr/xephi/authme/plugin/manager/CombatTagComunicator.java
+++ b/src/main/java/fr/xephi/authme/plugin/manager/CombatTagComunicator.java
@@ -19,8 +19,7 @@ public abstract class CombatTagComunicator {
public static boolean isNPC(Entity player) {
try {
if (Bukkit.getServer().getPluginManager().getPlugin("CombatTag") != null) {
- combatApi = new CombatTagApi((CombatTag) Bukkit.getServer()
- .getPluginManager().getPlugin("CombatTag"));
+ combatApi = new CombatTagApi((CombatTag) Bukkit.getServer().getPluginManager().getPlugin("CombatTag"));
try {
combatApi.getClass().getMethod("isNPC");
} catch (Exception e) {
diff --git a/src/main/java/fr/xephi/authme/plugin/manager/EssSpawn.java b/src/main/java/fr/xephi/authme/plugin/manager/EssSpawn.java
index 7ab5a089..16572023 100644
--- a/src/main/java/fr/xephi/authme/plugin/manager/EssSpawn.java
+++ b/src/main/java/fr/xephi/authme/plugin/manager/EssSpawn.java
@@ -12,7 +12,7 @@ public class EssSpawn extends CustomConfiguration {
private static EssSpawn spawn;
public EssSpawn() {
- super(new File("./plugins/Essentials/spawn.yml"));
+ super(new File("." + File.separator + "plugins" + File.separator + "Essentials" + File.separator + "spawn.yml"));
spawn = this;
load();
}
@@ -26,16 +26,11 @@ public class EssSpawn extends CustomConfiguration {
public Location getLocation() {
try {
- if (!this.contains("spawns.default.world")) return null;
- if (this.getString("spawns.default.world").isEmpty()
- || this.getString("spawns.default.world") == "") return null;
- Location location = new Location(Bukkit.getWorld(this
- .getString("spawns.default.world")),
- this.getDouble("spawns.default.x"),
- this.getDouble("spawns.default.y"),
- this.getDouble("spawns.default.z"), Float.parseFloat(this
- .getString("spawns.default.yaw")),
- Float.parseFloat(this.getString("spawns.default.pitch")));
+ if (!this.contains("spawns.default.world"))
+ return null;
+ if (this.getString("spawns.default.world").isEmpty() || this.getString("spawns.default.world") == "")
+ return null;
+ Location location = new Location(Bukkit.getWorld(this.getString("spawns.default.world")), this.getDouble("spawns.default.x"), this.getDouble("spawns.default.y"), this.getDouble("spawns.default.z"), Float.parseFloat(this.getString("spawns.default.yaw")), Float.parseFloat(this.getString("spawns.default.pitch")));
return location;
} catch (NullPointerException npe) {
return null;
diff --git a/src/main/java/fr/xephi/authme/process/Management.java b/src/main/java/fr/xephi/authme/process/Management.java
index fc52dd74..bdcd1de5 100644
--- a/src/main/java/fr/xephi/authme/process/Management.java
+++ b/src/main/java/fr/xephi/authme/process/Management.java
@@ -17,6 +17,7 @@ import fr.xephi.authme.settings.Settings;
*
*/
public class Management extends Thread {
+
public DataSource database;
public AuthMe plugin;
public static RandomString rdm = new RandomString(Settings.captchaLength);
@@ -33,13 +34,11 @@ public class Management extends Thread {
public void performLogin(final Player player, final String password,
final boolean forceLogin) {
- new AsyncronousLogin(player, password, forceLogin, plugin, database)
- .process();
+ new AsyncronousLogin(player, password, forceLogin, plugin, database).process();
}
public void performRegister(final Player player, final String password,
final String email) {
- new AsyncronousRegister(player, password, email, plugin, database)
- .process();
+ new AsyncronousRegister(player, password, email, plugin, database).process();
}
}
diff --git a/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java b/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java
index a72a5051..c2da7709 100644
--- a/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java
+++ b/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java
@@ -22,6 +22,7 @@ import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.task.MessageTask;
public class AsyncronousLogin {
+
protected Player player;
protected String name;
protected String password;
@@ -56,17 +57,13 @@ public class AsyncronousLogin {
plugin.captcha.remove(name);
plugin.captcha.put(name, i);
}
- if (plugin.captcha.containsKey(name)
- && plugin.captcha.get(name) >= Settings.maxLoginTry) {
+ if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) >= Settings.maxLoginTry) {
plugin.cap.put(name, rdm.nextString());
for (String s : m._("usage_captcha")) {
- player.sendMessage(s.replace("THE_CAPTCHA",
- plugin.cap.get(name)).replace("",
- plugin.cap.get(name)));
+ player.sendMessage(s.replace("THE_CAPTCHA", plugin.cap.get(name)).replace("", plugin.cap.get(name)));
}
return true;
- } else if (plugin.captcha.containsKey(name)
- && plugin.captcha.get(name) >= Settings.maxLoginTry) {
+ } else if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) >= Settings.maxLoginTry) {
try {
plugin.captcha.remove(name);
plugin.cap.remove(name);
@@ -89,28 +86,19 @@ public class AsyncronousLogin {
if (!database.isAuthAvailable(name)) {
m._(player, "user_unknown");
if (LimboCache.getInstance().hasLimboPlayer(name)) {
- Bukkit.getScheduler().cancelTask(
- LimboCache.getInstance().getLimboPlayer(name)
- .getMessageTaskId());
+ Bukkit.getScheduler().cancelTask(LimboCache.getInstance().getLimboPlayer(name).getMessageTaskId());
String[] msg;
if (Settings.emailRegistration) {
msg = m._("reg_email_msg");
} else {
msg = m._("reg_msg");
}
- int msgT = Bukkit.getScheduler().scheduleSyncDelayedTask(
- plugin,
- new MessageTask(plugin, name, msg,
- Settings.getWarnMessageInterval));
- LimboCache.getInstance().getLimboPlayer(name)
- .setMessageTaskId(msgT);
+ int msgT = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, msg, Settings.getWarnMessageInterval));
+ LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
}
return null;
}
- if (Settings.getMaxLoginPerIp > 0
- && !plugin.authmePermissible(player, "authme.allow2accounts")
- && !getIP().equalsIgnoreCase("127.0.0.1")
- && !getIP().equalsIgnoreCase("localhost")) {
+ if (Settings.getMaxLoginPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !getIP().equalsIgnoreCase("127.0.0.1") && !getIP().equalsIgnoreCase("localhost")) {
if (plugin.isLoggedIp(realName, getIP())) {
m._(player, "logged_in");
return null;
@@ -121,8 +109,7 @@ public class AsyncronousLogin {
m._(player, "user_unknown");
return null;
}
- if (!Settings.getMySQLColumnGroup.isEmpty()
- && pAuth.getGroupId() == Settings.getNonActivatedGroup) {
+ if (!Settings.getMySQLColumnGroup.isEmpty() && pAuth.getGroupId() == Settings.getNonActivatedGroup) {
m._(player, "vb_nonActiv");
return null;
}
@@ -131,22 +118,22 @@ public class AsyncronousLogin {
public void process() {
PlayerAuth pAuth = preAuth();
- if (pAuth == null || needsCaptcha()) return;
+ if (pAuth == null || needsCaptcha())
+ return;
String hash = pAuth.getHash();
String email = pAuth.getEmail();
boolean passwordVerified = true;
- if (!forceLogin) try {
- passwordVerified = PasswordSecurity.comparePasswordWithHash(
- password, hash, realName);
- } catch (Exception ex) {
- ConsoleLogger.showError(ex.getMessage());
- m._(player, "error");
- return;
- }
+ if (!forceLogin)
+ try {
+ passwordVerified = PasswordSecurity.comparePasswordWithHash(password, hash, realName);
+ } catch (Exception ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ m._(player, "error");
+ return;
+ }
if (passwordVerified && player.isOnline()) {
- PlayerAuth auth = new PlayerAuth(name, hash, getIP(),
- new Date().getTime(), email, realName);
+ PlayerAuth auth = new PlayerAuth(name, hash, getIP(), new Date().getTime(), email, realName);
database.updateSession(auth);
if (Settings.useCaptcha) {
@@ -163,12 +150,11 @@ public class AsyncronousLogin {
displayOtherAccounts(auth, player);
- if (!Settings.noConsoleSpam) ConsoleLogger.info(player.getName()
- + " logged in!");
+ if (!Settings.noConsoleSpam)
+ ConsoleLogger.info(player.getName() + " logged in!");
if (plugin.notifications != null) {
- plugin.notifications.showNotification(new Notification(
- "[AuthMe] " + player.getName() + " logged in!"));
+ plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " logged in!"));
}
// makes player isLoggedin via API
@@ -180,46 +166,32 @@ public class AsyncronousLogin {
// task, we schedule it in the end
// so that we can be sure, and have not to care if it might be
// processed in other order.
- ProcessSyncronousPlayerLogin syncronousPlayerLogin = new ProcessSyncronousPlayerLogin(
- player, plugin, database);
+ ProcessSyncronousPlayerLogin syncronousPlayerLogin = new ProcessSyncronousPlayerLogin(player, plugin, database);
if (syncronousPlayerLogin.getLimbo() != null) {
- player.getServer()
- .getScheduler()
- .cancelTask(
- syncronousPlayerLogin.getLimbo()
- .getTimeoutTaskId());
- player.getServer()
- .getScheduler()
- .cancelTask(
- syncronousPlayerLogin.getLimbo()
- .getMessageTaskId());
+ player.getServer().getScheduler().cancelTask(syncronousPlayerLogin.getLimbo().getTimeoutTaskId());
+ player.getServer().getScheduler().cancelTask(syncronousPlayerLogin.getLimbo().getMessageTaskId());
}
- Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
- syncronousPlayerLogin);
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, syncronousPlayerLogin);
} else if (player.isOnline()) {
- if (!Settings.noConsoleSpam) ConsoleLogger.info(player.getName()
- + " used the wrong password");
+ if (!Settings.noConsoleSpam)
+ ConsoleLogger.info(player.getName() + " used the wrong password");
if (Settings.isKickOnWrongPasswordEnabled) {
- Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
- new Runnable() {
- @Override
- public void run() {
- if (AuthMePlayerListener.gameMode != null
- && AuthMePlayerListener.gameMode
- .containsKey(name)) {
- player.setGameMode(AuthMePlayerListener.gameMode
- .get(name));
- }
- player.kickPlayer(m._("wrong_pwd")[0]);
- }
- });
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+
+ @Override
+ public void run() {
+ if (AuthMePlayerListener.gameMode != null && AuthMePlayerListener.gameMode.containsKey(name)) {
+ player.setGameMode(AuthMePlayerListener.gameMode.get(name));
+ }
+ player.kickPlayer(m._("wrong_pwd")[0]);
+ }
+ });
} else {
m._(player, "wrong_pwd");
return;
}
} else {
- ConsoleLogger.showError("Player " + name
- + " wasn't online during login process, aborted... ");
+ ConsoleLogger.showError("Player " + name + " wasn't online during login process, aborted... ");
}
}
@@ -260,8 +232,7 @@ public class AsyncronousLogin {
*/
for (Player player : plugin.getServer().getOnlinePlayers()) {
if (plugin.authmePermissible(player, "authme.seeOtherAccounts")) {
- player.sendMessage("[AuthMe] The player " + auth.getNickname()
- + " has " + auths.size() + " accounts");
+ player.sendMessage("[AuthMe] The player " + auth.getNickname() + " has " + auths.size() + " accounts");
player.sendMessage(message);
// player.sendMessage(uuidaccounts.replace("%size%",
// ""+uuidlist.size()));
diff --git a/src/main/java/fr/xephi/authme/process/login/ProcessSyncronousPlayerLogin.java b/src/main/java/fr/xephi/authme/process/login/ProcessSyncronousPlayerLogin.java
index 77ea73bf..58951c5d 100644
--- a/src/main/java/fr/xephi/authme/process/login/ProcessSyncronousPlayerLogin.java
+++ b/src/main/java/fr/xephi/authme/process/login/ProcessSyncronousPlayerLogin.java
@@ -24,6 +24,7 @@ import fr.xephi.authme.listener.AuthMePlayerListener;
import fr.xephi.authme.settings.Settings;
public class ProcessSyncronousPlayerLogin implements Runnable {
+
private LimboPlayer limbo;
private Player player;
private String name;
@@ -51,21 +52,18 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
protected void restoreOpState() {
player.setOp(limbo.getOperator());
- if (player.getGameMode() != GameMode.CREATIVE
- && !Settings.isMovementAllowed) {
+ if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
player.setAllowFlight(limbo.isFlying());
player.setFlying(limbo.isFlying());
}
}
protected void packQuitLocation() {
- Utils.getInstance().packCoords(auth.getQuitLocX(), auth.getQuitLocY(),
- auth.getQuitLocZ(), auth.getWorld(), player);
+ Utils.getInstance().packCoords(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), player);
}
protected void teleportBackFromSpawn() {
- AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player,
- limbo.getLoc());
+ AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
pm.callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
Location fLoc = tpEvent.getTo();
@@ -78,8 +76,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
protected void teleportToSpawn() {
Location spawnL = plugin.getSpawnLocation(player);
- SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player,
- player.getLocation(), spawnL, true);
+ SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnL, true);
pm.callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
Location fLoc = tpEvent.getTo();
@@ -91,12 +88,10 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
}
protected void restoreInventory() {
- RestoreInventoryEvent event = new RestoreInventoryEvent(player,
- limbo.getInventory(), limbo.getArmour());
+ RestoreInventoryEvent event = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
- API.setPlayerInventory(player, event.getInventory(),
- event.getArmor());
+ API.setPlayerInventory(player, event.getInventory(), event.getArmor());
}
}
@@ -108,9 +103,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
}
}
for (String command : Settings.forceCommandsAsConsole) {
- Bukkit.getServer().dispatchCommand(
- Bukkit.getServer().getConsoleSender(),
- command.replace("%p", player.getName()));
+ Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command.replace("%p", player.getName()));
}
}
@@ -132,16 +125,14 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
// Inventory - Make it after restore GameMode , cause we need to
// restore the
// right inventory in the right gamemode
- if (Settings.protectInventoryBeforeLogInEnabled
- && player.hasPlayedBefore()) {
+ if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
restoreInventory();
}
} else {
// Inventory - Make it before force the survival GameMode to
// cancel all
// inventory problem
- if (Settings.protectInventoryBeforeLogInEnabled
- && player.hasPlayedBefore()) {
+ if (Settings.protectInventoryBeforeLogInEnabled && player.hasPlayedBefore()) {
restoreInventory();
}
player.setGameMode(GameMode.SURVIVAL);
@@ -149,22 +140,15 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
if (!Settings.noTeleport) {
// Teleport
- if (Settings.isTeleportToSpawnEnabled
- && !Settings.isForceSpawnLocOnJoinEnabled
- && Settings.getForcedWorlds.contains(player.getWorld()
- .getName())) {
- if (Settings.isSaveQuitLocationEnabled
- && auth.getQuitLocY() != 0) {
+ if (Settings.isTeleportToSpawnEnabled && !Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
+ if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) {
packQuitLocation();
} else {
teleportBackFromSpawn();
}
- } else if (Settings.isForceSpawnLocOnJoinEnabled
- && Settings.getForcedWorlds.contains(player.getWorld()
- .getName())) {
+ } else if (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
teleportToSpawn();
- } else if (Settings.isSaveQuitLocationEnabled
- && auth.getQuitLocY() != 0) {
+ } else if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) {
packQuitLocation();
} else {
teleportBackFromSpawn();
@@ -173,7 +157,8 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
// Re-Force Survival GameMode if we need due to world change
// specification
- if (Settings.isForceSurvivalModeEnabled) Utils.forceGM(player);
+ if (Settings.isForceSurvivalModeEnabled)
+ Utils.forceGM(player);
// Restore Permission Group
Utils.getInstance().setGroup(player, groupType.LOGGEDIN);
@@ -186,35 +171,32 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
}
// We can now display the join message
- if (AuthMePlayerListener.joinMessage.containsKey(name)
- && AuthMePlayerListener.joinMessage.get(name) != null
- && !AuthMePlayerListener.joinMessage.get(name).isEmpty()) {
+ if (AuthMePlayerListener.joinMessage.containsKey(name) && AuthMePlayerListener.joinMessage.get(name) != null && !AuthMePlayerListener.joinMessage.get(name).isEmpty()) {
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
- if (p.isOnline()) p
- .sendMessage(AuthMePlayerListener.joinMessage.get(name));
+ if (p.isOnline())
+ p.sendMessage(AuthMePlayerListener.joinMessage.get(name));
}
AuthMePlayerListener.joinMessage.remove(name);
}
- if (Settings.applyBlindEffect) player
- .removePotionEffect(PotionEffectType.BLINDNESS);
+ if (Settings.applyBlindEffect)
+ player.removePotionEffect(PotionEffectType.BLINDNESS);
// The Loginevent now fires (as intended) after everything is processed
- Bukkit.getServer().getPluginManager()
- .callEvent(new LoginEvent(player, true));
+ Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
player.saveData();
// Login is finish, display welcome message
- if (Settings.useWelcomeMessage) if (Settings.broadcastWelcomeMessage) {
- for (String s : Settings.welcomeMsg) {
- Bukkit.getServer().broadcastMessage(
- plugin.replaceAllInfos(s, player));
+ if (Settings.useWelcomeMessage)
+ if (Settings.broadcastWelcomeMessage) {
+ for (String s : Settings.welcomeMsg) {
+ Bukkit.getServer().broadcastMessage(plugin.replaceAllInfos(s, player));
+ }
+ } else {
+ for (String s : Settings.welcomeMsg) {
+ player.sendMessage(plugin.replaceAllInfos(s, player));
+ }
}
- } else {
- for (String s : Settings.welcomeMsg) {
- player.sendMessage(plugin.replaceAllInfos(s, player));
- }
- }
// Login is now finish , we can force all commands
forceCommands();
diff --git a/src/main/java/fr/xephi/authme/process/register/AsyncronousRegister.java b/src/main/java/fr/xephi/authme/process/register/AsyncronousRegister.java
index 09ab2b17..46e9ea02 100644
--- a/src/main/java/fr/xephi/authme/process/register/AsyncronousRegister.java
+++ b/src/main/java/fr/xephi/authme/process/register/AsyncronousRegister.java
@@ -54,29 +54,21 @@ public class AsyncronousRegister {
}
String lowpass = password.toLowerCase();
- if ((lowpass.contains("delete") || lowpass.contains("where")
- || lowpass.contains("insert") || lowpass.contains("modify")
- || lowpass.contains("from") || lowpass.contains("select")
- || lowpass.contains(";") || lowpass.contains("null"))
- || !lowpass.matches(Settings.getPassRegex)) {
+ if ((lowpass.contains("delete") || lowpass.contains("where") || lowpass.contains("insert") || lowpass.contains("modify") || lowpass.contains("from") || lowpass.contains("select") || lowpass.contains(";") || lowpass.contains("null")) || !lowpass.matches(Settings.getPassRegex)) {
m._(player, "password_error");
allowRegister = false;
}
if (database.isAuthAvailable(player.getName().toLowerCase())) {
m._(player, "user_regged");
- if (plugin.pllog.getStringList("players")
- .contains(player.getName())) {
+ if (plugin.pllog.getStringList("players").contains(player.getName())) {
plugin.pllog.getStringList("players").remove(player.getName());
}
allowRegister = false;
}
if (Settings.getmaxRegPerIp > 0) {
- if (!plugin.authmePermissible(player, "authme.allow2accounts")
- && database.getAllAuthsByIp(getIp()).size() >= Settings.getmaxRegPerIp
- && !getIp().equalsIgnoreCase("127.0.0.1")
- && !getIp().equalsIgnoreCase("localhost")) {
+ if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByIp(getIp()).size() >= Settings.getmaxRegPerIp && !getIp().equalsIgnoreCase("127.0.0.1") && !getIp().equalsIgnoreCase("localhost")) {
m._(player, "max_reg");
allowRegister = false;
}
@@ -86,11 +78,11 @@ public class AsyncronousRegister {
public void process() {
preRegister();
- if (!allowRegister) return;
+ if (!allowRegister)
+ return;
if (!email.isEmpty() && email != "") {
if (Settings.getmaxRegPerEmail > 0) {
- if (!plugin.authmePermissible(player, "authme.allow2accounts")
- && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
+ if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
m._(player, "max_reg");
return;
}
@@ -103,21 +95,15 @@ public class AsyncronousRegister {
protected void emailRegister() {
if (Settings.getmaxRegPerEmail > 0) {
- if (!plugin.authmePermissible(player, "authme.allow2accounts")
- && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
+ if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
m._(player, "max_reg");
return;
}
}
PlayerAuth auth = null;
try {
- final String hashnew = PasswordSecurity.getHash(
- Settings.getPasswordHash, password, name);
- auth = new PlayerAuth(name, hashnew, getIp(), 0,
- (int) player.getLocation().getX(), (int) player
- .getLocation().getY(), (int) player.getLocation()
- .getZ(), player.getLocation().getWorld().getName(),
- email, realName);
+ final String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
+ auth = new PlayerAuth(name, hashnew, getIp(), 0, (int) player.getLocation().getX(), (int) player.getLocation().getY(), (int) player.getLocation().getZ(), player.getLocation().getWorld().getName(), email, realName);
} catch (NoSuchAlgorithmException e) {
ConsoleLogger.showError(e.getMessage());
m._(player, "error");
@@ -130,16 +116,13 @@ public class AsyncronousRegister {
database.updateEmail(auth);
database.updateSession(auth);
plugin.mail.main(auth, password);
- ProcessSyncronousEmailRegister syncronous = new ProcessSyncronousEmailRegister(
- player, plugin);
- plugin.getServer().getScheduler()
- .scheduleSyncDelayedTask(plugin, syncronous);
+ ProcessSyncronousEmailRegister syncronous = new ProcessSyncronousEmailRegister(player, plugin);
+ plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, syncronous);
return;
}
protected void passwordRegister() {
- if (password.length() < Settings.getPasswordMinLen
- || password.length() > Settings.passwordMaxLength) {
+ if (password.length() < Settings.getPasswordMinLen || password.length() > Settings.passwordMaxLength) {
m._(player, "pass_len");
return;
}
@@ -152,21 +135,16 @@ public class AsyncronousRegister {
PlayerAuth auth = null;
String hash = "";
try {
- hash = PasswordSecurity.getHash(Settings.getPasswordHash, password,
- name);
+ hash = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
} catch (NoSuchAlgorithmException e) {
ConsoleLogger.showError(e.getMessage());
m._(player, "error");
return;
}
- if (Settings.getMySQLColumnSalt.isEmpty()
- && !PasswordSecurity.userSalt.containsKey(name)) {
- auth = new PlayerAuth(name, hash, getIp(), new Date().getTime(),
- "your@email.com", player.getName());
+ if (Settings.getMySQLColumnSalt.isEmpty() && !PasswordSecurity.userSalt.containsKey(name)) {
+ auth = new PlayerAuth(name, hash, getIp(), new Date().getTime(), "your@email.com", player.getName());
} else {
- auth = new PlayerAuth(name, hash,
- PasswordSecurity.userSalt.get(name), getIp(),
- new Date().getTime(), player.getName());
+ auth = new PlayerAuth(name, hash, PasswordSecurity.userSalt.get(name), getIp(), new Date().getTime(), player.getName());
}
if (!database.saveAuth(auth)) {
m._(player, "error");
@@ -177,10 +155,8 @@ public class AsyncronousRegister {
database.setLogged(name);
}
plugin.otherAccounts.addPlayer(player.getUniqueId());
- ProcessSyncronousPasswordRegister syncronous = new ProcessSyncronousPasswordRegister(
- player, plugin);
- plugin.getServer().getScheduler()
- .scheduleSyncDelayedTask(plugin, syncronous);
+ ProcessSyncronousPasswordRegister syncronous = new ProcessSyncronousPasswordRegister(player, plugin);
+ plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, syncronous);
return;
}
}
diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousEmailRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousEmailRegister.java
index 9428d96d..a00dc693 100644
--- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousEmailRegister.java
+++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousEmailRegister.java
@@ -40,48 +40,37 @@ public class ProcessSyncronousEmailRegister implements Runnable {
int time = Settings.getRegistrationTimeout * 20;
int msgInterval = Settings.getWarnMessageInterval;
if (time != 0) {
- Bukkit.getScheduler().cancelTask(
- LimboCache.getInstance().getLimboPlayer(name)
- .getTimeoutTaskId());
- int id = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
- new TimeoutTask(plugin, name), time);
+ Bukkit.getScheduler().cancelTask(LimboCache.getInstance().getLimboPlayer(name).getTimeoutTaskId());
+ int id = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new TimeoutTask(plugin, name), time);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
- Bukkit.getScheduler().cancelTask(
- LimboCache.getInstance().getLimboPlayer(name)
- .getMessageTaskId());
- int nwMsg = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
- new MessageTask(plugin, name, m._("login_msg"), msgInterval));
+ Bukkit.getScheduler().cancelTask(LimboCache.getInstance().getLimboPlayer(name).getMessageTaskId());
+ int nwMsg = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("login_msg"), msgInterval));
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(nwMsg);
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location loca = plugin.getSpawnLocation(player);
- RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player,
- loca);
+ RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
- if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo())
- .isLoaded()) {
- tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo())
- .load();
+ if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
+ tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
}
player.teleport(tpEvent.getTo());
}
}
- if (player.getGameMode() != GameMode.CREATIVE
- && !Settings.isMovementAllowed) {
+ if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
player.setAllowFlight(false);
player.setFlying(false);
}
- if (Settings.applyBlindEffect) player
- .removePotionEffect(PotionEffectType.BLINDNESS);
+ if (Settings.applyBlindEffect)
+ player.removePotionEffect(PotionEffectType.BLINDNESS);
player.saveData();
- if (!Settings.noConsoleSpam) ConsoleLogger.info(player.getName()
- + " registered " + plugin.getIP(player));
+ if (!Settings.noConsoleSpam)
+ ConsoleLogger.info(player.getName() + " registered " + plugin.getIP(player));
if (plugin.notifications != null) {
- plugin.notifications.showNotification(new Notification("[AuthMe] "
- + player.getName() + " has registered by email!"));
+ plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered by email!"));
}
}
diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java
index ed8d2872..f3de0de5 100644
--- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java
+++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java
@@ -47,35 +47,31 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
protected void forceLogin(Player player) {
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location spawnLoc = plugin.getSpawnLocation(player);
- AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player,
- spawnLoc);
+ AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
- if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo())
- .isLoaded()) {
- tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo())
- .load();
+ if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
+ tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
}
player.teleport(tpEvent.getTo());
}
}
- if (LimboCache.getInstance().hasLimboPlayer(name)) LimboCache
- .getInstance().deleteLimboPlayer(name);
+ if (LimboCache.getInstance().hasLimboPlayer(name))
+ LimboCache.getInstance().deleteLimboPlayer(name);
LimboCache.getInstance().addLimboPlayer(player);
int delay = Settings.getRegistrationTimeout * 20;
int interval = Settings.getWarnMessageInterval;
BukkitScheduler sched = plugin.getServer().getScheduler();
if (delay != 0) {
- int id = sched.scheduleSyncDelayedTask(plugin, new TimeoutTask(
- plugin, name), delay);
+ int id = sched.scheduleSyncDelayedTask(plugin, new TimeoutTask(plugin, name), delay);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
}
- int msgT = sched.scheduleSyncDelayedTask(plugin, new MessageTask(
- plugin, name, m._("login_msg"), interval));
+ int msgT = sched.scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("login_msg"), interval));
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
try {
plugin.pllog.removePlayer(name);
- if (player.isInsideVehicle()) player.getVehicle().eject();
+ if (player.isInsideVehicle())
+ player.getVehicle().eject();
} catch (NullPointerException npe) {
}
}
@@ -87,22 +83,17 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
player.setGameMode(limbo.getGameMode());
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
Location loca = plugin.getSpawnLocation(player);
- RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(
- player, loca);
+ RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
- if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo())
- .isLoaded()) {
- tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo())
- .load();
+ if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
+ tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
}
player.teleport(tpEvent.getTo());
}
}
- plugin.getServer().getScheduler()
- .cancelTask(limbo.getTimeoutTaskId());
- plugin.getServer().getScheduler()
- .cancelTask(limbo.getMessageTaskId());
+ plugin.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
+ plugin.getServer().getScheduler().cancelTask(limbo.getMessageTaskId());
LimboCache.getInstance().deleteLimboPlayer(name);
}
@@ -110,24 +101,22 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
Utils.getInstance().setGroup(player, Utils.groupType.REGISTERED);
}
m._(player, "registered");
- if (!Settings.getmailAccount.isEmpty()) m._(player, "add_email");
- if (player.getGameMode() != GameMode.CREATIVE
- && !Settings.isMovementAllowed) {
+ if (!Settings.getmailAccount.isEmpty())
+ m._(player, "add_email");
+ if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
player.setAllowFlight(false);
player.setFlying(false);
}
- if (Settings.applyBlindEffect) player
- .removePotionEffect(PotionEffectType.BLINDNESS);
+ if (Settings.applyBlindEffect)
+ player.removePotionEffect(PotionEffectType.BLINDNESS);
// The Loginevent now fires (as intended) after everything is processed
- Bukkit.getServer().getPluginManager()
- .callEvent(new LoginEvent(player, true));
+ Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
player.saveData();
- if (!Settings.noConsoleSpam) ConsoleLogger.info(player.getName()
- + " registered " + plugin.getIP(player));
+ if (!Settings.noConsoleSpam)
+ ConsoleLogger.info(player.getName() + " registered " + plugin.getIP(player));
if (plugin.notifications != null) {
- plugin.notifications.showNotification(new Notification("[AuthMe] "
- + player.getName() + " has registered!"));
+ plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered!"));
}
// Kick Player after Registration is enabled, kick the player
@@ -143,16 +132,16 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
}
// Register is finish and player is logged, display welcome message
- if (Settings.useWelcomeMessage) if (Settings.broadcastWelcomeMessage) {
- for (String s : Settings.welcomeMsg) {
- Bukkit.getServer().broadcastMessage(
- plugin.replaceAllInfos(s, player));
+ if (Settings.useWelcomeMessage)
+ if (Settings.broadcastWelcomeMessage) {
+ for (String s : Settings.welcomeMsg) {
+ Bukkit.getServer().broadcastMessage(plugin.replaceAllInfos(s, player));
+ }
+ } else {
+ for (String s : Settings.welcomeMsg) {
+ player.sendMessage(plugin.replaceAllInfos(s, player));
+ }
}
- } else {
- for (String s : Settings.welcomeMsg) {
- player.sendMessage(plugin.replaceAllInfos(s, player));
- }
- }
// Register is now finish , we can force all commands
forceCommands(player);
diff --git a/src/main/java/fr/xephi/authme/security/HashAlgorithm.java b/src/main/java/fr/xephi/authme/security/HashAlgorithm.java
index b0795136..6e9f9e36 100644
--- a/src/main/java/fr/xephi/authme/security/HashAlgorithm.java
+++ b/src/main/java/fr/xephi/authme/security/HashAlgorithm.java
@@ -29,15 +29,15 @@ public enum HashAlgorithm {
ROYALAUTH(fr.xephi.authme.security.crypts.ROYALAUTH.class),
CRAZYCRYPT1(fr.xephi.authme.security.crypts.CRAZYCRYPT1.class),
CUSTOM(Null.class);
-
+
Class> classe;
HashAlgorithm(Class> classe) {
- this.classe = classe;
- }
-
- public Class> getclass() {
- return classe;
+ this.classe = classe;
}
-}
\ No newline at end of file
+ public Class> getclass() {
+ return classe;
+ }
+
+}
diff --git a/src/main/java/fr/xephi/authme/security/PasswordSecurity.java b/src/main/java/fr/xephi/authme/security/PasswordSecurity.java
index c92c48b9..ac912d5f 100644
--- a/src/main/java/fr/xephi/authme/security/PasswordSecurity.java
+++ b/src/main/java/fr/xephi/authme/security/PasswordSecurity.java
@@ -26,23 +26,20 @@ public class PasswordSecurity {
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
sha1.reset();
byte[] digest = sha1.digest(msg);
- return String.format("%0" + (digest.length << 1) + "x",
- new BigInteger(1, digest)).substring(0, length);
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest)).substring(0, length);
}
public static String getHash(HashAlgorithm alg, String password,
String playerName) throws NoSuchAlgorithmException {
EncryptionMethod method;
try {
- if (alg != HashAlgorithm.CUSTOM) method = (EncryptionMethod) alg
- .getclass().newInstance();
+ if (alg != HashAlgorithm.CUSTOM)
+ method = (EncryptionMethod) alg.getclass().newInstance();
else method = null;
} catch (InstantiationException e) {
- throw new NoSuchAlgorithmException(
- "Problem with this hash algorithm");
+ throw new NoSuchAlgorithmException("Problem with this hash algorithm");
} catch (IllegalAccessException e) {
- throw new NoSuchAlgorithmException(
- "Problem with this hash algorithm");
+ throw new NoSuchAlgorithmException("Problem with this hash algorithm");
}
String salt = "";
switch (alg) {
@@ -112,12 +109,11 @@ public class PasswordSecurity {
default:
throw new NoSuchAlgorithmException("Unknown hash algorithm");
}
- PasswordEncryptionEvent event = new PasswordEncryptionEvent(method,
- playerName);
+ PasswordEncryptionEvent event = new PasswordEncryptionEvent(method, playerName);
Bukkit.getPluginManager().callEvent(event);
method = event.getMethod();
- if (method == null) throw new NoSuchAlgorithmException(
- "Unknown hash algorithm");
+ if (method == null)
+ throw new NoSuchAlgorithmException("Unknown hash algorithm");
return method.getHash(password, salt, playerName);
}
@@ -126,30 +122,29 @@ public class PasswordSecurity {
HashAlgorithm algo = Settings.getPasswordHash;
EncryptionMethod method;
try {
- if (algo != HashAlgorithm.CUSTOM) method = (EncryptionMethod) algo
- .getclass().newInstance();
+ if (algo != HashAlgorithm.CUSTOM)
+ method = (EncryptionMethod) algo.getclass().newInstance();
else method = null;
} catch (InstantiationException e) {
- throw new NoSuchAlgorithmException(
- "Problem with this hash algorithm");
+ throw new NoSuchAlgorithmException("Problem with this hash algorithm");
} catch (IllegalAccessException e) {
- throw new NoSuchAlgorithmException(
- "Problem with this hash algorithm");
+ throw new NoSuchAlgorithmException("Problem with this hash algorithm");
}
- PasswordEncryptionEvent event = new PasswordEncryptionEvent(method,
- playerName);
+ PasswordEncryptionEvent event = new PasswordEncryptionEvent(method, playerName);
Bukkit.getPluginManager().callEvent(event);
method = event.getMethod();
- if (method == null) throw new NoSuchAlgorithmException(
- "Unknown hash algorithm");
+ if (method == null)
+ throw new NoSuchAlgorithmException("Unknown hash algorithm");
try {
- if (method.comparePassword(hash, password, playerName)) return true;
+ if (method.comparePassword(hash, password, playerName))
+ return true;
} catch (Exception e) {
}
if (Settings.supportOldPassword) {
try {
- if (compareWithAllEncryptionMethod(password, hash, playerName)) return true;
+ if (compareWithAllEncryptionMethod(password, hash, playerName))
+ return true;
} catch (Exception e) {
}
}
@@ -159,23 +154,21 @@ public class PasswordSecurity {
private static boolean compareWithAllEncryptionMethod(String password,
String hash, String playerName) throws NoSuchAlgorithmException {
for (HashAlgorithm algo : HashAlgorithm.values()) {
- if (algo != HashAlgorithm.CUSTOM) try {
- EncryptionMethod method = (EncryptionMethod) algo.getclass()
- .newInstance();
- if (method.comparePassword(hash, password, playerName)) {
- PlayerAuth nAuth = AuthMe.getInstance().database
- .getAuth(playerName);
- if (nAuth != null) {
- nAuth.setHash(getHash(Settings.getPasswordHash,
- password, playerName));
- nAuth.setSalt(userSalt.get(playerName));
- AuthMe.getInstance().database.updatePassword(nAuth);
- AuthMe.getInstance().database.updateSalt(nAuth);
+ if (algo != HashAlgorithm.CUSTOM)
+ try {
+ EncryptionMethod method = (EncryptionMethod) algo.getclass().newInstance();
+ if (method.comparePassword(hash, password, playerName)) {
+ PlayerAuth nAuth = AuthMe.getInstance().database.getAuth(playerName);
+ if (nAuth != null) {
+ nAuth.setHash(getHash(Settings.getPasswordHash, password, playerName));
+ nAuth.setSalt(userSalt.get(playerName));
+ AuthMe.getInstance().database.updatePassword(nAuth);
+ AuthMe.getInstance().database.updateSalt(nAuth);
+ }
+ return true;
}
- return true;
+ } catch (Exception e) {
}
- } catch (Exception e) {
- }
}
return false;
}
diff --git a/src/main/java/fr/xephi/authme/security/RandomString.java b/src/main/java/fr/xephi/authme/security/RandomString.java
index d504f4e9..260e5254 100644
--- a/src/main/java/fr/xephi/authme/security/RandomString.java
+++ b/src/main/java/fr/xephi/authme/security/RandomString.java
@@ -22,8 +22,8 @@ public class RandomString {
private final char[] buf;
public RandomString(int length) {
- if (length < 1) throw new IllegalArgumentException("length < 1: "
- + length);
+ if (length < 1)
+ throw new IllegalArgumentException("length < 1: " + length);
buf = new char[length];
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/BCRYPT.java b/src/main/java/fr/xephi/authme/security/crypts/BCRYPT.java
index f9881604..4cfab03e 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/BCRYPT.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/BCRYPT.java
@@ -61,6 +61,7 @@ import java.security.SecureRandom;
* @version 0.2
*/
public class BCRYPT implements EncryptionMethod {
+
// BCrypt parameters
private static final int GENSALT_DEFAULT_LOG2_ROUNDS = 10;
private static final int BCRYPT_SALT_LEN = 16;
@@ -69,238 +70,17 @@ public class BCRYPT implements EncryptionMethod {
private static final int BLOWFISH_NUM_ROUNDS = 16;
// Initial contents of key schedule
- private static final int P_orig[] = { 0x243f6a88, 0x85a308d3, 0x13198a2e,
- 0x03707344, 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
- 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, 0xc0ac29b7,
- 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b };
- private static final int S_orig[] = { 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db,
- 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
- 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8,
- 0x71574e69, 0xa458fea3, 0xf4933d7e, 0x0d95748f, 0x728eb658,
- 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539,
- 0x2af26013, 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
- 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e, 0xd71577c1,
- 0xbd314b27, 0x78af2fda, 0x55605c60, 0xe65525f3, 0xaa55ab94,
- 0x57489862, 0x63e81440, 0x55ca396a, 0x2aab10b6, 0xb4cc5c34,
- 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
- 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33,
- 0x6c24cf5c, 0x7a325381, 0x28958677, 0x3b8f4898, 0x6b4bb9af,
- 0xc4bfe81b, 0x66282193, 0x61d809cc, 0xfb21a991, 0x487cac60,
- 0x5dec8032, 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
- 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239, 0x2e0b4482,
- 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a,
- 0x670c9c61, 0xabd388f0, 0x6a51a0d2, 0xd8542f68, 0x960fa728,
- 0xab5133a3, 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
- 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, 0x8cee8619,
- 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe, 0xe06f75d8, 0x85c12073,
- 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706, 0x1bfedf72,
- 0x429b023d, 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
- 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, 0xe3fe501a,
- 0xb6794c3b, 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4,
- 0x5e5c9ec2, 0x196a2463, 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb,
- 0x3b52ec6f, 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
- 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, 0xc0cba857,
- 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, 0x5579c0bd, 0x1a60320a,
- 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8,
- 0xdb3222f8, 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
- 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82, 0x9e5c57bb,
- 0xca6f8ca0, 0x1a87562e, 0xdf1769db, 0xd542a8f6, 0x287effc3,
- 0xac6732c6, 0x8c4f5573, 0x695b27b0, 0xbbca58c8, 0xe1ffa35d,
- 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
- 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da,
- 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8, 0xef20cada, 0x36774c01,
- 0xd07e9efe, 0x2bf11fb4, 0x95dbda4d, 0xae909198, 0xeaad8e71,
- 0x6b93d5a0, 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
- 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c, 0x4fad5ea0,
- 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777,
- 0xea752dfe, 0x8b021fa1, 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6,
- 0xce89e299, 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
- 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, 0xe6ad2065,
- 0x77b5fa86, 0xc75442f5, 0xfb9d35cf, 0xebcdaf0c, 0x7b3e89a0,
- 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e, 0x226800bb,
- 0x57b8e0af, 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
- 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, 0x83260376,
- 0x6295cfa9, 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a,
- 0x1b510052, 0x9a532915, 0xd60f573f, 0xbc9bc6e4, 0x2b60a476,
- 0x81e67400, 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
- 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, 0x53b02d5d,
- 0xa99f8fa1, 0x08ba4799, 0x6e85076a, 0x4b7a70e9, 0xb5b32944,
- 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8,
- 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
- 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, 0x3f54989a,
- 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5,
- 0x4d2d38e6, 0xf0255dc1, 0x4cdd2086, 0x8470eb26, 0x6382e9c6,
- 0x021ecc5e, 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
- 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, 0x3e07841c,
- 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, 0xb03ada37, 0xf0500c0d,
- 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58,
- 0xdc0921bd, 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
- 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7, 0xa9446146,
- 0x0fd0030e, 0xecc8c73e, 0xa4751e41, 0xe238cd99, 0x3bea0e2f,
- 0x3280bba1, 0x183eb331, 0x4e548b38, 0x4f6db908, 0x6f420d03,
- 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
- 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f,
- 0x2e6b7124, 0x501adde6, 0x9f84cd87, 0x7a584718, 0x7408da17,
- 0xbc9f9abc, 0xe94b7d8c, 0xec7aec3a, 0xdb851dfa, 0x63094366,
- 0xc464c3d2, 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
- 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd, 0x71dff89e,
- 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b,
- 0x3c11183b, 0x5924a509, 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c,
- 0x1e153c6e, 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
- 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, 0x803e89d6,
- 0x5266c825, 0x2e4cc978, 0x9c10b36a, 0xc6150eba, 0x94e2ea78,
- 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d, 0x1939260f,
- 0x19c27960, 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
- 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, 0xc332ddef,
- 0xbe6c5aa5, 0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b,
- 0x2aef7dad, 0x5b6e2f84, 0x1521b628, 0x29076170, 0xecdd4775,
- 0x619f1510, 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
- 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, 0xeecc86bc,
- 0x60622ca7, 0x9cab5cab, 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca,
- 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5,
- 0xc021b8f7, 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
- 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281, 0x0e358829,
- 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, 0x57f584a5, 0x1b227263,
- 0x9b83c3ff, 0x1ac24696, 0xcdb30aeb, 0x532e3054, 0x8fd948e4,
- 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
- 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6,
- 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0, 0xc742f442, 0xef6abbb5,
- 0x654f3b1d, 0x41cd2105, 0xd81e799e, 0x86854dc7, 0xe44b476a,
- 0x3d816250, 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
- 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, 0x095bbf00,
- 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea,
- 0x1dadf43e, 0x233f7061, 0x3372f092, 0x8d937e41, 0xd65fecf1,
- 0x6c223bdb, 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
- 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, 0xa969a7aa,
- 0xc50c06c2, 0x5a04abfc, 0x800bcadc, 0x9e447a2e, 0xc3453484,
- 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd, 0x675fda79,
- 0xe3674340, 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
- 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7, 0xe93d5a68,
- 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7,
- 0xbcf46b2e, 0xd4a20068, 0xd4082471, 0x3320f46a, 0x43b7d4b7,
- 0x500061af, 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
- 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec,
- 0x03bd9785, 0x7fac6dd0, 0x31cb8504, 0x96eb27b3, 0x55fd3941,
- 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4, 0x0a2c86da,
- 0xe9b66dfb, 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
- 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, 0xaace1e7c,
- 0xd3375fec, 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9,
- 0xee39d7ab, 0x3b124e8b, 0x1dc9faf7, 0x4b6d1856, 0x26a36631,
- 0xeae397b2, 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
- 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, 0x55533a3a,
- 0x20838d87, 0xfe6ba9b7, 0xd096954b, 0x55a867bc, 0xa1159a58,
- 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c,
- 0x9029317c, 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
- 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc, 0x07f9c9ee,
- 0x41041f0f, 0x404779a4, 0x5d886e17, 0x325f51eb, 0xd59bc0d1,
- 0xf2bcc18f, 0x41113564, 0x257b7834, 0x602a9c60, 0xdff8e8a3,
- 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
- 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e,
- 0xe6ba0d99, 0xde720c8c, 0x2da2f728, 0xd0127845, 0x95b794fd,
- 0x647d0862, 0xe7ccf5f0, 0x5449a36f, 0x877d48fa, 0xc39dfd27,
- 0xf33e8d1e, 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
- 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d, 0xc67b5510,
- 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3,
- 0xb5390f92, 0x690fed0b, 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b,
- 0xd9155ea3, 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
- 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, 0x6842ada7,
- 0xc66a2b3b, 0x12754ccc, 0x782ef11c, 0x6a124237, 0xb79251e7,
- 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa, 0x3d25bdd8,
- 0xe2e1c3c9, 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
- 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, 0x9dbc8057,
- 0xf0f7c086, 0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0,
- 0x7745ae04, 0xd736fccc, 0x83426b33, 0xf01eab71, 0xb0804187,
- 0x3c005e5f, 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
- 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, 0x5366f9c3,
- 0xc8b38e74, 0xb475f255, 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84,
- 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591,
- 0xc902de4c, 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
- 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633, 0xe85a1f02,
- 0x09f0be8c, 0x4a99a025, 0x1d6efe10, 0x1ab93d1d, 0x0ba5a4df,
- 0xa186f20f, 0x2868f169, 0xdcb7da83, 0x573906fe, 0xa1e2ce9b,
- 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
- 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28,
- 0xc0f586e0, 0x006058aa, 0x30dc7d62, 0x11e69ed7, 0x2338ea63,
- 0x53c2dd94, 0xc2c21634, 0xbbcbee56, 0x90bcb6de, 0xebfc7da1,
- 0xce591d76, 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
- 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, 0xed545578,
- 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8,
- 0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4, 0x362abfce,
- 0xddc6c837, 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0,
- 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e,
- 0x4fa33742, 0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315,
- 0xd62d1c7e, 0xc700c47b, 0xb78c1b6b, 0x21a19045, 0xb26eb1be,
- 0x6a366eb4, 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
- 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6, 0x2939bbdb,
- 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a,
- 0x63ef8ce2, 0x9a86ee22, 0xc089c2b8, 0x43242ef6, 0xa51e03aa,
- 0x9cf2d0a4, 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
- 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, 0xc72fefd3,
- 0xf752f7da, 0x3f046f69, 0x77fa0a59, 0x80e4a915, 0x87b08601,
- 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9,
- 0x022b8b51, 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
- 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, 0xe029ac71,
- 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc,
- 0xf8d56629, 0x79132e28, 0x785f0191, 0xed756055, 0xf7960e44,
- 0xe3d35e8c, 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
- 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, 0x1b3f6d9b,
- 0x1e6321f5, 0xf59c66fb, 0x26dcf319, 0x7533d928, 0xb155fdf5,
- 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167,
- 0xccad925f, 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
- 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32, 0xa8b6e37e,
- 0xc3293d46, 0x48de5369, 0x6413e680, 0xa2ae0810, 0xdd6db224,
- 0x69852dfd, 0x09072166, 0xb39a460a, 0x6445c0dd, 0x586cdecf,
- 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
- 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8,
- 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47, 0xd29be463, 0x542f5d9e,
- 0xaec2771b, 0xf64e6370, 0x740e0d8d, 0xe75b1357, 0xf8721671,
- 0xaf537d5d, 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
- 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048, 0x6f3f3b82,
- 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc,
- 0xbb3a792b, 0x344525bd, 0xa08839e1, 0x51ce794b, 0x2f32c9b7,
- 0xa01fbac9, 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
- 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, 0x0339c32a,
- 0xc6913667, 0x8df9317c, 0xe0b12b4f, 0xf79e59b7, 0x43f5bb3a,
- 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a, 0x0f91fc71,
- 0x9b941525, 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
- 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, 0xe0ec6e0e,
- 0x1698db3b, 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df,
- 0xd3a0342b, 0x8971f21e, 0x1b0a7441, 0x4ba3348c, 0xc5be7120,
- 0xc37632d8, 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
- 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, 0x1618b166,
- 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, 0xf523f357, 0xa6327623,
- 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697,
- 0x88d273cc, 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
- 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a, 0xc9aa53fd,
- 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, 0x71126905, 0xb2040222,
- 0xb6cbcf7c, 0xcd769c2b, 0x53113ec0, 0x1640e3d3, 0x38abbd60,
- 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
- 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c,
- 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0,
- 0x3f09252d, 0xc208e69f, 0xb74e6132, 0xce77e25b, 0x578fdfe3,
- 0x3ac372e6 };
+ private static final int P_orig[] = { 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b };
+ private static final int S_orig[] = { 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e, 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a, 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677, 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239, 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0, 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe, 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d, 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463, 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09, 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8, 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82, 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b, 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8, 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c, 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1, 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf, 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af, 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a, 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1, 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1, 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd, 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7, 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af, 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87, 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd, 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509, 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a, 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960, 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84, 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf, 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7, 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281, 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73, 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0, 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061, 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340, 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7, 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068, 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb, 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b, 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb, 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc, 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728, 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d, 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b, 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9, 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61, 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c, 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633, 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62, 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0, 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6, 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22, 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59, 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51, 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28, 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd, 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f, 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32, 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb, 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47, 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048, 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd, 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f, 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525, 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e, 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d, 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc, 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a, 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060, 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 };
// bcrypt IV: "OrpheanBeholderScryDoubt"
- static private final int bf_crypt_ciphertext[] = { 0x4f727068, 0x65616e42,
- 0x65686f6c, 0x64657253, 0x63727944, 0x6f756274 };
+ static private final int bf_crypt_ciphertext[] = { 0x4f727068, 0x65616e42, 0x65686f6c, 0x64657253, 0x63727944, 0x6f756274 };
// Table for Base64 encoding
- static private final char base64_code[] = { '.', '/', 'A', 'B', 'C', 'D',
- 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',
- 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
- 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
- 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
- '4', '5', '6', '7', '8', '9' };
+ static private final char base64_code[] = { '.', '/', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
// Table for Base64 decoding
- static private final byte index_64[] = { -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 0, 1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, -1,
- -1, -1, -1, -1, -1, -1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, -1, -1, -1, -1,
- -1, -1, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
- 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, -1, -1, -1, -1, -1 };
+ static private final byte index_64[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, -1, -1, -1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, -1, -1, -1, -1, -1, -1, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, -1, -1, -1, -1, -1 };
// Expanded Blowfish key
private int P[];
@@ -325,8 +105,8 @@ public class BCRYPT implements EncryptionMethod {
StringBuffer rs = new StringBuffer();
int c1, c2;
- if (len <= 0 || len > d.length) throw new IllegalArgumentException(
- "Invalid len");
+ if (len <= 0 || len > d.length)
+ throw new IllegalArgumentException("Invalid len");
while (off < len) {
c1 = d[off++] & 0xff;
@@ -361,7 +141,8 @@ public class BCRYPT implements EncryptionMethod {
* @return the decoded value of x
*/
private static byte char64(char x) {
- if ((int) x < 0 || (int) x > index_64.length) return -1;
+ if ((int) x < 0 || (int) x > index_64.length)
+ return -1;
return index_64[(int) x];
}
@@ -385,22 +166,27 @@ public class BCRYPT implements EncryptionMethod {
byte ret[];
byte c1, c2, c3, c4, o;
- if (maxolen <= 0) throw new IllegalArgumentException("Invalid maxolen");
+ if (maxolen <= 0)
+ throw new IllegalArgumentException("Invalid maxolen");
while (off < slen - 1 && olen < maxolen) {
c1 = char64(s.charAt(off++));
c2 = char64(s.charAt(off++));
- if (c1 == -1 || c2 == -1) break;
+ if (c1 == -1 || c2 == -1)
+ break;
o = (byte) (c1 << 2);
o |= (c2 & 0x30) >> 4;
rs.append((char) o);
- if (++olen >= maxolen || off >= slen) break;
+ if (++olen >= maxolen || off >= slen)
+ break;
c3 = char64(s.charAt(off++));
- if (c3 == -1) break;
+ if (c3 == -1)
+ break;
o = (byte) ((c2 & 0x0f) << 4);
o |= (c3 & 0x3c) >> 2;
rs.append((char) o);
- if (++olen >= maxolen || off >= slen) break;
+ if (++olen >= maxolen || off >= slen)
+ break;
c4 = char64(s.charAt(off++));
o = (byte) ((c3 & 0x03) << 6);
o |= c4;
@@ -559,11 +345,11 @@ public class BCRYPT implements EncryptionMethod {
int clen = cdata.length;
byte ret[];
- if (log_rounds < 4 || log_rounds > 31) throw new IllegalArgumentException(
- "Bad number of rounds");
+ if (log_rounds < 4 || log_rounds > 31)
+ throw new IllegalArgumentException("Bad number of rounds");
rounds = 1 << log_rounds;
- if (salt.length != BCRYPT_SALT_LEN) throw new IllegalArgumentException(
- "Bad salt length");
+ if (salt.length != BCRYPT_SALT_LEN)
+ throw new IllegalArgumentException("Bad salt length");
init_key();
ekskey(salt, password);
@@ -604,25 +390,25 @@ public class BCRYPT implements EncryptionMethod {
int rounds, off = 0;
StringBuffer rs = new StringBuffer();
- if (salt.charAt(0) != '$' || salt.charAt(1) != '2') throw new IllegalArgumentException(
- "Invalid salt version");
- if (salt.charAt(2) == '$') off = 3;
+ if (salt.charAt(0) != '$' || salt.charAt(1) != '2')
+ throw new IllegalArgumentException("Invalid salt version");
+ if (salt.charAt(2) == '$')
+ off = 3;
else {
minor = salt.charAt(2);
- if (minor != 'a' || salt.charAt(3) != '$') throw new IllegalArgumentException(
- "Invalid salt revision");
+ if (minor != 'a' || salt.charAt(3) != '$')
+ throw new IllegalArgumentException("Invalid salt revision");
off = 4;
}
// Extract number of rounds
- if (salt.charAt(off + 2) > '$') throw new IllegalArgumentException(
- "Missing salt rounds");
+ if (salt.charAt(off + 2) > '$')
+ throw new IllegalArgumentException("Missing salt rounds");
rounds = Integer.parseInt(salt.substring(off, off + 2));
real_salt = salt.substring(off + 3, off + 25);
try {
- passwordb = (password + (minor >= 'a' ? "\000" : ""))
- .getBytes("UTF-8");
+ passwordb = (password + (minor >= 'a' ? "\000" : "")).getBytes("UTF-8");
} catch (UnsupportedEncodingException uee) {
throw new AssertionError("UTF-8 is not supported");
}
@@ -633,9 +419,11 @@ public class BCRYPT implements EncryptionMethod {
hashed = B.crypt_raw(passwordb, saltb, rounds);
rs.append("$2");
- if (minor >= 'a') rs.append(minor);
+ if (minor >= 'a')
+ rs.append(minor);
rs.append("$");
- if (rounds < 10) rs.append("0");
+ if (rounds < 10)
+ rs.append("0");
rs.append(Integer.toString(rounds));
rs.append("$");
rs.append(encode_base64(saltb, saltb.length));
@@ -660,7 +448,8 @@ public class BCRYPT implements EncryptionMethod {
random.nextBytes(rnd);
rs.append("$2a$");
- if (log_rounds < 10) rs.append("0");
+ if (log_rounds < 10)
+ rs.append("0");
rs.append(Integer.toString(log_rounds));
rs.append("$");
rs.append(encode_base64(rnd, rnd.length));
diff --git a/src/main/java/fr/xephi/authme/security/crypts/CRAZYCRYPT1.java b/src/main/java/fr/xephi/authme/security/crypts/CRAZYCRYPT1.java
index 0bd40bce..a5688953 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/CRAZYCRYPT1.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/CRAZYCRYPT1.java
@@ -7,14 +7,12 @@ import java.security.NoSuchAlgorithmException;
public class CRAZYCRYPT1 implements EncryptionMethod {
protected final Charset charset = Charset.forName("UTF-8");
- private static final char[] CRYPTCHARS = new char[] { '0', '1', '2', '3',
- '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+ private static final char[] CRYPTCHARS = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
@Override
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
- final String text = "ÜÄaeut//&/=I " + password + "7421€547" + name
- + "__+IÄIH§%NK " + password;
+ final String text = "ÜÄaeut//&/=I " + password + "7421€547" + name + "__+IÄIH§%NK " + password;
try {
final MessageDigest md = MessageDigest.getInstance("SHA-512");
md.update(text.getBytes(charset), 0, text.length());
diff --git a/src/main/java/fr/xephi/authme/security/crypts/CryptPBKDF2.java b/src/main/java/fr/xephi/authme/security/crypts/CryptPBKDF2.java
index f9d488ac..6cf7daea 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/CryptPBKDF2.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/CryptPBKDF2.java
@@ -11,8 +11,7 @@ public class CryptPBKDF2 implements EncryptionMethod {
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
String result = "pbkdf2_sha256$10000$" + salt + "$";
- PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII",
- salt.getBytes(), 10000);
+ PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 10000);
PBKDF2Engine engine = new PBKDF2Engine(params);
return result + engine.deriveKey(password, 64).toString();
@@ -24,8 +23,7 @@ public class CryptPBKDF2 implements EncryptionMethod {
String[] line = hash.split("\\$");
String salt = line[2];
String derivedKey = line[3];
- PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII",
- salt.getBytes(), 10000, derivedKey.getBytes());
+ PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 10000, derivedKey.getBytes());
PBKDF2Engine engine = new PBKDF2Engine(params);
return engine.verifyKey(password);
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/DOUBLEMD5.java b/src/main/java/fr/xephi/authme/security/crypts/DOUBLEMD5.java
index 3511509d..7ab2afb5 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/DOUBLEMD5.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/DOUBLEMD5.java
@@ -24,8 +24,7 @@ public class DOUBLEMD5 implements EncryptionMethod {
md5.reset();
md5.update(message.getBytes());
byte[] digest = md5.digest();
- return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
- 1, digest));
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
}
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/IPB3.java b/src/main/java/fr/xephi/authme/security/crypts/IPB3.java
index 87eedd45..9484c021 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/IPB3.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/IPB3.java
@@ -17,8 +17,7 @@ public class IPB3 implements EncryptionMethod {
@Override
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
- String salt = AuthMe.getInstance().database.getAuth(playerName)
- .getSalt();
+ String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
return hash.equals(getHash(password, salt, playerName));
}
@@ -28,7 +27,6 @@ public class IPB3 implements EncryptionMethod {
md5.reset();
md5.update(message.getBytes());
byte[] digest = md5.digest();
- return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
- 1, digest));
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
}
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/JOOMLA.java b/src/main/java/fr/xephi/authme/security/crypts/JOOMLA.java
index 519f1403..e99a01ff 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/JOOMLA.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/JOOMLA.java
@@ -25,7 +25,6 @@ public class JOOMLA implements EncryptionMethod {
md5.reset();
md5.update(message.getBytes());
byte[] digest = md5.digest();
- return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
- 1, digest));
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
}
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/MD5.java b/src/main/java/fr/xephi/authme/security/crypts/MD5.java
index 7cd3871e..c52c8b50 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/MD5.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/MD5.java
@@ -24,7 +24,6 @@ public class MD5 implements EncryptionMethod {
md5.reset();
md5.update(message.getBytes());
byte[] digest = md5.digest();
- return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
- 1, digest));
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
}
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/MD5VB.java b/src/main/java/fr/xephi/authme/security/crypts/MD5VB.java
index bdc1eb6b..616265be 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/MD5VB.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/MD5VB.java
@@ -25,8 +25,7 @@ public class MD5VB implements EncryptionMethod {
md5.reset();
md5.update(message.getBytes());
byte[] digest = md5.digest();
- return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
- 1, digest));
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
}
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/MYBB.java b/src/main/java/fr/xephi/authme/security/crypts/MYBB.java
index f5faa678..bf4b7f55 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/MYBB.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/MYBB.java
@@ -17,8 +17,7 @@ public class MYBB implements EncryptionMethod {
@Override
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
- String salt = AuthMe.getInstance().database.getAuth(playerName)
- .getSalt();
+ String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
return hash.equals(getHash(password, salt, playerName));
}
@@ -28,7 +27,6 @@ public class MYBB implements EncryptionMethod {
md5.reset();
md5.update(message.getBytes());
byte[] digest = md5.digest();
- return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
- 1, digest));
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
}
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/PHPBB.java b/src/main/java/fr/xephi/authme/security/crypts/PHPBB.java
index 40a93bd7..fc2f1896 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/PHPBB.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/PHPBB.java
@@ -14,6 +14,7 @@ import java.security.NoSuchAlgorithmException;
* @author stefano
*/
public class PHPBB implements EncryptionMethod {
+
private static final int PHP_VERSION = 4;
private String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
@@ -29,9 +30,9 @@ public class PHPBB implements EncryptionMethod {
}
random = random.substring(0, count);
}
- String hash = _hash_crypt_private(password,
- _hash_gensalt_private(random, itoa64));
- if (hash.length() == 34) return hash;
+ String hash = _hash_crypt_private(password, _hash_gensalt_private(random, itoa64));
+ if (hash.length() == 34)
+ return hash;
return md5(password);
}
@@ -46,8 +47,7 @@ public class PHPBB implements EncryptionMethod {
iteration_count_log2 = 8;
}
String output = "$H$";
- output += itoa64.charAt(Math.min(iteration_count_log2
- + ((PHP_VERSION >= 5) ? 5 : 3), 30));
+ output += itoa64.charAt(Math.min(iteration_count_log2 + ((PHP_VERSION >= 5) ? 5 : 3), 30));
output += _hash_encode64(input, 6);
return output;
}
@@ -61,12 +61,16 @@ public class PHPBB implements EncryptionMethod {
do {
int value = input.charAt(i++);
output += itoa64.charAt(value & 0x3f);
- if (i < count) value |= input.charAt(i) << 8;
+ if (i < count)
+ value |= input.charAt(i) << 8;
output += itoa64.charAt((value >> 6) & 0x3f);
- if (i++ >= count) break;
- if (i < count) value |= input.charAt(i) << 16;
+ if (i++ >= count)
+ break;
+ if (i < count)
+ value |= input.charAt(i) << 16;
output += itoa64.charAt((value >> 12) & 0x3f);
- if (i++ >= count) break;
+ if (i++ >= count)
+ break;
output += itoa64.charAt((value >> 18) & 0x3f);
} while (i < count);
return output;
@@ -74,12 +78,15 @@ public class PHPBB implements EncryptionMethod {
String _hash_crypt_private(String password, String setting) {
String output = "*";
- if (!setting.substring(0, 3).equals("$H$")) return output;
+ if (!setting.substring(0, 3).equals("$H$"))
+ return output;
int count_log2 = itoa64.indexOf(setting.charAt(3));
- if (count_log2 < 7 || count_log2 > 30) return output;
+ if (count_log2 < 7 || count_log2 > 30)
+ return output;
int count = 1 << count_log2;
String salt = setting.substring(4, 12);
- if (salt.length() != 8) return output;
+ if (salt.length() != 8)
+ return output;
String m1 = md5(salt + password);
String hash = pack(m1);
do {
@@ -91,8 +98,8 @@ public class PHPBB implements EncryptionMethod {
}
public boolean phpbb_check_hash(String password, String hash) {
- if (hash.length() == 34) return _hash_crypt_private(password, hash)
- .equals(hash);
+ if (hash.length() == 34)
+ return _hash_crypt_private(password, hash).equals(hash);
else return md5(password).equals(hash);
}
@@ -110,9 +117,11 @@ public class PHPBB implements EncryptionMethod {
}
static int hexToInt(char ch) {
- if (ch >= '0' && ch <= '9') return ch - '0';
+ if (ch >= '0' && ch <= '9')
+ return ch - '0';
ch = Character.toUpperCase(ch);
- if (ch >= 'A' && ch <= 'F') return ch - 'A' + 0xA;
+ if (ch >= 'A' && ch <= 'F')
+ return ch - 'A' + 0xA;
throw new IllegalArgumentException("Not a hex character: " + ch);
}
@@ -120,7 +129,8 @@ public class PHPBB implements EncryptionMethod {
StringBuffer r = new StringBuffer(32);
for (int i = 0; i < bytes.length; i++) {
String x = Integer.toHexString(bytes[i] & 0xff);
- if (x.length() < 2) r.append("0");
+ if (x.length() < 2)
+ r.append("0");
r.append(x);
}
return r.toString();
diff --git a/src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java b/src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java
index fe108c33..d9f50084 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/PHPFUSION.java
@@ -20,8 +20,7 @@ public class PHPFUSION implements EncryptionMethod {
String algo = "HmacSHA256";
String keyString = getSHA1(salt);
try {
- SecretKeySpec key = new SecretKeySpec(
- (keyString).getBytes("UTF-8"), algo);
+ SecretKeySpec key = new SecretKeySpec((keyString).getBytes("UTF-8"), algo);
Mac mac = Mac.getInstance(algo);
mac.init(key);
byte[] bytes = mac.doFinal(password.getBytes("ASCII"));
@@ -44,8 +43,7 @@ public class PHPFUSION implements EncryptionMethod {
@Override
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
- String salt = AuthMe.getInstance().database.getAuth(playerName)
- .getSalt();
+ String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
return hash.equals(getHash(password, salt, ""));
}
@@ -55,8 +53,7 @@ public class PHPFUSION implements EncryptionMethod {
sha1.reset();
sha1.update(message.getBytes());
byte[] digest = sha1.digest();
- return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
- 1, digest));
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
}
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/ROYALAUTH.java b/src/main/java/fr/xephi/authme/security/crypts/ROYALAUTH.java
index 8b61d855..a0376426 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/ROYALAUTH.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/ROYALAUTH.java
@@ -20,8 +20,7 @@ public class ROYALAUTH implements EncryptionMethod {
byte byteData[] = md.digest();
StringBuilder sb = new StringBuilder();
for (byte aByteData : byteData)
- sb.append(Integer.toString((aByteData & 0xff) + 0x100, 16)
- .substring(1));
+ sb.append(Integer.toString((aByteData & 0xff) + 0x100, 16).substring(1));
return sb.toString();
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/SALTED2MD5.java b/src/main/java/fr/xephi/authme/security/crypts/SALTED2MD5.java
index 8ca5fdd0..eac3466c 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/SALTED2MD5.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/SALTED2MD5.java
@@ -17,8 +17,7 @@ public class SALTED2MD5 implements EncryptionMethod {
@Override
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
- String salt = AuthMe.getInstance().database.getAuth(playerName)
- .getSalt();
+ String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
return hash.equals(getMD5(getMD5(password) + salt));
}
@@ -28,7 +27,6 @@ public class SALTED2MD5 implements EncryptionMethod {
md5.reset();
md5.update(message.getBytes());
byte[] digest = md5.digest();
- return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
- 1, digest));
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
}
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/SHA1.java b/src/main/java/fr/xephi/authme/security/crypts/SHA1.java
index 5865918d..ff6ebb0b 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/SHA1.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/SHA1.java
@@ -24,8 +24,7 @@ public class SHA1 implements EncryptionMethod {
sha1.reset();
sha1.update(message.getBytes());
byte[] digest = sha1.digest();
- return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
- 1, digest));
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
}
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/SHA256.java b/src/main/java/fr/xephi/authme/security/crypts/SHA256.java
index 089fe40e..34967397 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/SHA256.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/SHA256.java
@@ -25,8 +25,7 @@ public class SHA256 implements EncryptionMethod {
sha256.reset();
sha256.update(message.getBytes());
byte[] digest = sha256.digest();
- return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
- 1, digest));
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
}
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/SHA512.java b/src/main/java/fr/xephi/authme/security/crypts/SHA512.java
index f035766d..9924fa7f 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/SHA512.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/SHA512.java
@@ -24,7 +24,6 @@ public class SHA512 implements EncryptionMethod {
sha512.reset();
sha512.update(message.getBytes());
byte[] digest = sha512.digest();
- return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
- 1, digest));
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
}
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/SMF.java b/src/main/java/fr/xephi/authme/security/crypts/SMF.java
index 9fc2b8f9..13b95324 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/SMF.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/SMF.java
@@ -24,7 +24,6 @@ public class SMF implements EncryptionMethod {
sha1.reset();
sha1.update(message.getBytes());
byte[] digest = sha1.digest();
- return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
- 1, digest));
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
}
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/WBB3.java b/src/main/java/fr/xephi/authme/security/crypts/WBB3.java
index 21a9d05a..bb70e1bc 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/WBB3.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/WBB3.java
@@ -17,8 +17,7 @@ public class WBB3 implements EncryptionMethod {
@Override
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
- String salt = AuthMe.getInstance().database.getAuth(playerName)
- .getSalt();
+ String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
return hash.equals(getHash(password, salt, ""));
}
@@ -28,7 +27,6 @@ public class WBB3 implements EncryptionMethod {
sha1.reset();
sha1.update(message.getBytes());
byte[] digest = sha1.digest();
- return String.format("%0" + (digest.length << 1) + "x", new BigInteger(
- 1, digest));
+ return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1, digest));
}
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/WHIRLPOOL.java b/src/main/java/fr/xephi/authme/security/crypts/WHIRLPOOL.java
index 909df309..7dc84963 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/WHIRLPOOL.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/WHIRLPOOL.java
@@ -84,22 +84,7 @@ public class WHIRLPOOL implements EncryptionMethod {
/**
* The substitution box.
*/
- private static final String sbox = "\u1823\uc6E8\u87B8\u014F\u36A6\ud2F5\u796F\u9152"
- + "\u60Bc\u9B8E\uA30c\u7B35\u1dE0\ud7c2\u2E4B\uFE57"
- + "\u1577\u37E5\u9FF0\u4AdA\u58c9\u290A\uB1A0\u6B85"
- + "\uBd5d\u10F4\ucB3E\u0567\uE427\u418B\uA77d\u95d8"
- + "\uFBEE\u7c66\udd17\u479E\ucA2d\uBF07\uAd5A\u8333"
- + "\u6302\uAA71\uc819\u49d9\uF2E3\u5B88\u9A26\u32B0"
- + "\uE90F\ud580\uBEcd\u3448\uFF7A\u905F\u2068\u1AAE"
- + "\uB454\u9322\u64F1\u7312\u4008\uc3Ec\udBA1\u8d3d"
- + "\u9700\ucF2B\u7682\ud61B\uB5AF\u6A50\u45F3\u30EF"
- + "\u3F55\uA2EA\u65BA\u2Fc0\udE1c\uFd4d\u9275\u068A"
- + "\uB2E6\u0E1F\u62d4\uA896\uF9c5\u2559\u8472\u394c"
- + "\u5E78\u388c\ud1A5\uE261\uB321\u9c1E\u43c7\uFc04"
- + "\u5199\u6d0d\uFAdF\u7E24\u3BAB\ucE11\u8F4E\uB7EB"
- + "\u3c81\u94F7\uB913\u2cd3\uE76E\uc403\u5644\u7FA9"
- + "\u2ABB\uc153\udc0B\u9d6c\u3174\uF646\uAc89\u14E1"
- + "\u163A\u6909\u70B6\ud0Ed\ucc42\u98A4\u285c\uF886";
+ private static final String sbox = "\u1823\uc6E8\u87B8\u014F\u36A6\ud2F5\u796F\u9152" + "\u60Bc\u9B8E\uA30c\u7B35\u1dE0\ud7c2\u2E4B\uFE57" + "\u1577\u37E5\u9FF0\u4AdA\u58c9\u290A\uB1A0\u6B85" + "\uBd5d\u10F4\ucB3E\u0567\uE427\u418B\uA77d\u95d8" + "\uFBEE\u7c66\udd17\u479E\ucA2d\uBF07\uAd5A\u8333" + "\u6302\uAA71\uc819\u49d9\uF2E3\u5B88\u9A26\u32B0" + "\uE90F\ud580\uBEcd\u3448\uFF7A\u905F\u2068\u1AAE" + "\uB454\u9322\u64F1\u7312\u4008\uc3Ec\udBA1\u8d3d" + "\u9700\ucF2B\u7682\ud61B\uB5AF\u6A50\u45F3\u30EF" + "\u3F55\uA2EA\u65BA\u2Fc0\udE1c\uFd4d\u9275\u068A" + "\uB2E6\u0E1F\u62d4\uA896\uF9c5\u2559\u8472\u394c" + "\u5E78\u388c\ud1A5\uE261\uB321\u9c1E\u43c7\uFc04" + "\u5199\u6d0d\uFAdF\u7E24\u3BAB\ucE11\u8F4E\uB7EB" + "\u3c81\u94F7\uB913\u2cd3\uE76E\uc403\u5644\u7FA9" + "\u2ABB\uc153\udc0B\u9d6c\u3174\uF646\uAc89\u14E1" + "\u163A\u6909\u70B6\ud0Ed\ucc42\u98A4\u285c\uF886";
private static long[][] C = new long[8][256];
private static long[] rc = new long[R + 1];
@@ -126,8 +111,7 @@ public class WHIRLPOOL implements EncryptionMethod {
* build the circulant table C[0][x] = S[x].[1, 1, 4, 1, 8, 5, 2,
* 9]:
*/
- C[0][x] = (v1 << 56) | (v1 << 48) | (v4 << 40) | (v1 << 32)
- | (v8 << 24) | (v5 << 16) | (v2 << 8) | (v9);
+ C[0][x] = (v1 << 56) | (v1 << 48) | (v4 << 40) | (v1 << 32) | (v8 << 24) | (v5 << 16) | (v2 << 8) | (v9);
/*
* build the remaining circulant tables C[t][x] = C[0][x] rotr t
*/
@@ -144,14 +128,7 @@ public class WHIRLPOOL implements EncryptionMethod {
*/
for (int r = 1; r <= R; r++) {
int i = 8 * (r - 1);
- rc[r] = (C[0][i] & 0xff00000000000000L)
- ^ (C[1][i + 1] & 0x00ff000000000000L)
- ^ (C[2][i + 2] & 0x0000ff0000000000L)
- ^ (C[3][i + 3] & 0x000000ff00000000L)
- ^ (C[4][i + 4] & 0x00000000ff000000L)
- ^ (C[5][i + 5] & 0x0000000000ff0000L)
- ^ (C[6][i + 6] & 0x000000000000ff00L)
- ^ (C[7][i + 7] & 0x00000000000000ffL);
+ rc[r] = (C[0][i] & 0xff00000000000000L) ^ (C[1][i + 1] & 0x00ff000000000000L) ^ (C[2][i + 2] & 0x0000ff0000000000L) ^ (C[3][i + 3] & 0x000000ff00000000L) ^ (C[4][i + 4] & 0x00000000ff000000L) ^ (C[5][i + 5] & 0x0000000000ff0000L) ^ (C[6][i + 6] & 0x000000000000ff00L) ^ (C[7][i + 7] & 0x00000000000000ffL);
}
}
@@ -195,14 +172,7 @@ public class WHIRLPOOL implements EncryptionMethod {
* map the buffer to a block:
*/
for (int i = 0, j = 0; i < 8; i++, j += 8) {
- block[i] = (((long) buffer[j]) << 56)
- ^ (((long) buffer[j + 1] & 0xffL) << 48)
- ^ (((long) buffer[j + 2] & 0xffL) << 40)
- ^ (((long) buffer[j + 3] & 0xffL) << 32)
- ^ (((long) buffer[j + 4] & 0xffL) << 24)
- ^ (((long) buffer[j + 5] & 0xffL) << 16)
- ^ (((long) buffer[j + 6] & 0xffL) << 8)
- ^ (((long) buffer[j + 7] & 0xffL));
+ block[i] = (((long) buffer[j]) << 56) ^ (((long) buffer[j + 1] & 0xffL) << 48) ^ (((long) buffer[j + 2] & 0xffL) << 40) ^ (((long) buffer[j + 3] & 0xffL) << 32) ^ (((long) buffer[j + 4] & 0xffL) << 24) ^ (((long) buffer[j + 5] & 0xffL) << 16) ^ (((long) buffer[j + 6] & 0xffL) << 8) ^ (((long) buffer[j + 7] & 0xffL));
}
/*
* compute and apply K^0 to the cipher state:
@@ -294,8 +264,7 @@ public class WHIRLPOOL implements EncryptionMethod {
while (sourceBits > 8) { // at least source[sourcePos] and
// source[sourcePos+1] contain data.
// take a byte from the source:
- b = ((source[sourcePos] << sourceGap) & 0xff)
- | ((source[sourcePos + 1] & 0xff) >>> (8 - sourceGap));
+ b = ((source[sourcePos] << sourceGap) & 0xff) | ((source[sourcePos + 1] & 0xff) >>> (8 - sourceGap));
if (b < 0 || b >= 256) {
throw new RuntimeException("LOGIC ERROR");
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/WORDPRESS.java b/src/main/java/fr/xephi/authme/security/crypts/WORDPRESS.java
index ddf150e6..59871d7d 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/WORDPRESS.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/WORDPRESS.java
@@ -7,6 +7,7 @@ import java.security.SecureRandom;
import java.util.Arrays;
public class WORDPRESS implements EncryptionMethod {
+
private static String itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
private int iterationCountLog2 = 8;
private SecureRandom randomGen = new SecureRandom();
@@ -47,8 +48,7 @@ public class WORDPRESS implements EncryptionMethod {
private String crypt(String password, String setting) {
String output = "*0";
- if (((setting.length() < 2) ? setting : setting.substring(0, 2))
- .equalsIgnoreCase(output)) {
+ if (((setting.length() < 2) ? setting : setting.substring(0, 2)).equalsIgnoreCase(output)) {
output = "*1";
}
String id = (setting.length() < 3) ? setting : setting.substring(0, 3);
@@ -95,8 +95,7 @@ public class WORDPRESS implements EncryptionMethod {
try {
return string.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
- throw new UnsupportedOperationException(
- "This system doesn't support UTF-8!", e);
+ throw new UnsupportedOperationException("This system doesn't support UTF-8!", e);
}
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/XAUTH.java b/src/main/java/fr/xephi/authme/security/crypts/XAUTH.java
index b3127619..8930c162 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/XAUTH.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/XAUTH.java
@@ -8,16 +8,14 @@ public class XAUTH implements EncryptionMethod {
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
String hash = getWhirlpool(salt + password).toLowerCase();
- int saltPos = (password.length() >= hash.length() ? hash.length() - 1
- : password.length());
+ int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
return hash.substring(0, saltPos) + salt + hash.substring(saltPos);
}
@Override
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
- int saltPos = (password.length() >= hash.length() ? hash.length() - 1
- : password.length());
+ int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
String salt = hash.substring(saltPos, saltPos + 12);
return hash.equals(getHash(password, salt, ""));
}
diff --git a/src/main/java/fr/xephi/authme/security/crypts/XF.java b/src/main/java/fr/xephi/authme/security/crypts/XF.java
index 27e024e4..54ba7035 100644
--- a/src/main/java/fr/xephi/authme/security/crypts/XF.java
+++ b/src/main/java/fr/xephi/authme/security/crypts/XF.java
@@ -14,17 +14,14 @@ public class XF implements EncryptionMethod {
@Override
public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException {
- return getSHA256(getSHA256(password)
- + regmatch("\"salt\";.:..:\"(.*)\";.:.:\"hashFunc\"", salt));
+ return getSHA256(getSHA256(password) + regmatch("\"salt\";.:..:\"(.*)\";.:.:\"hashFunc\"", salt));
}
@Override
public boolean comparePassword(String hash, String password,
String playerName) throws NoSuchAlgorithmException {
- String salt = AuthMe.getInstance().database.getAuth(playerName)
- .getSalt();
- return hash
- .equals(regmatch("\"hash\";.:..:\"(.*)\";.:.:\"salt\"", salt));
+ String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
+ return hash.equals(regmatch("\"hash\";.:..:\"(.*)\";.:.:\"salt\"", salt));
}
public String getSHA256(String password) throws NoSuchAlgorithmException {
@@ -33,8 +30,7 @@ public class XF implements EncryptionMethod {
byte byteData[] = md.digest();
StringBuffer sb = new StringBuffer();
for (byte element : byteData) {
- sb.append(Integer.toString((element & 0xff) + 0x100, 16).substring(
- 1));
+ sb.append(Integer.toString((element & 0xff) + 0x100, 16).substring(1));
}
StringBuffer hexString = new StringBuffer();
for (byte element : byteData) {
diff --git a/src/main/java/fr/xephi/authme/security/pbkdf2/BinTools.java b/src/main/java/fr/xephi/authme/security/pbkdf2/BinTools.java
index d5055879..36481ee8 100644
--- a/src/main/java/fr/xephi/authme/security/pbkdf2/BinTools.java
+++ b/src/main/java/fr/xephi/authme/security/pbkdf2/BinTools.java
@@ -31,6 +31,7 @@ package fr.xephi.authme.security.pbkdf2;
* @version 1.0
*/
public class BinTools {
+
public static final String hex = "0123456789ABCDEF";
/**
@@ -101,9 +102,7 @@ public class BinTools {
if (c >= 'a' && c <= 'f') {
return (c - 'a' + 10);
}
- throw new IllegalArgumentException(
- "Input string may only contain hex digits, but found '" + c
- + "'");
+ throw new IllegalArgumentException("Input string may only contain hex digits, but found '" + c + "'");
}
public static void main(String[] args) {
diff --git a/src/main/java/fr/xephi/authme/security/pbkdf2/MacBasedPRF.java b/src/main/java/fr/xephi/authme/security/pbkdf2/MacBasedPRF.java
index 7582926c..27f8bc0c 100644
--- a/src/main/java/fr/xephi/authme/security/pbkdf2/MacBasedPRF.java
+++ b/src/main/java/fr/xephi/authme/security/pbkdf2/MacBasedPRF.java
@@ -42,6 +42,7 @@ import javax.crypto.spec.SecretKeySpec;
* @version 1.0
*/
public class MacBasedPRF implements PRF {
+
protected Mac mac;
protected int hLen;
diff --git a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2.java b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2.java
index eb5bd8c9..6b1c27d6 100644
--- a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2.java
+++ b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2.java
@@ -32,6 +32,7 @@ package fr.xephi.authme.security.pbkdf2;
* @version 1.0
*/
public interface PBKDF2 {
+
/**
* Convert String-based input to internal byte array, then invoke PBKDF2.
* Desired key length defaults to Pseudo Random Function block size.
diff --git a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Engine.java b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Engine.java
index 79a7fee4..0d947c56 100644
--- a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Engine.java
+++ b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Engine.java
@@ -70,6 +70,7 @@ import java.security.SecureRandom;
* @version 1.0
*/
public class PBKDF2Engine implements PBKDF2 {
+
protected PBKDF2Parameters parameters;
protected PRF prf;
@@ -135,8 +136,7 @@ public class PBKDF2Engine implements PBKDF2 {
if (dkLen == 0) {
dkLen = prf.getHLen();
}
- r = PBKDF2(prf, parameters.getSalt(), parameters.getIterationCount(),
- dkLen);
+ r = PBKDF2(prf, parameters.getSalt(), parameters.getIterationCount(), dkLen);
return r;
}
@@ -337,8 +337,7 @@ public class PBKDF2Engine implements PBKDF2 {
byte[] salt = new byte[8];
sr.nextBytes(salt);
int iterations = 1000;
- PBKDF2Parameters p = new PBKDF2Parameters("HmacSHA1", "ISO-8859-1",
- salt, iterations);
+ PBKDF2Parameters p = new PBKDF2Parameters("HmacSHA1", "ISO-8859-1", salt, iterations);
PBKDF2Engine e = new PBKDF2Engine(p);
p.setDerivedKey(e.deriveKey(password));
candidate = formatter.toString(p);
@@ -349,9 +348,7 @@ public class PBKDF2Engine implements PBKDF2 {
p.setHashAlgorithm("HmacSHA1");
p.setHashCharset("ISO-8859-1");
if (formatter.fromString(p, candidate)) {
- throw new IllegalArgumentException(
- "Candidate data does not have correct format (\""
- + candidate + "\")");
+ throw new IllegalArgumentException("Candidate data does not have correct format (\"" + candidate + "\")");
}
PBKDF2Engine e = new PBKDF2Engine(p);
boolean verifyOK = e.verifyKey(password);
diff --git a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Formatter.java b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Formatter.java
index 401edf34..d4e63e89 100644
--- a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Formatter.java
+++ b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Formatter.java
@@ -32,6 +32,7 @@ package fr.xephi.authme.security.pbkdf2;
* @version 1.0
*/
public interface PBKDF2Formatter {
+
/**
* Convert parameters to String.
*
diff --git a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2HexFormatter.java b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2HexFormatter.java
index 92c0a291..c36b747c 100644
--- a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2HexFormatter.java
+++ b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2HexFormatter.java
@@ -32,6 +32,7 @@ package fr.xephi.authme.security.pbkdf2;
* @version 1.0
*/
public class PBKDF2HexFormatter implements PBKDF2Formatter {
+
public boolean fromString(PBKDF2Parameters p, String s) {
if (p == null || s == null) {
return true;
@@ -53,9 +54,7 @@ public class PBKDF2HexFormatter implements PBKDF2Formatter {
}
public String toString(PBKDF2Parameters p) {
- String s = BinTools.bin2hex(p.getSalt()) + ":"
- + String.valueOf(p.getIterationCount()) + ":"
- + BinTools.bin2hex(p.getDerivedKey());
+ String s = BinTools.bin2hex(p.getSalt()) + ":" + String.valueOf(p.getIterationCount()) + ":" + BinTools.bin2hex(p.getDerivedKey());
return s;
}
}
diff --git a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Parameters.java b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Parameters.java
index 8b4286f7..84c0978c 100644
--- a/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Parameters.java
+++ b/src/main/java/fr/xephi/authme/security/pbkdf2/PBKDF2Parameters.java
@@ -37,6 +37,7 @@ package fr.xephi.authme.security.pbkdf2;
* @version 1.0
*/
public class PBKDF2Parameters {
+
protected byte[] salt;
protected int iterationCount;
diff --git a/src/main/java/fr/xephi/authme/security/pbkdf2/PRF.java b/src/main/java/fr/xephi/authme/security/pbkdf2/PRF.java
index 17955787..733c2211 100644
--- a/src/main/java/fr/xephi/authme/security/pbkdf2/PRF.java
+++ b/src/main/java/fr/xephi/authme/security/pbkdf2/PRF.java
@@ -32,6 +32,7 @@ package fr.xephi.authme.security.pbkdf2;
* @version 1.0
*/
public interface PRF {
+
/**
* Initialize this instance with the user-supplied password.
*
diff --git a/src/main/java/fr/xephi/authme/settings/CustomConfiguration.java b/src/main/java/fr/xephi/authme/settings/CustomConfiguration.java
index 84de2b2c..e1fee3f2 100644
--- a/src/main/java/fr/xephi/authme/settings/CustomConfiguration.java
+++ b/src/main/java/fr/xephi/authme/settings/CustomConfiguration.java
@@ -32,19 +32,12 @@ public class CustomConfiguration extends YamlConfiguration {
try {
super.load(configFile);
} catch (FileNotFoundException e) {
- Logger.getLogger(JavaPlugin.class.getName()).log(
- Level.SEVERE,
- "Could not find " + configFile.getName()
- + ", creating new one...");
+ Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Could not find " + configFile.getName() + ", creating new one...");
reLoad();
} catch (IOException e) {
- Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE,
- "Could not load " + configFile.getName(), e);
+ Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Could not load " + configFile.getName(), e);
} catch (InvalidConfigurationException e) {
- Logger.getLogger(JavaPlugin.class.getName())
- .log(Level.SEVERE,
- configFile.getName()
- + " is no valid configuration file", e);
+ Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, configFile.getName() + " is no valid configuration file", e);
}
}
@@ -53,7 +46,8 @@ public class CustomConfiguration extends YamlConfiguration {
if (!configFile.exists()) {
out = loadRessource(configFile);
}
- if (out) load();
+ if (out)
+ load();
return out;
}
@@ -61,8 +55,7 @@ public class CustomConfiguration extends YamlConfiguration {
try {
super.save(configFile);
} catch (IOException ex) {
- Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE,
- "Could not save config to " + configFile.getName(), ex);
+ Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Could not save config to " + configFile.getName(), ex);
}
}
@@ -70,15 +63,10 @@ public class CustomConfiguration extends YamlConfiguration {
boolean out = true;
if (!file.exists()) {
try {
- InputStream fis = getClass().getResourceAsStream(
- "/" + file.getName());
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(fis, Charset.forName("UTF-8")
- .newDecoder()));
+ InputStream fis = getClass().getResourceAsStream("/" + file.getName());
+ BufferedReader reader = new BufferedReader(new InputStreamReader(fis, Charset.forName("UTF-8").newDecoder()));
String str;
- Writer writer = new BufferedWriter(new OutputStreamWriter(
- new FileOutputStream(file), Charset.forName("UTF-8")
- .newEncoder()));
+ Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), Charset.forName("UTF-8").newEncoder()));
while ((str = reader.readLine()) != null) {
writer.append(str).append("\r\n");
}
@@ -87,8 +75,7 @@ public class CustomConfiguration extends YamlConfiguration {
reader.close();
fis.close();
} catch (Exception e) {
- Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE,
- "Failed to load config from JAR");
+ Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Failed to load config from JAR");
out = false;
}
/*
diff --git a/src/main/java/fr/xephi/authme/settings/Messages.java b/src/main/java/fr/xephi/authme/settings/Messages.java
index f83fdc02..b717d58f 100644
--- a/src/main/java/fr/xephi/authme/settings/Messages.java
+++ b/src/main/java/fr/xephi/authme/settings/Messages.java
@@ -27,7 +27,8 @@ public class Messages extends CustomConfiguration {
*/
public final void loadDefaults(File file) {
InputStream stream = AuthMe.getInstance().getResource(file.getName());
- if (stream == null) return;
+ if (stream == null)
+ return;
setDefaults(YamlConfiguration.loadConfiguration(stream));
}
@@ -71,9 +72,7 @@ public class Messages extends CustomConfiguration {
String loc = (String) this.get(msg);
if (loc == null) {
loc = "Error with Translation files; Please contact the admin for verify or update translation";
- ConsoleLogger.showError("Error with the " + msg
- + " translation, verify in your " + Settings.MESSAGE_FILE
- + "_" + Settings.messagesLanguage + ".yml !");
+ ConsoleLogger.showError("Error with the " + msg + " translation, verify in your " + Settings.MESSAGE_FILE + "_" + Settings.messagesLanguage + ".yml !");
}
for (String l : loc.split("&n")) {
sender.sendMessage(l.replace("&", "\u00a7"));
@@ -85,24 +84,18 @@ public class Messages extends CustomConfiguration {
String[] loc = new String[i];
int a;
for (a = 0; a < i; a++) {
- loc[a] = ((String) this.get(msg)).split("&n")[a].replace("&",
- "\u00a7");
+ loc[a] = ((String) this.get(msg)).split("&n")[a].replace("&", "\u00a7");
}
if (loc == null || loc.length == 0) {
- loc[0] = "Error with "
- + msg
- + " translation; Please contact the admin for verify or update translation files";
- ConsoleLogger.showError("Error with the " + msg
- + " translation, verify in your " + Settings.MESSAGE_FILE
- + "_" + Settings.messagesLanguage + ".yml !");
+ loc[0] = "Error with " + msg + " translation; Please contact the admin for verify or update translation files";
+ ConsoleLogger.showError("Error with the " + msg + " translation, verify in your " + Settings.MESSAGE_FILE + "_" + Settings.messagesLanguage + ".yml !");
}
return loc;
}
public static Messages getInstance() {
if (singleton == null) {
- singleton = new Messages(new File(Settings.MESSAGE_FILE + "_"
- + Settings.messagesLanguage + ".yml"));
+ singleton = new Messages(new File(Settings.MESSAGE_FILE + "_" + Settings.messagesLanguage + ".yml"));
}
return singleton;
}
diff --git a/src/main/java/fr/xephi/authme/settings/OtherAccounts.java b/src/main/java/fr/xephi/authme/settings/OtherAccounts.java
index 96d1aacd..4da7b677 100644
--- a/src/main/java/fr/xephi/authme/settings/OtherAccounts.java
+++ b/src/main/java/fr/xephi/authme/settings/OtherAccounts.java
@@ -13,10 +13,11 @@ import org.bukkit.entity.Player;
* @author Xephi59
*/
public class OtherAccounts extends CustomConfiguration {
+
private static OtherAccounts others = null;
public OtherAccounts() {
- super(new File("./plugins/AuthMe/otheraccounts.yml"));
+ super(new File("." + File.separator + "plugins" + File.separator + "AuthMe" + File.separator + "otheraccounts.yml"));
others = this;
load();
save();
@@ -37,7 +38,8 @@ public class OtherAccounts extends CustomConfiguration {
public void addPlayer(UUID uuid) {
try {
Player player = Bukkit.getPlayer(uuid);
- if (player == null) return;
+ if (player == null)
+ return;
if (!this.getStringList(uuid.toString()).contains(player.getName())) {
this.getStringList(uuid.toString()).add(player.getName());
save();
@@ -50,7 +52,8 @@ public class OtherAccounts extends CustomConfiguration {
public void removePlayer(UUID uuid) {
try {
Player player = Bukkit.getPlayer(uuid);
- if (player == null) return;
+ if (player == null)
+ return;
if (this.getStringList(uuid.toString()).contains(player.getName())) {
this.getStringList(uuid.toString()).remove(player.getName());
save();
diff --git a/src/main/java/fr/xephi/authme/settings/PlayersLogs.java b/src/main/java/fr/xephi/authme/settings/PlayersLogs.java
index 7cf06ced..b95d2098 100644
--- a/src/main/java/fr/xephi/authme/settings/PlayersLogs.java
+++ b/src/main/java/fr/xephi/authme/settings/PlayersLogs.java
@@ -9,11 +9,12 @@ import java.util.List;
* @author Xephi59
*/
public class PlayersLogs extends CustomConfiguration {
+
private static PlayersLogs pllog = null;
public List players;
public PlayersLogs() {
- super(new File("./plugins/AuthMe/players.yml"));
+ super(new File("." + File.separator + "plugins" + File.separator + "AuthMe" + File.separator + "players.yml"));
pllog = this;
load();
save();
diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java
index 60924943..94cb12ed 100644
--- a/src/main/java/fr/xephi/authme/settings/Settings.java
+++ b/src/main/java/fr/xephi/authme/settings/Settings.java
@@ -23,13 +23,11 @@ import fr.xephi.authme.security.HashAlgorithm;
public final class Settings extends YamlConfiguration {
- public static final String PLUGIN_FOLDER = "./plugins/AuthMe";
- public static final String CACHE_FOLDER = Settings.PLUGIN_FOLDER + "/cache";
- public static final String AUTH_FILE = Settings.PLUGIN_FOLDER + "/auths.db";
- public static final String MESSAGE_FILE = Settings.PLUGIN_FOLDER
- + "/messages";
- public static final String SETTINGS_FILE = Settings.PLUGIN_FOLDER
- + "/config.yml";
+ public static final String PLUGIN_FOLDER = "." + File.separator + "plugins" + File.separator + "AuthMe";
+ public static final String CACHE_FOLDER = Settings.PLUGIN_FOLDER + File.separator + "cache";
+ public static final String AUTH_FILE = Settings.PLUGIN_FOLDER + File.separator + "auths.db";
+ public static final String MESSAGE_FILE = Settings.PLUGIN_FOLDER + File.separator + "messages";
+ public static final String SETTINGS_FILE = Settings.PLUGIN_FOLDER + File.separator + "config.yml";
public static List allowCommands = null;
public static List getJoinPermissions = null;
public static List getUnrestrictedName = null;
@@ -113,271 +111,158 @@ public final class Settings extends YamlConfiguration {
plugin.getLogger().info("Loading Configuration File...");
mergeConfig();
- messagesLanguage = checkLang(configFile.getString(
- "settings.messagesLanguage", "en"));
- isPermissionCheckEnabled = configFile.getBoolean(
- "permission.EnablePermissionCheck", false);
- isForcedRegistrationEnabled = configFile.getBoolean(
- "settings.registration.force", true);
- isRegistrationEnabled = configFile.getBoolean(
- "settings.registration.enabled", true);
- isTeleportToSpawnEnabled = configFile.getBoolean(
- "settings.restrictions.teleportUnAuthedToSpawn", false);
- getWarnMessageInterval = configFile.getInt(
- "settings.registration.messageInterval", 5);
- isSessionsEnabled = configFile.getBoolean("settings.sessions.enabled",
- false);
+ messagesLanguage = checkLang(configFile.getString("settings.messagesLanguage", "en"));
+ isPermissionCheckEnabled = configFile.getBoolean("permission.EnablePermissionCheck", false);
+ isForcedRegistrationEnabled = configFile.getBoolean("settings.registration.force", true);
+ isRegistrationEnabled = configFile.getBoolean("settings.registration.enabled", true);
+ isTeleportToSpawnEnabled = configFile.getBoolean("settings.restrictions.teleportUnAuthedToSpawn", false);
+ getWarnMessageInterval = configFile.getInt("settings.registration.messageInterval", 5);
+ isSessionsEnabled = configFile.getBoolean("settings.sessions.enabled", false);
getSessionTimeout = configFile.getInt("settings.sessions.timeout", 10);
- getRegistrationTimeout = configFile.getInt(
- "settings.restrictions.timeout", 30);
- isChatAllowed = configFile.getBoolean(
- "settings.restrictions.allowChat", false);
- getMaxNickLength = configFile.getInt(
- "settings.restrictions.maxNicknameLength", 20);
- getMinNickLength = configFile.getInt(
- "settings.restrictions.minNicknameLength", 3);
- getPasswordMinLen = configFile.getInt(
- "settings.security.minPasswordLength", 4);
- getNickRegex = configFile.getString(
- "settings.restrictions.allowedNicknameCharacters",
- "[a-zA-Z0-9_?]*");
- isAllowRestrictedIp = configFile.getBoolean(
- "settings.restrictions.AllowRestrictedUser", false);
- getRestrictedIp = configFile
- .getStringList("settings.restrictions.AllowedRestrictedUser");
- isMovementAllowed = configFile.getBoolean(
- "settings.restrictions.allowMovement", false);
- getMovementRadius = configFile.getInt(
- "settings.restrictions.allowedMovementRadius", 100);
- getJoinPermissions = configFile
- .getStringList("GroupOptions.Permissions.PermissionsOnJoin");
- isKickOnWrongPasswordEnabled = configFile.getBoolean(
- "settings.restrictions.kickOnWrongPassword", false);
- isKickNonRegisteredEnabled = configFile.getBoolean(
- "settings.restrictions.kickNonRegistered", false);
- isForceSingleSessionEnabled = configFile.getBoolean(
- "settings.restrictions.ForceSingleSession", true);
- isForceSpawnLocOnJoinEnabled = configFile.getBoolean(
- "settings.restrictions.ForceSpawnLocOnJoinEnabled", false);
- isSaveQuitLocationEnabled = configFile.getBoolean(
- "settings.restrictions.SaveQuitLocation", false);
- isForceSurvivalModeEnabled = configFile.getBoolean(
- "settings.GameMode.ForceSurvivalMode", false);
- isResetInventoryIfCreative = configFile.getBoolean(
- "settings.GameMode.ResetInventoryIfCreative", false);
- getmaxRegPerIp = configFile.getInt("settings.restrictions.maxRegPerIp",
- 1);
+ getRegistrationTimeout = configFile.getInt("settings.restrictions.timeout", 30);
+ isChatAllowed = configFile.getBoolean("settings.restrictions.allowChat", false);
+ getMaxNickLength = configFile.getInt("settings.restrictions.maxNicknameLength", 20);
+ getMinNickLength = configFile.getInt("settings.restrictions.minNicknameLength", 3);
+ getPasswordMinLen = configFile.getInt("settings.security.minPasswordLength", 4);
+ getNickRegex = configFile.getString("settings.restrictions.allowedNicknameCharacters", "[a-zA-Z0-9_?]*");
+ isAllowRestrictedIp = configFile.getBoolean("settings.restrictions.AllowRestrictedUser", false);
+ getRestrictedIp = configFile.getStringList("settings.restrictions.AllowedRestrictedUser");
+ isMovementAllowed = configFile.getBoolean("settings.restrictions.allowMovement", false);
+ getMovementRadius = configFile.getInt("settings.restrictions.allowedMovementRadius", 100);
+ getJoinPermissions = configFile.getStringList("GroupOptions.Permissions.PermissionsOnJoin");
+ isKickOnWrongPasswordEnabled = configFile.getBoolean("settings.restrictions.kickOnWrongPassword", false);
+ isKickNonRegisteredEnabled = configFile.getBoolean("settings.restrictions.kickNonRegistered", false);
+ isForceSingleSessionEnabled = configFile.getBoolean("settings.restrictions.ForceSingleSession", true);
+ isForceSpawnLocOnJoinEnabled = configFile.getBoolean("settings.restrictions.ForceSpawnLocOnJoinEnabled", false);
+ isSaveQuitLocationEnabled = configFile.getBoolean("settings.restrictions.SaveQuitLocation", false);
+ isForceSurvivalModeEnabled = configFile.getBoolean("settings.GameMode.ForceSurvivalMode", false);
+ isResetInventoryIfCreative = configFile.getBoolean("settings.GameMode.ResetInventoryIfCreative", false);
+ getmaxRegPerIp = configFile.getInt("settings.restrictions.maxRegPerIp", 1);
getPasswordHash = getPasswordHash();
- getUnloggedinGroup = configFile.getString(
- "settings.security.unLoggedinGroup", "unLoggedInGroup");
+ getUnloggedinGroup = configFile.getString("settings.security.unLoggedinGroup", "unLoggedInGroup");
getDataSource = getDataSource();
isCachingEnabled = configFile.getBoolean("DataSource.caching", true);
- getMySQLHost = configFile
- .getString("DataSource.mySQLHost", "127.0.0.1");
+ getMySQLHost = configFile.getString("DataSource.mySQLHost", "127.0.0.1");
getMySQLPort = configFile.getString("DataSource.mySQLPort", "3306");
- getMySQLUsername = configFile.getString("DataSource.mySQLUsername",
- "authme");
- getMySQLPassword = configFile.getString("DataSource.mySQLPassword",
- "12345");
- getMySQLDatabase = configFile.getString("DataSource.mySQLDatabase",
- "authme");
- getMySQLTablename = configFile.getString("DataSource.mySQLTablename",
- "authme");
- getMySQLColumnEmail = configFile.getString(
- "DataSource.mySQLColumnEmail", "email");
- getMySQLColumnName = configFile.getString("DataSource.mySQLColumnName",
- "username");
- getMySQLColumnPassword = configFile.getString(
- "DataSource.mySQLColumnPassword", "password");
- getMySQLColumnIp = configFile.getString("DataSource.mySQLColumnIp",
- "ip");
- getMySQLColumnLastLogin = configFile.getString(
- "DataSource.mySQLColumnLastLogin", "lastlogin");
- getMySQLColumnSalt = configFile
- .getString("ExternalBoardOptions.mySQLColumnSalt");
- getMySQLColumnGroup = configFile.getString(
- "ExternalBoardOptions.mySQLColumnGroup", "");
- getMySQLlastlocX = configFile
- .getString("DataSource.mySQLlastlocX", "x");
- getMySQLlastlocY = configFile
- .getString("DataSource.mySQLlastlocY", "y");
- getMySQLlastlocZ = configFile
- .getString("DataSource.mySQLlastlocZ", "z");
- getMySQLlastlocWorld = configFile.getString(
- "DataSource.mySQLlastlocWorld", "world");
- getNonActivatedGroup = configFile.getInt(
- "ExternalBoardOptions.nonActivedUserGroup", -1);
- unRegisteredGroup = configFile.getString(
- "GroupOptions.UnregisteredPlayerGroup", "");
- getUnrestrictedName = configFile
- .getStringList("settings.unrestrictions.UnrestrictedName");
- getRegisteredGroup = configFile.getString(
- "GroupOptions.RegisteredPlayerGroup", "");
- getEnablePasswordVerifier = configFile.getBoolean(
- "settings.restrictions.enablePasswordVerifier", true);
- protectInventoryBeforeLogInEnabled = configFile.getBoolean(
- "settings.restrictions.ProtectInventoryBeforeLogIn", true);
- passwordMaxLength = configFile.getInt(
- "settings.security.passwordMaxLength", 20);
- isBackupActivated = configFile.getBoolean(
- "BackupSystem.ActivateBackup", false);
- isBackupOnStart = configFile.getBoolean("BackupSystem.OnServerStart",
- false);
- isBackupOnStop = configFile.getBoolean("BackupSystem.OnServeStop",
- false);
- backupWindowsPath = configFile.getString(
- "BackupSystem.MysqlWindowsPath",
- "C:\\Program Files\\MySQL\\MySQL Server 5.1\\");
- enablePasspartu = configFile.getBoolean("Passpartu.enablePasspartu",
- false);
- isStopEnabled = configFile.getBoolean("Security.SQLProblem.stopServer",
- true);
- reloadSupport = configFile.getBoolean(
- "Security.ReloadCommand.useReloadCommandSupport", true);
- allowCommands = (List) configFile
- .getList("settings.restrictions.allowCommands");
+ getMySQLUsername = configFile.getString("DataSource.mySQLUsername", "authme");
+ getMySQLPassword = configFile.getString("DataSource.mySQLPassword", "12345");
+ getMySQLDatabase = configFile.getString("DataSource.mySQLDatabase", "authme");
+ getMySQLTablename = configFile.getString("DataSource.mySQLTablename", "authme");
+ getMySQLColumnEmail = configFile.getString("DataSource.mySQLColumnEmail", "email");
+ getMySQLColumnName = configFile.getString("DataSource.mySQLColumnName", "username");
+ getMySQLColumnPassword = configFile.getString("DataSource.mySQLColumnPassword", "password");
+ getMySQLColumnIp = configFile.getString("DataSource.mySQLColumnIp", "ip");
+ getMySQLColumnLastLogin = configFile.getString("DataSource.mySQLColumnLastLogin", "lastlogin");
+ getMySQLColumnSalt = configFile.getString("ExternalBoardOptions.mySQLColumnSalt");
+ getMySQLColumnGroup = configFile.getString("ExternalBoardOptions.mySQLColumnGroup", "");
+ getMySQLlastlocX = configFile.getString("DataSource.mySQLlastlocX", "x");
+ getMySQLlastlocY = configFile.getString("DataSource.mySQLlastlocY", "y");
+ getMySQLlastlocZ = configFile.getString("DataSource.mySQLlastlocZ", "z");
+ getMySQLlastlocWorld = configFile.getString("DataSource.mySQLlastlocWorld", "world");
+ getNonActivatedGroup = configFile.getInt("ExternalBoardOptions.nonActivedUserGroup", -1);
+ unRegisteredGroup = configFile.getString("GroupOptions.UnregisteredPlayerGroup", "");
+ getUnrestrictedName = configFile.getStringList("settings.unrestrictions.UnrestrictedName");
+ getRegisteredGroup = configFile.getString("GroupOptions.RegisteredPlayerGroup", "");
+ getEnablePasswordVerifier = configFile.getBoolean("settings.restrictions.enablePasswordVerifier", true);
+ protectInventoryBeforeLogInEnabled = configFile.getBoolean("settings.restrictions.ProtectInventoryBeforeLogIn", true);
+ passwordMaxLength = configFile.getInt("settings.security.passwordMaxLength", 20);
+ isBackupActivated = configFile.getBoolean("BackupSystem.ActivateBackup", false);
+ isBackupOnStart = configFile.getBoolean("BackupSystem.OnServerStart", false);
+ isBackupOnStop = configFile.getBoolean("BackupSystem.OnServeStop", false);
+ backupWindowsPath = configFile.getString("BackupSystem.MysqlWindowsPath", "C:\\Program Files\\MySQL\\MySQL Server 5.1\\");
+ enablePasspartu = configFile.getBoolean("Passpartu.enablePasspartu", false);
+ isStopEnabled = configFile.getBoolean("Security.SQLProblem.stopServer", true);
+ reloadSupport = configFile.getBoolean("Security.ReloadCommand.useReloadCommandSupport", true);
+ allowCommands = (List) configFile.getList("settings.restrictions.allowCommands");
if (configFile.contains("allowCommands")) {
- if (!allowCommands.contains("/login")) allowCommands.add("/login");
- if (!allowCommands.contains("/register")) allowCommands
- .add("/register");
- if (!allowCommands.contains("/l")) allowCommands.add("/l");
- if (!allowCommands.contains("/reg")) allowCommands.add("/reg");
- if (!allowCommands.contains("/passpartu")) allowCommands
- .add("/passpartu");
- if (!allowCommands.contains("/email")) allowCommands.add("/email");
- if (!allowCommands.contains("/captcha")) allowCommands
- .add("/captcha");
+ if (!allowCommands.contains("/login"))
+ allowCommands.add("/login");
+ if (!allowCommands.contains("/register"))
+ allowCommands.add("/register");
+ if (!allowCommands.contains("/l"))
+ allowCommands.add("/l");
+ if (!allowCommands.contains("/reg"))
+ allowCommands.add("/reg");
+ if (!allowCommands.contains("/passpartu"))
+ allowCommands.add("/passpartu");
+ if (!allowCommands.contains("/email"))
+ allowCommands.add("/email");
+ if (!allowCommands.contains("/captcha"))
+ allowCommands.add("/captcha");
}
- rakamakUsers = configFile.getString("Converter.Rakamak.fileName",
- "users.rak");
- rakamakUsersIp = configFile.getString("Converter.Rakamak.ipFileName",
- "UsersIp.rak");
+ rakamakUsers = configFile.getString("Converter.Rakamak.fileName", "users.rak");
+ rakamakUsersIp = configFile.getString("Converter.Rakamak.ipFileName", "UsersIp.rak");
rakamakUseIp = configFile.getBoolean("Converter.Rakamak.useIp", false);
- noConsoleSpam = configFile.getBoolean("Security.console.noConsoleSpam",
- false);
- removePassword = configFile.getBoolean(
- "Security.console.removePassword", true);
+ noConsoleSpam = configFile.getBoolean("Security.console.noConsoleSpam", false);
+ removePassword = configFile.getBoolean("Security.console.removePassword", true);
getmailAccount = configFile.getString("Email.mailAccount", "");
getmailPassword = configFile.getString("Email.mailPassword", "");
getmailSMTP = configFile.getString("Email.mailSMTP", "smtp.gmail.com");
getMailPort = configFile.getInt("Email.mailPort", 465);
- getRecoveryPassLength = configFile.getInt(
- "Email.RecoveryPasswordLength", 8);
- getMySQLOtherUsernameColumn = (List) configFile.getList(
- "ExternalBoardOptions.mySQLOtherUsernameColumns",
- new ArrayList());
- displayOtherAccounts = configFile.getBoolean(
- "settings.restrictions.displayOtherAccounts", true);
- getMySQLColumnId = configFile.getString("DataSource.mySQLColumnId",
- "id");
+ getRecoveryPassLength = configFile.getInt("Email.RecoveryPasswordLength", 8);
+ getMySQLOtherUsernameColumn = (List) configFile.getList("ExternalBoardOptions.mySQLOtherUsernameColumns", new ArrayList());
+ displayOtherAccounts = configFile.getBoolean("settings.restrictions.displayOtherAccounts", true);
+ getMySQLColumnId = configFile.getString("DataSource.mySQLColumnId", "id");
getmailSenderName = configFile.getString("Email.mailSenderName", "");
- useCaptcha = configFile
- .getBoolean("Security.captcha.useCaptcha", false);
+ useCaptcha = configFile.getBoolean("Security.captcha.useCaptcha", false);
maxLoginTry = configFile.getInt("Security.captcha.maxLoginTry", 5);
captchaLength = configFile.getInt("Security.captcha.captchaLength", 5);
- getMailSubject = configFile.getString("Email.mailSubject",
- "Your new AuthMe Password");
- getMailText = configFile
- .getString(
- "Email.mailText",
- "Dear , This is your new AuthMe password for the server : Do not forget to change password after login! /changepassword newPassword");
- emailRegistration = configFile.getBoolean(
- "settings.registration.enableEmailRegistrationSystem", false);
- saltLength = configFile.getInt("settings.security.doubleMD5SaltLength",
- 8);
+ getMailSubject = configFile.getString("Email.mailSubject", "Your new AuthMe Password");
+ getMailText = configFile.getString("Email.mailText", "Dear , This is your new AuthMe password for the server : Do not forget to change password after login! /changepassword newPassword");
+ emailRegistration = configFile.getBoolean("settings.registration.enableEmailRegistrationSystem", false);
+ saltLength = configFile.getInt("settings.security.doubleMD5SaltLength", 8);
getmaxRegPerEmail = configFile.getInt("Email.maxRegPerEmail", 1);
multiverse = configFile.getBoolean("Hooks.multiverse", true);
chestshop = configFile.getBoolean("Hooks.chestshop", true);
notifications = configFile.getBoolean("Hooks.notifications", true);
bungee = configFile.getBoolean("Hooks.bungeecord", false);
- getForcedWorlds = (List) configFile.getList(
- "settings.restrictions.ForceSpawnOnTheseWorlds",
- new ArrayList());
- banUnsafeIp = configFile.getBoolean(
- "settings.restrictions.banUnsafedIP", false);
- doubleEmailCheck = configFile.getBoolean(
- "settings.registration.doubleEmailCheck", false);
- sessionExpireOnIpChange = configFile.getBoolean(
- "settings.sessions.sessionExpireOnIpChange", false);
- useLogging = configFile
- .getBoolean("Security.console.logConsole", false);
- disableSocialSpy = configFile
- .getBoolean("Hooks.disableSocialSpy", true);
- bCryptLog2Rounds = configFile.getInt(
- "ExternalBoardOptions.bCryptLog2Round", 10);
- forceOnlyAfterLogin = configFile.getBoolean(
- "settings.GameMode.ForceOnlyAfterLogin", false);
- useEssentialsMotd = configFile.getBoolean("Hooks.useEssentialsMotd",
- false);
+ getForcedWorlds = (List) configFile.getList("settings.restrictions.ForceSpawnOnTheseWorlds", new ArrayList());
+ banUnsafeIp = configFile.getBoolean("settings.restrictions.banUnsafedIP", false);
+ doubleEmailCheck = configFile.getBoolean("settings.registration.doubleEmailCheck", false);
+ sessionExpireOnIpChange = configFile.getBoolean("settings.sessions.sessionExpireOnIpChange", false);
+ useLogging = configFile.getBoolean("Security.console.logConsole", false);
+ disableSocialSpy = configFile.getBoolean("Hooks.disableSocialSpy", true);
+ bCryptLog2Rounds = configFile.getInt("ExternalBoardOptions.bCryptLog2Round", 10);
+ forceOnlyAfterLogin = configFile.getBoolean("settings.GameMode.ForceOnlyAfterLogin", false);
+ useEssentialsMotd = configFile.getBoolean("Hooks.useEssentialsMotd", false);
usePurge = configFile.getBoolean("Purge.useAutoPurge", false);
purgeDelay = configFile.getInt("Purge.daysBeforeRemovePlayer", 60);
purgePlayerDat = configFile.getBoolean("Purge.removePlayerDat", false);
- purgeEssentialsFile = configFile.getBoolean(
- "Purge.removeEssentialsFile", false);
+ purgeEssentialsFile = configFile.getBoolean("Purge.removeEssentialsFile", false);
defaultWorld = configFile.getString("Purge.defaultWorld", "world");
- getPhpbbPrefix = configFile.getString(
- "ExternalBoardOptions.phpbbTablePrefix", "phpbb_");
- getPhpbbGroup = configFile.getInt(
- "ExternalBoardOptions.phpbbActivatedGroupId", 2);
- supportOldPassword = configFile.getBoolean(
- "settings.security.supportOldPasswordHash", false);
- getWordPressPrefix = configFile.getString(
- "ExternalBoardOptions.wordpressTablePrefix", "wp_");
- purgeLimitedCreative = configFile.getBoolean(
- "Purge.removeLimitedCreativesInventories", false);
- purgeAntiXray = configFile
- .getBoolean("Purge.removeAntiXRayFile", false);
+ getPhpbbPrefix = configFile.getString("ExternalBoardOptions.phpbbTablePrefix", "phpbb_");
+ getPhpbbGroup = configFile.getInt("ExternalBoardOptions.phpbbActivatedGroupId", 2);
+ supportOldPassword = configFile.getBoolean("settings.security.supportOldPasswordHash", false);
+ getWordPressPrefix = configFile.getString("ExternalBoardOptions.wordpressTablePrefix", "wp_");
+ purgeLimitedCreative = configFile.getBoolean("Purge.removeLimitedCreativesInventories", false);
+ purgeAntiXray = configFile.getBoolean("Purge.removeAntiXRayFile", false);
// purgePermissions = configFile.getBoolean("Purge.removePermissions",
// false);
- enableProtection = configFile.getBoolean("Protection.enableProtection",
- false);
- countries = (List) configFile.getList("Protection.countries",
- new ArrayList());
- enableAntiBot = configFile
- .getBoolean("Protection.enableAntiBot", false);
- antiBotSensibility = configFile.getInt("Protection.antiBotSensibility",
- 5);
+ enableProtection = configFile.getBoolean("Protection.enableProtection", false);
+ countries = (List) configFile.getList("Protection.countries", new ArrayList());
+ enableAntiBot = configFile.getBoolean("Protection.enableAntiBot", false);
+ antiBotSensibility = configFile.getInt("Protection.antiBotSensibility", 5);
antiBotDuration = configFile.getInt("Protection.antiBotDuration", 10);
- forceCommands = (List) configFile.getList(
- "settings.forceCommands", new ArrayList());
- forceCommandsAsConsole = (List) configFile.getList(
- "settings.forceCommandsAsConsole", new ArrayList());
+ forceCommands = (List) configFile.getList("settings.forceCommands", new ArrayList());
+ forceCommandsAsConsole = (List) configFile.getList("settings.forceCommandsAsConsole", new ArrayList());
recallEmail = configFile.getBoolean("Email.recallPlayers", false);
delayRecall = configFile.getInt("Email.delayRecall", 5);
- useWelcomeMessage = configFile.getBoolean("settings.useWelcomeMessage",
- true);
- unsafePasswords = (List) configFile.getList(
- "settings.security.unsafePasswords", new ArrayList());
- countriesBlacklist = (List) configFile.getList(
- "Protection.countriesBlacklist", new ArrayList());
- broadcastWelcomeMessage = configFile.getBoolean(
- "settings.broadcastWelcomeMessage", false);
- forceRegKick = configFile.getBoolean(
- "settings.registration.forceKickAfterRegister", false);
- forceRegLogin = configFile.getBoolean(
- "settings.registration.forceLoginAfterRegister", false);
- getMySQLColumnLogged = configFile.getString(
- "DataSource.mySQLColumnLogged", "isLogged");
- spawnPriority = configFile.getString(
- "settings.restrictions.spawnPriority",
- "authme,essentials,multiverse,default");
- getMaxLoginPerIp = configFile.getInt(
- "settings.restrictions.maxLoginPerIp", 0);
- getMaxJoinPerIp = configFile.getInt(
- "settings.restrictions.maxJoinPerIp", 0);
- checkVeryGames = configFile
- .getBoolean("VeryGames.enableIpCheck", false);
- delayJoinMessage = configFile.getBoolean("settings.delayJoinMessage",
- false);
- noTeleport = configFile.getBoolean("settings.restrictions.noTeleport",
- false);
- crazyloginFileName = configFile.getString(
- "Converter.CrazyLogin.fileName", "accounts.db");
- getPassRegex = configFile.getString(
- "settings.restrictions.allowedPasswordCharacters",
- "[a-zA-Z0-9_?!@+&-]*");
- applyBlindEffect = configFile.getBoolean("settings.applyBlindEffect",
- false);
+ useWelcomeMessage = configFile.getBoolean("settings.useWelcomeMessage", true);
+ unsafePasswords = (List) configFile.getList("settings.security.unsafePasswords", new ArrayList());
+ countriesBlacklist = (List) configFile.getList("Protection.countriesBlacklist", new ArrayList());
+ broadcastWelcomeMessage = configFile.getBoolean("settings.broadcastWelcomeMessage", false);
+ forceRegKick = configFile.getBoolean("settings.registration.forceKickAfterRegister", false);
+ forceRegLogin = configFile.getBoolean("settings.registration.forceLoginAfterRegister", false);
+ getMySQLColumnLogged = configFile.getString("DataSource.mySQLColumnLogged", "isLogged");
+ spawnPriority = configFile.getString("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
+ getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
+ getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
+ checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false);
+ delayJoinMessage = configFile.getBoolean("settings.delayJoinMessage", false);
+ noTeleport = configFile.getBoolean("settings.restrictions.noTeleport", false);
+ crazyloginFileName = configFile.getString("Converter.CrazyLogin.fileName", "accounts.db");
+ getPassRegex = configFile.getString("settings.restrictions.allowedPasswordCharacters", "[a-zA-Z0-9_?!@+&-]*");
+ applyBlindEffect = configFile.getBoolean("settings.applyBlindEffect", false);
emailBlacklist = configFile.getStringList("Email.emailBlacklisted");
emailWhitelist = configFile.getStringList("Email.emailWhitelisted");
@@ -391,269 +276,158 @@ public final class Settings extends YamlConfiguration {
public static void reloadConfigOptions(YamlConfiguration newConfig) {
configFile = newConfig;
- messagesLanguage = checkLang(configFile.getString(
- "settings.messagesLanguage", "en"));
- isPermissionCheckEnabled = configFile.getBoolean(
- "permission.EnablePermissionCheck", false);
- isForcedRegistrationEnabled = configFile.getBoolean(
- "settings.registration.force", true);
- isRegistrationEnabled = configFile.getBoolean(
- "settings.registration.enabled", true);
- isTeleportToSpawnEnabled = configFile.getBoolean(
- "settings.restrictions.teleportUnAuthedToSpawn", false);
- getWarnMessageInterval = configFile.getInt(
- "settings.registration.messageInterval", 5);
- isSessionsEnabled = configFile.getBoolean("settings.sessions.enabled",
- false);
+ messagesLanguage = checkLang(configFile.getString("settings.messagesLanguage", "en"));
+ isPermissionCheckEnabled = configFile.getBoolean("permission.EnablePermissionCheck", false);
+ isForcedRegistrationEnabled = configFile.getBoolean("settings.registration.force", true);
+ isRegistrationEnabled = configFile.getBoolean("settings.registration.enabled", true);
+ isTeleportToSpawnEnabled = configFile.getBoolean("settings.restrictions.teleportUnAuthedToSpawn", false);
+ getWarnMessageInterval = configFile.getInt("settings.registration.messageInterval", 5);
+ isSessionsEnabled = configFile.getBoolean("settings.sessions.enabled", false);
getSessionTimeout = configFile.getInt("settings.sessions.timeout", 10);
- getRegistrationTimeout = configFile.getInt(
- "settings.restrictions.timeout", 30);
- isChatAllowed = configFile.getBoolean(
- "settings.restrictions.allowChat", false);
- getMaxNickLength = configFile.getInt(
- "settings.restrictions.maxNicknameLength", 20);
- getMinNickLength = configFile.getInt(
- "settings.restrictions.minNicknameLength", 3);
- getPasswordMinLen = configFile.getInt(
- "settings.security.minPasswordLength", 4);
- getNickRegex = configFile.getString(
- "settings.restrictions.allowedNicknameCharacters",
- "[a-zA-Z0-9_?]*");
- isAllowRestrictedIp = configFile.getBoolean(
- "settings.restrictions.AllowRestrictedUser", false);
- getRestrictedIp = configFile
- .getStringList("settings.restrictions.AllowedRestrictedUser");
- isMovementAllowed = configFile.getBoolean(
- "settings.restrictions.allowMovement", false);
- getMovementRadius = configFile.getInt(
- "settings.restrictions.allowedMovementRadius", 100);
- getJoinPermissions = configFile
- .getStringList("GroupOptions.Permissions.PermissionsOnJoin");
- isKickOnWrongPasswordEnabled = configFile.getBoolean(
- "settings.restrictions.kickOnWrongPassword", false);
- isKickNonRegisteredEnabled = configFile.getBoolean(
- "settings.restrictions.kickNonRegistered", false);
- isForceSingleSessionEnabled = configFile.getBoolean(
- "settings.restrictions.ForceSingleSession", true);
- isForceSpawnLocOnJoinEnabled = configFile.getBoolean(
- "settings.restrictions.ForceSpawnLocOnJoinEnabled", false);
- isSaveQuitLocationEnabled = configFile.getBoolean(
- "settings.restrictions.SaveQuitLocation", false);
- isForceSurvivalModeEnabled = configFile.getBoolean(
- "settings.GameMode.ForceSurvivalMode", false);
- isResetInventoryIfCreative = configFile.getBoolean(
- "settings.GameMode.ResetInventoryIfCreative", false);
- getmaxRegPerIp = configFile.getInt("settings.restrictions.maxRegPerIp",
- 1);
+ getRegistrationTimeout = configFile.getInt("settings.restrictions.timeout", 30);
+ isChatAllowed = configFile.getBoolean("settings.restrictions.allowChat", false);
+ getMaxNickLength = configFile.getInt("settings.restrictions.maxNicknameLength", 20);
+ getMinNickLength = configFile.getInt("settings.restrictions.minNicknameLength", 3);
+ getPasswordMinLen = configFile.getInt("settings.security.minPasswordLength", 4);
+ getNickRegex = configFile.getString("settings.restrictions.allowedNicknameCharacters", "[a-zA-Z0-9_?]*");
+ isAllowRestrictedIp = configFile.getBoolean("settings.restrictions.AllowRestrictedUser", false);
+ getRestrictedIp = configFile.getStringList("settings.restrictions.AllowedRestrictedUser");
+ isMovementAllowed = configFile.getBoolean("settings.restrictions.allowMovement", false);
+ getMovementRadius = configFile.getInt("settings.restrictions.allowedMovementRadius", 100);
+ getJoinPermissions = configFile.getStringList("GroupOptions.Permissions.PermissionsOnJoin");
+ isKickOnWrongPasswordEnabled = configFile.getBoolean("settings.restrictions.kickOnWrongPassword", false);
+ isKickNonRegisteredEnabled = configFile.getBoolean("settings.restrictions.kickNonRegistered", false);
+ isForceSingleSessionEnabled = configFile.getBoolean("settings.restrictions.ForceSingleSession", true);
+ isForceSpawnLocOnJoinEnabled = configFile.getBoolean("settings.restrictions.ForceSpawnLocOnJoinEnabled", false);
+ isSaveQuitLocationEnabled = configFile.getBoolean("settings.restrictions.SaveQuitLocation", false);
+ isForceSurvivalModeEnabled = configFile.getBoolean("settings.GameMode.ForceSurvivalMode", false);
+ isResetInventoryIfCreative = configFile.getBoolean("settings.GameMode.ResetInventoryIfCreative", false);
+ getmaxRegPerIp = configFile.getInt("settings.restrictions.maxRegPerIp", 1);
getPasswordHash = getPasswordHash();
- getUnloggedinGroup = configFile.getString(
- "settings.security.unLoggedinGroup", "unLoggedInGroup");
+ getUnloggedinGroup = configFile.getString("settings.security.unLoggedinGroup", "unLoggedInGroup");
getDataSource = getDataSource();
isCachingEnabled = configFile.getBoolean("DataSource.caching", true);
- getMySQLHost = configFile
- .getString("DataSource.mySQLHost", "127.0.0.1");
+ getMySQLHost = configFile.getString("DataSource.mySQLHost", "127.0.0.1");
getMySQLPort = configFile.getString("DataSource.mySQLPort", "3306");
- getMySQLUsername = configFile.getString("DataSource.mySQLUsername",
- "authme");
- getMySQLPassword = configFile.getString("DataSource.mySQLPassword",
- "12345");
- getMySQLDatabase = configFile.getString("DataSource.mySQLDatabase",
- "authme");
- getMySQLTablename = configFile.getString("DataSource.mySQLTablename",
- "authme");
- getMySQLColumnEmail = configFile.getString(
- "DataSource.mySQLColumnEmail", "email");
- getMySQLColumnName = configFile.getString("DataSource.mySQLColumnName",
- "username");
- getMySQLColumnPassword = configFile.getString(
- "DataSource.mySQLColumnPassword", "password");
- getMySQLColumnIp = configFile.getString("DataSource.mySQLColumnIp",
- "ip");
- getMySQLColumnLastLogin = configFile.getString(
- "DataSource.mySQLColumnLastLogin", "lastlogin");
- getMySQLlastlocX = configFile
- .getString("DataSource.mySQLlastlocX", "x");
- getMySQLlastlocY = configFile
- .getString("DataSource.mySQLlastlocY", "y");
- getMySQLlastlocZ = configFile
- .getString("DataSource.mySQLlastlocZ", "z");
- getMySQLlastlocWorld = configFile.getString(
- "DataSource.mySQLlastlocWorld", "world");
- getMySQLColumnSalt = configFile.getString(
- "ExternalBoardOptions.mySQLColumnSalt", "");
- getMySQLColumnGroup = configFile.getString(
- "ExternalBoardOptions.mySQLColumnGroup", "");
- getNonActivatedGroup = configFile.getInt(
- "ExternalBoardOptions.nonActivedUserGroup", -1);
- unRegisteredGroup = configFile.getString(
- "GroupOptions.UnregisteredPlayerGroup", "");
- getUnrestrictedName = configFile
- .getStringList("settings.unrestrictions.UnrestrictedName");
- getRegisteredGroup = configFile.getString(
- "GroupOptions.RegisteredPlayerGroup", "");
- getEnablePasswordVerifier = configFile.getBoolean(
- "settings.restrictions.enablePasswordVerifier", true);
- protectInventoryBeforeLogInEnabled = configFile.getBoolean(
- "settings.restrictions.ProtectInventoryBeforeLogIn", true);
- passwordMaxLength = configFile.getInt(
- "settings.security.passwordMaxLength", 20);
- isBackupActivated = configFile.getBoolean(
- "BackupSystem.ActivateBackup", false);
- isBackupOnStart = configFile.getBoolean("BackupSystem.OnServerStart",
- false);
- isBackupOnStop = configFile.getBoolean("BackupSystem.OnServeStop",
- false);
- backupWindowsPath = configFile.getString(
- "BackupSystem.MysqlWindowsPath",
- "C:\\Program Files\\MySQL\\MySQL Server 5.1\\");
- enablePasspartu = configFile.getBoolean("Passpartu.enablePasspartu",
- false);
- isStopEnabled = configFile.getBoolean("Security.SQLProblem.stopServer",
- true);
- reloadSupport = configFile.getBoolean(
- "Security.ReloadCommand.useReloadCommandSupport", true);
- allowCommands = (List) configFile
- .getList("settings.restrictions.allowCommands");
+ getMySQLUsername = configFile.getString("DataSource.mySQLUsername", "authme");
+ getMySQLPassword = configFile.getString("DataSource.mySQLPassword", "12345");
+ getMySQLDatabase = configFile.getString("DataSource.mySQLDatabase", "authme");
+ getMySQLTablename = configFile.getString("DataSource.mySQLTablename", "authme");
+ getMySQLColumnEmail = configFile.getString("DataSource.mySQLColumnEmail", "email");
+ getMySQLColumnName = configFile.getString("DataSource.mySQLColumnName", "username");
+ getMySQLColumnPassword = configFile.getString("DataSource.mySQLColumnPassword", "password");
+ getMySQLColumnIp = configFile.getString("DataSource.mySQLColumnIp", "ip");
+ getMySQLColumnLastLogin = configFile.getString("DataSource.mySQLColumnLastLogin", "lastlogin");
+ getMySQLlastlocX = configFile.getString("DataSource.mySQLlastlocX", "x");
+ getMySQLlastlocY = configFile.getString("DataSource.mySQLlastlocY", "y");
+ getMySQLlastlocZ = configFile.getString("DataSource.mySQLlastlocZ", "z");
+ getMySQLlastlocWorld = configFile.getString("DataSource.mySQLlastlocWorld", "world");
+ getMySQLColumnSalt = configFile.getString("ExternalBoardOptions.mySQLColumnSalt", "");
+ getMySQLColumnGroup = configFile.getString("ExternalBoardOptions.mySQLColumnGroup", "");
+ getNonActivatedGroup = configFile.getInt("ExternalBoardOptions.nonActivedUserGroup", -1);
+ unRegisteredGroup = configFile.getString("GroupOptions.UnregisteredPlayerGroup", "");
+ getUnrestrictedName = configFile.getStringList("settings.unrestrictions.UnrestrictedName");
+ getRegisteredGroup = configFile.getString("GroupOptions.RegisteredPlayerGroup", "");
+ getEnablePasswordVerifier = configFile.getBoolean("settings.restrictions.enablePasswordVerifier", true);
+ protectInventoryBeforeLogInEnabled = configFile.getBoolean("settings.restrictions.ProtectInventoryBeforeLogIn", true);
+ passwordMaxLength = configFile.getInt("settings.security.passwordMaxLength", 20);
+ isBackupActivated = configFile.getBoolean("BackupSystem.ActivateBackup", false);
+ isBackupOnStart = configFile.getBoolean("BackupSystem.OnServerStart", false);
+ isBackupOnStop = configFile.getBoolean("BackupSystem.OnServeStop", false);
+ backupWindowsPath = configFile.getString("BackupSystem.MysqlWindowsPath", "C:\\Program Files\\MySQL\\MySQL Server 5.1\\");
+ enablePasspartu = configFile.getBoolean("Passpartu.enablePasspartu", false);
+ isStopEnabled = configFile.getBoolean("Security.SQLProblem.stopServer", true);
+ reloadSupport = configFile.getBoolean("Security.ReloadCommand.useReloadCommandSupport", true);
+ allowCommands = (List) configFile.getList("settings.restrictions.allowCommands");
if (configFile.contains("allowCommands")) {
- if (!allowCommands.contains("/login")) allowCommands.add("/login");
- if (!allowCommands.contains("/register")) allowCommands
- .add("/register");
- if (!allowCommands.contains("/l")) allowCommands.add("/l");
- if (!allowCommands.contains("/reg")) allowCommands.add("/reg");
- if (!allowCommands.contains("/passpartu")) allowCommands
- .add("/passpartu");
- if (!allowCommands.contains("/email")) allowCommands.add("/email");
- if (!allowCommands.contains("/captcha")) allowCommands
- .add("/captcha");
+ if (!allowCommands.contains("/login"))
+ allowCommands.add("/login");
+ if (!allowCommands.contains("/register"))
+ allowCommands.add("/register");
+ if (!allowCommands.contains("/l"))
+ allowCommands.add("/l");
+ if (!allowCommands.contains("/reg"))
+ allowCommands.add("/reg");
+ if (!allowCommands.contains("/passpartu"))
+ allowCommands.add("/passpartu");
+ if (!allowCommands.contains("/email"))
+ allowCommands.add("/email");
+ if (!allowCommands.contains("/captcha"))
+ allowCommands.add("/captcha");
}
- rakamakUsers = configFile.getString("Converter.Rakamak.fileName",
- "users.rak");
- rakamakUsersIp = configFile.getString("Converter.Rakamak.ipFileName",
- "UsersIp.rak");
+ rakamakUsers = configFile.getString("Converter.Rakamak.fileName", "users.rak");
+ rakamakUsersIp = configFile.getString("Converter.Rakamak.ipFileName", "UsersIp.rak");
rakamakUseIp = configFile.getBoolean("Converter.Rakamak.useIp", false);
- noConsoleSpam = configFile.getBoolean("Security.console.noConsoleSpam",
- false);
- removePassword = configFile.getBoolean(
- "Security.console.removePassword", true);
+ noConsoleSpam = configFile.getBoolean("Security.console.noConsoleSpam", false);
+ removePassword = configFile.getBoolean("Security.console.removePassword", true);
getmailAccount = configFile.getString("Email.mailAccount", "");
getmailPassword = configFile.getString("Email.mailPassword", "");
getmailSMTP = configFile.getString("Email.mailSMTP", "smtp.gmail.com");
getMailPort = configFile.getInt("Email.mailPort", 465);
- getRecoveryPassLength = configFile.getInt(
- "Email.RecoveryPasswordLength", 8);
- getMySQLOtherUsernameColumn = (List) configFile.getList(
- "ExternalBoardOptions.mySQLOtherUsernameColumns",
- new ArrayList());
- displayOtherAccounts = configFile.getBoolean(
- "settings.restrictions.displayOtherAccounts", true);
- getMySQLColumnId = configFile.getString("DataSource.mySQLColumnId",
- "id");
+ getRecoveryPassLength = configFile.getInt("Email.RecoveryPasswordLength", 8);
+ getMySQLOtherUsernameColumn = (List) configFile.getList("ExternalBoardOptions.mySQLOtherUsernameColumns", new ArrayList());
+ displayOtherAccounts = configFile.getBoolean("settings.restrictions.displayOtherAccounts", true);
+ getMySQLColumnId = configFile.getString("DataSource.mySQLColumnId", "id");
getmailSenderName = configFile.getString("Email.mailSenderName", "");
- useCaptcha = configFile
- .getBoolean("Security.captcha.useCaptcha", false);
+ useCaptcha = configFile.getBoolean("Security.captcha.useCaptcha", false);
maxLoginTry = configFile.getInt("Security.captcha.maxLoginTry", 5);
captchaLength = configFile.getInt("Security.captcha.captchaLength", 5);
- getMailSubject = configFile.getString("Email.mailSubject",
- "Your new AuthMe Password");
- getMailText = configFile
- .getString(
- "Email.mailText",
- "Dear , This is your new AuthMe password for the server : Do not forget to change password after login! /changepassword newPassword");
- emailRegistration = configFile.getBoolean(
- "settings.registration.enableEmailRegistrationSystem", false);
- saltLength = configFile.getInt("settings.security.doubleMD5SaltLength",
- 8);
+ getMailSubject = configFile.getString("Email.mailSubject", "Your new AuthMe Password");
+ getMailText = configFile.getString("Email.mailText", "Dear , This is your new AuthMe password for the server : Do not forget to change password after login! /changepassword newPassword");
+ emailRegistration = configFile.getBoolean("settings.registration.enableEmailRegistrationSystem", false);
+ saltLength = configFile.getInt("settings.security.doubleMD5SaltLength", 8);
getmaxRegPerEmail = configFile.getInt("Email.maxRegPerEmail", 1);
multiverse = configFile.getBoolean("Hooks.multiverse", true);
chestshop = configFile.getBoolean("Hooks.chestshop", true);
notifications = configFile.getBoolean("Hooks.notifications", true);
bungee = configFile.getBoolean("Hooks.bungeecord", false);
- getForcedWorlds = (List) configFile
- .getList("settings.restrictions.ForceSpawnOnTheseWorlds");
- banUnsafeIp = configFile.getBoolean(
- "settings.restrictions.banUnsafedIP", false);
- doubleEmailCheck = configFile.getBoolean(
- "settings.registration.doubleEmailCheck", false);
- sessionExpireOnIpChange = configFile.getBoolean(
- "settings.sessions.sessionExpireOnIpChange", false);
- useLogging = configFile
- .getBoolean("Security.console.logConsole", false);
- disableSocialSpy = configFile
- .getBoolean("Hooks.disableSocialSpy", true);
- bCryptLog2Rounds = configFile.getInt(
- "ExternalBoardOptions.bCryptLog2Round", 10);
- forceOnlyAfterLogin = configFile.getBoolean(
- "settings.GameMode.ForceOnlyAfterLogin", false);
- useEssentialsMotd = configFile.getBoolean("Hooks.useEssentialsMotd",
- false);
+ getForcedWorlds = (List) configFile.getList("settings.restrictions.ForceSpawnOnTheseWorlds");
+ banUnsafeIp = configFile.getBoolean("settings.restrictions.banUnsafedIP", false);
+ doubleEmailCheck = configFile.getBoolean("settings.registration.doubleEmailCheck", false);
+ sessionExpireOnIpChange = configFile.getBoolean("settings.sessions.sessionExpireOnIpChange", false);
+ useLogging = configFile.getBoolean("Security.console.logConsole", false);
+ disableSocialSpy = configFile.getBoolean("Hooks.disableSocialSpy", true);
+ bCryptLog2Rounds = configFile.getInt("ExternalBoardOptions.bCryptLog2Round", 10);
+ forceOnlyAfterLogin = configFile.getBoolean("settings.GameMode.ForceOnlyAfterLogin", false);
+ useEssentialsMotd = configFile.getBoolean("Hooks.useEssentialsMotd", false);
usePurge = configFile.getBoolean("Purge.useAutoPurge", false);
purgeDelay = configFile.getInt("Purge.daysBeforeRemovePlayer", 60);
purgePlayerDat = configFile.getBoolean("Purge.removePlayerDat", false);
- purgeEssentialsFile = configFile.getBoolean(
- "Purge.removeEssentialsFile", false);
+ purgeEssentialsFile = configFile.getBoolean("Purge.removeEssentialsFile", false);
defaultWorld = configFile.getString("Purge.defaultWorld", "world");
- getPhpbbPrefix = configFile.getString(
- "ExternalBoardOptions.phpbbTablePrefix", "phpbb_");
- getPhpbbGroup = configFile.getInt(
- "ExternalBoardOptions.phpbbActivatedGroupId", 2);
- supportOldPassword = configFile.getBoolean(
- "settings.security.supportOldPasswordHash", false);
- getWordPressPrefix = configFile.getString(
- "ExternalBoardOptions.wordpressTablePrefix", "wp_");
- purgeLimitedCreative = configFile.getBoolean(
- "Purge.removeLimitedCreativesInventories", false);
- purgeAntiXray = configFile
- .getBoolean("Purge.removeAntiXRayFile", false);
+ getPhpbbPrefix = configFile.getString("ExternalBoardOptions.phpbbTablePrefix", "phpbb_");
+ getPhpbbGroup = configFile.getInt("ExternalBoardOptions.phpbbActivatedGroupId", 2);
+ supportOldPassword = configFile.getBoolean("settings.security.supportOldPasswordHash", false);
+ getWordPressPrefix = configFile.getString("ExternalBoardOptions.wordpressTablePrefix", "wp_");
+ purgeLimitedCreative = configFile.getBoolean("Purge.removeLimitedCreativesInventories", false);
+ purgeAntiXray = configFile.getBoolean("Purge.removeAntiXRayFile", false);
// purgePermissions = configFile.getBoolean("Purge.removePermissions",
// false);
- enableProtection = configFile.getBoolean("Protection.enableProtection",
- false);
+ enableProtection = configFile.getBoolean("Protection.enableProtection", false);
countries = (List) configFile.getList("Protection.countries");
- enableAntiBot = configFile
- .getBoolean("Protection.enableAntiBot", false);
- antiBotSensibility = configFile.getInt("Protection.antiBotSensibility",
- 5);
+ enableAntiBot = configFile.getBoolean("Protection.enableAntiBot", false);
+ antiBotSensibility = configFile.getInt("Protection.antiBotSensibility", 5);
antiBotDuration = configFile.getInt("Protection.antiBotDuration", 10);
- forceCommands = (List) configFile.getList(
- "settings.forceCommands", new ArrayList());
- forceCommandsAsConsole = (List) configFile.getList(
- "settings.forceCommandsAsConsole", new ArrayList());
+ forceCommands = (List) configFile.getList("settings.forceCommands", new ArrayList());
+ forceCommandsAsConsole = (List) configFile.getList("settings.forceCommandsAsConsole", new ArrayList());
recallEmail = configFile.getBoolean("Email.recallPlayers", false);
delayRecall = configFile.getInt("Email.delayRecall", 5);
- useWelcomeMessage = configFile.getBoolean("settings.useWelcomeMessage",
- true);
- unsafePasswords = (List) configFile.getList(
- "settings.security.unsafePasswords", new ArrayList());
- countriesBlacklist = (List) configFile.getList(
- "Protection.countriesBlacklist", new ArrayList());
- broadcastWelcomeMessage = configFile.getBoolean(
- "settings.broadcastWelcomeMessage", false);
- forceRegKick = configFile.getBoolean(
- "settings.registration.forceKickAfterRegister", false);
- forceRegLogin = configFile.getBoolean(
- "settings.registration.forceLoginAfterRegister", false);
- getMySQLColumnLogged = configFile.getString(
- "DataSource.mySQLColumnLogged", "isLogged");
- spawnPriority = configFile.getString(
- "settings.restrictions.spawnPriority",
- "authme,essentials,multiverse,default");
- getMaxLoginPerIp = configFile.getInt(
- "settings.restrictions.maxLoginPerIp", 0);
- getMaxJoinPerIp = configFile.getInt(
- "settings.restrictions.maxJoinPerIp", 0);
- checkVeryGames = configFile
- .getBoolean("VeryGames.enableIpCheck", false);
- delayJoinMessage = configFile.getBoolean("settings.delayJoinMessage",
- false);
- noTeleport = configFile.getBoolean("settings.restrictions.noTeleport",
- false);
- crazyloginFileName = configFile.getString(
- "Converter.CrazyLogin.fileName", "accounts.db");
- getPassRegex = configFile.getString(
- "settings.restrictions.allowedPasswordCharacters",
- "[a-zA-Z0-9_?!@+&-]*");
- applyBlindEffect = configFile.getBoolean("settings.applyBlindEffect",
- false);
+ useWelcomeMessage = configFile.getBoolean("settings.useWelcomeMessage", true);
+ unsafePasswords = (List) configFile.getList("settings.security.unsafePasswords", new ArrayList());
+ countriesBlacklist = (List) configFile.getList("Protection.countriesBlacklist", new ArrayList());
+ broadcastWelcomeMessage = configFile.getBoolean("settings.broadcastWelcomeMessage", false);
+ forceRegKick = configFile.getBoolean("settings.registration.forceKickAfterRegister", false);
+ forceRegLogin = configFile.getBoolean("settings.registration.forceLoginAfterRegister", false);
+ getMySQLColumnLogged = configFile.getString("DataSource.mySQLColumnLogged", "isLogged");
+ spawnPriority = configFile.getString("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
+ getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
+ getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
+ checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false);
+ delayJoinMessage = configFile.getBoolean("settings.delayJoinMessage", false);
+ noTeleport = configFile.getBoolean("settings.restrictions.noTeleport", false);
+ crazyloginFileName = configFile.getString("Converter.CrazyLogin.fileName", "accounts.db");
+ getPassRegex = configFile.getString("settings.restrictions.allowedPasswordCharacters", "[a-zA-Z0-9_?!@+&-]*");
+ applyBlindEffect = configFile.getBoolean("settings.applyBlindEffect", false);
emailBlacklist = configFile.getStringList("Email.emailBlacklisted");
emailWhitelist = configFile.getStringList("Email.emailWhitelisted");
@@ -664,14 +438,10 @@ public final class Settings extends YamlConfiguration {
public void mergeConfig() {
boolean changes = false;
- if (contains("Xenoforo.predefinedSalt")) set("Xenoforo.predefinedSalt",
- null);
- if (configFile.getString("settings.security.passwordHash", "SHA256")
- .toUpperCase().equals("XFSHA1")
- || configFile
- .getString("settings.security.passwordHash", "SHA256")
- .toUpperCase().equals("XFSHA256")) set(
- "settings.security.passwordHash", "XENFORO");
+ if (contains("Xenoforo.predefinedSalt"))
+ set("Xenoforo.predefinedSalt", null);
+ if (configFile.getString("settings.security.passwordHash", "SHA256").toUpperCase().equals("XFSHA1") || configFile.getString("settings.security.passwordHash", "SHA256").toUpperCase().equals("XFSHA256"))
+ set("settings.security.passwordHash", "XENFORO");
if (!contains("Protection.enableProtection")) {
set("Protection.enableProtection", false);
changes = true;
@@ -745,8 +515,7 @@ public final class Settings extends YamlConfiguration {
changes = true;
}
if (!contains("settings.restrictions.spawnPriority")) {
- set("settings.restrictions.spawnPriority",
- "authme,essentials,multiverse,default");
+ set("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
changes = true;
}
if (!contains("settings.restrictions.maxLoginPerIp")) {
@@ -761,10 +530,8 @@ public final class Settings extends YamlConfiguration {
set("VeryGames.enableIpCheck", false);
changes = true;
}
- if (getString("settings.restrictions.allowedNicknameCharacters")
- .equals("[a-zA-Z0-9_?]*")) set(
- "settings.restrictions.allowedNicknameCharacters",
- "[a-zA-Z0-9_]*");
+ if (getString("settings.restrictions.allowedNicknameCharacters").equals("[a-zA-Z0-9_?]*"))
+ set("settings.restrictions.allowedNicknameCharacters", "[a-zA-Z0-9_]*");
if (!contains("settings.delayJoinMessage")) {
set("settings.delayJoinMessage", false);
changes = true;
@@ -773,15 +540,14 @@ public final class Settings extends YamlConfiguration {
set("settings.restrictions.noTeleport", false);
changes = true;
}
- if (contains("Converter.Rakamak.newPasswordHash")) set(
- "Converter.Rakamak.newPasswordHash", null);
+ if (contains("Converter.Rakamak.newPasswordHash"))
+ set("Converter.Rakamak.newPasswordHash", null);
if (!contains("Converter.CrazyLogin.fileName")) {
set("Converter.CrazyLogin.fileName", "accounts.db");
changes = true;
}
if (!contains("settings.restrictions.allowedPasswordCharacters")) {
- set("settings.restrictions.allowedPasswordCharacters",
- "[a-zA-Z0-9_?!@+&-]*");
+ set("settings.restrictions.allowedPasswordCharacters", "[a-zA-Z0-9_?!@+&-]*");
changes = true;
}
if (!contains("settings.applyBlindEffect")) {
@@ -800,11 +566,8 @@ public final class Settings extends YamlConfiguration {
}
if (changes) {
- plugin.getLogger()
- .warning(
- "Merge new Config Options - I'm not an error, please don't report me");
- plugin.getLogger().warning(
- "Please check your config.yml file for new configs!");
+ plugin.getLogger().warning("Merge new Config Options - I'm not an error, please don't report me");
+ plugin.getLogger().warning("Please check your config.yml file for new configs!");
}
plugin.saveConfig();
@@ -814,11 +577,9 @@ public final class Settings extends YamlConfiguration {
private static HashAlgorithm getPasswordHash() {
String key = "settings.security.passwordHash";
try {
- return HashAlgorithm.valueOf(configFile.getString(key, "SHA256")
- .toUpperCase());
+ return HashAlgorithm.valueOf(configFile.getString(key, "SHA256").toUpperCase());
} catch (IllegalArgumentException ex) {
- ConsoleLogger
- .showError("Unknown Hash Algorithm; defaulting to SHA256");
+ ConsoleLogger.showError("Unknown Hash Algorithm; defaulting to SHA256");
return HashAlgorithm.SHA256;
}
}
@@ -826,11 +587,9 @@ public final class Settings extends YamlConfiguration {
private static DataSourceType getDataSource() {
String key = "DataSource.backend";
try {
- return DataSource.DataSourceType.valueOf(configFile.getString(key)
- .toUpperCase());
+ return DataSource.DataSourceType.valueOf(configFile.getString(key).toUpperCase());
} catch (IllegalArgumentException ex) {
- ConsoleLogger
- .showError("Unknown database backend; defaulting to file database");
+ ConsoleLogger.showError("Unknown database backend; defaulting to file database");
return DataSource.DataSourceType.FILE;
}
}
@@ -918,7 +677,8 @@ public final class Settings extends YamlConfiguration {
*/
public final void loadDefaults(String filename) {
InputStream stream = plugin.getResource(filename);
- if (stream == null) return;
+ if (stream == null)
+ return;
setDefaults(YamlConfiguration.loadConfiguration(stream));
}
@@ -970,9 +730,9 @@ public final class Settings extends YamlConfiguration {
}
public static void switchAntiBotMod(boolean mode) {
- if (mode) isKickNonRegisteredEnabled = true;
- else isKickNonRegisteredEnabled = configFile.getBoolean(
- "settings.restrictions.kickNonRegistered", false);
+ if (mode)
+ isKickNonRegisteredEnabled = true;
+ else isKickNonRegisteredEnabled = configFile.getBoolean("settings.restrictions.kickNonRegistered", false);
}
private static void getWelcomeMessage(AuthMe plugin) {
@@ -980,11 +740,9 @@ public final class Settings extends YamlConfiguration {
if (!useWelcomeMessage) {
return;
}
- if (!(new File(plugin.getDataFolder() + File.separator + "welcome.txt")
- .exists())) {
+ if (!(new File(plugin.getDataFolder() + File.separator + "welcome.txt").exists())) {
try {
- FileWriter fw = new FileWriter(plugin.getDataFolder()
- + File.separator + "welcome.txt", true);
+ FileWriter fw = new FileWriter(plugin.getDataFolder() + File.separator + "welcome.txt", true);
BufferedWriter w = new BufferedWriter(fw);
w.write("Welcome {PLAYER} on {SERVER} server");
w.newLine();
@@ -995,8 +753,7 @@ public final class Settings extends YamlConfiguration {
}
}
try {
- FileReader fr = new FileReader(plugin.getDataFolder()
- + File.separator + "welcome.txt");
+ FileReader fr = new FileReader(plugin.getDataFolder() + File.separator + "welcome.txt");
BufferedReader br = new BufferedReader(fr);
String line = "";
while ((line = br.readLine()) != null) {
@@ -1011,8 +768,10 @@ public final class Settings extends YamlConfiguration {
}
public static boolean isEmailCorrect(String email) {
- if (!email.contains("@")) return false;
- if (email.equalsIgnoreCase("your@email.com")) return false;
+ if (!email.contains("@"))
+ return false;
+ if (email.equalsIgnoreCase("your@email.com"))
+ return false;
String emailDomain = email.split("@")[1];
boolean correct = true;
if (emailWhitelist != null && !emailWhitelist.isEmpty()) {
@@ -1038,6 +797,26 @@ public final class Settings extends YamlConfiguration {
}
public enum messagesLang {
- en, de, br, cz, pl, fr, uk, ru, hu, sk, es, fi, zhtw, zhhk, zhcn, lt, it, ko, pt, nl, gl
+ en,
+ de,
+ br,
+ cz,
+ pl,
+ fr,
+ uk,
+ ru,
+ hu,
+ sk,
+ es,
+ fi,
+ zhtw,
+ zhhk,
+ zhcn,
+ lt,
+ it,
+ ko,
+ pt,
+ nl,
+ gl
}
}
diff --git a/src/main/java/fr/xephi/authme/settings/Spawn.java b/src/main/java/fr/xephi/authme/settings/Spawn.java
index 243a6b30..3685c88e 100644
--- a/src/main/java/fr/xephi/authme/settings/Spawn.java
+++ b/src/main/java/fr/xephi/authme/settings/Spawn.java
@@ -13,7 +13,7 @@ public class Spawn extends CustomConfiguration {
private static Spawn spawn;
public Spawn() {
- super(new File("./plugins/AuthMe/spawn.yml"));
+ super(new File("." + File.separator + "plugins" + File.separator + "AuthMe" + File.separator + "spawn.yml"));
spawn = this;
load();
save();
@@ -85,13 +85,9 @@ public class Spawn extends CustomConfiguration {
public Location getSpawn() {
try {
- if (this.getString("spawn.world").isEmpty()
- || this.getString("spawn.world") == "") return null;
- Location location = new Location(Bukkit.getWorld(this
- .getString("spawn.world")), this.getDouble("spawn.x"),
- this.getDouble("spawn.y"), this.getDouble("spawn.z"),
- Float.parseFloat(this.getString("spawn.yaw")),
- Float.parseFloat(this.getString("spawn.pitch")));
+ if (this.getString("spawn.world").isEmpty() || this.getString("spawn.world") == "")
+ return null;
+ Location location = new Location(Bukkit.getWorld(this.getString("spawn.world")), this.getDouble("spawn.x"), this.getDouble("spawn.y"), this.getDouble("spawn.z"), Float.parseFloat(this.getString("spawn.yaw")), Float.parseFloat(this.getString("spawn.pitch")));
return location;
} catch (NullPointerException npe) {
return null;
@@ -102,15 +98,9 @@ public class Spawn extends CustomConfiguration {
public Location getFirstSpawn() {
try {
- if (this.getString("firstspawn.world").isEmpty()
- || this.getString("firstspawn.world") == "") return null;
- Location location = new Location(Bukkit.getWorld(this
- .getString("firstspawn.world")),
- this.getDouble("firstspawn.x"),
- this.getDouble("firstspawn.y"),
- this.getDouble("firstspawn.z"), Float.parseFloat(this
- .getString("firstspawn.yaw")),
- Float.parseFloat(this.getString("firstspawn.pitch")));
+ if (this.getString("firstspawn.world").isEmpty() || this.getString("firstspawn.world") == "")
+ return null;
+ Location location = new Location(Bukkit.getWorld(this.getString("firstspawn.world")), this.getDouble("firstspawn.x"), this.getDouble("firstspawn.y"), this.getDouble("firstspawn.z"), Float.parseFloat(this.getString("firstspawn.yaw")), Float.parseFloat(this.getString("firstspawn.pitch")));
return location;
} catch (NullPointerException npe) {
return null;
diff --git a/src/main/java/fr/xephi/authme/settings/SpoutCfg.java b/src/main/java/fr/xephi/authme/settings/SpoutCfg.java
index f7cea432..bc293303 100644
--- a/src/main/java/fr/xephi/authme/settings/SpoutCfg.java
+++ b/src/main/java/fr/xephi/authme/settings/SpoutCfg.java
@@ -23,6 +23,7 @@ public class SpoutCfg extends CustomConfiguration {
this.set("LoginScreen.login button", "Login");
this.set("LoginScreen.title", "LOGIN");
this.set("LoginScreen.text", new ArrayList() {
+
{
add("Sample text");
add("Change this at spout.yml");
@@ -33,8 +34,8 @@ public class SpoutCfg extends CustomConfiguration {
}
public static SpoutCfg getInstance() {
- if (instance == null) instance = new SpoutCfg(new File(
- "plugins/AuthMe", "spout.yml"));
+ if (instance == null)
+ instance = new SpoutCfg(new File("plugins" + File.separator + "AuthMe", "spout.yml"));
return instance;
}
}
diff --git a/src/main/java/fr/xephi/authme/task/MessageTask.java b/src/main/java/fr/xephi/authme/task/MessageTask.java
index 247ca500..5a280751 100644
--- a/src/main/java/fr/xephi/authme/task/MessageTask.java
+++ b/src/main/java/fr/xephi/authme/task/MessageTask.java
@@ -24,7 +24,8 @@ public class MessageTask implements Runnable {
@Override
public void run() {
- if (PlayerCache.getInstance().isAuthenticated(name)) return;
+ if (PlayerCache.getInstance().isAuthenticated(name))
+ return;
for (Player player : plugin.getServer().getOnlinePlayers()) {
if (player.getName().toLowerCase().equals(name)) {
@@ -32,11 +33,9 @@ public class MessageTask implements Runnable {
player.sendMessage(ms);
}
BukkitScheduler sched = plugin.getServer().getScheduler();
- int late = sched.scheduleSyncDelayedTask(plugin, this,
- interval * 20);
+ int late = sched.scheduleSyncDelayedTask(plugin, this, interval * 20);
if (LimboCache.getInstance().hasLimboPlayer(name)) {
- LimboCache.getInstance().getLimboPlayer(name)
- .setMessageTaskId(late);
+ LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(late);
}
}
}
diff --git a/src/main/java/fr/xephi/authme/task/TimeoutTask.java b/src/main/java/fr/xephi/authme/task/TimeoutTask.java
index b88281bb..5ffdc6bd 100644
--- a/src/main/java/fr/xephi/authme/task/TimeoutTask.java
+++ b/src/main/java/fr/xephi/authme/task/TimeoutTask.java
@@ -31,25 +31,22 @@ public class TimeoutTask implements Runnable {
@Override
public void run() {
- if (PlayerCache.getInstance().isAuthenticated(name)) return;
+ if (PlayerCache.getInstance().isAuthenticated(name))
+ return;
for (Player player : plugin.getServer().getOnlinePlayers()) {
if (player.getName().toLowerCase().equals(name)) {
if (LimboCache.getInstance().hasLimboPlayer(name)) {
- LimboPlayer inv = LimboCache.getInstance().getLimboPlayer(
- name);
- player.getServer().getScheduler()
- .cancelTask(inv.getMessageTaskId());
- player.getServer().getScheduler()
- .cancelTask(inv.getTimeoutTaskId());
+ LimboPlayer inv = LimboCache.getInstance().getLimboPlayer(name);
+ player.getServer().getScheduler().cancelTask(inv.getMessageTaskId());
+ player.getServer().getScheduler().cancelTask(inv.getTimeoutTaskId());
if (playerCache.doesCacheExist(player)) {
playerCache.removeCache(player);
}
}
GameMode gm = AuthMePlayerListener.gameMode.get(name);
player.setGameMode(gm);
- ConsoleLogger.info("Set " + player.getName() + " to gamemode: "
- + gm.name());
+ ConsoleLogger.info("Set " + player.getName() + " to gamemode: " + gm.name());
player.kickPlayer(m._("timeout")[0]);
break;
}