Migrate the Carpet codebase to Mojang Mappings

This commit is contained in:
altrisi committed 2022-01-24 20:33:16 +01:00
1 parent a1a2488bc3
commit 06af9ce8b1
346 files changed
+8353 -8492

No files matched your search

+12 -13
View File
@@ -2,11 +2,10 @@ package carpet.settings;
import carpet.CarpetServer;
import carpet.utils.Messenger;
import net.minecraft.server.command.ServerCommandSource;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
import net.minecraft.commands.CommandSourceStack;
public abstract class Validator<T>
{
@@ -14,9 +13,9 @@ public abstract class Validator<T>
* Validate the new value of a rule
* @return true if valid, false if new rule invalid.
*/
public abstract T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string);
public abstract T validate(CommandSourceStack source, ParsedRule<T> currentRule, T newValue, String string);
public String description() {return null;}
public void notifyFailure(ServerCommandSource source, ParsedRule<T> currentRule, String providedValue)
public void notifyFailure(CommandSourceStack source, ParsedRule<T> currentRule, String providedValue)
{
Messenger.m(source, "r Wrong value for " + currentRule.name + ": " + providedValue);
}
@@ -24,7 +23,7 @@ public abstract class Validator<T>
public static class _COMMAND<T> extends Validator<T>
{
@Override
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
public T validate(CommandSourceStack source, ParsedRule<T> currentRule, T newValue, String string)
{
if (CarpetServer.settingsManager != null && source != null)
CarpetServer.settingsManager.notifyPlayersCommandsChanged();
@@ -37,7 +36,7 @@ public abstract class Validator<T>
public static class _CLIENT<T> extends Validator<T>
{
@Override
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
public T validate(CommandSourceStack source, ParsedRule<T> currentRule, T newValue, String string)
{
return newValue;
}
@@ -49,7 +48,7 @@ public abstract class Validator<T>
public static class _COMMAND_LEVEL_VALIDATOR extends Validator<String> {
private static List<String> OPTIONS = List.of("true", "false", "ops", "0", "1", "2", "3", "4");
@Override public String validate(ServerCommandSource source, ParsedRule<String> currentRule, String newValue, String userString) {
@Override public String validate(CommandSourceStack source, ParsedRule<String> currentRule, String newValue, String userString) {
if (!OPTIONS.contains(userString.toLowerCase(Locale.ROOT)))
{
Messenger.m(source, "r Valid options for command type rules is 'true' or 'false'");
@@ -64,7 +63,7 @@ public abstract class Validator<T>
public static class _SCARPET<T> extends Validator<T> {
@Override
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
public T validate(CommandSourceStack source, ParsedRule<T> currentRule, T newValue, String string)
{
return newValue;
}
@@ -76,7 +75,7 @@ public abstract class Validator<T>
public static class WIP<T> extends Validator<T>
{
@Override
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
public T validate(CommandSourceStack source, ParsedRule<T> currentRule, T newValue, String string)
{
Messenger.m(source, "r "+currentRule.name+" is missing a few bits - we are still working on it.");
return newValue;
@@ -87,7 +86,7 @@ public abstract class Validator<T>
public static class _STRICT<T> extends Validator<T>
{
@Override
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
public T validate(CommandSourceStack source, ParsedRule<T> currentRule, T newValue, String string)
{
if (!currentRule.options.contains(string))
{
@@ -101,7 +100,7 @@ public abstract class Validator<T>
public static class _STRICT_IGNORECASE<T> extends Validator<T>
{
@Override
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
public T validate(CommandSourceStack source, ParsedRule<T> currentRule, T newValue, String string)
{
if (!currentRule.options.stream().map(s->s.toLowerCase(Locale.ROOT)).collect(Collectors.toSet())
.contains(string.toLowerCase(Locale.ROOT)))
@@ -116,7 +115,7 @@ public abstract class Validator<T>
public static class NONNEGATIVE_NUMBER <T extends Number> extends Validator<T>
{
@Override
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
public T validate(CommandSourceStack source, ParsedRule<T> currentRule, T newValue, String string)
{
return newValue.doubleValue() >= 0 ? newValue : null;
}
@@ -127,7 +126,7 @@ public abstract class Validator<T>
public static class PROBABILITY <T extends Number> extends Validator<T>
{
@Override
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
public T validate(CommandSourceStack source, ParsedRule<T> currentRule, T newValue, String string)
{
return (newValue.doubleValue() >= 0 && newValue.doubleValue() <= 1 )? newValue : null;
}