Merge branch 'master' into inventory

This commit is contained in:
gnembon committed 2019-06-28 23:03:51 -03:00
commit 546134969d
9 files changed
+46 -35

No files matched your search

@@ -25,7 +25,7 @@ import static carpet.settings.RuleCategory.SURVIVAL;
public class CarpetSettings
{
public static final String carpetVersion = "v19_06_24alpha";
public static final String carpetVersion = "v190627";
public static final Logger LOG = LogManager.getLogger();
public static boolean skipGenerationChecks = false;
public static boolean impendingFillSkipUpdates = false;
@@ -117,7 +117,7 @@ public final class ParsedRule<T> implements Comparable<ParsedRule> {
if (!value.equals(get()))
{
this.field.set(null, value);
SettingsManager.notifyRuleChanged(this, stringValue);
SettingsManager.notifyRuleChanged(source, this, stringValue);
}
}
catch (IllegalAccessException e)
+1 -1
View File
@@ -17,7 +17,7 @@ import java.lang.annotation.Target;
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@interface Rule
public @interface Rule
{
/**
* The rule name, by default the same as the field name
@@ -7,6 +7,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.util.TriConsumer;
import java.io.BufferedReader;
import java.io.File;
@@ -25,7 +26,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
public class SettingsManager
@@ -34,7 +34,7 @@ public class SettingsManager
private static Map<String, ParsedRule<?>> rules = new HashMap<>();
public boolean locked;
private MinecraftServer server;
private static List<BiConsumer<ParsedRule<?>, String>> observers = new ArrayList<>();
private static List<TriConsumer<ServerCommandSource, ParsedRule<?>, String>> observers = new ArrayList<>();
public SettingsManager(MinecraftServer server)
{
@@ -53,14 +53,14 @@ public class SettingsManager
}
}
public static void addRuleObserver(BiConsumer<ParsedRule<?>, String> observer)
public static void addRuleObserver(TriConsumer<ServerCommandSource, ParsedRule<?>, String> observer)
{
observers.add(observer);
}
static void notifyRuleChanged(ParsedRule<?> rule, String userTypedValue)
static void notifyRuleChanged(ServerCommandSource source, ParsedRule<?> rule, String userTypedValue)
{
observers.forEach(observer -> observer.accept(rule, userTypedValue));
observers.forEach(observer -> observer.accept(source, rule, userTypedValue));
}
public static Iterable<String> getCategories()
@@ -71,7 +71,7 @@ public class SettingsManager
}
public ParsedRule getRule(String name)
public static ParsedRule<?> getRule(String name)
{
return rules.get(name);
}