Skip to content

Commit 87d8d66

Browse files
committed
🎨 Removed redundant CommandReturnDecorator.
1 parent 3b59454 commit 87d8d66

File tree

4 files changed

+18
-41
lines changed

4 files changed

+18
-41
lines changed

API/src/main/java/xyz/bitsquidd/bits/lib/command/BitsCommandManager.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,17 @@
33
import com.mojang.brigadier.context.CommandContext;
44
import io.papermc.paper.command.brigadier.CommandSourceStack;
55
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
6-
import net.kyori.adventure.text.Component;
76
import org.bukkit.Bukkit;
87
import org.bukkit.event.HandlerList;
98
import org.bukkit.plugin.java.JavaPlugin;
109
import org.jspecify.annotations.NullMarked;
11-
import org.spigotmc.SpigotConfig;
1210

1311
import xyz.bitsquidd.bits.lib.command.argument.BitsArgumentRegistry;
1412
import xyz.bitsquidd.bits.lib.command.requirement.BitsRequirementRegistry;
1513
import xyz.bitsquidd.bits.lib.command.util.BitsCommandBuilder;
1614
import xyz.bitsquidd.bits.lib.command.util.BitsCommandContext;
1715
import xyz.bitsquidd.bits.lib.command.util.BitsCommandSourceContext;
1816
import xyz.bitsquidd.bits.lib.config.BitsConfig;
19-
import xyz.bitsquidd.bits.lib.sendable.text.decorator.impl.CommandReturnDecorator;
2017

2118
import java.util.Collection;
2219

@@ -98,12 +95,7 @@ public void shutdown() {
9895
* We hook into this to provide custom formatting for unknown/error commands.
9996
* The default implementation returns a new instance of {@link BitsCommandListener}.
10097
*/
101-
protected BitsCommandListener getListenerInternal() {
102-
return new BitsCommandListener(
103-
CommandReturnDecorator.of(CommandReturnType.ERROR),
104-
Component.text(SpigotConfig.unknownCommandMessage)
105-
);
106-
}
98+
protected abstract BitsCommandListener getListenerInternal();
10799

108100
/**
109101
* Creates a new {@link BitsCommandContext} for the given {@link CommandContext}.
@@ -128,7 +120,7 @@ private void enableAllCommands() {
128120
LifecycleEvents.COMMANDS, commands -> {
129121
bitsCommands
130122
.forEach(bitsCommand -> {
131-
brigadierTreeGenerator.createNodes(new BitsCommandBuilder(bitsCommand.getClass()))
123+
brigadierTreeGenerator.createNodes(new BitsCommandBuilder(bitsCommand))
132124
.forEach(node -> {
133125
commands.registrar().register(node);
134126
});

API/src/main/java/xyz/bitsquidd/bits/lib/sendable/text/decorator/impl/CommandReturnDecorator.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

Common/src/main/java/xyz/bitsquidd/bits/example/command/CustomBitsCommandManager.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
import com.mojang.brigadier.context.CommandContext;
44
import io.papermc.paper.command.brigadier.CommandSourceStack;
5+
import net.kyori.adventure.text.Component;
56
import org.jetbrains.annotations.NotNull;
7+
import org.spigotmc.SpigotConfig;
68

79
import xyz.bitsquidd.bits.example.command.impl.TeleportCommand;
10+
import xyz.bitsquidd.bits.example.text.decorator.impl.CommandDecorator;
811
import xyz.bitsquidd.bits.lib.command.BitsCommand;
12+
import xyz.bitsquidd.bits.lib.command.BitsCommandListener;
913
import xyz.bitsquidd.bits.lib.command.BitsCommandManager;
14+
import xyz.bitsquidd.bits.lib.command.CommandReturnType;
1015
import xyz.bitsquidd.bits.lib.command.argument.BitsArgumentRegistry;
1116
import xyz.bitsquidd.bits.lib.command.requirement.BitsRequirementRegistry;
1217
import xyz.bitsquidd.bits.lib.command.util.BitsCommandContext;
@@ -30,6 +35,14 @@ protected BitsRequirementRegistry getRequirementRegistry() {
3035
return new CustomCommandContext(brigadierContext);
3136
}
3237

38+
@Override
39+
protected BitsCommandListener getListenerInternal() {
40+
return new BitsCommandListener(
41+
CommandDecorator.of(CommandReturnType.ERROR),
42+
Component.text(SpigotConfig.unknownCommandMessage)
43+
);
44+
}
45+
3346
@Override
3447
protected @NotNull List<BitsCommand> getAllCommands() {
3548
return List.of(new TeleportCommand());

Common/src/main/java/xyz/bitsquidd/bits/example/text/decorator/CommandDecorator.java renamed to Common/src/main/java/xyz/bitsquidd/bits/example/text/decorator/impl/CommandDecorator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package xyz.bitsquidd.bits.example.text.decorator;
1+
package xyz.bitsquidd.bits.example.text.decorator.impl;
22

33
import net.kyori.adventure.audience.Audience;
44
import net.kyori.adventure.text.Component;
@@ -7,6 +7,7 @@
77

88
import xyz.bitsquidd.bits.lib.command.CommandReturnType;
99
import xyz.bitsquidd.bits.lib.sendable.text.decorator.formatter.BasicColorFormatter;
10+
import xyz.bitsquidd.bits.lib.sendable.text.decorator.impl.ColorLightenerFormatter;
1011
import xyz.bitsquidd.bits.lib.sendable.text.decorator.impl.StyleDecorator;
1112

1213
public class CommandDecorator extends StyleDecorator {
@@ -15,6 +16,7 @@ public class CommandDecorator extends StyleDecorator {
1516
public CommandDecorator(@NotNull CommandReturnType commandReturnType) {
1617
this.commandReturnType = commandReturnType;
1718
this.globalFormatters.add(new BasicColorFormatter(toMessageColor(commandReturnType)));
19+
this.formatters.put("b", new ColorLightenerFormatter(0.4f));
1820
}
1921

2022
public static CommandDecorator of(@NotNull CommandReturnType commandReturnType) {

0 commit comments

Comments
 (0)