Skip to content

Commit fbdd13b

Browse files
committed
Adds new feature
1 parent 118b2bb commit fbdd13b

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

src/main/java/org/hydev/mcpm/client/commands/entries/ListController.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.hydev.mcpm.client.commands.entries;
22

33
import org.hydev.mcpm.client.database.ListAllBoundary;
4+
import org.hydev.mcpm.client.database.boundary.CheckForUpdatesBoundary;
45

56
import java.util.List;
67
import java.util.function.Consumer;
@@ -15,14 +16,16 @@
1516
*/
1617
public class ListController {
1718
private final ListAllBoundary listAllBoundary;
19+
private final CheckForUpdatesBoundary checkForUpdatesBoundary;
1820

1921
/**
2022
* Constructor for ListAllController.
2123
*
2224
* @param listAllBoundary The boundary class for ListAllController.
2325
*/
24-
public ListController(ListAllBoundary listAllBoundary) {
26+
public ListController(ListAllBoundary listAllBoundary, CheckForUpdatesBoundary checkForUpdatesBoundary) {
2527
this.listAllBoundary = listAllBoundary;
28+
this.checkForUpdatesBoundary = checkForUpdatesBoundary;
2629
}
2730

2831
/**

src/main/java/org/hydev/mcpm/client/database/ListAllInteractor.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package org.hydev.mcpm.client.database;
22

33
import org.apache.commons.lang3.NotImplementedException;
4+
import org.hydev.mcpm.client.database.boundary.CheckForUpdatesBoundary;
5+
import org.hydev.mcpm.client.database.inputs.CheckForUpdatesInput;
6+
import org.hydev.mcpm.client.database.model.PluginVersionState;
47
import org.hydev.mcpm.client.models.PluginYml;
8+
import org.hydev.mcpm.client.models.PluginTrackerModel;
59

610
import java.util.List;
11+
import java.util.ArrayList;
712

813
/**
914
* Implementation to the ListAll functionality
@@ -26,7 +31,7 @@ public class ListAllInteractor implements ListAllBoundary {
2631
* a request to list all manually installed plugins that are
2732
* outdated.
2833
*/
29-
public List<PluginYml> listAll(String parameter) {
34+
public List<PluginYml> listAll(String parameter, CheckForUpdatesBoundary checkForUpdatesBoundary) {
3035
var installed = localPluginTracker.listInstalled();
3136
switch (parameter) {
3237
case "all":
@@ -37,7 +42,9 @@ public List<PluginYml> listAll(String parameter) {
3742
return installed.stream().filter(it -> local.contains(it.name())).toList();
3843

3944
case "outdated":
40-
throw new NotImplementedException("Method to print outdated plugins not implemented yet");
45+
CheckForUpdatesInput input = new CheckForUpdatesInput(null, false);
46+
47+
ArrayList<PluginTrackerModel> installedAsModels = localPluginTracker.listInstalledAsModels();
4148

4249
default:
4350
return null;

src/main/java/org/hydev/mcpm/client/database/SuperLocalPluginTracker.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,19 @@ public void setManuallyInstalled(String name) {
310310
saveJson(newList);
311311
}
312312

313+
/**
314+
* Returns a list of all plugins, represented in PluginTrackerModel objects
315+
*
316+
*
317+
*/
318+
public ArrayList<PluginTrackerModel> listInstalledAsModels() {
319+
ArrayList<PluginTrackerModel> list = new ArrayList<>();
320+
for (PluginYml pluginYml : listInstalled()) {
321+
list.add(new PluginTrackerModel(pluginYml.name(), false, pluginYml.version(), "unknown"));
322+
}
323+
return list;
324+
}
325+
313326
/**
314327
* Remove a plugin from the manually installed plugin list
315328
*

src/main/java/org/hydev/mcpm/client/database/SuperPluginTracker.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import org.hydev.mcpm.client.database.boundary.SearchPackagesBoundary;
44
import org.hydev.mcpm.client.models.PluginModel;
55
import org.hydev.mcpm.client.models.PluginYml;
6+
import org.hydev.mcpm.client.models.PluginTrackerModel;
67

78
import java.io.File;
89
import java.util.List;
10+
import java.util.ArrayList;
911

1012
/**
1113
* Plugin tracker interface
@@ -20,6 +22,8 @@ public interface SuperPluginTracker {
2022

2123
List<PluginYml> listInstalled();
2224

25+
ArrayList<PluginTrackerModel> listInstalledAsModels();
26+
2327
void setManuallyInstalled(String name);
2428

2529
void removeManuallyInstalled(String name);

0 commit comments

Comments
 (0)