Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix composite punishments not being detected #9

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ of this software and associated documentation files(the "Software"), to deal
import com.djrapitops.plan.query.QueryService;
import space.arim.libertybans.api.*;
import space.arim.libertybans.api.punish.Punishment;
import space.arim.libertybans.api.select.SelectionPredicate;
import space.arim.libertybans.api.select.SortPunishments;
import space.arim.omnibus.Omnibus;
import space.arim.omnibus.OmnibusProvider;
Expand All @@ -52,7 +53,8 @@ public class LibertyBansExtension implements DataExtension {

private LibertyBans api;

public LibertyBansExtension() {}
public LibertyBansExtension() {
}

@Override
public CallEvents[] callExtensionMethodsOn() {
Expand All @@ -76,7 +78,12 @@ private Optional<Punishment> punishment(UUID playerUUID, PunishmentType type) {
return api()
.getSelector()
.selectionBuilder()
.victim(PlayerVictim.of(playerUUID))
.victims(
SelectionPredicate.matchingAnyOf(
PlayerVictim.of(playerUUID),
CompositeVictim.of(playerUUID, CompositeVictim.WILDCARD_ADDRESS)
)
)
.type(type)
.build()
.getFirstSpecificPunishment(SortPunishments.LATEST_END_DATE_FIRST)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.playeranalytics.extension.libertybans;

import com.djrapitops.plan.extension.Caller;
import space.arim.libertybans.api.CompositeVictim;
import space.arim.libertybans.api.PlayerVictim;
import space.arim.libertybans.api.Victim;
import space.arim.libertybans.api.event.PostPardonEvent;
Expand Down Expand Up @@ -38,6 +39,8 @@ private void actOnPunishment(Punishment punishment) {
Victim victim = punishment.getVictim();
if (victim instanceof PlayerVictim) {
caller.updatePlayerData(((PlayerVictim) victim).getUUID(), null);
} else if (victim instanceof CompositeVictim) {
caller.updatePlayerData(((CompositeVictim) victim).getUUID(), null);
}
}
}