Skip to content
Merged

V5.3 #644

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
21 changes: 1 addition & 20 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ group = 'org.mvplugins.multiverse.inventories'
description = 'Multiverse-Inventories'

repositories {
maven {
name = 'codemc'
url = uri('https://repo.codemc.org/repository/maven-releases')
}

maven {
name = "helpchatRepoReleases"
url = uri("https://repo.helpch.at/releases/")
Expand All @@ -36,7 +31,7 @@ configure(apiDependencies) {

dependencies {
// Core
externalPlugin 'org.mvplugins.multiverse.core:multiverse-core:5.2.0'
externalPlugin 'org.mvplugins.multiverse.core:multiverse-core:5.3.0'

// Config
shadowed 'com.dumptruckman.minecraft:JsonConfiguration:1.2-SNAPSHOT'
Expand All @@ -59,24 +54,10 @@ dependencies {
// Luckperms for group context
compileOnly 'net.luckperms:api:5.4'

// Other plugins for import
compileOnly('uk.co:MultiInv:3.0.6') {
exclude group: '*', module: '*'
}
compileOnly('me.drayshak:WorldInventories:1.0.2') {
exclude group: '*', module: '*'
}
// perworldinventory is weird and has snakeyaml included in the jar, so we can only use compileOnly for build to work properly
compileOnly('me.ebonjaeger:perworldinventory-kt:2.3.2') {
exclude group: '*', module: '*'
}

// hk2 for annotation processing only
compileOnly('org.glassfish.hk2:hk2-api:3.1.1') {
exclude group: '*', module: '*'
}
annotationProcessor 'org.glassfish.hk2:hk2-metadata-generator:3.1.1'
testAnnotationProcessor 'org.glassfish.hk2:hk2-metadata-generator:3.1.1'
}

shadowJar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
@Service
public class MultiverseInventories extends MultiverseModule {

private static final double TARGET_CORE_API_VERSION = 5.2;
private static final double TARGET_CORE_API_VERSION = 5.3;

@Inject
private Provider<CoreConfig> coreConfig;
Expand All @@ -63,8 +63,6 @@ public class MultiverseInventories extends MultiverseModule {
@Inject
private Provider<ProfileContainerStoreProvider> profileContainerStoreProvider;
@Inject
private Provider<DataImportManager> dataImportManager;
@Inject
private Provider<MVInvCommandCompletion> mvInvCommandCompletion;
@Inject
private Provider<MVInvCommandContexts> mvInvCommandContexts;
Expand Down Expand Up @@ -112,9 +110,6 @@ public final void onEnable() {
this.registerCommands();
this.registerDestinations();

// Hook plugins that can be imported from
this.hookImportables();

// Init other extensions
this.hookLuckPerms();
this.loadPlaceholderApiIntegration();
Expand Down Expand Up @@ -171,12 +166,6 @@ private void registerDestinations() {
destinationsProvider.get().registerDestination(serviceLocator.getService(LastLocationDestination.class));
}

private void hookImportables() {
serviceLocator.getAllServices(DataImporter.class).forEach(dataImporter -> {
dataImportManager.get().register(dataImporter);
});
}

private void hookLuckPerms() {
Try.run(() -> Class.forName("net.luckperms.api.LuckPerms"))
.onFailure(e -> Logging.fine("Luckperms is not installed!"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.mvplugins.multiverse.inventories.commands;

import com.dumptruckman.minecraft.util.Logging;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.core.command.MVCommandIssuer;
Expand Down Expand Up @@ -46,6 +47,13 @@ void onMigrateCommand(
@Syntax("<MultiInv|WorldInventories|PerWorldInventory>")
String pluginName) {

if (dataImportManager.getEnabledImporterNames().isEmpty()) {
issuer.sendError("Please install Multiverse-InventoriesImporter plugin to use this command.");
issuer.sendInfo("Download Link: https://modrinth.com/project/multiverse-inventoriesimporter/");
issuer.sendInfo("Learn More: https://mvplugins.org/inventories/how-to/import-playerdata/");
return;
}

dataImportManager.getImporter(pluginName)
.onEmpty(() -> issuer.sendError(MVInvi18n.MIGRATE_UNSUPPORTEDPLUGIN, replace("{plugin}").with(pluginName)))
.peek(dataImporter -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.mvplugins.multiverse.inventories.commands;

import com.google.common.io.Files;
import org.bukkit.World;
import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.core.command.MVCommandIssuer;
Expand All @@ -9,72 +8,18 @@
import org.mvplugins.multiverse.external.acf.commands.annotation.Description;
import org.mvplugins.multiverse.external.acf.commands.annotation.Subcommand;
import org.mvplugins.multiverse.external.acf.commands.annotation.Syntax;
import org.mvplugins.multiverse.external.jakarta.inject.Inject;
import org.mvplugins.multiverse.external.vavr.control.Try;
import org.mvplugins.multiverse.inventories.profile.ProfileDataSource;
import org.mvplugins.multiverse.inventories.profile.data.ProfileData;
import org.mvplugins.multiverse.inventories.profile.key.ContainerType;
import org.mvplugins.multiverse.inventories.profile.key.GlobalProfileKey;
import org.mvplugins.multiverse.inventories.profile.key.ProfileKey;
import org.mvplugins.multiverse.inventories.profile.key.ProfileTypes;
import org.mvplugins.multiverse.inventories.profile.nbt.PlayerDataExtractor;

import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;

@Service
final class PlayerDataImportCommand extends InventoriesCommand {

private final PlayerDataExtractor playerDataExtractor;
private final ProfileDataSource profileDataSource;

@Inject
PlayerDataImportCommand(PlayerDataExtractor playerDataExtractor, ProfileDataSource profileDataSource) {
this.playerDataExtractor = playerDataExtractor;
this.profileDataSource = profileDataSource;
}

@Subcommand("playerdata import")
@Syntax("<world>")
@CommandPermission("multiverse.inventories.importplayerdata")
@CommandCompletion("@worldwithplayerdata")
@Description("Import player data from the world's playerdata folder.")
void onCommand(MVCommandIssuer issuer, World world) {
Path worldPath = world.getWorldFolder().toPath();
File playerDataPath = worldPath.resolve("playerdata").toFile();
if (!playerDataPath.isDirectory()) {
issuer.sendMessage("World's playerdata folder does not exist: " + world.getName());
return;
}

List<CompletableFuture<Void>> playerDataFutures = new ArrayList<>();
File[] files = playerDataPath.listFiles();
if (files == null) {
issuer.sendMessage("No player data files found in the world's playerdata folder: " + world.getName());
return;
}

for (File playerDataFile : files) {
if (!Files.getFileExtension(playerDataFile.getName()).equals("dat")) {
continue;
}
UUID playerUUID = UUID.fromString(Files.getNameWithoutExtension(playerDataFile.getName()));
playerDataExtractor.extract(playerDataFile.toPath())
.onSuccess(profileData -> playerDataFutures.add(profileDataSource
.getGlobalProfile(GlobalProfileKey.of(playerUUID))
.thenCompose(profileDataSource::updateGlobalProfile)
.thenCompose(ignore -> profileDataSource.getPlayerProfile(
ProfileKey.of(ContainerType.WORLD, world.getName(), ProfileTypes.getDefault(), playerUUID)))
.thenCompose(playerProfile -> {
playerProfile.update(profileData);
return profileDataSource.updatePlayerProfile(playerProfile);
})));
}
CompletableFuture.allOf(playerDataFutures.toArray(new CompletableFuture[0]))
.thenRun(() -> issuer.sendMessage("Successfully imported all player data from " + world.getName() + "."));
issuer.sendError("Please install Multiverse-InventoriesImporter plugin to use this command.");
issuer.sendInfo("Download Link: https://modrinth.com/project/multiverse-inventoriesimporter/");
issuer.sendInfo("Learn More: https://mvplugins.org/inventories/how-to/import-playerdata/");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.mvplugins.multiverse.core.command.MVCommandIssuer;
import org.mvplugins.multiverse.inventories.config.InventoriesConfig;
import org.mvplugins.multiverse.inventories.share.Sharable;
import org.mvplugins.multiverse.inventories.share.Sharables;
import org.mvplugins.multiverse.inventories.share.Shares;
import org.mvplugins.multiverse.core.command.MVCommandManager;
import org.mvplugins.multiverse.external.acf.commands.annotation.CommandAlias;
Expand Down Expand Up @@ -54,6 +55,13 @@ void onToggleCommand(
} else {
optionalShares.add(sharable);
issuer.sendInfo(MVInvi18n.TOGGLE_NOWUSINGOPTIONAL, replace("{share}").with(sharable.getNames()[0]));

// special tip to our wiki page, hopefully this reduces the number of people asking the
// same old questions about last location config options on discord.
if (sharable == Sharables.LAST_LOCATION) {
issuer.sendInfo("For more information on configuring last location, please see: " +
"https://mvplugins.org/inventories/how-to/configure-last-location/");
}
}
inventoriesConfig.setActiveOptionalShares(optionalShares);
inventoriesConfig.save();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,14 @@ public Try<Void> setActiveOptionalShares(Shares shares) {
return this.configHandle.set(configNodes.activeOptionalShares, shares);
}

@Deprecated(since = "5.3", forRemoval = true)
public boolean getUseImprovedRespawnLocationDetection() {
return this.configHandle.get(configNodes.useImprovedRespawnLocationDetection);
return true;
}

@Deprecated(since = "5.3", forRemoval = true)
public Try<Void> setUseImprovedRespawnLocationDetection(boolean useImprovedRespawnLocationDetection) {
return this.configHandle.set(configNodes.useImprovedRespawnLocationDetection, useImprovedRespawnLocationDetection);
return Try.failure(new IllegalStateException("this config option has been removed"));
}

@ApiStatus.AvailableSince("5.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,7 @@ public Object serialize(Shares sharables, Class<Shares> aClass) {
.comment("")
.build());

final ConfigNode<Boolean> useImprovedRespawnLocationDetection = node(ConfigNode.builder("sharables.use-improved-respawn-location-detection", Boolean.class)
.comment("When enabled, we will use 1.21's PlayerSpawnChangeEvent to better detect bed and anchor respawn locations.")
.comment("This options is not applicable for older minecraft server versions.")
.defaultValue(true)
.name("use-improved-respawn-location-detection")
.build());

final ConfigNode<Boolean> validateBedAnchorRespawnLocation = node(ConfigNode.builder("sharables.validate-bed-anchor-respawn-location", Boolean.class)
.comment("")
.comment("When enabled, we will validate the bed/anchor respawn location on group/world change.")
.comment("The validation checks if the bed/anchor block still exists at the saved location and is usable.")
.comment("When the validation fails, the respawn location will be cleared and default world spawn will be used instead.")
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading