Remove deprecated log4j dependent methods in c.s.SettingsManager
And another one that is normally a bug to use, and a field that is broken. Enables `runtimeOnlyLog4j` in loom
This commit is contained in:
2 files changed
+1
-93
No files matched your search
+1
-1
@@ -13,7 +13,7 @@ group = project.maven_group
|
|||||||
|
|
||||||
loom {
|
loom {
|
||||||
accessWidenerPath = file("src/main/resources/carpet.accesswidener")
|
accessWidenerPath = file("src/main/resources/carpet.accesswidener")
|
||||||
runtimeOnlyLog4j = false // Can be turned on after TriConsumer is no longer present in public API
|
runtimeOnlyLog4j = true
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package carpet.settings;
|
package carpet.settings;
|
||||||
|
|
||||||
import carpet.CarpetServer;
|
import carpet.CarpetServer;
|
||||||
import carpet.CarpetSettings;
|
|
||||||
import carpet.api.settings.CarpetRule;
|
|
||||||
import carpet.utils.CommandHelper;
|
import carpet.utils.CommandHelper;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import net.minecraft.commands.CommandBuildContext;
|
import net.minecraft.commands.CommandBuildContext;
|
||||||
@@ -10,7 +8,6 @@ import net.minecraft.commands.CommandSourceStack;
|
|||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.world.flag.FeatureFlags;
|
import net.minecraft.world.flag.FeatureFlags;
|
||||||
import org.apache.logging.log4j.util.TriConsumer;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -22,12 +19,6 @@ import java.util.List;
|
|||||||
@SuppressWarnings("removal") // Gradle needs the explicit suppression
|
@SuppressWarnings("removal") // Gradle needs the explicit suppression
|
||||||
public class SettingsManager extends carpet.api.settings.SettingsManager
|
public class SettingsManager extends carpet.api.settings.SettingsManager
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #locked()} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true) //to private (or protected?)
|
|
||||||
public boolean locked;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link SettingsManager} without a fancy name.
|
* Creates a new {@link SettingsManager} without a fancy name.
|
||||||
* @see #SettingsManager(String, String, String)
|
* @see #SettingsManager(String, String, String)
|
||||||
@@ -57,61 +48,6 @@ public class SettingsManager extends carpet.api.settings.SettingsManager
|
|||||||
super(version, identifier, fancyName);
|
super(version, identifier, fancyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Adds a custom rule observer to changes in rules from
|
|
||||||
* <b>this specific</b> {@link SettingsManager} instance.</p>
|
|
||||||
*
|
|
||||||
* <p>This <b>outdated</b> method may not be able to listen to all {@link CarpetRule} implementations</p>
|
|
||||||
*
|
|
||||||
* @see SettingsManager#registerGlobalRuleObserver(RuleObserver)
|
|
||||||
*
|
|
||||||
* @param observer A {@link TriConsumer} that will be called with
|
|
||||||
* the used {@link CommandSourceStack}, the changed
|
|
||||||
* {@link ParsedRule} and a {@link String} being the
|
|
||||||
* value that the user typed.
|
|
||||||
* @deprecated Use {@link SettingsManager#registerRuleObserver(RuleObserver)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true) //to remove
|
|
||||||
public void addRuleObserver(TriConsumer<CommandSourceStack, ParsedRule<?>, String> observer)
|
|
||||||
{
|
|
||||||
registerRuleObserver((source, rule, stringValue) -> {
|
|
||||||
if (rule instanceof ParsedRule<?> pr)
|
|
||||||
observer.accept(source, pr, stringValue);
|
|
||||||
else
|
|
||||||
CarpetSettings.LOG.warn("Failed to notify observer '" + observer.getClass().getName() + "' about rule change");
|
|
||||||
});
|
|
||||||
CarpetSettings.LOG.warn("""
|
|
||||||
Extension added outdated rule observer, this is deprecated and will crash in later carpet versions \
|
|
||||||
(way before the rest of the old settings api because of relying on log4j)!
|
|
||||||
The observer class name is '%s'""".formatted(observer.getClass().getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a custom rule observer to changes in rules from
|
|
||||||
* <b>any</b> registered {@link SettingsManager} instance.
|
|
||||||
* @see SettingsManager#addRuleObserver(TriConsumer)
|
|
||||||
*
|
|
||||||
* @param observer A {@link TriConsumer} that will be called with
|
|
||||||
* the used {@link CommandSourceStack}, the changed
|
|
||||||
* {@link ParsedRule} and a {@link String} being the
|
|
||||||
* value that the user typed.
|
|
||||||
* @deprecated Use {@link SettingsManager#registerRuleObserver(RuleObserver)} instead, given this one can't deal with {@link CarpetRule}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true) // to remove. This isn't really used anywhere
|
|
||||||
public static void addGlobalRuleObserver(TriConsumer<CommandSourceStack, ParsedRule<?>, String> observer)
|
|
||||||
{
|
|
||||||
registerGlobalRuleObserver((source, rule, stringValue) -> {
|
|
||||||
if (rule instanceof ParsedRule<?> pr)
|
|
||||||
observer.accept(source, pr, stringValue);
|
|
||||||
else
|
|
||||||
CarpetSettings.LOG.warn("Failed to notify observer '" + observer.getClass().getName() + "' about rule change");
|
|
||||||
});
|
|
||||||
CarpetSettings.LOG.warn("""
|
|
||||||
Extension added outdated rule observer, this is deprecated and will crash in later carpet versions \
|
|
||||||
(way before the rest of the old settings api because of relying on log4j)!
|
|
||||||
The observer class name is '%s'""".formatted(observer.getClass().getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #identifier()} instead
|
* @deprecated Use {@link #identifier()} instead
|
||||||
*/
|
*/
|
||||||
@@ -178,34 +114,6 @@ public class SettingsManager extends carpet.api.settings.SettingsManager
|
|||||||
return CommandHelper.canUseCommand(source, commandLevel);
|
return CommandHelper.canUseCommand(source, commandLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param commandLevel A {@link String} being a permission level according to
|
|
||||||
* Carpet's standard for permissions (either 0-4, a {@link boolean},
|
|
||||||
* or "ops".
|
|
||||||
* @return An {@link int} with the translated Vanilla permission level
|
|
||||||
*
|
|
||||||
* @deprecated While there's not an API replacement for this (at least yet),
|
|
||||||
* you can use the similar {@link CommandHelper#canUseCommand(CommandSourceStack, Object)} instead
|
|
||||||
* @apiNote Note that this method returns {@code 2} for {@code false} and {@code 0} for {@code true}.
|
|
||||||
* You probably want to use {@link #canUseCommand(CommandSourceStack, Object)}e
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public static int getCommandLevel(String commandLevel)
|
|
||||||
{
|
|
||||||
switch (commandLevel)
|
|
||||||
{
|
|
||||||
case "true": return 2;
|
|
||||||
case "false": return 0;
|
|
||||||
case "ops": return 2; // typical for other cheaty commands
|
|
||||||
case "0":
|
|
||||||
case "1":
|
|
||||||
case "2":
|
|
||||||
case "3":
|
|
||||||
case "4":
|
|
||||||
return Integer.parseInt(commandLevel);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public void registerCommand(CommandDispatcher<CommandSourceStack> dispatcher)
|
public void registerCommand(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user