Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1023,8 +1023,10 @@ public void updateReplacements() {
*
* @param storageType the storage type to load
*/
@SuppressWarnings("deprecation")
public void loadUserAPI(UserStorage storageType) {
if (storageType == null) {
throw new IllegalArgumentException("User storage must be SQLITE or MYSQL");
}
if (storageType.equals(UserStorage.SQLITE)) {
ArrayList<Column> columns = new ArrayList<>();
Column key = new Column("uuid", DataType.STRING);
Expand All @@ -1043,8 +1045,6 @@ public void loadUserAPI(UserStorage storageType) {
getOptions().getYmlConfig().getData().getConfigurationSection("MySQL")));
}

} else if (storageType.equals(UserStorage.FLAT)) {
getLogger().severe("Detected using FLAT storage, this will be removed in the future!");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
import java.util.List;
import java.util.Map.Entry;

import org.bukkit.configuration.file.FileConfiguration;

import com.bencodez.advancedcore.api.user.usercache.UserDataCache;
import com.bencodez.advancedcore.api.user.usercache.change.UserDataChangeInt;
import com.bencodez.advancedcore.api.user.usercache.change.UserDataChangeString;
import com.bencodez.advancedcore.thread.FileThread;
import com.bencodez.simpleapi.array.ArrayUtils;
import com.bencodez.simpleapi.sql.Column;
import com.bencodez.simpleapi.sql.data.DataValue;
Expand Down Expand Up @@ -65,11 +62,6 @@ public boolean getBoolean(String key, boolean useCache, boolean waitForCache) {
return getBoolean(key, UserDataFetchMode.fromBooleans(useCache, waitForCache));
}

@Deprecated
public FileConfiguration getData(String uuid) {
return FileThread.getInstance().getThread().getData(this, uuid);
}

public DataValue getDataValue(String key) {
boolean isInt = user.getPlugin().getUserManager().getDataManager().isInt(key);
if (isInt) {
Expand Down Expand Up @@ -127,15 +119,8 @@ public int getInt(String key, int def, boolean useCache, boolean waitForCache) {
UserDataFetchMode.fromBooleans(useCache, waitForCache));
}

@SuppressWarnings("deprecation")
public int getInt(UserStorage storage, String key, int def, UserDataFetchMode mode) {
if (key == null || key.isEmpty()) {
if (storage.equals(UserStorage.FLAT)) {
try {
return getData(user.getUUID()).getInt(key, def);
} catch (Exception ignored) {
}
}
return def;
}

Expand Down Expand Up @@ -241,11 +226,6 @@ public int getInt(UserStorage storage, String key, int def, UserDataFetchMode mo
}
}
}
} else if (storage.equals(UserStorage.FLAT)) {
try {
return getData(user.getUUID()).getInt(key, def);
} catch (Exception ignored) {
}
}

return def;
Expand All @@ -263,12 +243,9 @@ public ArrayList<String> getKeys() {
return getKeys(user.getPlugin().getStorageType());
}

