mirror of
https://github.com/CarmJos/MineConfiguration.git
synced 2024-09-19 20:05:49 +00:00
[1.3.0] 版本更新
1. 更新 EasyConfiguration 到 3.0.0 (破坏性更新)。 2. 添加 ConfiguredTitle 用于快捷向玩家发送title消息。 3. 为 ConfiguredItem 添加name和lore的原生params变量支持。 4. 添加 ProtocolLibHelper 用于支持多版本情况下的部分功能。(如需使用请安装 ProtocolLib 插件)
This commit is contained in:
parent
98ee47f676
commit
9a95e3d105
@ -30,9 +30,9 @@ public class TitleConfigBuilder extends AbstractCraftBuilder<TitleConfig, TitleC
|
|||||||
|
|
||||||
protected @NotNull String[] params;
|
protected @NotNull String[] params;
|
||||||
|
|
||||||
protected @Range(from = 0L, to = Integer.MAX_VALUE) long fadeIn = 10;
|
protected @Range(from = 0L, to = Integer.MAX_VALUE) int fadeIn = 10;
|
||||||
protected @Range(from = 0L, to = Integer.MAX_VALUE) long stay = 60;
|
protected @Range(from = 0L, to = Integer.MAX_VALUE) int stay = 60;
|
||||||
protected @Range(from = 0L, to = Integer.MAX_VALUE) long fadeOut = 10;
|
protected @Range(from = 0L, to = Integer.MAX_VALUE) int fadeOut = 10;
|
||||||
|
|
||||||
protected @NotNull TitleSendConsumer sendConsumer;
|
protected @NotNull TitleSendConsumer sendConsumer;
|
||||||
protected @NotNull Function<@NotNull String, @NotNull String> paramFormatter;
|
protected @NotNull Function<@NotNull String, @NotNull String> paramFormatter;
|
||||||
@ -61,17 +61,17 @@ public class TitleConfigBuilder extends AbstractCraftBuilder<TitleConfig, TitleC
|
|||||||
return params(params.toArray(new String[0]));
|
return params(params.toArray(new String[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public TitleConfigBuilder fadeIn(@Range(from = 0L, to = Integer.MAX_VALUE) long fadeIn) {
|
public TitleConfigBuilder fadeIn(@Range(from = 0L, to = Integer.MAX_VALUE) int fadeIn) {
|
||||||
this.fadeIn = fadeIn;
|
this.fadeIn = fadeIn;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TitleConfigBuilder stay(@Range(from = 0L, to = Integer.MAX_VALUE) long stay) {
|
public TitleConfigBuilder stay(@Range(from = 0L, to = Integer.MAX_VALUE) int stay) {
|
||||||
this.stay = stay;
|
this.stay = stay;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TitleConfigBuilder fadeOut(@Range(from = 0L, to = Integer.MAX_VALUE) long fadeOut) {
|
public TitleConfigBuilder fadeOut(@Range(from = 0L, to = Integer.MAX_VALUE) int fadeOut) {
|
||||||
this.fadeOut = fadeOut;
|
this.fadeOut = fadeOut;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -90,8 +90,8 @@ public class TitleConfigBuilder extends AbstractCraftBuilder<TitleConfig, TitleC
|
|||||||
public @NotNull ConfiguredTitle build() {
|
public @NotNull ConfiguredTitle build() {
|
||||||
return new ConfiguredTitle(
|
return new ConfiguredTitle(
|
||||||
this.provider, this.path, this.headerComments, this.inlineComment,
|
this.provider, this.path, this.headerComments, this.inlineComment,
|
||||||
this.defaultValue, this.params, this.sendConsumer,
|
this.defaultValue, ParamsUtils.formatParams(this.paramFormatter, this.params),
|
||||||
this.fadeIn, this.stay, this.fadeOut
|
this.sendConsumer, this.fadeIn, this.stay, this.fadeOut
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,9 +34,9 @@ public class TitleConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void send(@NotNull Player player,
|
public void send(@NotNull Player player,
|
||||||
@Range(from = 0L, to = Long.MAX_VALUE) long fadeIn,
|
@Range(from = 0L, to = Long.MAX_VALUE) int fadeIn,
|
||||||
@Range(from = 0L, to = Long.MAX_VALUE) long stay,
|
@Range(from = 0L, to = Long.MAX_VALUE) int stay,
|
||||||
@Range(from = 0L, to = Long.MAX_VALUE) long fadeOut,
|
@Range(from = 0L, to = Long.MAX_VALUE) int fadeOut,
|
||||||
@NotNull Map<String, Object> placeholders,
|
@NotNull Map<String, Object> placeholders,
|
||||||
@Nullable TitleSendConsumer sendConsumer) {
|
@Nullable TitleSendConsumer sendConsumer) {
|
||||||
if (this.line1 == null && this.line2 == null) return;
|
if (this.line1 == null && this.line2 == null) return;
|
||||||
|
@ -18,9 +18,9 @@ public interface TitleSendConsumer {
|
|||||||
* @param line2 第二行文字
|
* @param line2 第二行文字
|
||||||
*/
|
*/
|
||||||
void send(@NotNull Player player,
|
void send(@NotNull Player player,
|
||||||
@Range(from = 0L, to = Integer.MAX_VALUE) long fadeIn,
|
@Range(from = 0L, to = Integer.MAX_VALUE) int fadeIn,
|
||||||
@Range(from = 0L, to = Integer.MAX_VALUE) long stay,
|
@Range(from = 0L, to = Integer.MAX_VALUE) int stay,
|
||||||
@Range(from = 0L, to = Integer.MAX_VALUE) long fadeOut,
|
@Range(from = 0L, to = Integer.MAX_VALUE) int fadeOut,
|
||||||
@NotNull String line1, @NotNull String line2);
|
@NotNull String line1, @NotNull String line2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,10 +56,6 @@ public class ConfiguredItem extends ConfiguredSection<ItemConfig> {
|
|||||||
return getItem(player, amount, new HashMap<>());
|
return getItem(player, amount, new HashMap<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable ItemStack getItem(@Nullable Player player, @NotNull Object... values) {
|
|
||||||
return getItem(player, 1, values);
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable ItemStack getItem(@Nullable Player player, int amount, @NotNull Object... values) {
|
public @Nullable ItemStack getItem(@Nullable Player player, int amount, @NotNull Object... values) {
|
||||||
return getItem(player, amount, ParamsUtils.buildParams(params, values));
|
return getItem(player, amount, ParamsUtils.buildParams(params, values));
|
||||||
}
|
}
|
||||||
|
@ -29,22 +29,22 @@ public class ConfiguredTitle extends ConfiguredSection<TitleConfig> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ConfiguredTitle of(@Nullable String line1, @Nullable String line2,
|
public static ConfiguredTitle of(@Nullable String line1, @Nullable String line2,
|
||||||
long fadeIn, long stay, long fadeOut) {
|
int fadeIn, int stay, int fadeOut) {
|
||||||
return create().defaults(line1, line2).fadeIn(fadeIn).stay(stay).fadeOut(fadeOut).build();
|
return create().defaults(line1, line2).fadeIn(fadeIn).stay(stay).fadeOut(fadeOut).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final @NotNull TitleSendConsumer sendConsumer;
|
protected final @NotNull TitleSendConsumer sendConsumer;
|
||||||
protected final @NotNull String[] params;
|
protected final @NotNull String[] params;
|
||||||
|
|
||||||
protected final long fadeIn;
|
protected final int fadeIn;
|
||||||
protected final long stay;
|
protected final int stay;
|
||||||
protected final long fadeOut;
|
protected final int fadeOut;
|
||||||
|
|
||||||
public ConfiguredTitle(@Nullable ConfigurationProvider<?> provider, @Nullable String sectionPath,
|
public ConfiguredTitle(@Nullable ConfigurationProvider<?> provider, @Nullable String sectionPath,
|
||||||
@Nullable List<String> headerComments, @Nullable String inlineComments,
|
@Nullable List<String> headerComments, @Nullable String inlineComments,
|
||||||
@Nullable TitleConfig defaultValue, @NotNull String[] params,
|
@Nullable TitleConfig defaultValue, @NotNull String[] params,
|
||||||
@NotNull TitleSendConsumer sendConsumer,
|
@NotNull TitleSendConsumer sendConsumer,
|
||||||
long fadeIn, long stay, long fadeOut) {
|
int fadeIn, int stay, int fadeOut) {
|
||||||
super(provider, sectionPath, headerComments, inlineComments, TitleConfig.class, defaultValue, getTitleParser(), TitleConfig::serialize);
|
super(provider, sectionPath, headerComments, inlineComments, TitleConfig.class, defaultValue, getTitleParser(), TitleConfig::serialize);
|
||||||
this.sendConsumer = sendConsumer;
|
this.sendConsumer = sendConsumer;
|
||||||
this.params = params;
|
this.params = params;
|
||||||
@ -53,18 +53,18 @@ public class ConfiguredTitle extends ConfiguredSection<TitleConfig> {
|
|||||||
this.fadeOut = fadeOut;
|
this.fadeOut = fadeOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Range(from = 0L, to = Long.MAX_VALUE)
|
@Range(from = 0L, to = Integer.MAX_VALUE)
|
||||||
public long getFadeInTicks() {
|
public int getFadeInTicks() {
|
||||||
return fadeIn;
|
return fadeIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Range(from = 0L, to = Long.MAX_VALUE)
|
@Range(from = 0L, to = Integer.MAX_VALUE)
|
||||||
public long getStayTicks() {
|
public int getStayTicks() {
|
||||||
return stay;
|
return stay;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Range(from = 0L, to = Long.MAX_VALUE)
|
@Range(from = 0L, to = Integer.MAX_VALUE)
|
||||||
public long getFadeOutTicks() {
|
public int getFadeOutTicks() {
|
||||||
return fadeOut;
|
return fadeOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user