Skip to content

Commit

Permalink
Finishing touches and bug-fix before release of 1.0.0
Browse files Browse the repository at this point in the history
* Documentation updates
* Update contributors file
* Fix NPE in joiner thread
  • Loading branch information
A248 committed Jan 3, 2022
1 parent 02b94f4 commit c3fdb3b
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 39 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:

jobs:
build:
# Credits to ViaVersion; this prevents the build from running twice
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ You will need:

1. Git
2. Maven
3. JDK 11 or greater (JDK 17 is recommended)
3. JDK 17 or greater

These can be installed through your package manager of choice.

Expand All @@ -17,7 +17,7 @@ Run `git clone https://github.com/A248/LibertyBans.git && cd LibertyBans && mvn

This will clone the source repository and start the Maven build in the cloned directory.

When the build is complete, the jar at `bans-distribution/executable/target/LibertyBans-Executable_version.jar` can run as a plugin on any supported platform.
When the build is complete, the jar at `bans-distribution/executable/target/LibertyBans_version.jar` can run as a plugin on any supported platform.

# Introduction to the Codebase

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<img alt="LibertyBans" src="./.github/banner.png" />

<!-- Shields -->
[Document]:https://img.shields.io/badge/-Document-blue.svg?logo=Wikipedia&style=for-the-badge&logoColor=black
[Documentation]:https://img.shields.io/badge/-Documentation-blue.svg?logo=Wikipedia&style=for-the-badge&logoColor=black
[Discord]:https://img.shields.io/badge/-Discord-5865F2.svg?logo=discord&style=for-the-badge&logoColor=white
[Spigot]:https://img.shields.io/badge/-SpigotMC-ef9023.svg?logo=Accenture&style=for-the-badge&logoColor=grey

Expand All @@ -14,7 +14,7 @@
[CodeSize]:https://img.shields.io/github/languages/code-size/A248/LibertyBans
<!-- Shields -->
[![Discord]](https://discord.gg/3C4qeG8XhE)
[![Document]](https://libertybans.org/#/Getting-Started)
[![Documentation]](https://libertybans.org/#/Getting-Started)
[![Spigot]](https://spigotmc.org/resources/81063)
<br><br>[![TestedVersion]](https://spigotmc.org/resources/81063) ![SpigotRating]
<br>![License] ![GitHubStar] ![CodeSize]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package space.arim.libertybans.core.commands;

import org.jetbrains.annotations.Nullable;
import space.arim.omnibus.util.concurrent.ReactionStage;

interface CommandExecution {
Expand All @@ -29,6 +30,12 @@ interface CommandExecution {
*
* @return a future or {@code null} for convenience
*/
ReactionStage<Void> execute();
@Nullable ReactionStage<Void> execute();

default void executeNow() {
var future = execute();
if (future != null) {
future.toCompletableFuture().join();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import space.arim.libertybans.core.config.Configs;
import space.arim.libertybans.core.env.CmdSender;
import space.arim.libertybans.core.service.FuturePoster;
import space.arim.omnibus.util.concurrent.ReactionStage;

import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -100,7 +101,10 @@ public void execute(CmdSender sender, CommandPackage command) {
return;
}
CommandExecution execution = subCommand.execute(sender, command, firstArg);
futurePoster.postFuture(execution.execute());
ReactionStage<Void> future = execution.execute();
if (future != null) {
futurePoster.postFuture(future);
}
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package space.arim.libertybans.core.service;

import java.util.Objects;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletionException;
import java.util.concurrent.CompletionStage;
Expand Down Expand Up @@ -70,6 +71,7 @@ public FactoryOfTheFuture get() {

@Override
public void postFuture(CompletionStage<?> future) {
Objects.requireNonNull(future);
universalJoiner.execute(() -> {
try {
future.toCompletableFuture().join();
Expand Down
3 changes: 2 additions & 1 deletion bans-core/src/main/resources/contributors
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
A248
Simon (KoxSosen)

4drian3d
ahdg6
BlueTree242
D3adhkwen
Fabian Adrian
FranMC23
Gamer153
gepron1x
IceWaffles
Simon (KoxSosen)

AGI
BumbleTree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
import java.util.List;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.notNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -134,4 +136,19 @@ public void matchNoCommand() {
verify(usage).sendUsage(sender, commandNone, false);
}

@Test
public void nullExecution(@Mock SubCommandGroup subCommand, @Mock CommandExecution commandExecution) {
addBasePermission();

when(subCommand.matches("arg")).thenReturn(true);
when(subCommand.execute(any(), any(), any())).thenReturn(commandExecution);
when(commandExecution.execute()).thenReturn(null);

CommandPackage command = ArrayCommandPackage.create("arg");
newCommandsCore(List.of(subCommand)).execute(sender, command);

verify(subCommand).execute(sender, command, "arg");
verify(commandExecution).execute();
verify(futurePoster, times(0)).postFuture(isNull());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ public void unbanExplicitAddress(@Mock CmdSender sender,

when(revoker.revokeByTypeAndPossibleVictims(any(), any())).thenReturn(new EmptyRevocationOrder(futuresFactory));

commands
.execute(sender, ArrayCommandPackage.create(address), "unban")
.execute()
.toCompletableFuture().join();
commands.execute(sender, ArrayCommandPackage.create(address), "unban").executeNow();

verify(revoker).revokeByTypeAndPossibleVictims(
eq(PunishmentType.BAN), argThat(argument -> argument.contains(victim))
Expand Down Expand Up @@ -139,10 +136,7 @@ public void unbanExplicitAddressRequiresPermission(@Mock CmdSender sender,
}
lenient().when(revoker.revokeByTypeAndPossibleVictims(any(), any())).thenReturn(new EmptyRevocationOrder(futuresFactory));

commands
.execute(sender, ArrayCommandPackage.create(address), "unban")
.execute()
.toCompletableFuture().join();
commands.execute(sender, ArrayCommandPackage.create(address), "unban").executeNow();

verify(sender).sendMessage(argThat(new ComponentMatcher<>(noPermission)));
verifyNoMoreInteractions(revoker);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,9 @@ public void setConfigSection(AbstractSubCommandGroup.Dependencies dependencies,

private void executeBan(CmdSender sender) {
when(sender.hasPermission(any())).thenReturn(true);
var future = punishCommands
.execute(sender, ArrayCommandPackage.create("A248"), "ban")
.execute()
.toCompletableFuture();
var execution = punishCommands.execute(sender, ArrayCommandPackage.create("A248"), "ban");
try {
future.join();
execution.executeNow();
} catch (CompletionException ex) {
if (ex.getCause() instanceof RuntimeException cause) {
throw cause;
Expand Down
10 changes: 5 additions & 5 deletions bans-distribution/distributable/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
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-distribution</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>bans-distributable</artifactId>
<description>Shaded combination of API, main plugin classes, and bootstrap launcher.</description>

<build>
<finalName>LibertyBans_${project.version}</finalName>
<finalName>LibertyBans_Release-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -63,7 +63,7 @@
</build>
</profile>
</profiles>

<dependencies>
<dependency>
<groupId>space.arim.libertybans</groupId>
Expand Down
10 changes: 5 additions & 5 deletions bans-distribution/executable/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
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-distribution</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>bans-executable</artifactId>
<description>Runnable plugin jar which uses the latest sources</description>

<build>
<finalName>LibertyBans-Executable_${project.version}</finalName>
<finalName>LibertyBans_${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -44,7 +44,7 @@
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>space.arim.libertybans</groupId>
Expand Down
11 changes: 10 additions & 1 deletion docs/Changes-in-LibertyBans-1.0.0.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

This is a formal change-log of changes made in LibertyBans 1.0.0. It notes all manners of changes, including breaking changes; technically-detailed, little-mentioned changes which are invisible to the user; sweeping feature additions, and in-depth descriptions thereof; design and architectural decisions, and various minor matters.

If you are interested in a guide for upgrading to LibertyBans 0.8.x to 1.0.0, which focuses on breaking changes and their impact to you,
If you are interested in a guide for upgrading to LibertyBans 0.8.x to 1.0.0, which focuses on breaking changes and their impact to you, see [this page](Upgrading-to-LibertyBans-1.0.0-from-0.8.x)

## Changes

Expand All @@ -26,6 +27,13 @@ If you are interested in a guide for upgrading to LibertyBans 0.8.x to 1.0.0, wh
* Composite victims are a better choice when you want to IP-ban users by default, but do not want the technical intricacies associated with banning an IP address rather than a user. In other words, you want user bans to be enforced as IP-bans but be able to punish, unpunish, and list punishments as if you were doing so for a user rather than an IP address.
* See the wiki page on composite punishments for more details.
* The /accounthistory command accepts the `-both` argument to show the accounts matching the specified user's UUID or current IP address.
* HikariCP is now relocated in release builds.
* New variables are added to punishment messages:
* %TYPE_VERB% - verb-based rendition of the punishment type
* %TIME_PASSED_SIMPLE% - like TIME_PASSED but rounds to the largest time unit
* %TIME_REMAINING_SIMPLE% - like TIME_REMAINING but rounds to the largest time unit
* %HAS_EXPIRED% - whether the punishment has expired on account of the passage of time
* Added the %PREVIOUSPAGE% variable

### API Changes

Expand All @@ -50,3 +58,4 @@ If you are interested in a guide for upgrading to LibertyBans 0.8.x to 1.0.0, wh
* Getter methods on `RevocationOrder` reflect the expanded API.
* The Punishment.PERMANENT_END_DATE constant is added to the API.
* It is now possible to dispatch "silent" punishments using the API.
* Added `PunishmentFormatter#formatPunishmentTypeVerb`
32 changes: 27 additions & 5 deletions docs/Upgrading-to-LibertyBans-1.0.0-from-0.8.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ The upgrade should be mostly seamless and core functionality will work out of th

