1
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:
Carm Jos 2022-05-19 02:04:57 +08:00
parent 98ee47f676
commit 9a95e3d105
5 changed files with 25 additions and 29 deletions

View File

@ -30,9 +30,9 @@ public class TitleConfigBuilder extends AbstractCraftBuilder<TitleConfig, TitleC
protected @NotNull String[] params;
protected @Range(from = 0L, to = Integer.MAX_VALUE) long fadeIn = 10;
protected @Range(from = 0L, to = Integer.MAX_VALUE) long stay = 60;
protected @Range(from = 0L, to = Integer.MAX_VALUE) long fadeOut = 10;
protected @Range(from = 0L, to = Integer.MAX_VALUE) int fadeIn = 10;
protected @Range(from = 0L, to = Integer.MAX_VALUE) int stay = 60;
protected @Range(from = 0L, to = Integer.MAX_VALUE) int fadeOut = 10;
protected @NotNull TitleSendConsumer sendConsumer;
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]));
}
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;
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;
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;
return this;
}
@ -90,8 +90,8 @@ public class TitleConfigBuilder extends AbstractCraftBuilder<TitleConfig, TitleC
public @NotNull ConfiguredTitle build() {
return new ConfiguredTitle(
this.provider, this.path, this.headerComments, this.inlineComment,
this.defaultValue, this.params, this.sendConsumer,
this.fadeIn, this.stay, this.fadeOut
this.defaultValue, ParamsUtils.formatParams(this.paramFormatter, this.params),
this.sendConsumer, this.fadeIn, this.stay, this.fadeOut
);
}
}

View File

@ -34,9 +34,9 @@ public class TitleConfig {
}
public void send(@NotNull Player player,
@Range(from = 0L, to = Long.MAX_VALUE) long fadeIn,
@Range(from = 0L, to = Long.MAX_VALUE) long stay,
@Range(from = 0L, to = Long.MAX_VALUE) long fadeOut,
@Range(from = 0L, to = Long.MAX_VALUE) int fadeIn,
@Range(from = 0L, to = Long.MAX_VALUE) int stay,
@Range(from = 0L, to = Long.MAX_VALUE) int fadeOut,
@NotNull Map<String, Object> placeholders,
@Nullable TitleSendConsumer sendConsumer) {
if (this.line1 == null && this.line2 == null) return;

View File

@ -18,9 +18,9 @@ public interface TitleSendConsumer {
* @param line2 第二行文字
*/
void send(@NotNull Player player,
@Range(from = 0L, to = Integer.MAX_VALUE) long fadeIn,
@Range(from = 0L, to = Integer.MAX_VALUE) long stay,
@Range(from = 0L, to = Integer.MAX_VALUE) long fadeOut,
@Range(from = 0L, to = Integer.MAX_VALUE) int fadeIn,
@Range(from = 0L, to = Integer.MAX_VALUE) int stay,
@Range(from = 0L, to = Integer.MAX_VALUE) int fadeOut,
@NotNull String line1, @NotNull String line2);
}

View File

@ -56,10 +56,6 @@ public class ConfiguredItem extends ConfiguredSection<ItemConfig> {
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) {
return getItem(player, amount, ParamsUtils.buildParams(params, values));
}

View File

@ -29,22 +29,22 @@ public class ConfiguredTitle extends ConfiguredSection<TitleConfig> {
}
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();
}
protected final @NotNull TitleSendConsumer sendConsumer;
protected final @NotNull String[] params;
protected final long fadeIn;
protected final long stay;
protected final long fadeOut;
protected final int fadeIn;
protected final int stay;
protected final int fadeOut;
public ConfiguredTitle(@Nullable ConfigurationProvider<?> provider, @Nullable String sectionPath,
@Nullable List<String> headerComments, @Nullable String inlineComments,
@Nullable TitleConfig defaultValue, @NotNull String[] params,
@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);
this.sendConsumer = sendConsumer;
this.params = params;
@ -53,18 +53,18 @@ public class ConfiguredTitle extends ConfiguredSection<TitleConfig> {
this.fadeOut = fadeOut;
}
@Range(from = 0L, to = Long.MAX_VALUE)
public long getFadeInTicks() {
@Range(from = 0L, to = Integer.MAX_VALUE)
public int getFadeInTicks() {
return fadeIn;
}
@Range(from = 0L, to = Long.MAX_VALUE)
public long getStayTicks() {
@Range(from = 0L, to = Integer.MAX_VALUE)
public int getStayTicks() {
return stay;
}
@Range(from = 0L, to = Long.MAX_VALUE)
public long getFadeOutTicks() {
@Range(from = 0L, to = Integer.MAX_VALUE)
public int getFadeOutTicks() {
return fadeOut;
}