Make case conversion operations use the English locale

feat/data-edit-commands
William 2 years ago
parent 54cc11fce0
commit 7bb4bff485
No known key found for this signature in database

@ -31,6 +31,7 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -163,7 +164,7 @@ public class BukkitEventListener extends EventListener implements BukkitJoinEven
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPermissionCommand(@NotNull PlayerCommandPreprocessEvent event) { public void onPermissionCommand(@NotNull PlayerCommandPreprocessEvent event) {
String[] commandArgs = event.getMessage().substring(1).split(" "); String[] commandArgs = event.getMessage().substring(1).split(" ");
String commandLabel = commandArgs[0].toLowerCase(); String commandLabel = commandArgs[0].toLowerCase(Locale.ENGLISH);
if (blacklistedCommands.contains(commandLabel)) { if (blacklistedCommands.contains(commandLabel)) {
event.setCancelled(cancelPlayerEvent(event.getPlayer().getUniqueId())); event.setCancelled(cancelPlayerEvent(event.getPlayer().getUniqueId()));

@ -66,7 +66,7 @@ public class LegacyMigrator extends Migrator {
connectionPool.setJdbcUrl(jdbcUrl); connectionPool.setJdbcUrl(jdbcUrl);
connectionPool.setUsername(sourceUsername); connectionPool.setUsername(sourceUsername);
connectionPool.setPassword(sourcePassword); connectionPool.setPassword(sourcePassword);
connectionPool.setPoolName((getIdentifier() + "_migrator_pool").toUpperCase()); connectionPool.setPoolName((getIdentifier() + "_migrator_pool").toUpperCase(Locale.ENGLISH));
plugin.log(Level.INFO, "Downloading raw data from the legacy database (this might take a while)..."); plugin.log(Level.INFO, "Downloading raw data from the legacy database (this might take a while)...");
final List<LegacyData> dataToMigrate = new ArrayList<>(); final List<LegacyData> dataToMigrate = new ArrayList<>();
@ -141,7 +141,7 @@ public class LegacyMigrator extends Migrator {
@Override @Override
public void handleConfigurationCommand(@NotNull String[] args) { public void handleConfigurationCommand(@NotNull String[] args) {
if (args.length == 2) { if (args.length == 2) {
if (switch (args[0].toLowerCase()) { if (switch (args[0].toLowerCase(Locale.ENGLISH)) {
case "host" -> { case "host" -> {
this.sourceHost = args[1]; this.sourceHost = args[1];
yield true; yield true;

@ -17,6 +17,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -73,7 +74,7 @@ public class MpdbMigrator extends Migrator {
connectionPool.setJdbcUrl(jdbcUrl); connectionPool.setJdbcUrl(jdbcUrl);
connectionPool.setUsername(sourceUsername); connectionPool.setUsername(sourceUsername);
connectionPool.setPassword(sourcePassword); connectionPool.setPassword(sourcePassword);
connectionPool.setPoolName((getIdentifier() + "_migrator_pool").toUpperCase()); connectionPool.setPoolName((getIdentifier() + "_migrator_pool").toUpperCase(Locale.ENGLISH));
plugin.log(Level.INFO, "Downloading raw data from the MySQLPlayerDataBridge database (this might take a while)..."); plugin.log(Level.INFO, "Downloading raw data from the MySQLPlayerDataBridge database (this might take a while)...");
final List<MpdbData> dataToMigrate = new ArrayList<>(); final List<MpdbData> dataToMigrate = new ArrayList<>();
@ -137,7 +138,7 @@ public class MpdbMigrator extends Migrator {
@Override @Override
public void handleConfigurationCommand(@NotNull String[] args) { public void handleConfigurationCommand(@NotNull String[] args) {
if (args.length == 2) { if (args.length == 2) {
if (switch (args[0].toLowerCase()) { if (switch (args[0].toLowerCase(Locale.ENGLISH)) {
case "host" -> { case "host" -> {
this.sourceHost = args[1]; this.sourceHost = args[1];
yield true; yield true;

@ -1,6 +1,7 @@
package net.william278.husksync; package net.william278.husksync;
import net.william278.desertwell.UpdateChecker; import net.william278.desertwell.UpdateChecker;
import net.william278.desertwell.Version;
import net.william278.husksync.config.Locales; import net.william278.husksync.config.Locales;
import net.william278.husksync.config.Settings; import net.william278.husksync.config.Settings;
import net.william278.husksync.data.DataAdapter; import net.william278.husksync.data.DataAdapter;
@ -9,7 +10,6 @@ import net.william278.husksync.event.EventCannon;
import net.william278.husksync.migrator.Migrator; import net.william278.husksync.migrator.Migrator;
import net.william278.husksync.player.OnlineUser; import net.william278.husksync.player.OnlineUser;
import net.william278.husksync.redis.RedisManager; import net.william278.husksync.redis.RedisManager;
import net.william278.desertwell.Version;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;

@ -12,6 +12,7 @@ import org.jetbrains.annotations.NotNull;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -31,7 +32,7 @@ public class EnderChestCommand extends CommandBase implements TabCompletable {
.ifPresent(player::sendMessage); .ifPresent(player::sendMessage);
return; return;
} }
plugin.getDatabase().getUserByName(args[0].toLowerCase()).thenAccept(optionalUser -> plugin.getDatabase().getUserByName(args[0].toLowerCase(Locale.ENGLISH)).thenAccept(optionalUser ->
optionalUser.ifPresentOrElse(user -> { optionalUser.ifPresentOrElse(user -> {
if (args.length == 2) { if (args.length == 2) {
// View user data by specified UUID // View user data by specified UUID

@ -7,10 +7,7 @@ import net.william278.husksync.migrator.Migrator;
import net.william278.husksync.player.OnlineUser; import net.william278.husksync.player.OnlineUser;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Arrays; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -53,7 +50,7 @@ public class HuskSyncCommand extends CommandBase implements TabCompletable, Cons
sendAboutMenu(player); sendAboutMenu(player);
return; return;
} }
switch (args[0].toLowerCase()) { switch (args[0].toLowerCase(Locale.ENGLISH)) {
case "update", "version" -> { case "update", "version" -> {
if (!player.hasPermission(Permission.COMMAND_HUSKSYNC_UPDATE.node)) { if (!player.hasPermission(Permission.COMMAND_HUSKSYNC_UPDATE.node)) {
plugin.getLocales().getLocale("error_no_permission").ifPresent(player::sendMessage); plugin.getLocales().getLocale("error_no_permission").ifPresent(player::sendMessage);
@ -91,7 +88,7 @@ public class HuskSyncCommand extends CommandBase implements TabCompletable, Cons
plugin.log(Level.INFO, "Console usage: \"husksync <update/about/reload/migrate>\""); plugin.log(Level.INFO, "Console usage: \"husksync <update/about/reload/migrate>\"");
return; return;
} }
switch (args[0].toLowerCase()) { switch (args[0].toLowerCase(Locale.ENGLISH)) {
case "update", "version" -> plugin.getLatestVersionIfOutdated().thenAccept(newestVersion -> case "update", "version" -> plugin.getLatestVersionIfOutdated().thenAccept(newestVersion ->
newestVersion.ifPresentOrElse(newVersion -> plugin.log(Level.WARNING, newestVersion.ifPresentOrElse(newVersion -> plugin.log(Level.WARNING,
"An update is available for HuskSync, v" + newVersion "An update is available for HuskSync, v" + newVersion

@ -12,6 +12,7 @@ import org.jetbrains.annotations.NotNull;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -31,7 +32,7 @@ public class InventoryCommand extends CommandBase implements TabCompletable {
.ifPresent(player::sendMessage); .ifPresent(player::sendMessage);
return; return;
} }
plugin.getDatabase().getUserByName(args[0].toLowerCase()).thenAccept(optionalUser -> plugin.getDatabase().getUserByName(args[0].toLowerCase(Locale.ENGLISH)).thenAccept(optionalUser ->
optionalUser.ifPresentOrElse(user -> { optionalUser.ifPresentOrElse(user -> {
if (args.length == 2) { if (args.length == 2) {
// View user data by specified UUID // View user data by specified UUID

@ -3,16 +3,13 @@ package net.william278.husksync.command;
import net.william278.husksync.HuskSync; import net.william278.husksync.HuskSync;
import net.william278.husksync.data.DataSaveCause; import net.william278.husksync.data.DataSaveCause;
import net.william278.husksync.data.UserData; import net.william278.husksync.data.UserData;
import net.william278.husksync.util.DataSnapshotList;
import net.william278.husksync.player.OnlineUser; import net.william278.husksync.player.OnlineUser;
import net.william278.husksync.util.DataDumper; import net.william278.husksync.util.DataDumper;
import net.william278.husksync.util.DataSnapshotList;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -34,7 +31,7 @@ public class UserDataCommand extends CommandBase implements TabCompletable {
return; return;
} }
switch (args[0].toLowerCase()) { switch (args[0].toLowerCase(Locale.ENGLISH)) {
case "view" -> { case "view" -> {
if (args.length < 2) { if (args.length < 2) {
plugin.getLocales().getLocale("error_invalid_syntax", plugin.getLocales().getLocale("error_invalid_syntax",
@ -47,7 +44,7 @@ public class UserDataCommand extends CommandBase implements TabCompletable {
try { try {
final UUID versionUuid = UUID.fromString(args[2]); final UUID versionUuid = UUID.fromString(args[2]);
CompletableFuture.runAsync(() -> plugin.getDatabase() CompletableFuture.runAsync(() -> plugin.getDatabase()
.getUserByName(username.toLowerCase()) .getUserByName(username.toLowerCase(Locale.ENGLISH))
.thenAccept(optionalUser -> optionalUser .thenAccept(optionalUser -> optionalUser
.ifPresentOrElse(user -> plugin.getDatabase().getUserData(user, versionUuid) .ifPresentOrElse(user -> plugin.getDatabase().getUserData(user, versionUuid)
.thenAccept(data -> data.ifPresentOrElse( .thenAccept(data -> data.ifPresentOrElse(
@ -63,7 +60,7 @@ public class UserDataCommand extends CommandBase implements TabCompletable {
} }
} else { } else {
CompletableFuture.runAsync(() -> plugin.getDatabase() CompletableFuture.runAsync(() -> plugin.getDatabase()
.getUserByName(username.toLowerCase()) .getUserByName(username.toLowerCase(Locale.ENGLISH))
.thenAccept(optionalUser -> optionalUser .thenAccept(optionalUser -> optionalUser
.ifPresentOrElse(user -> plugin.getDatabase().getCurrentUserData(user) .ifPresentOrElse(user -> plugin.getDatabase().getCurrentUserData(user)
.thenAccept(latestData -> latestData.ifPresentOrElse( .thenAccept(latestData -> latestData.ifPresentOrElse(
@ -87,7 +84,7 @@ public class UserDataCommand extends CommandBase implements TabCompletable {
} }
final String username = args[1]; final String username = args[1];
CompletableFuture.runAsync(() -> plugin.getDatabase() CompletableFuture.runAsync(() -> plugin.getDatabase()
.getUserByName(username.toLowerCase()) .getUserByName(username.toLowerCase(Locale.ENGLISH))
.thenAccept(optionalUser -> optionalUser.ifPresentOrElse( .thenAccept(optionalUser -> optionalUser.ifPresentOrElse(
user -> plugin.getDatabase().getUserData(user).thenAccept(dataList -> { user -> plugin.getDatabase().getUserData(user).thenAccept(dataList -> {
// Check if there is data to display // Check if there is data to display
@ -133,7 +130,7 @@ public class UserDataCommand extends CommandBase implements TabCompletable {
try { try {
final UUID versionUuid = UUID.fromString(args[2]); final UUID versionUuid = UUID.fromString(args[2]);
CompletableFuture.runAsync(() -> plugin.getDatabase() CompletableFuture.runAsync(() -> plugin.getDatabase()
.getUserByName(username.toLowerCase()) .getUserByName(username.toLowerCase(Locale.ENGLISH))
.thenAccept(optionalUser -> optionalUser.ifPresentOrElse( .thenAccept(optionalUser -> optionalUser.ifPresentOrElse(
user -> plugin.getDatabase().deleteUserData(user, versionUuid).thenAccept(deleted -> { user -> plugin.getDatabase().deleteUserData(user, versionUuid).thenAccept(deleted -> {
if (deleted) { if (deleted) {
@ -172,7 +169,7 @@ public class UserDataCommand extends CommandBase implements TabCompletable {
try { try {
final UUID versionUuid = UUID.fromString(args[2]); final UUID versionUuid = UUID.fromString(args[2]);
CompletableFuture.runAsync(() -> plugin.getDatabase() CompletableFuture.runAsync(() -> plugin.getDatabase()
.getUserByName(username.toLowerCase()) .getUserByName(username.toLowerCase(Locale.ENGLISH))
.thenAccept(optionalUser -> optionalUser.ifPresentOrElse( .thenAccept(optionalUser -> optionalUser.ifPresentOrElse(
user -> plugin.getDatabase().getUserData(user, versionUuid).thenAccept(data -> { user -> plugin.getDatabase().getUserData(user, versionUuid).thenAccept(data -> {
if (data.isEmpty()) { if (data.isEmpty()) {
@ -219,7 +216,7 @@ public class UserDataCommand extends CommandBase implements TabCompletable {
try { try {
final UUID versionUuid = UUID.fromString(args[2]); final UUID versionUuid = UUID.fromString(args[2]);
CompletableFuture.runAsync(() -> plugin.getDatabase() CompletableFuture.runAsync(() -> plugin.getDatabase()
.getUserByName(username.toLowerCase()) .getUserByName(username.toLowerCase(Locale.ENGLISH))
.thenAccept(optionalUser -> optionalUser.ifPresentOrElse( .thenAccept(optionalUser -> optionalUser.ifPresentOrElse(
user -> plugin.getDatabase().getUserData(user, versionUuid).thenAccept( user -> plugin.getDatabase().getUserData(user, versionUuid).thenAccept(
optionalUserData -> optionalUserData.ifPresentOrElse(userData -> { optionalUserData -> optionalUserData.ifPresentOrElse(userData -> {
@ -267,7 +264,7 @@ public class UserDataCommand extends CommandBase implements TabCompletable {
try { try {
final UUID versionUuid = UUID.fromString(args[2]); final UUID versionUuid = UUID.fromString(args[2]);
CompletableFuture.runAsync(() -> plugin.getDatabase() CompletableFuture.runAsync(() -> plugin.getDatabase()
.getUserByName(username.toLowerCase()) .getUserByName(username.toLowerCase(Locale.ENGLISH))
.thenAccept(optionalUser -> optionalUser.ifPresentOrElse( .thenAccept(optionalUser -> optionalUser.ifPresentOrElse(
user -> plugin.getDatabase().getUserData(user, versionUuid).thenAccept( user -> plugin.getDatabase().getUserData(user, versionUuid).thenAccept(
optionalUserData -> optionalUserData.ifPresentOrElse(userData -> { optionalUserData -> optionalUserData.ifPresentOrElse(userData -> {

@ -5,10 +5,7 @@ import net.william278.annotaml.YamlFile;
import net.william278.annotaml.YamlKey; import net.william278.annotaml.YamlKey;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/** /**
* Plugin settings, read from config.yml * Plugin settings, read from config.yml
@ -182,7 +179,7 @@ public class Settings {
@NotNull @NotNull
public String getTableName(@NotNull TableName tableName) { public String getTableName(@NotNull TableName tableName) {
return tableNames.getOrDefault(tableName.name().toLowerCase(), tableName.defaultName); return tableNames.getOrDefault(tableName.name().toLowerCase(Locale.ENGLISH), tableName.defaultName);
} }
public int getMySqlConnectionPoolSize() { public int getMySqlConnectionPoolSize() {
@ -262,7 +259,7 @@ public class Settings {
} }
public boolean getSynchronizationFeature(@NotNull SynchronizationFeature feature) { public boolean getSynchronizationFeature(@NotNull SynchronizationFeature feature) {
return getSynchronizationFeatures().getOrDefault(feature.name().toLowerCase(), feature.enabledByDefault); return getSynchronizationFeatures().getOrDefault(feature.name().toLowerCase(Locale.ENGLISH), feature.enabledByDefault);
} }
@NotNull @NotNull
@ -273,7 +270,7 @@ public class Settings {
@NotNull @NotNull
public EventPriority getEventPriority(@NotNull Settings.EventType eventType) { public EventPriority getEventPriority(@NotNull Settings.EventType eventType) {
try { try {
return EventPriority.valueOf(synchronizationEventPriorities.get(eventType.name().toLowerCase())); return EventPriority.valueOf(synchronizationEventPriorities.get(eventType.name().toLowerCase(Locale.ENGLISH)));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
return EventPriority.NORMAL; return EventPriority.NORMAL;
@ -295,7 +292,7 @@ public class Settings {
@NotNull @NotNull
private Map.Entry<String, String> toEntry() { private Map.Entry<String, String> toEntry() {
return Map.entry(name().toLowerCase(), defaultName); return Map.entry(name().toLowerCase(Locale.ENGLISH), defaultName);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -355,7 +352,7 @@ public class Settings {
@NotNull @NotNull
private Map.Entry<String, Boolean> toEntry() { private Map.Entry<String, Boolean> toEntry() {
return Map.entry(name().toLowerCase(), enabledByDefault); return Map.entry(name().toLowerCase(Locale.ENGLISH), enabledByDefault);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -383,7 +380,7 @@ public class Settings {
@NotNull @NotNull
private Map.Entry<String, String> toEntry() { private Map.Entry<String, String> toEntry() {
return Map.entry(name().toLowerCase(), defaultPriority.name()); return Map.entry(name().toLowerCase(Locale.ENGLISH), defaultPriority.name());
} }

@ -1,11 +1,13 @@
package net.william278.husksync.data; package net.william278.husksync.data;
import net.william278.husksync.api.BaseHuskSyncAPI;
import net.william278.husksync.config.Locales; import net.william278.husksync.config.Locales;
import net.william278.husksync.player.OnlineUser; import net.william278.husksync.player.OnlineUser;
import net.william278.husksync.api.BaseHuskSyncAPI;
import net.william278.husksync.player.User; import net.william278.husksync.player.User;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Locale;
/** /**
* Identifies the cause of a player data save. * Identifies the cause of a player data save.
* *
@ -103,7 +105,7 @@ public enum DataSaveCause {
@NotNull @NotNull
public String getDisplayName() { public String getDisplayName() {
return Locales.truncate(name().toLowerCase(), 10); return Locales.truncate(name().toLowerCase(Locale.ENGLISH), 10);
} }
} }

@ -7,10 +7,7 @@ import net.william278.husksync.player.User;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.*;
import java.util.List;
import java.util.StringJoiner;
import java.util.UUID;
/** /**
* Represents a uniquely versioned and timestamped snapshot of a user's data, including why it was saved. * Represents a uniquely versioned and timestamped snapshot of a user's data, including why it was saved.
@ -57,7 +54,7 @@ public record UserDataSnapshot(@NotNull UUID versionUUID, @NotNull Date versionT
if (pinned()) { if (pinned()) {
locales.getLocale("data_manager_pinned").ifPresent(user::sendMessage); locales.getLocale("data_manager_pinned").ifPresent(user::sendMessage);
} }
locales.getLocale("data_manager_cause", cause().name().toLowerCase().replaceAll("_", " ")) locales.getLocale("data_manager_cause", cause().name().toLowerCase(Locale.ENGLISH).replaceAll("_", " "))
.ifPresent(user::sendMessage); .ifPresent(user::sendMessage);
// User status data, if present in the snapshot // User status data, if present in the snapshot
@ -67,7 +64,7 @@ public record UserDataSnapshot(@NotNull UUID versionUUID, @NotNull Date versionT
Integer.toString((int) statusData.maxHealth), Integer.toString((int) statusData.maxHealth),
Integer.toString(statusData.hunger), Integer.toString(statusData.hunger),
Integer.toString(statusData.expLevel), Integer.toString(statusData.expLevel),
statusData.gameMode.toLowerCase())) statusData.gameMode.toLowerCase(Locale.ENGLISH)))
.ifPresent(user::sendMessage); .ifPresent(user::sendMessage);
// Advancement and statistic data, if both are present in the snapshot // Advancement and statistic data, if both are present in the snapshot

@ -3,7 +3,10 @@ package net.william278.husksync.database;
import com.zaxxer.hikari.HikariDataSource; import com.zaxxer.hikari.HikariDataSource;
import net.william278.husksync.HuskSync; import net.william278.husksync.HuskSync;
import net.william278.husksync.config.Settings; import net.william278.husksync.config.Settings;
import net.william278.husksync.data.*; import net.william278.husksync.data.DataAdaptionException;
import net.william278.husksync.data.DataSaveCause;
import net.william278.husksync.data.UserData;
import net.william278.husksync.data.UserDataSnapshot;
import net.william278.husksync.event.DataSaveEvent; import net.william278.husksync.event.DataSaveEvent;
import net.william278.husksync.player.User; import net.william278.husksync.player.User;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;

@ -16,6 +16,7 @@ import net.william278.husksync.player.User;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Date; import java.util.Date;
import java.util.Locale;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -212,7 +213,7 @@ public class PlanDataExtension implements DataExtension {
plugin.getDatabase().getUserData(user).join().forEach(versionedUserData -> dataSnapshotsTable.addRow( plugin.getDatabase().getUserData(user).join().forEach(versionedUserData -> dataSnapshotsTable.addRow(
versionedUserData.versionTimestamp().getTime(), versionedUserData.versionTimestamp().getTime(),
versionedUserData.versionUUID().toString().split("-")[0], versionedUserData.versionUUID().toString().split("-")[0],
versionedUserData.cause().name().toLowerCase().replaceAll("_", " "), versionedUserData.cause().name().toLowerCase(Locale.ENGLISH).replaceAll("_", " "),
versionedUserData.pinned() ? PINNED_HTML_STRING + "Pinned" : "Unpinned" versionedUserData.pinned() ? PINNED_HTML_STRING + "Pinned" : "Unpinned"
))); )));
return dataSnapshotsTable.build(); return dataSnapshotsTable.build();

@ -1,8 +1,8 @@
package net.william278.husksync.migrator; package net.william278.husksync.migrator;
import net.william278.husksync.HuskSync; import net.william278.husksync.HuskSync;
import org.jetbrains.annotations.NotNull;
import net.william278.husksync.data.UserData; import net.william278.husksync.data.UserData;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;

@ -8,10 +8,7 @@ import net.william278.husksync.data.*;
import net.william278.husksync.event.PreSyncEvent; import net.william278.husksync.event.PreSyncEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.logging.Level; import java.util.logging.Level;
@ -43,12 +40,12 @@ public abstract class OnlineUser extends User {
public final CompletableFuture<Void> setStatus(@NotNull StatusData statusData, public final CompletableFuture<Void> setStatus(@NotNull StatusData statusData,
@NotNull List<StatusDataFlag> statusDataFlags) { @NotNull List<StatusDataFlag> statusDataFlags) {
final Settings settings = new Settings(); final Settings settings = new Settings();
settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.HEALTH.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_HEALTH)); settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.HEALTH.name().toLowerCase(Locale.ENGLISH), statusDataFlags.contains(StatusDataFlag.SET_HEALTH));
settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.MAX_HEALTH.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_MAX_HEALTH)); settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.MAX_HEALTH.name().toLowerCase(Locale.ENGLISH), statusDataFlags.contains(StatusDataFlag.SET_MAX_HEALTH));
settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.HUNGER.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_HUNGER)); settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.HUNGER.name().toLowerCase(Locale.ENGLISH), statusDataFlags.contains(StatusDataFlag.SET_HUNGER));
settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.EXPERIENCE.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_EXPERIENCE)); settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.EXPERIENCE.name().toLowerCase(Locale.ENGLISH), statusDataFlags.contains(StatusDataFlag.SET_EXPERIENCE));
settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.INVENTORIES.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_SELECTED_ITEM_SLOT)); settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.INVENTORIES.name().toLowerCase(Locale.ENGLISH), statusDataFlags.contains(StatusDataFlag.SET_SELECTED_ITEM_SLOT));
settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.LOCATION.name().toLowerCase(), statusDataFlags.contains(StatusDataFlag.SET_GAME_MODE) || statusDataFlags.contains(StatusDataFlag.SET_FLYING)); settings.getSynchronizationFeatures().put(Settings.SynchronizationFeature.LOCATION.name().toLowerCase(Locale.ENGLISH), statusDataFlags.contains(StatusDataFlag.SET_GAME_MODE) || statusDataFlags.contains(StatusDataFlag.SET_FLYING));
return setStatus(statusData, settings); return setStatus(statusData, settings);
} }
@ -59,8 +56,7 @@ public abstract class OnlineUser extends User {
* @param settings settings, containing information about which features should be synced * @param settings settings, containing information about which features should be synced
* @return a future returning void when complete * @return a future returning void when complete
*/ */
public abstract CompletableFuture<Void> setStatus(@NotNull StatusData statusData, public abstract CompletableFuture<Void> setStatus(@NotNull StatusData statusData, @NotNull Settings settings);
@NotNull Settings settings);
/** /**
* Get the player's inventory {@link ItemData} contents * Get the player's inventory {@link ItemData} contents

@ -2,6 +2,8 @@ package net.william278.husksync.redis;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Locale;
public enum RedisKeyType { public enum RedisKeyType {
CACHE(60 * 60 * 24), CACHE(60 * 60 * 24),
DATA_UPDATE(10), DATA_UPDATE(10),
@ -15,6 +17,6 @@ public enum RedisKeyType {
@NotNull @NotNull
public String getKeyPrefix() { public String getKeyPrefix() {
return RedisManager.KEY_NAMESPACE.toLowerCase() + ":" + RedisManager.clusterId.toLowerCase() + ":" + name().toLowerCase(); return RedisManager.KEY_NAMESPACE.toLowerCase(Locale.ENGLISH) + ":" + RedisManager.clusterId.toLowerCase(Locale.ENGLISH) + ":" + name().toLowerCase(Locale.ENGLISH);
} }
} }

@ -3,6 +3,7 @@ package net.william278.husksync.redis;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale;
import java.util.Optional; import java.util.Optional;
public enum RedisMessageType { public enum RedisMessageType {
@ -11,8 +12,8 @@ public enum RedisMessageType {
@NotNull @NotNull
public String getMessageChannel() { public String getMessageChannel() {
return RedisManager.KEY_NAMESPACE.toLowerCase() + ":" + RedisManager.clusterId.toLowerCase() return RedisManager.KEY_NAMESPACE.toLowerCase(Locale.ENGLISH) + ":" + RedisManager.clusterId.toLowerCase(Locale.ENGLISH)
+ ":" + name().toLowerCase(); + ":" + name().toLowerCase(Locale.ENGLISH);
} }
public static Optional<RedisMessageType> getTypeFromChannel(@NotNull String messageChannel) { public static Optional<RedisMessageType> getTypeFromChannel(@NotNull String messageChannel) {

@ -13,6 +13,7 @@ import java.net.URL;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.StringJoiner; import java.util.StringJoiner;
import java.util.logging.Level; import java.util.logging.Level;
@ -164,7 +165,7 @@ public class DataDumper {
return new StringJoiner("_") return new StringJoiner("_")
.add(user.username) .add(user.username)
.add(new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(dataSnapshot.versionTimestamp())) .add(new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(dataSnapshot.versionTimestamp()))
.add(dataSnapshot.cause().name().toLowerCase()) .add(dataSnapshot.cause().name().toLowerCase(Locale.ENGLISH))
.add(dataSnapshot.versionUUID().toString().split("-")[0]) .add(dataSnapshot.versionUUID().toString().split("-")[0])
+ ".json"; + ".json";
} }

@ -1,9 +1,9 @@
package net.william278.husksync.player; package net.william278.husksync.player;
import de.themoep.minedown.adventure.MineDown; import de.themoep.minedown.adventure.MineDown;
import net.william278.desertwell.Version;
import net.william278.husksync.config.Settings; import net.william278.husksync.config.Settings;
import net.william278.husksync.data.*; import net.william278.husksync.data.*;
import net.william278.desertwell.Version;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.*; import java.util.*;

Loading…
Cancel
Save