-
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eh added a bit of docs before I make a bigger pr with way more docs #53
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,16 +16,33 @@ | |
|
||
package com.mattmalec.pterodactyl4j; | ||
|
||
/** | ||
* Represents a format of data such as a {@link DataType#GB} | ||
*/ | ||
public enum DataType { | ||
|
||
// MB((byte) 0, 1, "Megabyte"), | ||
// GB((byte) 1, 1024, "Gigabyte"), | ||
// TB((byte) 2, 1048576, "Terabyte"); | ||
|
||
/** | ||
* DataType format for Bytes | ||
*/ | ||
B ((byte) 0, 1, "Byte"), | ||
/** | ||
* DataType format for Kilo-Bytes | ||
*/ | ||
KB((byte) 1, 1024, "Kilobyte"), | ||
/** | ||
* DataType format for Mega-Bytes | ||
*/ | ||
MB((byte) 2, 1048576, "Megabyte"), | ||
/** | ||
* DataType format for Giga-Bytes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For stuff like this, you don't need to document each individual enum. They're pretty self-explanatory as it is. |
||
*/ | ||
GB((byte) 3, 1_073_741_824, "Gigabyte"), | ||
/** | ||
* DataType format for Tera-Bytes | ||
*/ | ||
TB((byte) 4, 1_099_511_627_776L, "Terabyte"); | ||
|
||
private final byte identifier; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,18 +17,29 @@ | |
package com.mattmalec.pterodactyl4j; | ||
|
||
/** | ||
* Represents a servers state. | ||
* Represents a server's state. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks :) |
||
*/ | ||
public enum UtilizationState { | ||
|
||
/** | ||
* Represents when the server is offline | ||
*/ | ||
OFFLINE, | ||
/** | ||
* Represents when the server is in the process of starting up | ||
*/ | ||
STARTING, | ||
/** | ||
* Represents when the server is online | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this scenario, this makes sense to document the enum. I like what you did here :) |
||
*/ | ||
RUNNING, | ||
/** | ||
* Represents when the server is shutting down | ||
*/ | ||
STOPPING; | ||
|
||
public static UtilizationState of(String s) { | ||
for(UtilizationState state : values()) { | ||
if(state.name().equalsIgnoreCase(s)) { | ||
for (UtilizationState state : values()) { | ||
if (state.name().equalsIgnoreCase(s)) { | ||
return state; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,34 +19,46 @@ | |
import com.mattmalec.pterodactyl4j.PteroAction; | ||
import com.mattmalec.pterodactyl4j.application.managers.UserAction; | ||
import com.mattmalec.pterodactyl4j.entities.User; | ||
import com.mattmalec.pterodactyl4j.utils.Relationed; | ||
|
||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.UUID; | ||
|
||
/** | ||
* Represents a user on a {@link ApplicationServer} server | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be explained better too. Also still confused on why these lines are spread out. |
||
*/ | ||
public interface ApplicationUser extends User, ISnowflake { | ||
|
||
String getFirstName(); | ||
String getLastName(); | ||
default String getFullName() { | ||
return String.format("%s %s", getFirstName(), getLastName()); | ||
} | ||
String getExternalId(); | ||
UUID getUUID(); | ||
boolean has2FA(); | ||
String getLanguage(); | ||
default Locale getLocale() { | ||
return Locale.forLanguageTag(getLanguage()); | ||
} | ||
boolean isRootAdmin(); | ||
PteroAction<List<ApplicationServer>> retrieveServers(); | ||
UserAction edit(); | ||
PteroAction<Void> delete(); | ||
|
||
@Override | ||
String toString(); | ||
String getFirstName(); | ||
|
||
String getLastName(); | ||
|
||
default String getFullName() { | ||
return String.format("%s %s", getFirstName(), getLastName()); | ||
} | ||
|
||
String getExternalId(); | ||
|
||
UUID getUUID(); | ||
|
||
boolean has2FA(); | ||
|
||
String getLanguage(); | ||
|
||
default Locale getLocale() { | ||
return Locale.forLanguageTag(getLanguage()); | ||
} | ||
|
||
boolean isRootAdmin(); | ||
|
||
PteroAction<List<ApplicationServer>> retrieveServers(); | ||
|
||
UserAction edit(); | ||
|
||
PteroAction<Void> delete(); | ||
|
||
@Override | ||
String toString(); | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,9 @@ | |
import java.util.List; | ||
import java.util.Optional; | ||
|
||
/** | ||
* Represents a Pterodactyl {@link Nest} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be explained better too. I should have some comments around the review saying the same thing. |
||
*/ | ||
public interface Nest extends ISnowflake { | ||
|
||
String getUUID(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
|
||
import com.mattmalec.pterodactyl4j.PowerAction; | ||
import com.mattmalec.pterodactyl4j.PteroAction; | ||
import com.mattmalec.pterodactyl4j.PteroBuilder; | ||
import com.mattmalec.pterodactyl4j.client.managers.*; | ||
import com.mattmalec.pterodactyl4j.entities.Server; | ||
import com.mattmalec.pterodactyl4j.requests.PaginationAction; | ||
|
@@ -27,94 +28,130 @@ | |
import java.util.Set; | ||
import java.util.UUID; | ||
|
||
/** | ||
* Represents a {@link PteroClient}'s server | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would check how I did this with the ApplicationServer implementation. I'd ideally like to keep everything using the same conventions if possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm also kinda confused why this is all spaced out now. |
||
* Use a {@link PteroClient} to retrieve a ptero information and servers | ||
* To build a {@link PteroClient} use the {@link PteroBuilder#buildClient()} method. | ||
*/ | ||
public interface ClientServer extends Server { | ||
|
||
boolean isServerOwner(); | ||
long getInternalIdLong(); | ||
default String getInternalId() { return Long.toUnsignedString(getInternalIdLong()); } | ||
SFTP getSFTPDetails(); | ||
String getInvocation(); | ||
Set<String> getEggFeatures(); | ||
ClientEgg getEgg(); | ||
String getNode(); | ||
boolean isSuspended(); | ||
boolean isInstalling(); | ||
boolean isTransferring(); | ||
|
||
ClientServerManager getManager(); | ||
|
||
PteroAction<Utilization> retrieveUtilization(); | ||
PteroAction<Void> setPower(PowerAction powerAction); | ||
|
||
default PteroAction<Void> start() { | ||
return setPower(PowerAction.START); | ||
} | ||
|
||
default PteroAction<Void> stop() { | ||
return setPower(PowerAction.STOP); | ||
} | ||
|
||
default PteroAction<Void> restart() { | ||
return setPower(PowerAction.RESTART); | ||
} | ||
|
||
default PteroAction<Void> kill() { | ||
return setPower(PowerAction.KILL); | ||
} | ||
|
||
PteroAction<Void> sendCommand(String command); | ||
|
||
WebSocketBuilder getWebSocketBuilder(); | ||
|
||
List<ClientSubuser> getSubusers(); | ||
PteroAction<ClientSubuser> retrieveSubuser(UUID uuid); | ||
default PteroAction<ClientSubuser> retrieveSubuser(String uuid) { | ||
return retrieveSubuser(UUID.fromString(uuid)); | ||
} | ||
SubuserManager getSubuserManager(); | ||
|
||
PaginationAction<Backup> retrieveBackups(); | ||
PteroAction<Backup> retrieveBackup(UUID uuid); | ||
default PteroAction<Backup> retrieveBackup(String uuid) { | ||
return retrieveBackup(UUID.fromString(uuid)); | ||
} | ||
BackupManager getBackupManager(); | ||
|
||
PteroAction<List<Schedule>> retrieveSchedules(); | ||
default PteroAction<Schedule> retrieveSchedule(long id) { | ||
return retrieveSchedule(Long.toUnsignedString(id)); | ||
} | ||
PteroAction<Schedule> retrieveSchedule(String id); | ||
ScheduleManager getScheduleManager(); | ||
|
||
FileManager getFileManager(); | ||
|
||
default PteroAction<Directory> retrieveDirectory() { | ||
return retrieveDirectory("/"); | ||
} | ||
PteroAction<Directory> retrieveDirectory(Directory previousDirectory, Directory directory); | ||
PteroAction<Directory> retrieveDirectory(String path); | ||
|
||
PteroAction<List<ClientDatabase>> retrieveDatabases(); | ||
default PteroAction<Optional<ClientDatabase>> retrieveDatabaseById(String id) { | ||
return retrieveDatabases().map(List::stream).map(stream -> stream.filter(db -> db.getId().equals(id)).findFirst()); | ||
} | ||
default PteroAction<Optional<ClientDatabase>> retrieveDatabaseByName(String name, boolean caseSensitive) { | ||
return retrieveDatabases().map(List::stream).map(stream -> stream.filter(db -> caseSensitive ? | ||
db.getName().contains(name) : db.getName().toLowerCase().contains(name.toLowerCase())).findFirst()); | ||
} | ||
ClientDatabaseManager getDatabaseManager(); | ||
|
||
List<ClientAllocation> getAllocations(); | ||
default ClientAllocation getPrimaryAllocation() { | ||
return getAllocations().stream().filter(ClientAllocation::isDefault).findFirst().get(); | ||
} | ||
default Optional<ClientAllocation> getAllocationByPort(int port) { | ||
return getAllocations().stream().filter(allocation -> allocation.getPortInt() == port).findFirst(); | ||
} | ||
default Optional<ClientAllocation> getAllocationById(long id) { | ||
return getAllocations().stream().filter(allocation -> allocation.getIdLong() == id).findFirst(); | ||
} | ||
ClientAllocationManager getAllocationManager(); | ||
boolean isServerOwner(); | ||
|
||
long getInternalIdLong(); | ||
|
||
default String getInternalId() { | ||
return Long.toUnsignedString(getInternalIdLong()); | ||
} | ||
|
||
SFTP getSFTPDetails(); | ||
|
||
String getInvocation(); | ||
|
||
Set<String> getEggFeatures(); | ||
|
||
ClientEgg getEgg(); | ||
|
||
String getNode(); | ||
|
||
boolean isSuspended(); | ||
|
||
boolean isInstalling(); | ||
|
||
boolean isTransferring(); | ||
|
||
ClientServerManager getManager(); | ||
|
||
PteroAction<Utilization> retrieveUtilization(); | ||
|
||
PteroAction<Void> setPower(PowerAction powerAction); | ||
|
||
default PteroAction<Void> start() { | ||
return setPower(PowerAction.START); | ||
} | ||
|
||
default PteroAction<Void> stop() { | ||
return setPower(PowerAction.STOP); | ||
} | ||
|
||
default PteroAction<Void> restart() { | ||
return setPower(PowerAction.RESTART); | ||
} | ||
|
||
default PteroAction<Void> kill() { | ||
return setPower(PowerAction.KILL); | ||
} | ||
|
||
PteroAction<Void> sendCommand(String command); | ||
|
||
WebSocketBuilder getWebSocketBuilder(); | ||
|
||
List<ClientSubuser> getSubusers(); | ||
|
||
PteroAction<ClientSubuser> retrieveSubuser(UUID uuid); | ||
|
||
default PteroAction<ClientSubuser> retrieveSubuser(String uuid) { | ||
return retrieveSubuser(UUID.fromString(uuid)); | ||
} | ||
|
||
SubuserManager getSubuserManager(); | ||
|
||
PaginationAction<Backup> retrieveBackups(); | ||
|
||
PteroAction<Backup> retrieveBackup(UUID uuid); | ||
|
||
default PteroAction<Backup> retrieveBackup(String uuid) { | ||
return retrieveBackup(UUID.fromString(uuid)); | ||
} | ||
|
||
BackupManager getBackupManager(); | ||
|
||
PteroAction<List<Schedule>> retrieveSchedules(); | ||
|
||
default PteroAction<Schedule> retrieveSchedule(long id) { | ||
return retrieveSchedule(Long.toUnsignedString(id)); | ||
} | ||
|
||
PteroAction<Schedule> retrieveSchedule(String id); | ||
|
||
ScheduleManager getScheduleManager(); | ||
|
||
FileManager getFileManager(); | ||
|
||
default PteroAction<Directory> retrieveDirectory() { | ||
return retrieveDirectory("/"); | ||
} | ||
|
||
PteroAction<Directory> retrieveDirectory(Directory previousDirectory, Directory directory); | ||
|
||
PteroAction<Directory> retrieveDirectory(String path); | ||
|
||
PteroAction<List<ClientDatabase>> retrieveDatabases(); | ||
|
||
default PteroAction<Optional<ClientDatabase>> retrieveDatabaseById(String id) { | ||
return retrieveDatabases().map(List::stream).map(stream -> stream.filter(db -> db.getId().equals(id)).findFirst()); | ||
} | ||
|
||
default PteroAction<Optional<ClientDatabase>> retrieveDatabaseByName(String name, boolean caseSensitive) { | ||
return retrieveDatabases().map(List::stream).map(stream -> stream.filter(db -> caseSensitive ? | ||
db.getName().contains(name) : db.getName().toLowerCase().contains(name.toLowerCase())).findFirst()); | ||
} | ||
|
||
ClientDatabaseManager getDatabaseManager(); | ||
|
||
List<ClientAllocation> getAllocations(); | ||
|
||
default ClientAllocation getPrimaryAllocation() { | ||
return getAllocations().stream().filter(ClientAllocation::isDefault).findFirst().get(); | ||
} | ||
|
||
default Optional<ClientAllocation> getAllocationByPort(int port) { | ||
return getAllocations().stream().filter(allocation -> allocation.getPortInt() == port).findFirst(); | ||
} | ||
|
||
default Optional<ClientAllocation> getAllocationById(long id) { | ||
return getAllocations().stream().filter(allocation -> allocation.getIdLong() == id).findFirst(); | ||
} | ||
|
||
ClientAllocationManager getAllocationManager(); | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can’t this be just Kilobytes? (Same for gb / mb)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could yes, Just wanted to be clear, really just preference-based feel free to change it tho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is your PR, you would have to be the one to change it