Создание AntiCheat для minecraft и попытка получить доступ к списку из другого класса в java - PullRequest
0 голосов
/ 03 марта 2020

Я пытаюсь закодировать очень простой, но эффективный античит. Всякий раз, когда я помещаю ArrayList в один из моих классов и пытаюсь получить к нему доступ в другом месте, он не говорит, что в списке ничего нет.

    public List<String> map = new ArrayList<String>();

    public List<String> getMap() {
        return map;
    }

    /**
     * Defines a instance of {@link finalexception.anticheat.AntiCheat} and
     * adds all listeners
     */
    public AimA() {
        super("Aim", "A");
        AntiCheat.getInstance().addReset("aimVlA");
    }

Это часть кода проверки цели, который создает ArrayList в AimA. java.

public List<String> map = new AimA().getMap();

И здесь я пытаюсь получить к нему доступ, в InfoCommand. java.

Я не получаю ошибок, только это :

[21:05:28 INFO]: MajesticMagician issued server command: /menu info

Спасибо за ваше время. Если есть что-то, чего я не предоставил, пожалуйста, скажите мне.

Я не знаю, так это или нет, но здесь.

/**
     * Data describing the check
     */
    private String name, data;

    /**
     * The instance of {@link finalexception.anticheat.AntiCheat}
     *
     * <p>
     *     For API usage, use {@link Check#getPlugin()}
     * </p>
     */
    private final AntiCheat plugin;

    /**
     * Defines a instance of {@link finalexception.anticheat.AntiCheat} and
     * adds all listeners
     */
    public Check(String name, String data) {
        this.name = name;
        this.data = data;
        this.plugin = AntiCheat.getInstance();

        listen();
    }

    /**
     * If events can be sent to the current check
     *
     * <p>
     *     Most of the time, this is returned as <code>true</code>,
     *     but in some instances such as whenever the player is in
     *     creative or is flying, it's returned as <code>false</code>
     * </p>
     *
     * @param player   player the event is ran on
     * @param event    event called
     *
     * @return         if the event can be called on the check
     */
    public abstract boolean isRunnable(Profile player, Event event);

    /**
     * Runs the check with the player and event
     *
     * <p>
     *     This is a boolean because we want to return <code>true</code>
     *     if the target has failed the check, then the {@link finalexception.anticheat.check.CheckManager}
     *     will take care of it
     * </p>
     *
     * @param profile   player the event is ran on
     * @param event     event called
     *
     * @return          if the target failed the check
     */
    public abstract CheckResult run(Profile profile, Event event);

    /**
     * Installs all the listeners
     *
     * <p>
     *     This installs all listeners including bukkit and packet
     *     events using {@link Check#addPacketListener(PacketAdapter)}
     * </p>
     *
     * <p>
     *     This is also only called once per initialization of plugin
     *     at start of the check, but may be used for the entire
     *     class to listen for events
     * </p>
     */
    public abstract void listen();

    /**
     * Adds a packet listener
     *
     * <p>
     *     Adds a packet listener using the {@link finalexception.anticheat.listener.PacketListener#addListener(PacketAdapter)}
     *     method
     * </p>
     *
     * @param adapter   the packet adapter
     */
    public Check addPacketListener(PacketAdapter adapter) {
        getPlugin().getPacketListener().addListener(adapter);

        return this;
    }

    /**
     * Returns a instance of {@link finalexception.anticheat.AntiCheat} for
     * easy API usage
     *
     * <p>
     *     Instead of using {@link Check#plugin}, we use a
     *     thread-safe getter for the plugin
     * </p>
     *
     * @return          instance of {@link finalexception.anticheat.AntiCheat}
     */
    public AntiCheat getPlugin() {
        return plugin;
    }

    public String getName() {
        return name;
    }

    public String getData() {
        return data;
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...