Code Monkey home page Code Monkey logo

necrify's Introduction

Necrify

Necrify is a punishment plugin designed for currently Velocity (and maybe Paper/BungeeCord in the future).

Table of contents

  1. Plugin installation
  2. Mutes (only affects Velocity)
  3. Duration
  4. Commands
  5. API

Plugin installation

  1. Download the latest version of the plugin or download dev builds here (may be unstable or not working)
  2. Put the downloaded file into the plugins folder of your server.
  3. (Re-)Start the server.

Mutes

With the 1.19.1, Minecraft's chat system got changed (detailed explanation). Since then, it is no longer possible to block chat messages in the ChatEvent of Velocity due to the signed chat messages. This is why the chat listener does not block any messages anymore which means mutes are effectively useless. A solution to this problem is developing an extension plugin for the actual game servers where cancelling these messages is still possible. Downloads for this paper plugin are found in the releases and also as dev builds on Jenkins.
For further information about 1.19.1, please refer to the official release notes

Commands

All commands are registered with the prefix /necrify. Moreover, it is possible to register top-level commands too by setting allow-top-level-commands to true (which is per default)
legend:

  • <arg> means the argument is required
  • [arg] means the argument is optional
  • player as argument name means the a player name OR uuid is required
  • reason means a reason that supports MiniMessage
  • duration as argument name means a duration

Command overview

  • /ban <player> [reason] bans a player permanently for the given or the default reason
  • /mute <player> [reason] mutes a player permanently for the given or the default reason
  • /tempban [reason] bans a player for the given duration for the given or the default reason
  • /tempmute [reason] mutes a player for the given duration for the given or the default reason
  • /unban unbans the given player
  • /unmute unmutes the given player
  • /necrify user <player> <info|delete|whitelist> shows either information about a player's punishments and his whitelist status, deletes this user including all punishments or inverts his whitelist status (from whitelisted to blacklisted or vice versa)
  • /necrify punishment <punishment id> <cancel|change|info|remove> cancels/removes, changes or shows information about the given punishment(must be a uuid)

Duration

To be parsed by PunishmentDuration#parse(String), a string must follow this scheme:
[0-9][s, m, h, d]
s - second(s)
m - minute(s)
h - hour(s)
d - day(s)
These value can be composed, all of them can be omitted.
Example: 1d12h15m30s means a duration of 1 day, 12 hours, 15 minutes and 30 seconds.

Punishment API

Installation

Replace {version} with the current version, e.g. 1.0.0. The latest version can be found here. Note that you only want to use the string after necrify-{platform}- and without the version build number.

Gradle (kotlin)

repositories {
   mavenCentral()
}

depenencies {
   implementation("de.jvstvshd.necrify:necrify-api:{version}")
}

Gradle (groovy)

repositories {
    mavenCentral()
}

dependencies {
   implementation 'de.jvstvshd.necrify:necrify-api:{version}'
}

Maven

<dependencies>
   <dependency>
      <groupId>de.jvstvshd.necrify</groupId>
      <artifactId>necrify-api</artifactId>
      <version>{version}</version>
   </dependency>
</dependencies>

You can also depend on the plugin modules or common module. In order to do so, replace the artifactId with the desired module name. Note that code outside the API module is always subject to change and may not be stable. It is also not designed to allow access and modifications from outside the plugin itself and is often not documented.

Usage

Obtaining an instance of the api

If the plugin is used, you can obtain an instance of the api using the following snippet:

    try {
        Necrify api = (Necrify) server.getPluginManager().getPlugin("necrify").orElseThrow().getInstance().orElseThrow();
    } catch(NoSuchElementException e) {
        logger.error("Punishment API is not available");
    }

Punishing a player

