three things:
- logger is carpet, fixes #522 - fixed fancy commands to functions - so could be used later with lambdas and functions that use different argument names - moved a few builtin apps to commands via /carpet
This commit is contained in:
1 parent
68cd896376
commit
741edf1465
7 files changed
+67
-30
No files matched your search
@@ -1,6 +1,5 @@
|
||||
package carpet.settings;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import carpet.utils.Translations;
|
||||
import carpet.utils.Messenger;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -43,7 +42,7 @@ public final class ParsedRule<T> implements Comparable<ParsedRule> {
|
||||
this.isStrict = rule.strict();
|
||||
this.extraInfo = ImmutableList.copyOf(rule.extra());
|
||||
this.categories = ImmutableList.copyOf(rule.category());
|
||||
this.scarpetApp = rule.scarpetApp();
|
||||
this.scarpetApp = rule.appSource();
|
||||
this.settingsManager = settingsManager;
|
||||
this.validators = new ArrayList<>();
|
||||
for (Class v : rule.validate())
|
||||
|
||||
@@ -58,7 +58,7 @@ public @interface Rule
|
||||
* Consider telling the rule name so users can edit globals
|
||||
* (in case there are relevant globals to edit ofc)
|
||||
*/
|
||||
String scarpetApp() default "";
|
||||
String appSource() default "";
|
||||
|
||||
/**
|
||||
* The class of the validator checked when the rule is changed.
|
||||
|
||||
@@ -57,6 +57,8 @@ public class SettingsManager
|
||||
private final String fancyName;
|
||||
private MinecraftServer server;
|
||||
private List<TriConsumer<ServerCommandSource, ParsedRule<?>, String>> observers = new ArrayList<>();
|
||||
private static List<TriConsumer<ServerCommandSource, ParsedRule<?>, String>> staticObservers = new ArrayList<>();
|
||||
|
||||
|
||||
public SettingsManager(String version, String identifier)
|
||||
{
|
||||
@@ -103,13 +105,19 @@ public class SettingsManager
|
||||
{
|
||||
observers.add(observer);
|
||||
}
|
||||
public static void addGlobalRuleObserver(TriConsumer<ServerCommandSource, ParsedRule<?>, String> observer)
|
||||
{
|
||||
staticObservers.add(observer);
|
||||
}
|
||||
|
||||
|
||||
void notifyRuleChanged(ServerCommandSource source, ParsedRule<?> rule, String userTypedValue)
|
||||
{
|
||||
observers.forEach(observer -> observer.accept(source, rule, userTypedValue));
|
||||
staticObservers.forEach(observer -> observer.accept(source, rule, userTypedValue));
|
||||
ServerNetworkHandler.updateRuleWithConnectedClients(rule);
|
||||
switchScarpetRule(source, rule);
|
||||
CARPET_RULE_CHANGES.onCarpetRuleChanges(rule, source);
|
||||
if (CARPET_RULE_CHANGES.isNeeded()) CARPET_RULE_CHANGES.onCarpetRuleChanges(rule, source);
|
||||
}
|
||||
|
||||
void switchScarpetRule(ServerCommandSource source, ParsedRule<?> rule)
|
||||
|
||||
Reference in new issue
Block a user