Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
ac45e09
reworked the command system
WizardlyBump17 Nov 13, 2024
b0181a6
registering the command extractors
WizardlyBump17 Nov 13, 2024
4528843
fixed the arguments list
WizardlyBump17 Nov 13, 2024
272137f
weakened the constructor's visibility
WizardlyBump17 Nov 13, 2024
e22e013
added the CommandManager#registerCommands(Collection) method
WizardlyBump17 Nov 13, 2024
f58b63c
added the CommandData#getName() method
WizardlyBump17 Nov 13, 2024
8046e8f
added the RegisteredCommand#onRegister(CommandManager) method
WizardlyBump17 Nov 13, 2024
3f0866b
added the RegisteredPluginCommand class
WizardlyBump17 Nov 13, 2024
5b24ac6
added the CommandMapAdapter system
WizardlyBump17 Nov 14, 2024
88b3209
added the RegisteredCommand#onUnregister(CommandManager) method
WizardlyBump17 Nov 14, 2024
c68bdf0
added the CommandMapAdapter for the other versions
WizardlyBump17 Nov 14, 2024
c60e2ec
renamed to RegisteredBukkitCommand
WizardlyBump17 Nov 14, 2024
c81482e
added the ArgsNode.literal(String) method
WizardlyBump17 Nov 14, 2024
0afb70e
calling the RegisteredCommand#onUnregister(CommandManager) method whe…
WizardlyBump17 Nov 14, 2024
b4cdfc1
using the public lookup
WizardlyBump17 Nov 14, 2024
f074945
unregistering the command properly
WizardlyBump17 Nov 14, 2024
a6f8dcc
using the fields instead of their values
WizardlyBump17 Nov 14, 2024
519250d
added the RequiredSenderType annotation
WizardlyBump17 Nov 14, 2024
9417cd9
moved the sender check to the RegisteredCommand
WizardlyBump17 Nov 14, 2024
c45cd78
moved the sender type requirement to the CommandData interface
WizardlyBump17 Nov 14, 2024
ecbdb5c
deleted the unused file
WizardlyBump17 Nov 14, 2024
a874f8a
improved the sender checking
WizardlyBump17 Nov 14, 2024
04af805
fixed the RegisteredCommand#canExecute(CommandSender) method by check…
WizardlyBump17 Nov 15, 2024
4ba1757
made CommandData be an abstract class
WizardlyBump17 Nov 15, 2024
25b9e5b
added the SimpleCommandData system
WizardlyBump17 Nov 15, 2024
9052f1f
added the ArgsNode.userInput(String, ArgsReader) method
WizardlyBump17 Nov 15, 2024
f3eb68a
added the CommandSender#hasId(UUID) method
WizardlyBump17 Nov 15, 2024
8fac630
added the ArgsNode.userInput(String, Class) method
WizardlyBump17 Nov 15, 2024
421a46f
using the CommandManager to execute the command instead
WizardlyBump17 Nov 16, 2024
658cd00
removed the unused field
WizardlyBump17 Nov 16, 2024
faadaea
made the CommandManager store commands using a Map where the key is t…
WizardlyBump17 Nov 16, 2024
7f15598
annotated with NotNull
WizardlyBump17 Nov 16, 2024
a83e178
added methods to manipulate the CommandManager#getCommandExtractors()
WizardlyBump17 Nov 16, 2024
e7d02f1
using a List instead
WizardlyBump17 Nov 16, 2024
fb83f0b
moved to the proper package and renamed the classes implementing Comm…
WizardlyBump17 Nov 23, 2024
47e9fe1
added the BasicCommandSender class
WizardlyBump17 Nov 24, 2024
5f1c5cd
added the builder system
WizardlyBump17 Nov 24, 2024
986fb39
added some tests for the BasicCommandSender
WizardlyBump17 Nov 24, 2024
f631248
added the annotations dependency to the test scope
WizardlyBump17 Dec 5, 2024
fe6cbc3
version changed
WizardlyBump17 Jan 14, 2025
f3d9f58
improved the build.gradle
WizardlyBump17 Jan 14, 2025
6017fed
added the MiniMessageUtil class
WizardlyBump17 Feb 15, 2025
1384fd8
added support for the Adventure API on non-Paper environments
WizardlyBump17 Feb 16, 2025
618c6ce
added some methods with some Adventure stuff
WizardlyBump17 Feb 16, 2025
8c12af8
version changed :D
WizardlyBump17 Apr 17, 2025
756ca77
using suppliers
WizardlyBump17 May 24, 2025
5d9087e
version changed
WizardlyBump17 May 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ plugins {
id 'maven-publish'
}

apply plugin: 'maven-publish'

