change package of core command classes so it makes more sense and rename getType() to getCategory() in command interface
This commit is contained in:
1 parent
ffb393706b
commit
febd12f2f2
6 files changed
+199
-29
No files matched your search
+3
-3
@@ -1,4 +1,4 @@
|
||||
package me.bobert.netneutrality.command;
|
||||
package me.bobert.netneutrality.core.command;
|
||||
/*
|
||||
* Copyright (c) anthorob
|
||||
*
|
||||
@@ -20,7 +20,7 @@ public abstract class AbstractAdminCommand extends AbstractCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandType getType() {
|
||||
return CommandType.ADMINISTRATION;
|
||||
public CommandCategory getCategory() {
|
||||
return CommandCategory.ADMINISTRATION;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package me.bobert.netneutrality.core.command.builder;
|
||||
/*
|
||||
* Copyright (c) anthorob
|
||||
*
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.command.Command;
|
||||
import me.bobert.netneutrality.command.CommandOptions;
|
||||
import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
||||
|
||||
public class CommandOptionsBuilder extends CommandDataImpl {
|
||||
private final Command command;
|
||||
|
||||
public CommandOptionsBuilder(Command command) {
|
||||
super(command.getCommandName(), command.getDescription());
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public CommandOptions build() {
|
||||
//TODO: add more command types (slash, context menu), constructors are not the same so we can't extend CommandDataImpl
|
||||
return new CommandOptions(command, this);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
<<<<<<<< HEAD:src/main/java/me/bobert/netneutrality/core/command/impl/AbstractCommand.java
|
||||
package me.bobert.netneutrality.core.command.impl;
|
||||
========
|
||||
package me.bobert.netneutrality.core.command;
|
||||
>>>>>>>> 8479f71 (change package of core command classes so it makes more sense and rename getType() to getCategory() in command interface):src/main/java/me/bobert/netneutrality/core/command/AbstractCommand.java
|
||||
|
||||
/*
|
||||
* Copyright (c) anthorob
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<<<<<<<< HEAD:src/main/java/me/bobert/netneutrality/core/command/impl/MusicCommand.java
|
||||
package me.bobert.netneutrality.core.command.impl;
|
||||
========
|
||||
package me.bobert.netneutrality.core.command;
|
||||
>>>>>>>> 8479f71 (change package of core command classes so it makes more sense and rename getType() to getCategory() in command interface):src/main/java/me/bobert/netneutrality/core/command/AbstractMusicCommand.java
|
||||
/*
|
||||
* Copyright (c) anthorob
|
||||
*
|
||||
|
||||
+3
-2
@@ -1,10 +1,11 @@
|
||||
package me.bobert.netneutrality.command;
|
||||
package me.bobert.netneutrality.core.command.options;
|
||||
/*
|
||||
* Copyright (c) anthorob
|
||||
*
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.Command;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||
@@ -15,7 +16,7 @@ import java.util.List;
|
||||
|
||||
public class CommandOptions {
|
||||
private final Command command;
|
||||
private final SlashCommandData commandData;
|
||||
private final CommandDataImpl commandData;
|
||||
private final List<OptionData> options;
|
||||
private final List<SubcommandData> subcommands;
|
||||
private final List<SubcommandGroupData> subcommandGroups;
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
package me.bobert.netneutrality.core.command.options;
|
||||
/*
|
||||
* Copyright (c) anthorob
|
||||
*
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.Command;
|
||||
import net.dv8tion.jda.api.interactions.DiscordLocale;
|
||||
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.*;
|
||||
import net.dv8tion.jda.api.interactions.commands.localization.LocalizationFunction;
|
||||
import net.dv8tion.jda.api.interactions.commands.localization.LocalizationMap;
|
||||
import net.dv8tion.jda.api.utils.data.DataObject;
|
||||
import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class CommandOptionsBuilder implements SlashCommandData {
|
||||
private final Command command;
|
||||
private CommandDataImpl commandData;
|
||||
|
||||
public CommandOptionsBuilder(Command.Type type, Command command) {
|
||||
this.command = command;
|
||||
|
||||
if (type == Command.Type.SLASH) {
|
||||
commandData = (CommandDataImpl) Commands.slash(command.getCommandName(), command.getDescription());
|
||||
}
|
||||
|
||||
if (type == Command.Type.USER) {
|
||||
commandData = (CommandDataImpl) Commands.user(command.getCommandName());
|
||||
}
|
||||
|
||||
if (type == Command.Type.MESSAGE) {
|
||||
commandData = (CommandDataImpl) Commands.message(command.getCommandName());
|
||||
}
|
||||
}
|
||||
|
||||
public CommandOptions build() {
|
||||
return new CommandOptions(command, commandData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull SlashCommandData setLocalizationFunction(@Nonnull LocalizationFunction localizationFunction) {
|
||||
return commandData.setLocalizationFunction(localizationFunction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull SlashCommandData setName(@Nonnull String name) {
|
||||
return commandData.setName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull SlashCommandData setNameLocalization(@Nonnull DiscordLocale locale, @Nonnull String name) {
|
||||
return commandData.setNameLocalization(locale, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull SlashCommandData setNameLocalizations(@Nonnull Map<DiscordLocale, String> map) {
|
||||
return commandData.setNameLocalizations(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull SlashCommandData setDefaultPermissions(@Nonnull DefaultMemberPermissions permission) {
|
||||
return commandData.setDefaultPermissions(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull SlashCommandData setGuildOnly(boolean guildOnly) {
|
||||
return commandData.setGuildOnly(guildOnly);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull SlashCommandData setNSFW(boolean nsfw) {
|
||||
return commandData.setNSFW(nsfw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull String getName() {
|
||||
return commandData.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull LocalizationMap getNameLocalizations() {
|
||||
return commandData.getNameLocalizations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull net.dv8tion.jda.api.interactions.commands.Command.Type getType() {
|
||||
return commandData.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull DefaultMemberPermissions getDefaultPermissions() {
|
||||
return commandData.getDefaultPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGuildOnly() {
|
||||
return commandData.isGuildOnly();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNSFW() {
|
||||
return commandData.isNSFW();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull SlashCommandData setDescription(@Nonnull String description) {
|
||||
return commandData.setDescription(description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull SlashCommandData setDescriptionLocalization(@Nonnull DiscordLocale locale, @Nonnull String description) {
|
||||
return commandData.setDescriptionLocalization(locale, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull SlashCommandData setDescriptionLocalizations(@Nonnull Map<DiscordLocale, String> map) {
|
||||
return commandData.setDescriptionLocalizations(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull String getDescription() {
|
||||
return commandData.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull LocalizationMap getDescriptionLocalizations() {
|
||||
return commandData.getDescriptionLocalizations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeOptions(@Nonnull Predicate<? super OptionData> condition) {
|
||||
return commandData.removeOptions(condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeSubcommands(@Nonnull Predicate<? super SubcommandData> condition) {
|
||||
return commandData.removeSubcommands(condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeSubcommandGroups(@Nonnull Predicate<? super SubcommandGroupData> condition) {
|
||||
return commandData.removeSubcommandGroups(condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull List<SubcommandData> getSubcommands() {
|
||||
return commandData.getSubcommands();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull List<SubcommandGroupData> getSubcommandGroups() {
|
||||
return commandData.getSubcommandGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull List<OptionData> getOptions() {
|
||||
return commandData.getOptions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull SlashCommandData addOptions(@Nonnull OptionData... options) {
|
||||
return commandData.addOptions(options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull SlashCommandData addSubcommands(@Nonnull SubcommandData... subcommands) {
|
||||
return commandData.addSubcommands(subcommands);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull SlashCommandData addSubcommandGroups(@Nonnull SubcommandGroupData... groups) {
|
||||
return commandData.addSubcommandGroups(groups);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nonnull DataObject toData() {
|
||||
return commandData.toData();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user