Merge branch 'master' into 1.17
This commit is contained in:
commit
41a34b52a3
8 files changed
+35
-11
No files matched your search
@@ -453,6 +453,7 @@ public class CarpetSettings
|
|||||||
"have when running commands with run()"
|
"have when running commands with run()"
|
||||||
},
|
},
|
||||||
category = {SCARPET},
|
category = {SCARPET},
|
||||||
|
options = {"ops", "0", "1", "2", "3", "4"},
|
||||||
validate = {Validator._COMMAND_LEVEL_VALIDATOR.class, ModulePermissionLevel.class}
|
validate = {Validator._COMMAND_LEVEL_VALIDATOR.class, ModulePermissionLevel.class}
|
||||||
)
|
)
|
||||||
public static String commandScriptACE = "ops";
|
public static String commandScriptACE = "ops";
|
||||||
@@ -484,6 +485,7 @@ public class CarpetSettings
|
|||||||
"using <user>/<repo>/contents/<path...>"
|
"using <user>/<repo>/contents/<path...>"
|
||||||
},
|
},
|
||||||
category = SCARPET,
|
category = SCARPET,
|
||||||
|
strict = false,
|
||||||
validate= AppStoreManager.ScarpetAppStoreValidator.class
|
validate= AppStoreManager.ScarpetAppStoreValidator.class
|
||||||
)
|
)
|
||||||
public static String scriptsAppStore = "gnembon/scarpet/contents/programs";
|
public static String scriptsAppStore = "gnembon/scarpet/contents/programs";
|
||||||
|
|||||||
@@ -991,6 +991,7 @@ public class CarpetEventServer
|
|||||||
public final String name;
|
public final String name;
|
||||||
|
|
||||||
public final CallbackList handler;
|
public final CallbackList handler;
|
||||||
|
@Deprecated
|
||||||
public final boolean globalOnly;
|
public final boolean globalOnly;
|
||||||
public final boolean isPublic; // public events can be targetted with __on_<event> defs
|
public final boolean isPublic; // public events can be targetted with __on_<event> defs
|
||||||
public Event(String name, int reqArgs, boolean isGlobalOnly)
|
public Event(String name, int reqArgs, boolean isGlobalOnly)
|
||||||
|
|||||||
@@ -21,20 +21,13 @@ import java.util.function.BiFunction;
|
|||||||
|
|
||||||
public class BiomeInfo
|
public class BiomeInfo
|
||||||
{
|
{
|
||||||
// copy of from Biome.getDefaultFoliageColor
|
|
||||||
private static int getDefaultFoliageColor(Biome b) {
|
|
||||||
double d = MathHelper.clamp(b.getTemperature(), 0.0F, 1.0F);
|
|
||||||
double e = MathHelper.clamp(b.getDownfall(), 0.0F, 1.0F);
|
|
||||||
return FoliageColors.getColor(d, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final static Map<String, BiFunction<ServerWorld, Biome, Value>> biomeFeatures = new HashMap<String, BiFunction<ServerWorld, Biome, Value>>(){{
|
public final static Map<String, BiFunction<ServerWorld, Biome, Value>> biomeFeatures = new HashMap<String, BiFunction<ServerWorld, Biome, Value>>(){{
|
||||||
put("top_material", (w, b) -> new BlockValue( b.getGenerationSettings().getSurfaceConfig().getTopMaterial(), null, null));
|
put("top_material", (w, b) -> new BlockValue( b.getGenerationSettings().getSurfaceConfig().getTopMaterial(), null, null));
|
||||||
put("under_material", (w, b) -> new BlockValue( b.getGenerationSettings().getSurfaceConfig().getUnderMaterial(), null, null));
|
put("under_material", (w, b) -> new BlockValue( b.getGenerationSettings().getSurfaceConfig().getUnderMaterial(), null, null));
|
||||||
put("category", (w, b) -> StringValue.of(b.getCategory().getName()));
|
put("category", (w, b) -> StringValue.of(b.getCategory().getName()));
|
||||||
put("temperature", (w, b) -> NumericValue.of(b.getTemperature()));
|
put("temperature", (w, b) -> NumericValue.of(b.getTemperature()));
|
||||||
put("fog_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMFogColor()));
|
put("fog_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMFogColor()));
|
||||||
put("foliage_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMFoliageColor().orElseGet(() -> getDefaultFoliageColor(b))));
|
put("foliage_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMFoliageColor().orElse(4764952))); // client Biome.getDefaultFoliageColor
|
||||||
put("sky_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMSkyColor()));
|
put("sky_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMSkyColor()));
|
||||||
put("water_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMWaterColor()));
|
put("water_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMWaterColor()));
|
||||||
put("water_fog_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMWaterFogColor()));
|
put("water_fog_color", (w, b) -> ValueConversions.ofRGB(((BiomeEffectsInterface)b.getEffects()).getCMWaterFogColor()));
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package carpet.settings;
|
||||||
|
|
||||||
|
public interface Condition {
|
||||||
|
boolean isTrue();
|
||||||
|
}
|
||||||
@@ -163,7 +163,7 @@ public final class ParsedRule<T> implements Comparable<ParsedRule> {
|
|||||||
{
|
{
|
||||||
if (source != null)
|
if (source != null)
|
||||||
{
|
{
|
||||||
Messenger.m(source, "r Wrong value for " + name + ": " + stringValue);
|
validator.notifyFailure(source, this, stringValue);
|
||||||
if (validator.description() != null)
|
if (validator.description() != null)
|
||||||
Messenger.m(source, "r " + validator.description());
|
Messenger.m(source, "r " + validator.description());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,4 +64,9 @@ public @interface Rule
|
|||||||
* The class of the validator checked when the rule is changed.
|
* The class of the validator checked when the rule is changed.
|
||||||
*/
|
*/
|
||||||
Class<? extends Validator>[] validate() default {};
|
Class<? extends Validator>[] validate() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class of the condition checked when the rule is parsed.
|
||||||
|
*/
|
||||||
|
Class<? extends Condition>[] condition() default {};
|
||||||
}
|
}
|
||||||
@@ -30,6 +30,7 @@ import java.io.BufferedReader;
|
|||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.NoSuchFileException;
|
import java.nio.file.NoSuchFileException;
|
||||||
@@ -138,11 +139,24 @@ public class SettingsManager
|
|||||||
*/
|
*/
|
||||||
public void parseSettingsClass(Class settingsClass)
|
public void parseSettingsClass(Class settingsClass)
|
||||||
{
|
{
|
||||||
for (Field f : settingsClass.getDeclaredFields())
|
rule: for (Field f : settingsClass.getDeclaredFields())
|
||||||
{
|
{
|
||||||
Rule rule = f.getAnnotation(Rule.class);
|
Rule rule = f.getAnnotation(Rule.class);
|
||||||
if (rule == null) continue;
|
if (rule == null) continue;
|
||||||
ParsedRule parsed = new ParsedRule(f, rule, this);
|
ParsedRule<?> parsed = new ParsedRule<>(f, rule, this);
|
||||||
|
for (Class<? extends Condition> condition : rule.condition()) {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Constructor<?> constr = condition.getDeclaredConstructor();
|
||||||
|
constr.setAccessible(true);
|
||||||
|
if (!((Condition) constr.newInstance()).isTrue())
|
||||||
|
continue rule;
|
||||||
|
}
|
||||||
|
catch (ReflectiveOperationException e)
|
||||||
|
{
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
rules.put(parsed.name, parsed);
|
rules.put(parsed.name, parsed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ public abstract class Validator<T>
|
|||||||
*/
|
*/
|
||||||
public abstract T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string);
|
public abstract T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string);
|
||||||
public String description() {return null;}
|
public String description() {return null;}
|
||||||
|
public void notifyFailure(ServerCommandSource source, ParsedRule<T> currentRule, String providedValue)
|
||||||
|
{
|
||||||
|
Messenger.m(source, "r Wrong value for " + currentRule.name + ": " + providedValue);
|
||||||
|
}
|
||||||
|
|
||||||
public static class _COMMAND<T> extends Validator<T>
|
public static class _COMMAND<T> extends Validator<T>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user