Skip to content

Commit ec4c89f

Browse files
committed
Adds new feature
1 parent 869943c commit ec4c89f

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.hydev.mcpm.client.commands.controllers;
22

3-
import org.hydev.mcpm.client.list.ListAllBoundary;
3+
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/tracker/SuperPluginTracker.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
import org.hydev.mcpm.client.models.PluginModel;
44
import org.hydev.mcpm.client.models.PluginYml;
5+
import org.hydev.mcpm.client.models.PluginTrackerModel;
56
import org.hydev.mcpm.client.search.SearchPackagesBoundary;
67

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

1012
/**
11-
* Extended plugin tracker interface (with methods for specific versionId/pluginId).
13+
* Extended plugin tracker interface (with methods for specific
14+
* versionId/pluginId).
1215
*/
1316
public interface SuperPluginTracker {
1417
void addEntry(String name, boolean status, String versionId, String pluginId);
@@ -17,6 +20,8 @@ public interface SuperPluginTracker {
1720

1821
List<PluginYml> listInstalled();
1922

23+
ArrayList<PluginTrackerModel> listInstalledAsModels();
24+
2025
void setManuallyInstalled(String name);
2126

2227
void removeManuallyInstalled(String name);

src/main/java/org/hydev/mcpm/client/list/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/local/SuperLocalPluginTracker.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ public void syncMainLockFile(Boolean tryPreserveLocalStatus) {
253253
toAdd.add(currentListName.get(pluginRepresentation.getName()));
254254
} else if (tryPreserveLocalStatus) {
255255
// if the plugin exists in both currentList and installedPlugins, but the
256-
// version differs, and we are trying to preserve local status, pass it on with the same status
256+
// version differs, and we are trying to preserve local status, pass it on with
257+
// the same status
257258
boolean status = currentListName.get(pluginRepresentation.getName()).isManual();
258259
pluginRepresentation.setManual(status);
259260
}
@@ -300,6 +301,19 @@ public void setManuallyInstalled(String name) {
300301
saveJson(newList);
301302
}
302303

304+
/**
305+
* Returns a list of all plugins, represented in PluginTrackerModel objects
306+
*
307+
*
308+
*/
309+
public ArrayList<PluginTrackerModel> listInstalledAsModels() {
310+
ArrayList<PluginTrackerModel> list = new ArrayList<>();
311+
for (PluginYml pluginYml : listInstalled()) {
312+
list.add(new PluginTrackerModel(pluginYml.name(), false, pluginYml.version(), "unknown"));
313+
}
314+
return list;
315+
}
316+
303317
/**
304318
* Remove a plugin from the manually installed plugin list
305319
*
@@ -420,7 +434,8 @@ public String getVersion(String name) {
420434
for (File child : directoryListing) {
421435
if (child.getName().equals(name)) {
422436
// We probably want to keep this try catch.
423-
// A plugin can be malformed in many ways, this will just drop it from our list if needed.
437+
// A plugin can be malformed in many ways, this will just drop it from our list
438+
// if needed.
424439
try {
425440
return readMeta(child).version();
426441
} catch (Exception e) {

0 commit comments

Comments
 (0)