From ae17c8dbc65839cd0e671ca16fd09443d0fabcef Mon Sep 17 00:00:00 2001 From: Sascha Bartl Date: Wed, 27 Dec 2023 18:02:18 +0100 Subject: [PATCH 1/4] Node: setMaintanceMode --- .../application/entities/impl/CreateNodeImpl.java | 3 ++- .../application/entities/impl/EditNodeImpl.java | 6 +++++- .../pterodactyl4j/application/managers/NodeAction.java | 4 +++- .../requests/action/AbstractNodeAction.java | 9 ++++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/CreateNodeImpl.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/CreateNodeImpl.java index 4bf3511..64a0f52 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/CreateNodeImpl.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/CreateNodeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2022 Matt Malec, and the Pterodactyl4J contributors + * Copyright 2021-2023 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. @@ -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", hasMaintanceMode ? "1" : "0"); return getRequestBody(json); } } diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/EditNodeImpl.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/EditNodeImpl.java index 968d38b..46adcb0 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/EditNodeImpl.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/EditNodeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2022 Matt Malec, and the Pterodactyl4J contributors + * Copyright 2021-2023 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. @@ -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", + hasMaintanceMode == null ? (node.hasMaintanceMode() ? "1" : "0") : (hasMaintanceMode ? "1" : "0")); + return getRequestBody(json); } } diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/managers/NodeAction.java b/src/main/java/com/mattmalec/pterodactyl4j/application/managers/NodeAction.java index 781b8ef..00024d3 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/managers/NodeAction.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/managers/NodeAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2022 Matt Malec, and the Pterodactyl4J contributors + * Copyright 2021-2023 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. @@ -65,4 +65,6 @@ default NodeAction setDiskSpaceOverallocate(long diskSpaceOverallocate) { NodeAction setThrottle(boolean throttle); NodeAction setScheme(boolean secure); + + NodeAction setMaintanceMode(boolean hasMaintanceMode); } diff --git a/src/main/java/com/mattmalec/pterodactyl4j/requests/action/AbstractNodeAction.java b/src/main/java/com/mattmalec/pterodactyl4j/requests/action/AbstractNodeAction.java index aa02279..dacad8d 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/requests/action/AbstractNodeAction.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/requests/action/AbstractNodeAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2022 Matt Malec, and the Pterodactyl4J contributors + * Copyright 2021-2023 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. @@ -40,6 +40,7 @@ public abstract class AbstractNodeAction extends PteroActionImpl implement protected String daemonListenPort; protected Boolean throttle; protected Boolean secure; + protected Boolean hasMaintanceMode; public AbstractNodeAction(PteroApplicationImpl impl, Route.CompiledRoute route) { super(impl.getP4J(), route, (response, request) -> new NodeImpl(response.getObject(), impl)); @@ -128,4 +129,10 @@ public NodeAction setScheme(boolean secure) { this.secure = secure; return this; } + + @Override + public NodeAction setMaintanceMode(boolean hasMaintanceMode) { + this.hasMaintanceMode = hasMaintanceMode; + return this; + } } From 0ba95c4a723b263e3bb190f08b4cee747b5dc309 Mon Sep 17 00:00:00 2001 From: Sascha Bartl Date: Mon, 1 Jan 2024 17:06:20 +0100 Subject: [PATCH 2/4] Node: setMaintanceMode - change property name --- .../application/entities/impl/CreateNodeImpl.java | 4 ++-- .../application/entities/impl/EditNodeImpl.java | 6 ++++-- .../pterodactyl4j/application/managers/NodeAction.java | 4 ++-- .../pterodactyl4j/requests/action/AbstractNodeAction.java | 8 ++++---- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/CreateNodeImpl.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/CreateNodeImpl.java index 64a0f52..ec885cf 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/CreateNodeImpl.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/CreateNodeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2023 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. @@ -55,7 +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", hasMaintanceMode ? "1" : "0"); + json.put("maintenance_mode", isInMaintenanceMode ? "1" : "0"); return getRequestBody(json); } } diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/EditNodeImpl.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/EditNodeImpl.java index 46adcb0..b0a9217 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/EditNodeImpl.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/EditNodeImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2023 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. @@ -65,7 +65,9 @@ protected RequestBody finalizeData() { throttle == null ? new JSONObject().put("enabled", false) : new JSONObject().put("enabled", throttle)); json.put( "maintenance_mode", - hasMaintanceMode == null ? (node.hasMaintanceMode() ? "1" : "0") : (hasMaintanceMode ? "1" : "0")); + isInMaintenanceMode == null + ? (node.hasMaintanceMode() ? "1" : "0") + : (isInMaintenanceMode ? "1" : "0")); return getRequestBody(json); } diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/managers/NodeAction.java b/src/main/java/com/mattmalec/pterodactyl4j/application/managers/NodeAction.java index 00024d3..e49a6f5 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/managers/NodeAction.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/managers/NodeAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2023 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. @@ -66,5 +66,5 @@ default NodeAction setDiskSpaceOverallocate(long diskSpaceOverallocate) { NodeAction setScheme(boolean secure); - NodeAction setMaintanceMode(boolean hasMaintanceMode); + NodeAction setMaintanceMode(boolean isInMaintenanceMode); } diff --git a/src/main/java/com/mattmalec/pterodactyl4j/requests/action/AbstractNodeAction.java b/src/main/java/com/mattmalec/pterodactyl4j/requests/action/AbstractNodeAction.java index dacad8d..13a9ede 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/requests/action/AbstractNodeAction.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/requests/action/AbstractNodeAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2023 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. @@ -40,7 +40,7 @@ public abstract class AbstractNodeAction extends PteroActionImpl implement protected String daemonListenPort; protected Boolean throttle; protected Boolean secure; - protected Boolean hasMaintanceMode; + protected Boolean isInMaintenanceMode; public AbstractNodeAction(PteroApplicationImpl impl, Route.CompiledRoute route) { super(impl.getP4J(), route, (response, request) -> new NodeImpl(response.getObject(), impl)); @@ -131,8 +131,8 @@ public NodeAction setScheme(boolean secure) { } @Override - public NodeAction setMaintanceMode(boolean hasMaintanceMode) { - this.hasMaintanceMode = hasMaintanceMode; + public NodeAction setMaintanceMode(boolean isInMaintenanceMode) { + this.isInMaintenanceMode = isInMaintenanceMode; return this; } } From 99cfaf308b00f1109228de4c2d235b9f69d3bc09 Mon Sep 17 00:00:00 2001 From: Sascha Bartl Date: Tue, 2 Jan 2024 18:13:05 +0100 Subject: [PATCH 3/4] Node: setMaintanceMode - change property name / fix function naming --- .../pterodactyl4j/application/entities/Node.java | 13 +++++++++++-- .../application/entities/impl/CreateNodeImpl.java | 2 +- .../application/entities/impl/EditNodeImpl.java | 4 +--- .../application/entities/impl/NodeImpl.java | 4 ++-- .../application/managers/NodeAction.java | 2 +- .../requests/action/AbstractNodeAction.java | 6 +++--- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/Node.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/Node.java index 4ac5af5..ead38a5 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/Node.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/Node.java @@ -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. @@ -42,7 +42,16 @@ public interface Node extends ISnowflake { boolean isBehindProxy(); - boolean hasMaintanceMode(); + boolean isInMaintenanceMode(); + + /** + * @deprecated Use {@link #isInMaintenanceMode()} instead + * @return {@code true} if the node is in maintenance mode + */ + @Deprecated + default boolean hasMaintanceMode() { + return isInMaintenanceMode(); + } default String getMemory() { return Long.toUnsignedString(getMemoryLong()); diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/CreateNodeImpl.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/CreateNodeImpl.java index ec885cf..f2d40a8 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/CreateNodeImpl.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/CreateNodeImpl.java @@ -55,7 +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", isInMaintenanceMode ? "1" : "0"); + json.put("maintenance_mode", maintenanceMode ? "1" : "0"); return getRequestBody(json); } } diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/EditNodeImpl.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/EditNodeImpl.java index b0a9217..a3db259 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/EditNodeImpl.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/EditNodeImpl.java @@ -65,9 +65,7 @@ protected RequestBody finalizeData() { throttle == null ? new JSONObject().put("enabled", false) : new JSONObject().put("enabled", throttle)); json.put( "maintenance_mode", - isInMaintenanceMode == null - ? (node.hasMaintanceMode() ? "1" : "0") - : (isInMaintenanceMode ? "1" : "0")); + maintenanceMode == null ? (node.isInMaintenanceMode() ? "1" : "0") : (maintenanceMode ? "1" : "0")); return getRequestBody(json); } diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/NodeImpl.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/NodeImpl.java index cd5f6e4..1a2b8a5 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/NodeImpl.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/impl/NodeImpl.java @@ -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. @@ -89,7 +89,7 @@ public boolean isBehindProxy() { } @Override - public boolean hasMaintanceMode() { + public boolean isInMaintenanceMode() { return json.getBoolean("maintenance_mode"); } diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/managers/NodeAction.java b/src/main/java/com/mattmalec/pterodactyl4j/application/managers/NodeAction.java index e49a6f5..e7e077e 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/managers/NodeAction.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/managers/NodeAction.java @@ -66,5 +66,5 @@ default NodeAction setDiskSpaceOverallocate(long diskSpaceOverallocate) { NodeAction setScheme(boolean secure); - NodeAction setMaintanceMode(boolean isInMaintenanceMode); + NodeAction setMaintenanceMode(boolean maintenanceMode); } diff --git a/src/main/java/com/mattmalec/pterodactyl4j/requests/action/AbstractNodeAction.java b/src/main/java/com/mattmalec/pterodactyl4j/requests/action/AbstractNodeAction.java index 13a9ede..002bb69 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/requests/action/AbstractNodeAction.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/requests/action/AbstractNodeAction.java @@ -40,7 +40,7 @@ public abstract class AbstractNodeAction extends PteroActionImpl implement protected String daemonListenPort; protected Boolean throttle; protected Boolean secure; - protected Boolean isInMaintenanceMode; + protected Boolean maintenanceMode; public AbstractNodeAction(PteroApplicationImpl impl, Route.CompiledRoute route) { super(impl.getP4J(), route, (response, request) -> new NodeImpl(response.getObject(), impl)); @@ -131,8 +131,8 @@ public NodeAction setScheme(boolean secure) { } @Override - public NodeAction setMaintanceMode(boolean isInMaintenanceMode) { - this.isInMaintenanceMode = isInMaintenanceMode; + public NodeAction setMaintenanceMode(boolean maintenanceMode) { + this.maintenanceMode = maintenanceMode; return this; } } From 5109ab246c58c2805335ce290af3a4b9e154994d Mon Sep 17 00:00:00 2001 From: Sascha Bartl Date: Sun, 14 Jan 2024 10:44:33 +0100 Subject: [PATCH 4/4] Node: hasMaintanceMode - fix docstring --- .../com/mattmalec/pterodactyl4j/application/entities/Node.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/Node.java b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/Node.java index ead38a5..1dec6e8 100644 --- a/src/main/java/com/mattmalec/pterodactyl4j/application/entities/Node.java +++ b/src/main/java/com/mattmalec/pterodactyl4j/application/entities/Node.java @@ -45,8 +45,9 @@ public interface Node extends ISnowflake { boolean isInMaintenanceMode(); /** - * @deprecated Use {@link #isInMaintenanceMode()} instead * @return {@code true} if the node is in maintenance mode + * + * @deprecated For spelling mistake only. Use {@link #isInMaintenanceMode()} instead */ @Deprecated default boolean hasMaintanceMode() {