added option to display rules from category
This commit is contained in:
1 parent
7d51326144
commit
2f83cb3100
2 files changed
+7
-2
No files matched your search
@@ -16,7 +16,10 @@ public class TestCommand
|
|||||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
|
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
|
||||||
{
|
{
|
||||||
dispatcher.register(literal("test").
|
dispatcher.register(literal("test").
|
||||||
then(literal("dump").executes((c) -> CarpetServer.settingsManager.printAllRulesToLog())).
|
then(literal("dump").
|
||||||
|
executes((c) -> CarpetServer.settingsManager.printAllRulesToLog(null)).
|
||||||
|
then(argument("category", word()).
|
||||||
|
executes( (c) -> CarpetServer.settingsManager.printAllRulesToLog(getString(c, "category"))))).
|
||||||
then(argument("first",word()).
|
then(argument("first",word()).
|
||||||
executes( (c)-> test(c, getString(c, "first")+" 1"))).
|
executes( (c)-> test(c, getString(c, "first")+" 1"))).
|
||||||
then(argument("second", word()).
|
then(argument("second", word()).
|
||||||
|
|||||||
@@ -257,13 +257,15 @@ public class SettingsManager
|
|||||||
}).collect(ImmutableList.toImmutableList());
|
}).collect(ImmutableList.toImmutableList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int printAllRulesToLog()
|
public int printAllRulesToLog(String category)
|
||||||
{
|
{
|
||||||
PrintStream ps = System.out;
|
PrintStream ps = System.out;
|
||||||
ps.println("# "+fancyName+" Settings");
|
ps.println("# "+fancyName+" Settings");
|
||||||
for (Map.Entry<String, ParsedRule<?>> e : new TreeMap<>(rules).entrySet())
|
for (Map.Entry<String, ParsedRule<?>> e : new TreeMap<>(rules).entrySet())
|
||||||
{
|
{
|
||||||
ParsedRule<?> rule = e.getValue();
|
ParsedRule<?> rule = e.getValue();
|
||||||
|
if (category != null && !rule.categories.contains(category))
|
||||||
|
continue;
|
||||||
ps.println("## " + rule.name);
|
ps.println("## " + rule.name);
|
||||||
ps.println(rule.description+" ");
|
ps.println(rule.description+" ");
|
||||||
for (String extra : rule.extraInfo)
|
for (String extra : rule.extraInfo)
|
||||||
|
|||||||
Reference in new issue
Block a user