Skip to content

Commit

Permalink
Feature: Node: setMaintanceMode (#74)
Browse files Browse the repository at this point in the history
* Node: setMaintanceMode

* Node: setMaintanceMode - change property name

* Node: setMaintanceMode - change property name / fix function naming

* Node: hasMaintanceMode - fix docstring
  • Loading branch information
DerMistkaefer authored Jun 23, 2024
1 parent 844ffdc commit 1b8825f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2022 Matt Malec, and the Pterodactyl4J contributors
* Copyright 2021-2024 Matt Malec, and the Pterodactyl4J contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,7 +42,17 @@ public interface Node extends ISnowflake {

boolean isBehindProxy();

boolean hasMaintanceMode();
boolean isInMaintenanceMode();

/**
* @return {@code true} if the node is in maintenance mode
*
* @deprecated For spelling mistake only. Use {@link #isInMaintenanceMode()} instead
*/
@Deprecated
default boolean hasMaintanceMode() {
return isInMaintenanceMode();
}

default String getMemory() {
return Long.toUnsignedString(getMemoryLong());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2022 Matt Malec, and the Pterodactyl4J contributors
* Copyright 2021-2024 Matt Malec, and the Pterodactyl4J contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -55,6 +55,7 @@ protected RequestBody finalizeData() {
json.put("daemon_listen", daemonListenPort);
json.put("daemon_sftp", daemonSFTPPort);
json.put("throttle", new JSONObject().put("enabled", throttle));
json.put("maintenance_mode", maintenanceMode ? "1" : "0");
return getRequestBody(json);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2022 Matt Malec, and the Pterodactyl4J contributors
* Copyright 2021-2024 Matt Malec, and the Pterodactyl4J contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -63,6 +63,10 @@ protected RequestBody finalizeData() {
json.put(
"throttle",
throttle == null ? new JSONObject().put("enabled", false) : new JSONObject().put("enabled", throttle));
json.put(
"maintenance_mode",
maintenanceMode == null ? (node.isInMaintenanceMode() ? "1" : "0") : (maintenanceMode ? "1" : "0"));

return getRequestBody(json);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2022 Matt Malec, and the Pterodactyl4J contributors
* Copyright 2021-2024 Matt Malec, and the Pterodactyl4J contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -89,7 +89,7 @@ public boolean isBehindProxy() {
}

@Override
public boolean hasMaintanceMode() {
public boolean isInMaintenanceMode() {
return json.getBoolean("maintenance_mode");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2022 Matt Malec, and the Pterodactyl4J contributors
* Copyright 2021-2024 Matt Malec, and the Pterodactyl4J contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -65,4 +65,6 @@ default NodeAction setDiskSpaceOverallocate(long diskSpaceOverallocate) {
NodeAction setThrottle(boolean throttle);

NodeAction setScheme(boolean secure);

NodeAction setMaintenanceMode(boolean maintenanceMode);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2022 Matt Malec, and the Pterodactyl4J contributors
* Copyright 2021-2024 Matt Malec, and the Pterodactyl4J contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,6 +40,7 @@ public abstract class AbstractNodeAction extends PteroActionImpl<Node> implement
protected String daemonListenPort;
protected Boolean throttle;
protected Boolean secure;
protected Boolean maintenanceMode;

public AbstractNodeAction(PteroApplicationImpl impl, Route.CompiledRoute route) {
super(impl.getP4J(), route, (response, request) -> new NodeImpl(response.getObject(), impl));
Expand Down Expand Up @@ -128,4 +129,10 @@ public NodeAction setScheme(boolean secure) {
this.secure = secure;
return this;
}

@Override
public NodeAction setMaintenanceMode(boolean maintenanceMode) {
this.maintenanceMode = maintenanceMode;
return this;
}
}

0 comments on commit 1b8825f

Please sign in to comment.