|
|
@ -12,8 +12,10 @@ import org.jetbrains.annotations.NotNull;
|
|
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Optional;
|
|
|
|
import java.util.UUID;
|
|
|
|
import java.util.UUID;
|
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
|
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
public class InventoryCommand extends CommandBase implements TabCompletable {
|
|
|
|
public class InventoryCommand extends CommandBase implements TabCompletable {
|
|
|
@ -69,13 +71,15 @@ public class InventoryCommand extends CommandBase implements TabCompletable {
|
|
|
|
player.showMenu(itemData, allowEdit, 5, plugin.getLocales()
|
|
|
|
player.showMenu(itemData, allowEdit, 5, plugin.getLocales()
|
|
|
|
.getLocale("inventory_viewer_menu_title", dataOwner.username)
|
|
|
|
.getLocale("inventory_viewer_menu_title", dataOwner.username)
|
|
|
|
.orElse(new MineDown("Inventory Viewer")))
|
|
|
|
.orElse(new MineDown("Inventory Viewer")))
|
|
|
|
|
|
|
|
.exceptionally(throwable -> {
|
|
|
|
|
|
|
|
plugin.getLoggingAdapter().log(Level.WARNING, "Exception displaying inventory menu to " + player.username, throwable);
|
|
|
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
|
|
|
})
|
|
|
|
.thenAccept(dataOnClose -> {
|
|
|
|
.thenAccept(dataOnClose -> {
|
|
|
|
if (dataOnClose.isEmpty() || !allowEdit) {
|
|
|
|
if (dataOnClose.isEmpty() || !allowEdit) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
plugin.getLoggingAdapter().debug("Inventory data changed, updating user, etc!");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create the updated data
|
|
|
|
// Create the updated data
|
|
|
|
final UserDataBuilder builder = UserData.builder(plugin.getMinecraftVersion());
|
|
|
|
final UserDataBuilder builder = UserData.builder(plugin.getMinecraftVersion());
|
|
|
|
data.getStatus().ifPresent(builder::setStatus);
|
|
|
|
data.getStatus().ifPresent(builder::setStatus);
|
|
|
@ -89,8 +93,9 @@ public class InventoryCommand extends CommandBase implements TabCompletable {
|
|
|
|
|
|
|
|
|
|
|
|
// Set the updated data
|
|
|
|
// Set the updated data
|
|
|
|
final UserData updatedUserData = builder.build();
|
|
|
|
final UserData updatedUserData = builder.build();
|
|
|
|
plugin.getDatabase().setUserData(dataOwner, updatedUserData, DataSaveCause.INVENTORY_COMMAND).join();
|
|
|
|
plugin.getDatabase()
|
|
|
|
plugin.getRedisManager().sendUserDataUpdate(dataOwner, updatedUserData).join();
|
|
|
|
.setUserData(dataOwner, updatedUserData, DataSaveCause.INVENTORY_COMMAND)
|
|
|
|
|
|
|
|
.thenRun(() -> plugin.getRedisManager().sendUserDataUpdate(dataOwner, updatedUserData));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|