@SuppressWarnings("deprecation")
public ArrayList<String> getKeys(UserStorage storage) {
ArrayList<String> keys = new ArrayList<>();
if (storage.equals(UserStorage.FLAT)) {
keys = new ArrayList<>(getData(user.getUUID()).getConfigurationSection("").getKeys(false));
} else if (storage.equals(UserStorage.MYSQL)) {
if (storage.equals(UserStorage.MYSQL)) {
List<Column> col = getMySqlRow();
if (col != null && !col.isEmpty()) {
for (Column c : col) {
Expand Down Expand Up @@ -319,7 +296,6 @@ public String getString(String key, UserDataFetchMode mode) {
return getString(user.getPlugin().getStorageType(), key, mode);
}

@SuppressWarnings("deprecation")
public String getString(UserStorage storage, String key, UserDataFetchMode mode) {
if (key == null || key.isEmpty()) {
return "";
Expand Down Expand Up @@ -388,11 +364,6 @@ public String getString(UserStorage storage, String key, UserDataFetchMode mode)
}
}
}
} else if (storage.equals(UserStorage.FLAT)) {
try {
return getData(user.getUUID()).getString(key, "");
} catch (Exception ignored) {
}
}

return "";
Expand Down Expand Up @@ -454,49 +425,31 @@ public HashMap<String, DataValue> getValues() {
return getValues(user.getPlugin().getStorageType());
}

@SuppressWarnings("deprecation")
public HashMap<String, DataValue> getValues(UserStorage storage) {
if (storage.equals(UserStorage.MYSQL)) {
return convert(getMySqlRow());
}
if (storage.equals(UserStorage.SQLITE)) {
return convert(getSQLiteRow());
} else if (storage.equals(UserStorage.FLAT)) {
HashMap<String, DataValue> list = new HashMap<>();
FileConfiguration data = getData(user.getUUID());
for (String str : data.getKeys(false)) {
if (data.isInt(str)) {
list.put(str, new DataValueInt(data.getInt(str)));
} else {
list.put(str, new DataValueString(data.getString(str, "")));
}
}
return list;
}
return null;
}

@SuppressWarnings("deprecation")
public boolean hasData() {
if (user.getPlugin().getStorageType().equals(UserStorage.MYSQL)) {
return user.getPlugin().getMysql().containsKey(user.getUUID());
}
if (user.getPlugin().getStorageType().equals(UserStorage.SQLITE)) {
return user.getPlugin().getSQLiteUserTable().containsKey(user.getUUID());
} else if (user.getPlugin().getStorageType().equals(UserStorage.FLAT)) {
return FileThread.getInstance().getThread().hasPlayerFile(user.getUUID());
}
return false;
}

@SuppressWarnings("deprecation")
public void remove() {
if (user.getPlugin().getStorageType().equals(UserStorage.MYSQL)) {
user.getPlugin().getMysql().deletePlayer(user.getUUID());
} else if (user.getPlugin().getStorageType().equals(UserStorage.SQLITE)) {
user.getPlugin().getSQLiteUserTable().delete(new Column("uuid", new DataValueString(user.getUUID())));
} else if (user.getPlugin().getStorageType().equals(UserStorage.FLAT)) {
FileThread.getInstance().getThread().deletePlayerFile(user.getUUID());
}
user.clearCache();
}
Expand All @@ -509,11 +462,6 @@ public void setBoolean(String key, boolean value, boolean queue) {
setString(key, "" + value, queue);
}

@Deprecated
private void setData(final String uuid, final String path, final Object value) {
FileThread.getInstance().getThread().setData(this, uuid, path, value);
}

public void setInt(final String key, final int value) {
setInt(key, value, true);
}
Expand All @@ -530,7 +478,6 @@ public void setInt(UserStorage storage, final String key, final int value, boole
setInt(storage, key, value, queue, false);
}

@SuppressWarnings("deprecation")
public void setInt(final UserStorage storage, final String key, final int value, boolean queue, boolean async) {
if (key.equals("")) {
user.getPlugin().debug("No key: " + key + " to " + value);
Expand Down Expand Up @@ -565,8 +512,6 @@ public void run() {
user.getPlugin().getSQLiteUserTable().update(primary, columns);
} else if (storage.equals(UserStorage.MYSQL)) {
user.getPlugin().getMysql().update(user.getUUID(), key, new DataValueInt(value));
} else if (storage.equals(UserStorage.FLAT)) {
setData(user.getUUID(), key, value);
}

if (!user.isCached()) {
Expand All @@ -585,8 +530,6 @@ public void run() {
user.getPlugin().getSQLiteUserTable().update(primary, columns);
} else if (storage.equals(UserStorage.MYSQL)) {
user.getPlugin().getMysql().update(user.getUUID(), key, new DataValueInt(value));
} else if (storage.equals(UserStorage.FLAT)) {
setData(user.getUUID(), key, value);
}

if (!user.isCached()) {
Expand All @@ -611,7 +554,6 @@ public void setString(UserStorage storage, final String key, final String value,
setString(storage, key, value, queue, false);
}

@SuppressWarnings("deprecation")
public void setString(final UserStorage storage, final String key, final String value, boolean queue,
boolean async) {
if (key.equals("") && value != null) {
Expand Down Expand Up @@ -647,8 +589,6 @@ public void run() {
user.getPlugin().getSQLiteUserTable().update(primary, columns);
} else if (storage.equals(UserStorage.MYSQL)) {
user.getPlugin().getMysql().update(user.getUUID(), key, new DataValueString(value));
} else if (storage.equals(UserStorage.FLAT)) {
setData(user.getUUID(), key, value);
}
if (!user.isCached()) {
user.getPlugin().getUserManager().onChange(user, key);
Expand All @@ -665,8 +605,6 @@ public void run() {
user.getPlugin().getSQLiteUserTable().update(primary, columns);
} else if (storage.equals(UserStorage.MYSQL)) {
user.getPlugin().getMysql().update(user.getUUID(), key, new DataValueString(value));
} else if (storage.equals(UserStorage.FLAT)) {
setData(user.getUUID(), key, value);
}
if (!user.isCached()) {
user.getPlugin().getUserManager().onChange(user, key);
Expand Down Expand Up @@ -700,7 +638,6 @@ public void setValues(String key, DataValue value) {
setValues(user.getPlugin().getStorageType(), values);
}

@SuppressWarnings("deprecation")
public void setValues(UserStorage storage, HashMap<String, DataValue> values) {
if (storage.equals(UserStorage.MYSQL)) {
if (user.getPlugin().getMysql() != null) {
Expand All @@ -721,14 +658,6 @@ public void setValues(UserStorage storage, HashMap<String, DataValue> values) {
user.getPlugin().getSQLiteUserTable().update(new Column("uuid", new DataValueString(user.getUUID())),
cols);
}
} else if (storage.equals(UserStorage.FLAT)) {
for (Entry<String, DataValue> entry : values.entrySet()) {
if (entry.getValue() instanceof DataValueString) {
setData(user.getUUID(), entry.getKey(), entry.getValue().getString());
} else if (entry.getValue() instanceof DataValueInt) {
setData(user.getUUID(), entry.getKey(), entry.getValue().getInt());
}
}
}
}

Expand Down
Loading
Loading