## Pre-requisites and Getting Started

To start with, you should be on LibertyBans 0.8.2 before you upgrade to 1.0.0.
To start with, you should be on the latest LibertyBans 0.8.x before you upgrade to 1.0.0 - currently LibertyBans 0.8.1.

# Manual Action

For some changes, you will need to adjust your server configuration manually.

## Changes to permissions

Expand Down Expand Up @@ -44,13 +48,31 @@ It is now necessary to distinguish between MariaDB and MySQL when configuring th

## Multi-Instance / Multi-Proxy Support

LibertyBans 0.8.2 can co-exist with LibertyBans 1.0.0 on the same database. Before beginning to upgrade to 1.0.0, you must set the option `version1-compatibility-mode` to `true` in the `sql.yml` for all your 0.8.2 LibertyBans instances.
This documentation is intended for LibertyBans 0.8.2, an upcoming 0.8.x release which will add a compatibility mode.

The compatibility mode will allow you to run LibertyBans 0.8.2 on the same database as 1.0.x.

Until this compatibility mode is released, it is not possible to use LibertyBans 0.8.x and 1.0.x side-by-side on the same database. Therefore, you should upgrade your multi-proxy network once 0.8.2 has been made available.

~~LibertyBans 0.8.2 can co-exist with LibertyBans 1.0.0 on the same database. Before beginning to upgrade to 1.0.0, you must set the option `version1-compatibility-mode` to `true` in the `sql.yml` for all your 0.8.2 LibertyBans instances.~~

