Skip to content
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

Feature: Node: setMaintanceMode #74

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,16 @@ public interface Node extends ISnowflake {

boolean isBehindProxy();

boolean hasMaintanceMode();
boolean isInMaintenanceMode();

/**
* @deprecated Use {@link #isInMaintenanceMode()} instead
DerMistkaefer marked this conversation as resolved.
Show resolved Hide resolved
* @return {@code true} if the node is in maintenance mode
*/
@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;
}
}