package com.pie.tlatoani.Miscellaneous.MiscBukkit;

import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import org.bukkit.Bukkit;
import org.bukkit.event.Event;

import javax.annotation.Nullable;

/*
This code was given to MundoSK by tim740
 */

/**
 * Created by tim740 on 25/06/16
 */
public class ExprServerIP extends SimpleExpression<String> {

    @Override
    @Nullable
    protected String[] get(Event e) {
        return new String[]{Bukkit.getIp()};
    }

    @SuppressWarnings("unchecked")
    @Override
    public boolean init(Expression<?>[] e, int i, Kleenean k, ParseResult p) {
        return true;
    }

    @Override
    public Class<? extends String> getReturnType() {
        return String.class;
    }

    @Override
    public boolean isSingle() {
        return true;
    }

    @Override
    public String toString(@Nullable Event e, boolean b) {
        return "the server's ip";
    }
}
