<commit_before>package de.lergin.sponge.laborus.api;

import de.lergin.sponge.laborus.Laborus;
import de.lergin.sponge.laborus.config.TranslationKeys;
import de.lergin.sponge.laborus.job.Job;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.data.Transaction;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.Event;
import org.spongepowered.api.text.TextElement;

import java.io.Serializable;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.function.BooleanSupplier;

import static de.lergin.sponge.laborus.api.JobActionState.BLOCK;
import static de.lergin.sponge.laborus.api.JobActionState.IGNORE;
import static de.lergin.sponge.laborus.api.JobActionState.SUCCESS;

public abstract class JobAction<T extends JobItem> implements Serializable {
    public JobAction() {}

    public abstract String getId();

    private Laborus plugin = Laborus.instance();

    private Job job;

    public abstract List<T> getJobItems();

    public Job getJob() {
        return job;
    }

    public void init(Job job){
        this.job = job;
        Sponge.getEventManager().registerListeners(plugin, this);
    }

    public JobActionState onEvent(Player player, BooleanSupplier isWorking, Callable<T> getJobItem) throws Exception {
        if (!job.enabled(player) || !isWorking.getAsBoolean()) return IGNORE;

        T jobItem = getJobItem.call();

        if (getJobItems().stream().noneMatch((item) -> item.matches(jobItem))) return IGNORE;

        if (!jobItem.canDo(getJob().getLevel(player))) return BLOCK;


        plugin.config.base.loggingConfig
                .jobActions(getJob(), "Awarding JobItem ({})", jobItem.getItem());<commit_msg>fixed awarding of xp<commit_after>package de.lergin.sponge.laborus.api;

import de.lergin.sponge.laborus.Laborus;
import de.lergin.sponge.laborus.config.TranslationKeys;
import de.lergin.sponge.laborus.job.Job;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.data.Transaction;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.Event;
import org.spongepowered.api.text.TextElement;

import java.io.Serializable;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.function.BooleanSupplier;

import static de.lergin.sponge.laborus.api.JobActionState.BLOCK;
import static de.lergin.sponge.laborus.api.JobActionState.IGNORE;
import static de.lergin.sponge.laborus.api.JobActionState.SUCCESS;

public abstract class JobAction<T extends JobItem> implements Serializable {
    public JobAction() {}

    public abstract String getId();

    private Laborus plugin = Laborus.instance();

    private Job job;

    public abstract List<T> getJobItems();

    public Job getJob() {
        return job;
    }

    public void init(Job job){
        this.job = job;
        Sponge.getEventManager().registerListeners(plugin, this);
    }

    public JobActionState onEvent(Player player, BooleanSupplier isWorking, Callable<T> getJobItem) throws Exception {
        if (!job.enabled(player) || !isWorking.getAsBoolean()) return IGNORE;

        T actionJobItem = getJobItem.call();

        Optional<T> optional = getJobItems().stream().filter((item) -> item.matches(actionJobItem)).findAny();

        if(!optional.isPresent()) return IGNORE;

        T jobItem = optional.get();

        if (!jobItem.canDo(getJob().getLevel(player))) return BLOCK;


        plugin.config.base.loggingConfig
                .jobActions(getJob(), "Awarding JobItem ({})", jobItem.getItem());
{'fraction_non_alphanumeric': 0.11704366123093109, 'fraction_numerical': 0.0, 'mean_word_length': 4.1531165311653115, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7388938', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1173, 'n_words': 231}