<commit_before>package net.twasi.core.plugin.api.customcommands;

import net.twasi.core.database.models.TwitchAccount;
import net.twasi.core.models.Message.TwasiCommand;
import net.twasi.core.models.Streamer;
import net.twasi.core.plugin.api.events.TwasiCommandEvent;
import net.twasi.core.translations.renderer.TranslationRenderer;

import java.util.ArrayList;
import java.util.List;

import static java.util.Arrays.asList;

public class TwasiCustomCommandEvent extends TwasiCommandEvent {

    private TwitchAccount sender;
    private Streamer streamer;
    private String usedCommandName;
    private List<String> args;
    private ClassLoader loader;

    public TwasiCustomCommandEvent(TwasiCommand command, ClassLoader loader) {
        super(command);
        this.sender = command.getSender();
        this.streamer = command.getTwasiInterface().getStreamer();
        this.usedCommandName = command.getCommandName();
        this.args = new ArrayList<>(asList(command.getMessage().split(" "))); // As ArrayList to prevent UnsupportedOperationException in next line
        this.loader = loader;
        this.args.remove(0); // Remove command name from args
    }

    public void reply(String text) {
        getCommand().reply(text);
    }

    public TwitchAccount getSender() {
        return sender;
    }

    public Streamer getStreamer() {
        return streamer;
    }

    public String getUsedCommandName() {
        return usedCommandName;
    }

    public List<String> getArgs() {
        return args;
    }

    public String getArgsAsOne() {
        StringBuilder connected = new StringBuilder();
        for (String s : getArgs()) connected.append(" ").append(s);
        String string = connected.toString();
        if (string.equals("")) return null;
        else return string.substring(1); // Substring to remove leading whitespace
    }

    public boolean hasArgs() {
        return getArgs().size() > 0;
    }

    public boolean hasPermission(String key) {
        return this.streamer.getUser().hasPermission(this.sender, key);
    }

    public TranslationRenderer getRenderer(TranslationRenderer copyBindings) {
        return TranslationRenderer
                .getInstance(loader, streamer.getUser().getConfig().getLanguage())
                .bindAll(copyBindings.getBindings())<commit_msg>Fixed NullPointerException on getArgsAsOne Method<commit_after>package net.twasi.core.plugin.api.customcommands;

import net.twasi.core.database.models.TwitchAccount;
import net.twasi.core.models.Message.TwasiCommand;
import net.twasi.core.models.Streamer;
import net.twasi.core.plugin.api.events.TwasiCommandEvent;
import net.twasi.core.translations.renderer.TranslationRenderer;

import java.util.ArrayList;
import java.util.List;

import static java.util.Arrays.asList;

public class TwasiCustomCommandEvent extends TwasiCommandEvent {

    private TwitchAccount sender;
    private Streamer streamer;
    private String usedCommandName;
    private List<String> args;
    private ClassLoader loader;

    public TwasiCustomCommandEvent(TwasiCommand command, ClassLoader loader) {
        super(command);
        this.sender = command.getSender();
        this.streamer = command.getTwasiInterface().getStreamer();
        this.usedCommandName = command.getCommandName();
        this.args = new ArrayList<>(asList(command.getMessage().split(" "))); // As ArrayList to prevent UnsupportedOperationException in next line
        this.loader = loader;
        this.args.remove(0); // Remove command name from args
    }

    public void reply(String text) {
        getCommand().reply(text);
    }

    public TwitchAccount getSender() {
        return sender;
    }

    public Streamer getStreamer() {
        return streamer;
    }

    public String getUsedCommandName() {
        return usedCommandName;
    }

    public List<String> getArgs() {
        return args;
    }

    public String getArgsAsOne() {
        StringBuilder connected = new StringBuilder();
        for (String s : getArgs()) connected.append(" ").append(s);
        String string = connected.toString();
        if (string.equals("")) return "";
        else return string.substring(1); // Substring to remove leading whitespace
    }

    public boolean hasArgs() {
        return getArgs().size() > 0;
    }

    public boolean hasPermission(String key) {
        return this.streamer.getUser().hasPermission(this.sender, key);
    }

    public TranslationRenderer getRenderer(TranslationRenderer copyBindings) {
        return TranslationRenderer
                .getInstance(loader, streamer.getUser().getConfig().getLanguage())
                .bindAll(copyBindings.getBindings())
{'fraction_non_alphanumeric': 0.10042553191489362, 'fraction_numerical': 0.001276595744680851, 'mean_word_length': 3.231323132313231, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '1797129', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1260, 'n_words': 292}