Skip to content

Commit

Permalink
Adding ability to retrieve docker_images value
Browse files Browse the repository at this point in the history
  • Loading branch information
Goksi committed Mar 4, 2024
1 parent d99570a commit 85c02a6
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public interface ApplicationEgg extends Egg, ISnowflake {
*/
String getDockerImage();

List<DockerImage> getDockerImages();

/**
* The stop command for the ApplicationEgg
* <br>This is ran when a user executes {@link ClientServer#stop()} or hits the <code>Stop</code> button on the panel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.mattmalec.pterodactyl4j.application.entities;

public interface DockerImage {
String getName();

String getImage();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.mattmalec.pterodactyl4j.EnvironmentValue;
import com.mattmalec.pterodactyl4j.PteroAction;
import com.mattmalec.pterodactyl4j.application.entities.ApplicationEgg;
import com.mattmalec.pterodactyl4j.application.entities.DockerImage;
import com.mattmalec.pterodactyl4j.application.entities.Nest;
import com.mattmalec.pterodactyl4j.application.entities.Script;
import com.mattmalec.pterodactyl4j.requests.CompletedPteroAction;
Expand Down Expand Up @@ -82,6 +83,16 @@ public String getDockerImage() {
return json.getString("docker_image");
}

@Override
public List<DockerImage> getDockerImages() {
JSONObject images = json.getJSONObject("docker_images");
List<DockerImage> dockerImages = new ArrayList<>();
for (String key : images.keySet()) {
dockerImages.add(new DockerImageImpl(key, images.getString(key)));
}
return dockerImages;
}

@Override
public String getStopCommand() {
return json.getString("stop");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.mattmalec.pterodactyl4j.application.entities.impl;

import com.mattmalec.pterodactyl4j.application.entities.DockerImage;

public class DockerImageImpl implements DockerImage {
private final String name;
private final String image;

public DockerImageImpl(String name, String image) {
this.name = name;
this.image = image;
}
@Override
public String getName() {
return name;
}

@Override
public String getImage() {
return image;
}
}

0 comments on commit 85c02a6

Please sign in to comment.