allprojects {
group = 'com.wizardlybump17.wlib'
version = '1.6.7'

apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'java'
apply plugin: 'maven-publish'

group = 'com.wizardlybump17.wlib'
version = '1.6.7-ncs-2'

repositories {
mavenLocal()
Expand All @@ -24,6 +23,10 @@ allprojects {
compileJava {
options.encoding = 'UTF-8'
}

assemble {
dependsOn(shadowJar)
}
}

java {
Expand All @@ -32,8 +35,6 @@ allprojects {
}

subprojects {
apply plugin: 'maven-publish'

if (project.name == 'versions' || project.name.matches('v\\d_\\d+_R\\d+')) {
tasks.withType(PublishToMavenRepository).configureEach {
it.enabled = false
Expand Down Expand Up @@ -79,8 +80,4 @@ subprojects {
events "passed", "skipped", "failed", "standardOut", "standardError"
}
}

build {
dependsOn(test, shadowJar)
}
}
3 changes: 3 additions & 0 deletions bukkit-utils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ dependencies {
'org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT',
'org.jetbrains:annotations:23.0.0',
)
compileOnly("net.kyori:adventure-api:4.18.0")
compileOnly("net.kyori:adventure-text-minimessage:4.18.0")
compileOnly("net.kyori:adventure-platform-bukkit:4.3.4")
implementation(
project(':utils')
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.wizardlybump17.wlib.util.bukkit;

import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.jetbrains.annotations.NotNull;

import java.util.Map;

public final class MiniMessageUtil {

private MiniMessageUtil() {
}

public static @NotNull Component getMessage(@NotNull String message, @NotNull Map<String, Object> placeholders) {
MiniMessage miniMessage = MiniMessage.miniMessage();
if (placeholders.isEmpty())
return miniMessage.deserialize(message);

TagResolver[] resolvers = new TagResolver[placeholders.size()];
int resolverIndex = 0;
for (Map.Entry<String, Object> entry : placeholders.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
resolvers[resolverIndex++] = TagResolver.builder()
.tag(
key,
Tag.inserting(value instanceof Component component ? component : Component.text(String.valueOf(value)))
)
.build();
}
return miniMessage.deserialize(message, resolvers);
}

public static @NotNull Component getMessage(@NotNull String message) {
return getMessage(message, Map.of());
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.wizardlybump17.wlib.bungee.command;

import com.wizardlybump17.wlib.bungee.command.sender.GenericSender;
import com.wizardlybump17.wlib.bungee.command.sender.ProxiedPlayerSender;
import com.wizardlybump17.wlib.bungee.command.sender.BungeeCommandSender;
import com.wizardlybump17.wlib.command.CommandManager;
import com.wizardlybump17.wlib.command.CommandSender;
import com.wizardlybump17.wlib.command.exception.CommandException;
import com.wizardlybump17.wlib.command.holder.CommandExecutor;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;

import java.util.logging.Level;

public class BungeeCommandExecutor extends Command implements CommandExecutor {

private final CommandManager manager;
Expand All @@ -18,17 +18,16 @@ public BungeeCommandExecutor(CommandManager manager, String name) {
}

@Override
public void execute(CommandSender<?> sender, String commandName, String[] args) {
public void execute(com.wizardlybump17.wlib.command.sender.CommandSender<?> sender, String commandName, String[] args) throws CommandException {
manager.execute(sender, commandName + " " + String.join(" ", args));
}

@Override
public void execute(net.md_5.bungee.api.CommandSender sender, String[] args) {
CommandSender<?> realSender;
if (sender instanceof ProxiedPlayer)
realSender = new ProxiedPlayerSender((ProxiedPlayer) sender);
else
realSender = new GenericSender(sender);
execute(realSender, getName(), args);
try {
execute(new BungeeCommandSender(sender), getName(), args);
} catch (CommandException e) {
manager.getHolder().getLogger().log(Level.SEVERE, "Error while executing a command", e);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.wizardlybump17.wlib.bungee.command;

import com.wizardlybump17.wlib.command.CommandManager;
import com.wizardlybump17.wlib.command.RegisteredCommand;
import com.wizardlybump17.wlib.command.registered.RegisteredCommand;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.Plugin;
import org.jetbrains.annotations.NotNull;

public class BungeeCommandManager extends CommandManager {

Expand All @@ -12,7 +13,7 @@ public BungeeCommandManager(BungeeCommandHolder holder) {
}

@Override
public void registerCommands(Object... objects) {
public void registerCommands(@NotNull Object @NotNull ... objects) {
super.registerCommands(objects);
for (Object object : objects) {
for (RegisteredCommand command : getCommands(object)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.wizardlybump17.wlib.bungee.command.sender;

import com.wizardlybump17.wlib.command.CommandSender;
import lombok.RequiredArgsConstructor;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ConnectedPlayer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import org.jetbrains.annotations.NotNull;

import java.util.UUID;

@RequiredArgsConstructor
public class GenericSender implements CommandSender<net.md_5.bungee.api.CommandSender> {
public class BungeeCommandSender implements com.wizardlybump17.wlib.command.sender.CommandSender<net.md_5.bungee.api.CommandSender> {

private final net.md_5.bungee.api.CommandSender handle;

Expand Down Expand Up @@ -34,12 +38,16 @@ public boolean hasPermission(String permission) {
return handle.hasPermission(permission);
}

@Override
public GenericSender toGeneric() {
return this;
public @NotNull ProxiedPlayer asProxiedPlayer() {
return (ProxiedPlayer) handle;
}

public static boolean isGeneric() {
return true;
public @NotNull ConnectedPlayer asConnectedPlayer() {
return (ConnectedPlayer) handle;
}

@Override
public boolean hasId(@NotNull UUID id) {
return handle instanceof ProxiedPlayer player && player.getUniqueId().equals(id);
}
}

This file was deleted.

1 change: 1 addition & 0 deletions commands/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies {
implementation("com.github.sisyphsu:dateparser:1.0.11") {
exclude(group: "org.projectlombok", module: "lombok")
}
testCompileOnly("org.jetbrains:annotations:26.0.1")
}

shadowJar {
Expand Down
Loading