All punishments are issued via the target user. For example, banning a player could be done this way:

    //Firstly, obtain the user instance
    NecrifyUser user = api.getUserManager().getUser(uuid).orElseThrow(() -> new NoSuchElementException("User not found"));
    MiniMessage miniMessage = MiniMessage.miniMessage();
    //temporary ban:
    Ban temporaryBan = user.ban(PunishmentDuration.parse(miniMessage.deserialize("<red>You broke the server's rules! Don't cheat!"), PunishmentDuration.parse("1d"))).join();//1d equals 1 day, the duration is relative to the current time until the punishment is imposed.
    //permanent ban:
    Ban permanentBan = user.banPermanent(miniMessage.deserialize("<red>You broke the server's rules again! You are not allowed to join someday again!")).join();
    //The ban instance you get via #join is the punishment that was issued. Note that using #join blocks the current 
    //Thread and since database operations take some time to complete, it is recommended to use #whenComplete or other.
    //You can now use this instance to change or cancel the punishment:
    temporaryBan.cancel().whenComplete((punishment, throwable) -> {
        if(throwable != null) {
            logger.error("An error occurred while cancelling the punishment", throwable);
            return;
        }
        logger.info("The punishment was successfully cancelled");
    });
    //#cancel should always return the same instance that you called the method on
    //Event tough a permanent ban was issued for an indefinite time, you can still change the duration and the reason:        
    permanentBan.change(PunishmentDuration.parse("300d"), miniMessage.deseriaize("<green>Okay, you may join again in 300 days!")).whenComplete((punishment, throwable) -> {
        if(throwable != null) {
            logger.error("An error occurred while changing the punishment", throwable);
            return;
        }
        logger.info("The punishment was successfully changed");
    });

Muting a player is similar, just replace 'ban' with 'mute'.
Kicking a player can be done by calling user.kick(Reason).join(); where it is safe to call #join since there is no database query done synchronously. This form of punishment cannot be changed nor cancelled as it only lasts a single moment.

necrify's People

Contributors

jvstvshd avatar renovate[bot] avatar

Watchers

 avatar

necrify's Issues

Update translations

On startup, new translations should be added to the local files (if already exist).

Punishment templates and stages

For easier use, a less time-consuming solution for punishing should be established. This consists of a list of templates that define the duration and reason that caused this punishment. Such templates will be identified by either numbers or a string identifier or both. Reason are going to be stored (in db/i18n files?) internationalized. For simpler usability, reasons will be formatted as MiniMessage components.
Additionally, templates can be assigned in a specific order to stages. With each new punishment in the same template, the stage of the actual punishment will get increased and thus its severity. This requires #8 to work and store template ids per punishment. If there is the need to reset/decrease the stage (for e.g. wrongful punishment), this is denoted in the punishment history.

Migrate commands into single command

As of now, for all functions exists one single, extra command (/ban, /unban, ...). Since those sometimes clash with other commands from other sources (e.g. /ban and /whitelist from Bukkit based servers), they should all be merged into one single command with all respective branches (/necrify ban ... instead of /ban). There still should be the config option to allow those top-level-commands, which will be enabled by default. To accommodate with multi-platform support, this command should be done with the cloud framework.

Current progress: #38

Loading strategy for active punishments

This strategy describes when active punishments will be loaded. There are the following options:

  • At user load: Active punishments will be concurrently to the user
  • When needed: If NecrifyUser#getPunishments or #getPunishment gets called, it will then load and cache those punishments.
    Per default, option 1 should be used as the amount of active punishments per user should usually be contained. This option will be configurable in the plugin's config.
    Note: /necrify punishment <...> will not work properly until this gets implemented.

Add events

There should events (use the existing event systems on the platforms) for the following:

  • punishment enforcement
  • punishment cancellation
  • punishment change
    These are also required to support other platforms (or to make it easier to integrate those), since Velocity doesn't allow the cancellation of chat messages directly. Thus, a message has to be sent to all game servers so they can block messages. As it is planned to move the current punishment implementations out of the plugin module into plugin-common, such an extra has to be done via events.

Message rework

Remove the current MessageProvider from the plugin and replace with MiniMessage.