~~After you upgrade to 1.0.0, it is safe to remove `version1-compatibility-mode` since this option does not exist in 1.0.0~~

# Automatic Action

## Database Migration

LibertyBans 1.0.0, when it starts, will automatically upgrade your database to 1.0.0.

The database schema has breaking changes, and some software which relies on it, such as the NamelessMC punishment panel, may need to be updated.

## Configuration Migration

If you forgot to enable `version1-compatibility-mode`, the upgrade will still work, as long as you do not restart the 0.8.2 LibertyBans instances. If you restart a 0.8.2 LibertyBans instance which does not have `version1-compatibility-mode` enabled, the instance will fail to start.
New configuration options will be added automatically.

After you upgrade to 1.0.0, it is safe to remove `version1-compatibility-mode` since this option does not exist in 1.0.0
Existing configuration options will be preserved.

## Non-Breaking Changes
# Non-Breaking Changes

There are some improvements which are non-breaking, but might be useful to know.

Expand Down
5 changes: 4 additions & 1 deletion docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
* [Silent Punishments](Silent-Punishments)
* [Composite Punishments](Guide-to-Composite-Punishments)
* [Running Multiple Instances](Running-Multiple-Instances)
* Advanced Topics / For Developers
* Versioning and Upgrades
* [Versioning and Support Policy](Versioning-and-Support-Policies)
* [Upgrading to 1.0.0 from 0.8.x](Upgrading-to-LibertyBans-1.0.0-from-0.8.x)
* [Full changelog for 1.0.0](Changes-in-LibertyBans-1.0.0)
* For Developers
* [Developer API](Developer-API)
* [The Database Schema](The-Database-Schema)
* Relations to other software
Expand Down

0 comments on commit c3fdb3b

Please sign in to comment.