Skip to content

Commit

Permalink
Fix PardonEvent, add Javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
MCMDEV committed Feb 8, 2024
1 parent 4952500 commit 12880c0
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,11 @@ public interface PardonEvent extends Cancellable, AsyncEvent {
*/
PunishmentType getPunishmentType();

/**
* Gets the reason for the pardon
*
* @return the reason
*/
String getReason();

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
* @author A248
*
*/
//TODO: Adjust Javadoc
public interface PunishmentRevoker {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,18 @@
*/
public interface RevocationOrder extends EnforcementOptionsFactory {

// TODO: Javadocs
/**
* Gets the operator who is revoking the punishment
*
* @return the operator responsible for the revocation
*/
Operator getOperator();

/**
* Gets the reason for the revocation
*
* @return the reason for the revocation
*/
String getReason();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private CompletionStage<Punishment> performUndo(Operator operator, String reason
revocationOrder = revoker.revokeByTypeAndPossibleVictims(type, List.of(victim, compositeWildcard), operator, reason);
id = -1;
}
return fireWithTimeout(new PardonEventImpl(operator, victim, type)).thenCompose((event) -> {
return fireWithTimeout(new PardonEventImpl(operator, victim, type, reason)).thenCompose((event) -> {
if (event.isCancelled()) {
return completedFuture(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@
import space.arim.libertybans.api.Victim;
import space.arim.libertybans.api.event.PardonEvent;

//TODO: Add reason
public class PardonEventImpl extends AbstractCancellable implements PardonEvent {

private final Operator operator;
private final Victim victim;
private final PunishmentType type;
private final String reason;

public PardonEventImpl(Operator operator, Victim victim, PunishmentType type) {
public PardonEventImpl(Operator operator, Victim victim, PunishmentType type, String reason) {
this.operator = Objects.requireNonNull(operator, "operator");
this.victim = Objects.requireNonNull(victim, "victim");
this.type = Objects.requireNonNull(type, "type");
this.reason = Objects.requireNonNull(reason, "reason");
}

@Override
Expand All @@ -53,4 +54,8 @@ public PunishmentType getPunishmentType() {
return type;
}

@Override
public String getReason() {
return reason;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,12 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.mockito.junit.jupiter.MockitoExtension;
import space.arim.libertybans.api.ConsoleOperator;
import space.arim.libertybans.api.PlayerOperator;
import space.arim.libertybans.api.PunishmentType;
import space.arim.libertybans.api.punish.EnforcementOptions;
import space.arim.libertybans.core.punish.Mode;
import space.arim.omnibus.util.concurrent.FactoryOfTheFuture;
import space.arim.omnibus.util.concurrent.impl.IndifferentFactoryOfTheFuture;

import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -51,7 +48,6 @@ public void setSynchronizationProtocol() {
id = ThreadLocalRandom.current().nextLong();
}

//TODO: This test should fail now
@ParameterizedTest
@EnumSource(PunishmentType.class)
public void enactPunishment(PunishmentType type) {
Expand Down

0 comments on commit 12880c0

Please sign in to comment.