Skip to content

Commit 13162b5

Browse files
authored
Merge pull request #640 from Multiverse/refactor/remove-migrate
Remove migration plugin support and playerdata import (reimplemented in Multiverse-InventoriesImporter)
2 parents 4468350 + 37613f2 commit 13162b5

21 files changed

+17
-1286
lines changed

build.gradle

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ group = 'org.mvplugins.multiverse.inventories'
77
description = 'Multiverse-Inventories'
88

99
repositories {
10-
maven {
11-
name = 'codemc'
12-
url = uri('https://repo.codemc.org/repository/maven-releases')
13-
}
14-
1510
maven {
1611
name = "helpchatRepoReleases"
1712
url = uri("https://repo.helpch.at/releases/")
@@ -59,24 +54,10 @@ dependencies {
5954
// Luckperms for group context
6055
compileOnly 'net.luckperms:api:5.4'
6156

62-
// Other plugins for import
63-
compileOnly('uk.co:MultiInv:3.0.6') {
64-
exclude group: '*', module: '*'
65-
}
66-
compileOnly('me.drayshak:WorldInventories:1.0.2') {
67-
exclude group: '*', module: '*'
68-
}
69-
// perworldinventory is weird and has snakeyaml included in the jar, so we can only use compileOnly for build to work properly
70-
compileOnly('me.ebonjaeger:perworldinventory-kt:2.3.2') {
71-
exclude group: '*', module: '*'
72-
}
73-
7457
// hk2 for annotation processing only
7558
compileOnly('org.glassfish.hk2:hk2-api:3.1.1') {
7659
exclude group: '*', module: '*'
7760
}
78-
annotationProcessor 'org.glassfish.hk2:hk2-metadata-generator:3.1.1'
79-
testAnnotationProcessor 'org.glassfish.hk2:hk2-metadata-generator:3.1.1'
8061
}
8162

8263
shadowJar {

src/main/java/org/mvplugins/multiverse/inventories/MultiverseInventories.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ public class MultiverseInventories extends MultiverseModule {
6363
@Inject
6464
private Provider<ProfileContainerStoreProvider> profileContainerStoreProvider;
6565
@Inject
66-
private Provider<DataImportManager> dataImportManager;
67-
@Inject
6866
private Provider<MVInvCommandCompletion> mvInvCommandCompletion;
6967
@Inject
7068
private Provider<MVInvCommandContexts> mvInvCommandContexts;
@@ -112,9 +110,6 @@ public final void onEnable() {
112110
this.registerCommands();
113111
this.registerDestinations();
114112

115-
// Hook plugins that can be imported from
116-
this.hookImportables();
117-
118113
// Init other extensions
119114
this.hookLuckPerms();
120115
this.loadPlaceholderApiIntegration();
@@ -171,12 +166,6 @@ private void registerDestinations() {
171166
destinationsProvider.get().registerDestination(serviceLocator.getService(LastLocationDestination.class));
172167
}
173168

174-
private void hookImportables() {
175-
serviceLocator.getAllServices(DataImporter.class).forEach(dataImporter -> {
176-
dataImportManager.get().register(dataImporter);
177-
});
178-
}
179-
180169
private void hookLuckPerms() {
181170
Try.run(() -> Class.forName("net.luckperms.api.LuckPerms"))
182171
.onFailure(e -> Logging.fine("Luckperms is not installed!"))

src/main/java/org/mvplugins/multiverse/inventories/commands/MigrateCommand.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.mvplugins.multiverse.inventories.commands;
22

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

50+
if (dataImportManager.getEnabledImporterNames().isEmpty()) {
51+
issuer.sendError("Please install Multiverse-InventoriesImporter plugin to use this command.");
52+
issuer.sendInfo("Download Link: https://modrinth.com/project/multiverse-inventoriesimporter/");
53+
issuer.sendInfo("Learn More: https://mvplugins.org/inventories/how-to/import-playerdata/");
54+
return;
55+
}
56+
4957
dataImportManager.getImporter(pluginName)
5058
.onEmpty(() -> issuer.sendError(MVInvi18n.MIGRATE_UNSUPPORTEDPLUGIN, replace("{plugin}").with(pluginName)))
5159
.peek(dataImporter -> {
Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.mvplugins.multiverse.inventories.commands;
22

3-
import com.google.common.io.Files;
43
import org.bukkit.World;
54
import org.jvnet.hk2.annotations.Service;
65
import org.mvplugins.multiverse.core.command.MVCommandIssuer;
@@ -9,72 +8,18 @@
98
import org.mvplugins.multiverse.external.acf.commands.annotation.Description;
109
import org.mvplugins.multiverse.external.acf.commands.annotation.Subcommand;
1110
import org.mvplugins.multiverse.external.acf.commands.annotation.Syntax;
12-
import org.mvplugins.multiverse.external.jakarta.inject.Inject;
13-
import org.mvplugins.multiverse.external.vavr.control.Try;
14-
import org.mvplugins.multiverse.inventories.profile.ProfileDataSource;
15-
import org.mvplugins.multiverse.inventories.profile.data.ProfileData;
16-
import org.mvplugins.multiverse.inventories.profile.key.ContainerType;
17-
import org.mvplugins.multiverse.inventories.profile.key.GlobalProfileKey;
18-
import org.mvplugins.multiverse.inventories.profile.key.ProfileKey;
19-
import org.mvplugins.multiverse.inventories.profile.key.ProfileTypes;
20-
import org.mvplugins.multiverse.inventories.profile.nbt.PlayerDataExtractor;
21-
22-
import java.io.File;
23-
import java.nio.file.Path;
24-
import java.util.ArrayList;
25-
import java.util.List;
26-
import java.util.UUID;
27-
import java.util.concurrent.CompletableFuture;
2811

2912
@Service
3013
final class PlayerDataImportCommand extends InventoriesCommand {
3114

32-
private final PlayerDataExtractor playerDataExtractor;
33-
private final ProfileDataSource profileDataSource;
34-
35-
@Inject
36-
PlayerDataImportCommand(PlayerDataExtractor playerDataExtractor, ProfileDataSource profileDataSource) {
37-
this.playerDataExtractor = playerDataExtractor;
38-
this.profileDataSource = profileDataSource;
39-
}
40-
4115
@Subcommand("playerdata import")
4216
@Syntax("<world>")
4317
@CommandPermission("multiverse.inventories.importplayerdata")
4418
@CommandCompletion("@worldwithplayerdata")
4519
@Description("Import player data from the world's playerdata folder.")
4620
void onCommand(MVCommandIssuer issuer, World world) {
47-
Path worldPath = world.getWorldFolder().toPath();
48-
File playerDataPath = worldPath.resolve("playerdata").toFile();
49-
if (!playerDataPath.isDirectory()) {
50-
issuer.sendMessage("World's playerdata folder does not exist: " + world.getName());
51-
return;
52-
}
53-
54-
List<CompletableFuture<Void>> playerDataFutures = new ArrayList<>();
55-
File[] files = playerDataPath.listFiles();
56-
if (files == null) {
57-
issuer.sendMessage("No player data files found in the world's playerdata folder: " + world.getName());
58-
return;
59-
}
60-
61-
for (File playerDataFile : files) {
62-
if (!Files.getFileExtension(playerDataFile.getName()).equals("dat")) {
63-
continue;
64-
}
65-
UUID playerUUID = UUID.fromString(Files.getNameWithoutExtension(playerDataFile.getName()));
66-
playerDataExtractor.extract(playerDataFile.toPath())
67-
.onSuccess(profileData -> playerDataFutures.add(profileDataSource
68-
.getGlobalProfile(GlobalProfileKey.of(playerUUID))
69-
.thenCompose(profileDataSource::updateGlobalProfile)
70-
.thenCompose(ignore -> profileDataSource.getPlayerProfile(
71-
ProfileKey.of(ContainerType.WORLD, world.getName(), ProfileTypes.getDefault(), playerUUID)))
72-
.thenCompose(playerProfile -> {
73-
playerProfile.update(profileData);
74-
return profileDataSource.updatePlayerProfile(playerProfile);
75-
})));
76-
}
77-
CompletableFuture.allOf(playerDataFutures.toArray(new CompletableFuture[0]))
78-
.thenRun(() -> issuer.sendMessage("Successfully imported all player data from " + world.getName() + "."));
21+
issuer.sendError("Please install Multiverse-InventoriesImporter plugin to use this command.");
22+
issuer.sendInfo("Download Link: https://modrinth.com/project/multiverse-inventoriesimporter/");
23+
issuer.sendInfo("Learn More: https://mvplugins.org/inventories/how-to/import-playerdata/");
7924
}
8025
}

src/main/java/org/mvplugins/multiverse/inventories/dataimport/multiinv/MIInventoryConverter.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/main/java/org/mvplugins/multiverse/inventories/dataimport/multiinv/MIInventoryInterface.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/main/java/org/mvplugins/multiverse/inventories/dataimport/multiinv/MIInventoryOldWrapper.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/main/java/org/mvplugins/multiverse/inventories/dataimport/multiinv/MIInventoryWrapper.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/main/java/org/mvplugins/multiverse/inventories/dataimport/multiinv/MIPlayerFileLoader.java

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)