Skip to content

Instantly share code, notes, and snippets.

Additions / Improvements

/**
* Sends a plugin message using the first player from {@link Bukkit#getOnlinePlayers()}.
*
* The next plugin message to be received through {@code channel} will be assumed to be
* the response.
*
* @param channel the channel for this plugin message
* @param data the data to add to the outgoing message
* @return a completable future for the message of the responding plugin message, if there is one.
* this completable future will complete exceptionally if no players are online.
public static CompletableFuture<ByteArrayDataInput> sendPluginMessage(String channel, String... data) {
return sendPluginMessage(Iterables.getFirst(Bukkit.getOnlinePlayers(), null), channel, data);
}
public static CompletableFuture<ByteArrayDataInput> sendPluginMessage(Player player, String channel, String... data) {
CompletableFuture<ByteArrayDataInput> completableFuture = new CompletableFuture<>();
if (player == null) {
completableFuture.completeExceptionally(new IllegalStateException("Can't send plugin messages without a player"));
return completableFuture;
public static CompletableFuture<ByteArrayDataInput> sendPluginMessage(String channel, String... data) {
return sendPluginMessage(Iterables.getFirst(Bukkit.getOnlinePlayers(), null), channel, data);
}
public static CompletableFuture<ByteArrayDataInput> sendPluginMessage(Player player, String channel, String... data) {
CompletableFuture<ByteArrayDataInput> completableFuture = new CompletableFuture<>();
if (player == null) {
completableFuture.completeExceptionally(new IllegalStateException("Can't send plugin messages without a player"));
return completableFuture;
public static CompletableFuture<ByteArrayDataInput> sendPluginMessage(String channel, String... data) {
return sendPluginMessage(Iterables.getFirst(Bukkit.getOnlinePlayers(), null), channel, data);
}
public static CompletableFuture<ByteArrayDataInput> sendPluginMessage(Player player, String channel, String... data) {
CompletableFuture<ByteArrayDataInput> completableFuture = new CompletableFuture<>();
if (player == null) {
completableFuture.completeExceptionally(new IllegalStateException("Can't send plugin messages without a player"));
return completableFuture;
package org.bukkit.event.server;
import java.net.InetAddress;
import java.util.Iterator;
import org.apache.commons.lang.Validate;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.util.CachedServerIcon;
/**
* This file is part of Skript.
*
* Skript is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Skript is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
/**
* This file is part of Skript.
*
* Skript is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Skript is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
final Parser<User> = new Parser<>() {
private final Pattern DISCRIM_PATTERN = Pattern.compile("(.+)#(\\d+)");
private final Pattern MENTION_OR_ID_PATTERN = Pattern.compile("(<@)?(\\d+)(>)?");
public User parse(String input, ParseContext context) {
Matcher discrimMatcher = DISCRIM_PATTERN.matcher(input);
Matcher mentionMatcher = MENTION_OR_ID_PATTERN.matcher(input);
if (discrimMatcher.matches()) {
// use the groups for discrim
import:
ch.njol.skript.log.SkriptLogger
ch.njol.skript.ScriptLoader
ch.njol.skript.config.SectionNode
ch.njol.skript.lang.Condition
ch.njol.skript.Skript
ch.njol.skript.config.validate.SectionValidator
ch.njol.skript.lang.SkriptParser
com.btk5h.skriptmirror.Util as MirrorUtil
java.util.Arrays