mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Fix comment for permission handler config setting (#8466)
This commit is contained in:
1 parent
512d4d7271
commit
117be913da
2 files changed
+23
-16
No files matched your search
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
* Copyright (c) 2016-2022.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -85,7 +85,7 @@ public class ForgeConfig {
|
||||
.define("fixAdvancementLoading", true);
|
||||
|
||||
permissionHandler = builder
|
||||
.comment("")
|
||||
.comment("The permission handler used by the server. Defaults to forge:default_handler if no such handler with that name is registered.")
|
||||
.translation("forge.configgui.permissionHandler")
|
||||
.define("permissionHandler", "forge:default_handler");
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
* Copyright (c) 2016-2022.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -293,6 +293,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper<UnmodifiableConfi
|
||||
private Map<List<String>, String> levelComments = new HashMap<>();
|
||||
private List<String> currentPath = new ArrayList<>();
|
||||
private List<ConfigValue<?>> values = new ArrayList<>();
|
||||
private boolean hasInvalidComment = false;
|
||||
|
||||
//Object
|
||||
public <T> ConfigValue<T> define(String path, T defaultValue) {
|
||||
@@ -326,6 +327,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper<UnmodifiableConfi
|
||||
path = tmp;
|
||||
}
|
||||
storage.set(path, value);
|
||||
checkComment(path);
|
||||
context = new BuilderContext();
|
||||
return new ConfigValue<>(this, path, defaultSupplier);
|
||||
}
|
||||
@@ -546,28 +548,20 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper<UnmodifiableConfi
|
||||
|
||||
public Builder comment(String comment)
|
||||
{
|
||||
if(comment == null || comment.isEmpty())
|
||||
hasInvalidComment = comment == null || comment.isEmpty();
|
||||
if (hasInvalidComment)
|
||||
{
|
||||
comment = "No comment";
|
||||
if(!FMLEnvironment.production)
|
||||
{
|
||||
LogManager.getLogger().error(CORE, "Null comment for config option {}, this is invalid and may be disallowed in the future.",
|
||||
DOT_JOINER.join(this.currentPath));
|
||||
}
|
||||
}
|
||||
context.setComment(comment);
|
||||
return this;
|
||||
}
|
||||
public Builder comment(String... comment)
|
||||
{
|
||||
if(comment == null || comment.length < 1 || (comment.length == 1 && comment[0].isEmpty()))
|
||||
hasInvalidComment = comment == null || comment.length < 1 || (comment.length == 1 && comment[0].isEmpty());
|
||||
if (hasInvalidComment)
|
||||
{
|
||||
comment = new String[] {"No comment"};
|
||||
if(!FMLEnvironment.production)
|
||||
{
|
||||
LogManager.getLogger().error(CORE, "Null comment for config option {}, this is invalid and may be disallowed in the future.",
|
||||
DOT_JOINER.join(this.currentPath));
|
||||
}
|
||||
}
|
||||
|
||||
context.setComment(comment);
|
||||
@@ -592,8 +586,8 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper<UnmodifiableConfi
|
||||
|
||||
public Builder push(List<String> path) {
|
||||
currentPath.addAll(path);
|
||||
checkComment(currentPath);
|
||||
if (context.hasComment()) {
|
||||
|
||||
levelComments.put(new ArrayList<String>(currentPath), context.buildComment());
|
||||
context.setComment(); // Set to empty
|
||||
}
|
||||
@@ -629,6 +623,19 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper<UnmodifiableConfi
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void checkComment(List<String> path)
|
||||
{
|
||||
if (hasInvalidComment)
|
||||
{
|
||||
hasInvalidComment = false;
|
||||
if (!FMLEnvironment.production)
|
||||
{
|
||||
LogManager.getLogger().error(CORE, "Null comment for config option {}, this is invalid and may be disallowed in the future.",
|
||||
DOT_JOINER.join(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface BuilderConsumer {
|
||||
void accept(Builder builder);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user