Skip to content

Commit 118b2bb

Browse files
committed
Added way to check of a plugin is in the lock file (by name or ID)
1 parent 8d4faba commit 118b2bb

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,40 @@ private void saveJson(ArrayList<PluginTrackerModel> list) {
157157
* }
158158
*/
159159

160+
/**
161+
* Returns whether a plugin with the given name is within
162+
* the lock file
163+
*
164+
* @param name Id of the plugin
165+
* @return Whether the plugin is within the lock file
166+
*/
167+
public Boolean findIfInLockById(String name) {
168+
ArrayList<PluginTrackerModel> list = readJson();
169+
for (PluginTrackerModel pluginTrackerModel : list) {
170+
if (pluginTrackerModel.getPluginId().equals(name)) {
171+
return true;
172+
}
173+
}
174+
return false;
175+
}
176+
177+
/**
178+
* Returns whether a plugin with the given name is within
179+
* the lock file
180+
*
181+
* @param name Name of the plugin
182+
* @return Whether the plugin is within the lock file
183+
*/
184+
public Boolean findIfInLockByName(String name) {
185+
ArrayList<PluginTrackerModel> list = readJson();
186+
for (PluginTrackerModel pluginTrackerModel : list) {
187+
if (pluginTrackerModel.getName().equals(name)) {
188+
return true;
189+
}
190+
}
191+
return false;
192+
}
193+
160194
/**
161195
* Add a plugin to the JSON file
162196
*

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public interface SuperPluginTracker {
2424

2525
void removeManuallyInstalled(String name);
2626

27+
Boolean findIfInLockById(String id);
28+
29+
Boolean findIfInLockByName(String name);
30+
2731
List<String> listManuallyInstalled();
2832

2933
List<String> listOrphanPlugins(boolean considerSoftDependencies);

0 commit comments

Comments
 (0)