mirror of
https://github.com/Shiewk/SModeration.git
synced 2026-04-29 06:34:17 +02:00
broadcast punishment to admins when issued
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
package de.shiewk.smoderation.storage;
|
||||
|
||||
import de.shiewk.smoderation.punishments.Punishment;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -20,8 +26,8 @@ public class PunishmentContainer {
|
||||
return punishments.remove(index);
|
||||
}
|
||||
|
||||
public boolean remove(Punishment punishment){
|
||||
return punishments.remove(punishment);
|
||||
public void remove(Punishment punishment){
|
||||
punishments.remove(punishment);
|
||||
}
|
||||
|
||||
public @Nullable Punishment find(Predicate<Punishment> predicate){
|
||||
@@ -33,6 +39,17 @@ public class PunishmentContainer {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<CommandSender> collectBroadcastTargets(){
|
||||
ArrayList<CommandSender> senders = new ArrayList<>();
|
||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||
if (onlinePlayer.hasPermission("smod.notifications")){
|
||||
senders.add(onlinePlayer);
|
||||
}
|
||||
}
|
||||
senders.add(Bukkit.getConsoleSender());
|
||||
return Collections.unmodifiableList(senders);
|
||||
}
|
||||
|
||||
public @Nullable Punishment findByTimestamp(long timestamp){
|
||||
return find(punishment -> punishment.time == timestamp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user