-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify punishments; extend time (#115)
* Create and implement API to modify punishment reason, scope and end time, with possibility to modify end time (#162) * Add command-extend addon to extend a punishment by specified duration (#115) * Guarantee end > start in database, increment database revision accordingly * Update Github workflow
- Loading branch information
Showing
49 changed files
with
1,178 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
bans-api/src/main/java/space/arim/libertybans/api/punish/PunishmentEditor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* LibertyBans | ||
* Copyright © 2023 Anand Beh | ||
* | ||
* LibertyBans is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* LibertyBans is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with LibertyBans. If not, see <https://www.gnu.org/licenses/> | ||
* and navigate to version 3 of the GNU Affero General Public License. | ||
*/ | ||
|
||
package space.arim.libertybans.api.punish; | ||
|
||
import space.arim.libertybans.api.scope.ServerScope; | ||
|
||
import java.time.Duration; | ||
import java.time.Instant; | ||
|
||
/** | ||
* Assistant interface for modifying a punishment | ||
* | ||
*/ | ||
public interface PunishmentEditor { | ||
|
||
/** | ||
* Sets the new reason | ||
* | ||
* @param reason the new reason | ||
*/ | ||
void setReason(String reason); | ||
|
||
/** | ||
* Sets the new scope | ||
* | ||
* @param scope the new scope | ||
*/ | ||
void setScope(ServerScope scope); | ||
|
||
/** | ||
* Sets the new end date. {@link Punishment#PERMANENT_END_DATE} is used for a | ||
* permanent punishment | ||
* | ||
* @param endDate the new end date | ||
* @throws IllegalStateException if {@link #extendEndDate(Duration)} was used | ||
*/ | ||
void setEndDate(Instant endDate); | ||
|
||
/** | ||
* Modifies the end date by adding the given duration. <br> | ||
* <br> | ||
* It is possible to reduce the end date by using a negative duration. Note that if | ||
* the subtraction operation would otherwise cause the punishment to have an end date less | ||
* than or equal to the start date, then 1 second plus the start date is used as the new | ||
* end date. | ||
* | ||
* @param endDateDelta the amount by which to change the end date, may be negative | ||
* @throws IllegalStateException if {@link #setEndDate(Instant)} was used | ||
*/ | ||
void extendEndDate(Duration endDateDelta); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>space.arim.libertybans</groupId> | ||
<artifactId>bans-core-addons</artifactId> | ||
<version>1.1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<name>command-extend</name> | ||
<artifactId>addon-command-extend</artifactId> | ||
</project> |
16 changes: 16 additions & 0 deletions
16
bans-core-addons/command-extend/src/main/java/module-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import space.arim.libertybans.core.addon.AddonProvider; | ||
import space.arim.libertybans.core.addon.extend.ExtendProvider; | ||
|
||
module space.arim.libertybans.core.addon.extend { | ||
requires jakarta.inject; | ||
requires net.kyori.adventure; | ||
requires net.kyori.examination.api; | ||
requires static org.checkerframework.checker.qual; | ||
requires static org.jetbrains.annotations; | ||
requires space.arim.api.jsonchat; | ||
requires space.arim.dazzleconf; | ||
requires space.arim.injector; | ||
requires space.arim.libertybans.core; | ||
exports space.arim.libertybans.core.addon.extend; | ||
provides AddonProvider with ExtendProvider; | ||
} |
54 changes: 54 additions & 0 deletions
54
...ns/command-extend/src/main/java/space/arim/libertybans/core/addon/extend/ExtendAddon.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* LibertyBans | ||
* Copyright © 2023 Anand Beh | ||
* | ||
* LibertyBans is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* LibertyBans is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with LibertyBans. If not, see <https://www.gnu.org/licenses/> | ||
* and navigate to version 3 of the GNU Affero General Public License. | ||
*/ | ||
|
||
package space.arim.libertybans.core.addon.extend; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
import space.arim.libertybans.core.addon.AbstractAddon; | ||
import space.arim.libertybans.core.addon.AddonCenter; | ||
|
||
@Singleton | ||
public final class ExtendAddon extends AbstractAddon<ExtendConfig> { | ||
|
||
@Inject | ||
public ExtendAddon(AddonCenter addonCenter) { | ||
super(addonCenter); | ||
} | ||
|
||
@Override | ||
public void startup() { | ||
|
||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
|
||
} | ||
|
||
@Override | ||
public Class<ExtendConfig> configInterface() { | ||
return ExtendConfig.class; | ||
} | ||
|
||
@Override | ||
public String identifier() { | ||
return "command-extend"; | ||
} | ||
} |
Oops, something went wrong.