mirror of
https://github.com/CarmJos/MineConfiguration.git
synced 2024-09-19 20:05:49 +00:00
feat(msg): 添加 sendToEach 方法支持
This commit is contained in:
parent
e781d54348
commit
02f59b99f0
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>2.2.0</version>
|
<version>2.2.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -0,0 +1,127 @@
|
|||||||
|
package cc.carm.lib.mineconfiguration.common.value;
|
||||||
|
|
||||||
|
import cc.carm.lib.mineconfiguration.common.builder.message.MessageValueBuilder;
|
||||||
|
import cc.carm.lib.mineconfiguration.common.utils.ParamsUtils;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
public interface BaseMessage<R, M> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 得到所有的接收者
|
||||||
|
*
|
||||||
|
* @return 全部可能的接收者
|
||||||
|
*/
|
||||||
|
@Unmodifiable
|
||||||
|
@NotNull Iterable<R> getAllReceivers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 得到消息中的通过 {@link MessageValueBuilder#params(String...)}已定变量名(按定义顺序)
|
||||||
|
*
|
||||||
|
* @return 已定变量
|
||||||
|
*/
|
||||||
|
@NotNull String[] getParams();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向接收者发送消息的根方法。
|
||||||
|
*
|
||||||
|
* @param receiver 接收者
|
||||||
|
* @param message 消息内容
|
||||||
|
*/
|
||||||
|
@ApiStatus.OverrideOnly
|
||||||
|
void apply(@NotNull R receiver, @NotNull M message);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为某位接收者解析此消息。
|
||||||
|
*
|
||||||
|
* @param sender 接收者
|
||||||
|
* @param placeholders 消息中的变量与对应参数
|
||||||
|
* @return 解析变量后的消息内容
|
||||||
|
*/
|
||||||
|
@Nullable M parse(@Nullable R sender, @NotNull Map<String, Object> placeholders);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为某位接收者解析此消息。
|
||||||
|
*
|
||||||
|
* @param sender 接收者
|
||||||
|
* @param values 已定变量的对应参数
|
||||||
|
* @return 解析变量后的消息内容
|
||||||
|
*/
|
||||||
|
default @Nullable M parse(@Nullable R sender, @Nullable Object... values) {
|
||||||
|
return parse(sender, ParamsUtils.buildParams(getParams(), values));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向某位接收者发送消息
|
||||||
|
*
|
||||||
|
* @param receiver 消息的接收者
|
||||||
|
* @param values 已定变量的对应参数
|
||||||
|
*/
|
||||||
|
default void send(@Nullable R receiver, @Nullable Object... values) {
|
||||||
|
send(receiver, ParamsUtils.buildParams(getParams(), values));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向某位接收者发送消息
|
||||||
|
*
|
||||||
|
* @param receiver 消息的接收者
|
||||||
|
* @param placeholders 消息中的变量与对应参数
|
||||||
|
*/
|
||||||
|
default void send(@Nullable R receiver, @NotNull Map<String, Object> placeholders) {
|
||||||
|
if (receiver == null) return;
|
||||||
|
M parsed = parse(receiver, placeholders);
|
||||||
|
if (parsed == null) return;
|
||||||
|
apply(receiver, parsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向全部接收者(包括后台)发送不同参数的消息
|
||||||
|
*
|
||||||
|
* @param eachValues 每位接收者将收到已定变量的对应参数(按定义顺序)
|
||||||
|
*/
|
||||||
|
default void sendToEach(@NotNull Function<@NotNull R, Object[]> eachValues) {
|
||||||
|
sendToEach(null, eachValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向特定接收者发送不同参数的消息
|
||||||
|
*
|
||||||
|
* @param limiter 接收者限定器,为空则不限定接收者。
|
||||||
|
* @param eachValues 每位接收者将收到已定变量的对应参数(按定义顺序)
|
||||||
|
*/
|
||||||
|
default void sendToEach(@Nullable Predicate<R> limiter,
|
||||||
|
@NotNull Function<@NotNull R, Object[]> eachValues) {
|
||||||
|
Predicate<R> predicate = Optional.ofNullable(limiter).orElse(r -> true);
|
||||||
|
for (R r : getAllReceivers()) {
|
||||||
|
if (predicate.test(r)) {
|
||||||
|
send(r, ParamsUtils.buildParams(getParams(), eachValues.apply(r)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 广播此消息(包括后台)
|
||||||
|
*
|
||||||
|
* @param values 已定变量的对应参数(按定义顺序)
|
||||||
|
*/
|
||||||
|
default void broadcast(@Nullable Object... values) {
|
||||||
|
broadcast(ParamsUtils.buildParams(getParams(), values));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 广播此消息(包括后台)
|
||||||
|
*
|
||||||
|
* @param placeholders 消息中的变量与对应参数
|
||||||
|
*/
|
||||||
|
default void broadcast(@NotNull Map<String, Object> placeholders) {
|
||||||
|
getAllReceivers().forEach(r -> send(r, placeholders));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,10 +1,9 @@
|
|||||||
package cc.carm.lib.mineconfiguration.common.value;
|
package cc.carm.lib.mineconfiguration.common.value;
|
||||||
|
|
||||||
import cc.carm.lib.mineconfiguration.common.data.AbstractText;
|
|
||||||
import cc.carm.lib.mineconfiguration.common.utils.ParamsUtils;
|
|
||||||
import cc.carm.lib.configuration.core.function.ConfigValueParser;
|
import cc.carm.lib.configuration.core.function.ConfigValueParser;
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
||||||
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
|
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
|
||||||
|
import cc.carm.lib.mineconfiguration.common.data.AbstractText;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -15,11 +14,11 @@ import java.util.function.BiFunction;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public abstract class ConfigMessage<M, T extends AbstractText<R>, R>
|
public abstract class ConfigMessage<M, T extends AbstractText<R>, R>
|
||||||
extends ConfiguredValue<T> {
|
extends ConfiguredValue<T> implements BaseMessage<R, M> {
|
||||||
|
|
||||||
protected final @NotNull String[] params;
|
protected final @NotNull String[] params;
|
||||||
protected final @NotNull BiFunction<@Nullable R, @NotNull String, @Nullable M> messageParser;
|
protected final @NotNull BiFunction<@Nullable R, @NotNull String, @Nullable M> messageParser;
|
||||||
protected final @NotNull BiConsumer<@NotNull R, @NotNull M> messageConsumer;
|
protected final @NotNull BiConsumer<@NotNull R, @NotNull M> sendFunction;
|
||||||
|
|
||||||
protected final @NotNull Function<String, T> textBuilder;
|
protected final @NotNull Function<String, T> textBuilder;
|
||||||
|
|
||||||
@ -27,44 +26,35 @@ public abstract class ConfigMessage<M, T extends AbstractText<R>, R>
|
|||||||
@Nullable List<String> headerComments, @Nullable String inlineComments,
|
@Nullable List<String> headerComments, @Nullable String inlineComments,
|
||||||
@NotNull Class<T> textClazz, @NotNull T defaultMessage, @NotNull String[] params,
|
@NotNull Class<T> textClazz, @NotNull T defaultMessage, @NotNull String[] params,
|
||||||
@NotNull BiFunction<@Nullable R, @NotNull String, @Nullable M> messageParser,
|
@NotNull BiFunction<@Nullable R, @NotNull String, @Nullable M> messageParser,
|
||||||
@NotNull BiConsumer<@NotNull R, @NotNull M> messageConsumer,
|
@NotNull BiConsumer<@NotNull R, @NotNull M> sendFunction,
|
||||||
@NotNull Function<String, T> textBuilder) {
|
@NotNull Function<String, T> textBuilder) {
|
||||||
super(provider, sectionPath, headerComments, inlineComments, textClazz, defaultMessage,
|
super(
|
||||||
|
provider, sectionPath, headerComments, inlineComments, textClazz, defaultMessage,
|
||||||
ConfigValueParser.castToString().andThen((s, d) -> textBuilder.apply(s)), AbstractText::getMessage
|
ConfigValueParser.castToString().andThen((s, d) -> textBuilder.apply(s)), AbstractText::getMessage
|
||||||
);
|
);
|
||||||
this.params = params;
|
this.params = params;
|
||||||
this.messageParser = messageParser;
|
this.messageParser = messageParser;
|
||||||
this.messageConsumer = messageConsumer;
|
this.sendFunction = sendFunction;
|
||||||
this.textBuilder = textBuilder;
|
this.textBuilder = textBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable M parse(@Nullable R sender, @Nullable Object... values) {
|
@Override
|
||||||
return parse(sender, ParamsUtils.buildParams(params, values));
|
public String[] getParams() {
|
||||||
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply(@NotNull R receiver, @NotNull M message) {
|
||||||
|
sendFunction.accept(receiver, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public @Nullable M parse(@Nullable R sender, @NotNull Map<String, Object> placeholders) {
|
public @Nullable M parse(@Nullable R sender, @NotNull Map<String, Object> placeholders) {
|
||||||
T value = get();
|
T value = get();
|
||||||
if (value == null || value.getMessage().isEmpty()) return null;
|
if (value == null || value.getMessage().isEmpty()) return null;
|
||||||
else return value.parse(this.messageParser, sender, placeholders);
|
else return value.parse(this.messageParser, sender, placeholders);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(@Nullable R receiver, @Nullable Object... values) {
|
|
||||||
send(receiver, ParamsUtils.buildParams(params, values));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void send(@Nullable R receiver, @NotNull Map<String, Object> placeholders) {
|
|
||||||
if (receiver == null) return;
|
|
||||||
M parsed = parse(receiver, placeholders);
|
|
||||||
if (parsed == null) return;
|
|
||||||
messageConsumer.accept(receiver, parsed);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void broadcast(@Nullable Object... values) {
|
|
||||||
broadcast(ParamsUtils.buildParams(params, values));
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void broadcast(@NotNull Map<String, Object> placeholders);
|
|
||||||
|
|
||||||
public void set(@Nullable String value) {
|
public void set(@Nullable String value) {
|
||||||
this.set(value == null ? null : buildText(value));
|
this.set(value == null ? null : buildText(value));
|
||||||
}
|
}
|
||||||
@ -72,4 +62,5 @@ public abstract class ConfigMessage<M, T extends AbstractText<R>, R>
|
|||||||
protected T buildText(String value) {
|
protected T buildText(String value) {
|
||||||
return textBuilder.apply(value);
|
return textBuilder.apply(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import cc.carm.lib.configuration.core.function.ConfigDataFunction;
|
|||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
||||||
import cc.carm.lib.configuration.core.value.type.ConfiguredList;
|
import cc.carm.lib.configuration.core.value.type.ConfiguredList;
|
||||||
import cc.carm.lib.mineconfiguration.common.data.AbstractText;
|
import cc.carm.lib.mineconfiguration.common.data.AbstractText;
|
||||||
import cc.carm.lib.mineconfiguration.common.utils.ParamsUtils;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -16,7 +15,8 @@ import java.util.function.BiFunction;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public abstract class ConfigMessageList<M, T extends AbstractText<R>, R> extends ConfiguredList<T> {
|
public abstract class ConfigMessageList<M, T extends AbstractText<R>, R>
|
||||||
|
extends ConfiguredList<T> implements BaseMessage<R, List<M>> {
|
||||||
|
|
||||||
protected final @NotNull String[] params;
|
protected final @NotNull String[] params;
|
||||||
protected final @NotNull BiFunction<@Nullable R, @NotNull String, @Nullable M> messageParser;
|
protected final @NotNull BiFunction<@Nullable R, @NotNull String, @Nullable M> messageParser;
|
||||||
@ -40,38 +40,34 @@ public abstract class ConfigMessageList<M, T extends AbstractText<R>, R> extends
|
|||||||
this.textBuilder = textBuilder;
|
this.textBuilder = textBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable List<M> parse(@Nullable R sender, @Nullable Object... values) {
|
@Override
|
||||||
return parse(sender, ParamsUtils.buildParams(params, values));
|
public String[] getParams() {
|
||||||
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable List<M> parse(@Nullable R sender, @NotNull Map<String, Object> placeholders) {
|
@Override
|
||||||
|
public void apply(@NotNull R receiver, @NotNull List<M> message) {
|
||||||
|
sendFunction.accept(receiver, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 为某位接收者解析消息
|
||||||
|
*
|
||||||
|
* @param receiver 消息的接收者
|
||||||
|
* @param placeholders 消息中的变量与对应参数
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public @Nullable List<M> parse(@Nullable R receiver, @NotNull Map<String, Object> placeholders) {
|
||||||
List<T> list = get();
|
List<T> list = get();
|
||||||
if (list.isEmpty()) return null;
|
if (list.isEmpty()) return null;
|
||||||
|
|
||||||
List<String> messages = list.stream().map(T::getMessage).collect(Collectors.toList());
|
List<String> messages = list.stream().map(T::getMessage).collect(Collectors.toList());
|
||||||
if (String.join("", messages).isEmpty()) return null;
|
if (String.join("", messages).isEmpty()) return null;
|
||||||
|
|
||||||
return list.stream().map(value -> value.parse(this.messageParser, sender, placeholders))
|
return list.stream().map(value -> value.parse(this.messageParser, receiver, placeholders))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(@Nullable R receiver, @Nullable Object... values) {
|
|
||||||
send(receiver, ParamsUtils.buildParams(params, values));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void send(@Nullable R receiver, @NotNull Map<String, Object> placeholders) {
|
|
||||||
if (receiver == null) return;
|
|
||||||
List<M> parsed = parse(receiver, placeholders);
|
|
||||||
if (parsed == null) return;
|
|
||||||
sendFunction.accept(receiver, parsed);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void broadcast(@Nullable Object... values) {
|
|
||||||
broadcast(ParamsUtils.buildParams(params, values));
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void broadcast(@NotNull Map<String, Object> placeholders);
|
|
||||||
|
|
||||||
public void setMessages(@NotNull String... values) {
|
public void setMessages(@NotNull String... values) {
|
||||||
setMessages(values.length == 0 ? null : Arrays.asList(values));
|
setMessages(values.length == 0 ? null : Arrays.asList(values));
|
||||||
}
|
}
|
||||||
@ -82,7 +78,6 @@ public abstract class ConfigMessageList<M, T extends AbstractText<R>, R> extends
|
|||||||
} else {
|
} else {
|
||||||
set(buildText(values));
|
set(buildText(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<T> buildText(List<String> values) {
|
protected List<T> buildText(List<String> values) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mineconfiguration-bukkit-parent</artifactId>
|
<artifactId>mineconfiguration-bukkit-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>2.2.0</version>
|
<version>2.2.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
package cc.carm.lib.mineconfiguration.bukkit.value;
|
package cc.carm.lib.mineconfiguration.bukkit.value;
|
||||||
|
|
||||||
|
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
||||||
import cc.carm.lib.mineconfiguration.bukkit.CraftConfigValue;
|
import cc.carm.lib.mineconfiguration.bukkit.CraftConfigValue;
|
||||||
|
import cc.carm.lib.mineconfiguration.bukkit.builder.message.CraftMessageValueBuilder;
|
||||||
import cc.carm.lib.mineconfiguration.bukkit.data.TextConfig;
|
import cc.carm.lib.mineconfiguration.bukkit.data.TextConfig;
|
||||||
import cc.carm.lib.mineconfiguration.common.value.ConfigMessage;
|
import cc.carm.lib.mineconfiguration.common.value.ConfigMessage;
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
|
||||||
import cc.carm.lib.mineconfiguration.bukkit.builder.message.CraftMessageValueBuilder;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
@ -43,10 +44,11 @@ public class ConfiguredMessage<M> extends ConfigMessage<M, TextConfig, CommandSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void broadcast(@NotNull Map<String, Object> placeholders) {
|
public @NotNull Collection<CommandSender> getAllReceivers() {
|
||||||
Bukkit.getOnlinePlayers().forEach(pl -> send(pl, placeholders));
|
List<CommandSender> senders = new ArrayList<>();
|
||||||
send(Bukkit.getConsoleSender(), placeholders);
|
senders.add(Bukkit.getConsoleSender());
|
||||||
|
senders.addAll(Bukkit.getOnlinePlayers());
|
||||||
|
return senders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
package cc.carm.lib.mineconfiguration.bukkit.value;
|
package cc.carm.lib.mineconfiguration.bukkit.value;
|
||||||
|
|
||||||
|
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
||||||
import cc.carm.lib.mineconfiguration.bukkit.CraftConfigValue;
|
import cc.carm.lib.mineconfiguration.bukkit.CraftConfigValue;
|
||||||
|
import cc.carm.lib.mineconfiguration.bukkit.builder.message.CraftMessageListBuilder;
|
||||||
import cc.carm.lib.mineconfiguration.bukkit.data.TextConfig;
|
import cc.carm.lib.mineconfiguration.bukkit.data.TextConfig;
|
||||||
import cc.carm.lib.mineconfiguration.common.value.ConfigMessageList;
|
import cc.carm.lib.mineconfiguration.common.value.ConfigMessageList;
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
|
||||||
import cc.carm.lib.mineconfiguration.bukkit.builder.message.CraftMessageListBuilder;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
@ -38,9 +39,11 @@ public class ConfiguredMessageList<M> extends ConfigMessageList<M, TextConfig, C
|
|||||||
super(provider, sectionPath, headerComments, inlineComments, TextConfig.class, messages, params, messageParser, sendFunction, TextConfig::of);
|
super(provider, sectionPath, headerComments, inlineComments, TextConfig.class, messages, params, messageParser, sendFunction, TextConfig::of);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void broadcast(@NotNull Map<String, Object> placeholders) {
|
@Override
|
||||||
Bukkit.getOnlinePlayers().forEach(pl -> send(pl, placeholders));
|
public @NotNull Collection<CommandSender> getAllReceivers() {
|
||||||
send(Bukkit.getConsoleSender(), placeholders);
|
List<CommandSender> senders = new ArrayList<>();
|
||||||
|
senders.add(Bukkit.getConsoleSender());
|
||||||
|
senders.addAll(Bukkit.getOnlinePlayers());
|
||||||
|
return senders;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mineconfiguration-bukkit-parent</artifactId>
|
<artifactId>mineconfiguration-bukkit-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>2.2.0</version>
|
<version>2.2.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>2.2.0</version>
|
<version>2.2.1</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<version>2.2.0</version>
|
<version>2.2.1</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
package cc.carm.lib.mineconfiguration.bungee.value;
|
package cc.carm.lib.mineconfiguration.bungee.value;
|
||||||
|
|
||||||
|
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
||||||
import cc.carm.lib.mineconfiguration.bungee.BungeeConfigValue;
|
import cc.carm.lib.mineconfiguration.bungee.BungeeConfigValue;
|
||||||
import cc.carm.lib.mineconfiguration.bungee.builder.message.BungeeMessageValueBuilder;
|
import cc.carm.lib.mineconfiguration.bungee.builder.message.BungeeMessageValueBuilder;
|
||||||
import cc.carm.lib.mineconfiguration.bungee.data.MessageText;
|
import cc.carm.lib.mineconfiguration.bungee.data.MessageText;
|
||||||
import cc.carm.lib.mineconfiguration.common.value.ConfigMessage;
|
import cc.carm.lib.mineconfiguration.common.value.ConfigMessage;
|
||||||
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
@ -43,9 +44,11 @@ public class ConfiguredMessage<M> extends ConfigMessage<M, MessageText, CommandS
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void broadcast(@NotNull Map<String, Object> placeholders) {
|
public @NotNull Collection<CommandSender> getAllReceivers() {
|
||||||
ProxyServer.getInstance().getPlayers().forEach(pl -> send(pl, placeholders));
|
List<CommandSender> senders = new ArrayList<>();
|
||||||
send(ProxyServer.getInstance().getConsole(), placeholders);
|
senders.add(ProxyServer.getInstance().getConsole());
|
||||||
|
senders.addAll(ProxyServer.getInstance().getPlayers());
|
||||||
|
return senders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ import net.md_5.bungee.api.ProxyServer;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
@ -38,9 +40,11 @@ public class ConfiguredMessageList<M> extends ConfigMessageList<M, MessageText,
|
|||||||
super(provider, sectionPath, headerComments, inlineComments, MessageText.class, messages, params, messageParser, sendFunction, MessageText::of);
|
super(provider, sectionPath, headerComments, inlineComments, MessageText.class, messages, params, messageParser, sendFunction, MessageText::of);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void broadcast(@NotNull Map<String, Object> placeholders) {
|
@Override
|
||||||
ProxyServer.getInstance().getPlayers().forEach(pl -> send(pl, placeholders));
|
public @NotNull Collection<CommandSender> getAllReceivers() {
|
||||||
send(ProxyServer.getInstance().getConsole(), placeholders);
|
List<CommandSender> senders = new ArrayList<>();
|
||||||
|
senders.add(ProxyServer.getInstance().getConsole());
|
||||||
|
senders.addAll(ProxyServer.getInstance().getPlayers());
|
||||||
|
return senders;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<version>2.2.0</version>
|
<version>2.2.1</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
2
pom.xml
2
pom.xml
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<groupId>cc.carm.lib</groupId>
|
<groupId>cc.carm.lib</groupId>
|
||||||
<artifactId>mineconfiguration-parent</artifactId>
|
<artifactId>mineconfiguration-parent</artifactId>
|
||||||
<version>2.2.0</version>
|
<version>2.2.1</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<modules>
|
<modules>
|
||||||
<module>common</module>
|
<module>common</module>
|
||||||
|
Loading…
Reference in New Issue
Block a user