Skip to content

Commit

Permalink
Implement punishment successors
Browse files Browse the repository at this point in the history
You can now chain punishments via /necrify punishment <ID> chain  <other>.
Automatic questioning about whether to chain punishments still needs to be added.
  • Loading branch information
JvstvsHD committed Aug 7, 2024
1 parent 1020aec commit d6e56ba
Show file tree
Hide file tree
Showing 100 changed files with 737 additions and 249 deletions.
44 changes: 23 additions & 21 deletions HEADER.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
This file is part of Necrify (formerly Velocity Punishment), which is licensed under the MIT license.

Copyright (c) 2022-2024 JvstvsHD

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
/*
* This file is part of Necrify (formerly Velocity Punishment), which is licensed under the MIT license.
*
* Copyright (c) 2022-2024 JvstvsHD
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
26 changes: 13 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import com.diffplug.gradle.spotless.SpotlessPlugin
import io.papermc.hangarpublishplugin.model.Platforms
import org.cadixdev.gradle.licenser.Licenser
import java.io.ByteArrayOutputStream
import java.util.*

plugins {
`maven-publish`
signing
id("org.cadixdev.licenser") version "0.6.1"
id("io.papermc.hangar-publish-plugin") version "0.1.2"
id("io.github.goooler.shadow") version "8.1.8" apply false
id("com.diffplug.spotless") version "6.25.0"
java
}

Expand All @@ -16,16 +16,15 @@ version = "1.2.0-SNAPSHOT"

subprojects {
apply {
plugin<Licenser>()
plugin<MavenPublishPlugin>()
plugin<SigningPlugin>()
plugin("java")
plugin<SpotlessPlugin>()
}

license {
header(rootProject.file("HEADER.txt"))
include("**/*.java")
newLine(true)
spotless {
java {
licenseHeaderFile(rootProject.file("HEADER.txt"))
}
}
java {
toolchain.languageVersion = JavaLanguageVersion.of(21)
Expand Down Expand Up @@ -105,14 +104,15 @@ hangarPublish {
version.set(buildVersion())
channel.set(if (!isRelease()) "Snapshot" else "Release")
id.set("necrify")
apiKey.set("5eb868d8-6dbf-4d5e-92be-6cf2c0126818.cfb7e524-0b1f-48c9-9ac4-8f31f0fa1f80")
//apiKey.set(System.getenv("HANGAR_API_TOKEN"))
apiKey.set(System.getenv("HANGAR_API_TOKEN"))
if (!isRelease()) {
changelog.set(latestGitCommitMessage())
changelog.set(changelogMessage())
} else {
changelog.set("Changes will be provided shortly.\nComplete changelog can be found on GitHub: https://www.github.com/JvstvsHD/necrify/releases/tag/v$version")
}
platforms {
register(Platforms.PAPER) {
jar.set(project(":necrify-paper").tasks.jar.flatMap { it.archiveFile })
jar.set((project(":necrify-paper").tasks.getByName("shadowJar") as Jar).archiveFile)
val versions: List<String> = (property("paperVersion") as String)
.split(",")
.map { it.trim() }
Expand Down
8 changes: 7 additions & 1 deletion buildSrc/src/main/kotlin/Version.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class Version(val project: Project) {
return executeGitCommand("log", "-1", "--pretty=%B")
}

fun latestCommitHash(): String {
return executeGitCommand("rev-parse", "HEAD")
}

val versionString: String = project.version as String
val isRelease: Boolean = !versionString.contains('-')

Expand All @@ -30,6 +34,8 @@ class Version(val project: Project) {

fun Project.buildVersion() = Version(this).suffixedVersion

fun Project.latestGitCommitMessage() = Version(this).latestCommitMessage()
fun Project.changelogMessage() = with(Version(this)) {
"https://github.com/JvstvsHD/necrify/commit/${latestCommitHash()}: ${latestCommitMessage()}"
}

fun Project.isRelease() = Version(this).isRelease
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api;

import de.jvstvshd.necrify.api.event.EventDispatcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api;

public class PunishmentException extends RuntimeException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.duration;

import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.duration;

import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -88,4 +87,4 @@ public int hashCode() {
public String toString() {
return "PermanentPunishmentDuration{} " + super.toString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.duration;

import java.sql.Timestamp;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.temporal.Temporal;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -182,6 +182,16 @@ default PunishmentDuration initialDuration() {
throw new UnsupportedOperationException("Initial durations are not stored.");
}

/**
* The remaining duration as a {@link Duration} object.
* @return the remaining duration
* @since 1.2.0
* @see Duration#between(Temporal, Temporal)
*/
default Duration javaDuration() {
return Duration.between(LocalDateTime.now(), expiration());
}

/**
* A class for parsing player inputs into a valid {@link PunishmentDuration}.
* Allowed format: <b>{@code \d+[smhdSMHD]}</b> (e.g. 1m (one minute), 2d (two days), 1d6h (one day and six hours) or 1h30m (one hour and thirty minutes))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.duration;

import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -148,4 +147,4 @@ private String normalizeTimeUnit(long value) {
return "0" + s;
return s;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event;

import org.greenrobot.eventbus.EventBus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event;

import de.jvstvshd.necrify.api.event.origin.EventOrigin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event;

import org.greenrobot.eventbus.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event.origin;

public record ClassEventOrigin(Class<?> origin) implements EventOrigin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event.origin;

public interface EventOrigin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event.origin;

public record StringEventOrigin(String origin) implements EventOrigin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event.punishment;

import de.jvstvshd.necrify.api.punishment.Punishment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event.punishment;

import de.jvstvshd.necrify.api.punishment.Punishment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event.punishment;

import de.jvstvshd.necrify.api.event.user.UserEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event.punishment;

import de.jvstvshd.necrify.api.punishment.Punishment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event.state;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event.state;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event.state;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event.state;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event.state;

import de.jvstvshd.necrify.api.event.NecrifyEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event.user;

import de.jvstvshd.necrify.api.user.NecrifyUser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event.user;

import de.jvstvshd.necrify.api.user.NecrifyUser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event.user;

import de.jvstvshd.necrify.api.event.NecrifyEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.event.user;

import de.jvstvshd.necrify.api.user.NecrifyUser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.message;

import net.kyori.adventure.text.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package de.jvstvshd.necrify.api.punishment;

public interface Ban extends TemporalPunishment {
Expand Down
Loading

0 comments on commit d6e56ba

Please sign in to comment.