Skip to content

Latest commit

 

History

History
133 lines (101 loc) · 4.33 KB

README.md

File metadata and controls

133 lines (101 loc) · 4.33 KB

Velocity Punishment

Velocity punishment is a punishment plugin designed for velocity.
Please not that this plugin is in its development stage at the moment and has not been release fully yet.

Table of contents

  1. Plugin installation
  2. Duration
  3. Commands
  4. API

Plugin installation

  1. Download the latest version of the plugin
  2. Put the downloaded file into the plugins folder of your server.
  3. (Re-)Start the server.

Punishment API

Installation

Replace {version} with the current version, e.g. 1.0.0. Note that the artifacts are not yet published.

Commands

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 with legacy color codes
  • 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
  • /punishment <playerinfo> <player> shows information about a player's punishments
  • /punishment <cancel|change|info|remove> <punishment id> cancels/removes, changes or shows information about the given punishment(must be a uuid)
  • /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

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.

Gradle (kotlin)

repositories {
   mavenCentral()
}

depenencies {
   implementation("de.jvstvshd.punishment.velocity:api:{version}")
}

Gradle (groovy)

repositories {
    mavenCentral()
}

dependencies {
   implementation 'de.jvstvshd.punishment.velocity:api:{version}'
}

Maven

<dependencies>
   <dependency>
      <groupId>de.jvstvshd.punishment.velocity</groupId>
      <artifactId>api</artifactId>
      <version>{version}</version>
   </dependency>
</dependencies>

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 {
        VelocityPunishment api = (VelocityPunishment) server.getPluginManager().getPlugin("velocity-punishment").orElseThrow().getInstance().orElseThrow();
    } catch(NoSuchElementException e) {
        logger.error("Punishment API is not available");
    }

Punishing a player

All punishments are imposed via the punishment manager (obtainable via VelocityPunishment#getPunishmentManager). For example, banning a player could be done this way:

    PunishmentManager punishmentManager = api.getPunishmentManager();
    //temporary ban:
    Ban temporaryBan = punishmentManager.createBan(uuid, Component.text("You are banned from this server.").color(NamedTextColor.RED), PunishmentDuration.parse("1d"));//1d equals 1 day, the duration is relative to the current time until the punishment is imposed.
    //permanent ban:
    Ban permanentBan = punishmentManager.createPermanentBan(uuid2, Component.text("You are banned permanently from this server").color(NamedTextColor.RED))
    //To finally punish the player, use Punishment#punish which will return a CompletableFuture with the punishment was imposed
    temporaryBan.punish().whenCompleteAsync((ban,throwable) -> {
    if (throwable != null) {
        logger.error("Error punishing player", throwable);
        return;
    }
    logger.info("The player was successfully banned. Punishment id: " + ban.getPunishmentUuid());
    });

Muting a player is similar, just replace 'ban' with 'mute'.