Cancelling chat messages

Since 1.19.1, cancelling chat messages on proxy is not possible anymore. Therefore, we have to listen to the chat event on the actual game server. This means that there has to be a spigot/paper extension to this plugin to still being able to cancel chat messages unless there is a possibility from Velocity to cancel chat messages (which is currently not that probable). Such an extension will likely be added after the command rework (see #2) is done.

SQL: punishment history

A new SQL table for punishment histories should be added. It shall contain the player (identified by only the UUID) and per row one entry for all actions related to punishment, idest imposing, changing and revoking a punishment.

Accumulate punishments

Add a possibility to accumulate punishments of the same type, e.g. if the player was already banned for using illegal modifications for 30 days and gets banned for another reason for 14 days, there should not be 2 seperate punishments since the latter one would have no impact on the player anyways. Instead, an accumulated punishment should be created that states every misdemeanour in its reason.

Config rework

Replace the current config with a constructor-based config.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency ch.qos.logback:logback-classic to v1.5.7
  • Update dependency org.slf4j:slf4j-api to v2.0.16
  • Update plugin xyz.jpenilla.run-velocity to v2.3.1
  • Update sadu to v2.2.5 (de.chojo.sadu:sadu-queries, de.chojo.sadu:sadu)
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/publish.yml
  • actions/checkout v3
  • actions/setup-java v3
  • gradle/wrapper-validation-action 88425854a36845f9c881450d9660b5fd46bee142
gradle
settings.gradle.kts
build.gradle.kts
  • org.cadixdev.licenser 0.6.1
api/build.gradle.kts
  • ch.qos.logback:logback-classic 1.5.6
gradle/libs.versions.toml
  • com.velocitypowered:velocity-api 3.3.0-SNAPSHOT
  • net.luckperms:api 5.4
  • com.fasterxml.jackson.core:jackson-databind 2.17.1
  • com.fasterxml.jackson.dataformat:jackson-dataformat-yaml 2.13.4
  • com.fasterxml.jackson.datatype:jackson-datatype-jsr310 2.13.4
  • org.postgresql:postgresql 42.5.0
  • com.zaxxer:HikariCP 5.0.1
  • de.chojo.sadu:sadu 2.2.1
  • de.chojo.sadu:sadu-queries 2.2.1
  • org.junit.jupiter:junit-jupiter-api 5.9.1
  • org.junit.jupiter:junit-jupiter-engine 5.9.1
  • io.papermc.paper:paper-api 1.20.6-R0.1-SNAPSHOT
  • com.mojang:brigadier 1.0.500
  • org.mariadb.jdbc:mariadb-java-client 3.4.0
  • org.xerial:sqlite-jdbc 3.45.3.0
  • com.mysql:mysql-connector-j 8.4.0
  • net.kyori:adventure-api 4.17.0
  • net.kyori:adventure-text-minimessage 4.17.0
  • org.incendo:cloud-core 2.0.0-SNAPSHOT
  • org.incendo:cloud-annotations 2.0.0-SNAPSHOT
  • org.jetbrains:annotations 24.1.0
  • org.greenrobot:eventbus-java 3.3.1
  • org.slf4j:slf4j-api 2.0.13
paper-extension/build.gradle.kts
  • com.github.johnrengelman.shadow 7.1.2
  • net.minecrell.plugin-yml.paper 0.6.0
plugin/build.gradle.kts
  • io.github.goooler.shadow 8.1.8
  • xyz.jpenilla.run-velocity 2.3.0
plugin-common/build.gradle.kts
  • com.google.code.gson:gson 2.10.1
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.8

  • Check this box to trigger a request for Renovate to run again on this repository

SQLite is used as default database, but is not supported

Currently, whenever the velocity plugin's config gets newly created on first startup, the sql type gets set to SQLite. Since this database is not compatible to the current storage architechture, it should be set to a supported platform (PostgreSQL).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.