Skip to content

Commit

Permalink
refactored BreadBotClient -> BreadBot
Browse files Browse the repository at this point in the history
  • Loading branch information
BreadMoirai committed Jan 18, 2018
1 parent 7cca944 commit aeb84b1
Show file tree
Hide file tree
Showing 26 changed files with 141 additions and 141 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ plugins {
final author = 'BreadMoirai'
final artifactId = 'breadbot-framework'
group "com.github.${author.toLowerCase()}"
version '0.10.3'
version '0.11.0'

//project.hasProperty never seems to work properly
final boolean keysArePresent = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
import java.util.List;
import java.util.Map;

public interface BreadBotClient {
public interface BreadBot {

boolean hasModule(String pluginName);
boolean hasPlugin(String pluginName);

boolean hasModule(Class<? extends CommandPlugin> pluginClass);
boolean hasPlugin(Class<? extends CommandPlugin> pluginClass);

<T extends CommandPlugin> T getPlugin(Class<T> pluginClass);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.github.breadmoirai.breadbot.framework;

import com.github.breadmoirai.breadbot.framework.builder.BreadBotClientBuilder;
import com.github.breadmoirai.breadbot.framework.builder.BreadBotBuilder;
import com.github.breadmoirai.breadbot.framework.event.CommandEvent;

public interface CommandPlugin {
Expand All @@ -25,14 +25,14 @@ default String getName() {
return this.getClass().getSimpleName().replace("Plugin", "");
}

void initialize(BreadBotClientBuilder builder);
void initialize(BreadBotBuilder builder);

/**
* This method is called when the BreadBotClient has been built.
*
* @param client
*/
default void onBreadReady(BreadBotClient client) {
default void onBreadReady(BreadBot client) {
}

default void onHelpEvent(CommandEvent event) {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ default CommandHandleBuilder sortPreprocessors(Comparator<CommandPreprocessor> c
*/
Method getDeclaringMethod();

BreadBotClientBuilder getClientBuilder();
BreadBotBuilder getClientBuilder();


default CommandHandleBuilder sortPreprocessors() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
public interface CommandParameterBuilder {

BreadBotClientBuilder getClientBuilder();
BreadBotBuilder getClientBuilder();

CommandHandleBuilder getCommandBuilder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public interface CommandPluginBuilder {
* <p>This method's implementation is:
* <pre><code> {@link CommandPluginBuilder#addPlugin(CommandPlugin) addModule}(new {@link UnmodifiablePrefixPlugin DefaultPrefixModule}(prefix)) </code></pre>
*
* <p>You can define a different prefix implementation by providing an object to {@link BreadBotClientBuilder#addPlugin(CommandPlugin) addModule(ICommandModule)} that implements {@link PrefixPlugin IPrefixModule}
* <p>You can define a different prefix implementation by providing an object to {@link BreadBotBuilder#addPlugin(CommandPlugin) addModule(ICommandModule)} that implements {@link PrefixPlugin IPrefixModule}
*
* @param prefix a string the defines a global prefix
* @return this
Expand All @@ -81,7 +81,7 @@ default CommandPluginBuilder addStaticPrefix(String prefix) {
/**
* This enables the {@link com.github.breadmoirai.breadbot.plugins.admin.Admin @Admin} annotation that is marked on Command classes.
* This ensures that Commands marked with {@link com.github.breadmoirai.breadbot.plugins.admin.Admin @Admin} are only usable by Administrators.
* <p>It is <b>important</b> to include an implementation of {@link AdminPlugin AdminModule} through either this method, {@link BreadBotClientBuilder#addAdminPlugin(Predicate)}, or your own implementation.
* <p>It is <b>important</b> to include an implementation of {@link AdminPlugin AdminModule} through either this method, {@link BreadBotBuilder#addAdminPlugin(Predicate)}, or your own implementation.
* Otherwise, all users will have access to Administrative Commands
* <p>
* <p>The default criteria for defining an Administrator is as follows:
Expand All @@ -90,7 +90,7 @@ default CommandPluginBuilder addStaticPrefix(String prefix) {
* <li>Is higher than the bot on the role hierarchy</li>
* </ul>
* <p>
* <p>Different criteria to determine which member has administrative status with {@link BreadBotClientBuilder#addAdminPlugin(Predicate)}
* <p>Different criteria to determine which member has administrative status with {@link BreadBotBuilder#addAdminPlugin(Predicate)}
* or your own implementation of {@link AdminPlugin}
*
* @return this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.github.breadmoirai.breadbot.framework.annotation.command.Command;
import com.github.breadmoirai.breadbot.framework.annotation.command.MainCommand;
import com.github.breadmoirai.breadbot.framework.builder.BreadBotClientBuilder;
import com.github.breadmoirai.breadbot.framework.builder.BreadBotBuilder;
import com.github.breadmoirai.breadbot.framework.builder.CommandParameterBuilder;
import com.github.breadmoirai.breadbot.framework.command.internal.CommandObjectFactory;
import com.github.breadmoirai.breadbot.framework.command.internal.CommandPropertiesManagerImpl;
Expand Down Expand Up @@ -55,9 +55,9 @@ public class CommandHandleBuilderFactoryImpl implements CommandHandleBuilderFact

private static final Logger log = LoggerFactory.getLogger("CommandBuilder");

private final BreadBotClientBuilder clientBuilder;
private final BreadBotBuilder clientBuilder;

public CommandHandleBuilderFactoryImpl(BreadBotClientBuilder clientBuilder) {
public CommandHandleBuilderFactoryImpl(BreadBotBuilder clientBuilder) {
this.clientBuilder = clientBuilder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.github.breadmoirai.breadbot.framework.command.internal.builder;

import com.github.breadmoirai.breadbot.framework.builder.BreadBotClientBuilder;
import com.github.breadmoirai.breadbot.framework.builder.BreadBotBuilder;
import com.github.breadmoirai.breadbot.framework.builder.CommandHandleBuilder;
import com.github.breadmoirai.breadbot.framework.builder.CommandParameterBuilder;
import com.github.breadmoirai.breadbot.framework.command.Command;
Expand Down Expand Up @@ -50,7 +50,7 @@ public class CommandHandleBuilderImpl implements CommandHandleBuilderInternal {
private final Method declaringMethod;
private String[] keys;
private String name, group, description;
private final BreadBotClientBuilder clientBuilder;
private final BreadBotBuilder clientBuilder;
private final CommandObjectFactory commandFactory;
private final CommandParameterBuilder[] parameterBuilders;
private final InvokableCommand commandFunction;
Expand All @@ -67,7 +67,7 @@ public class CommandHandleBuilderImpl implements CommandHandleBuilderInternal {
public CommandHandleBuilderImpl(Object declaringObject,
Class<?> declaringClass,
Method declaringMethod,
BreadBotClientBuilder clientBuilder,
BreadBotBuilder clientBuilder,
CommandObjectFactory commandFactory,
CommandParameterBuilder[] parameterBuilders,
InvokableCommand commandFunction,
Expand Down Expand Up @@ -169,7 +169,7 @@ public Object getDeclaringObject() {
}

@Override
public BreadBotClientBuilder getClientBuilder() {
public BreadBotBuilder getClientBuilder() {
return clientBuilder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.github.breadmoirai.breadbot.framework.event;

import com.github.breadmoirai.breadbot.framework.BreadBotClient;
import com.github.breadmoirai.breadbot.framework.BreadBot;
import com.github.breadmoirai.breadbot.framework.command.Command;
import com.github.breadmoirai.breadbot.framework.parameter.CommandArgument;
import com.github.breadmoirai.breadbot.framework.parameter.CommandArgumentList;
Expand Down Expand Up @@ -60,18 +60,18 @@ public static void setDefaultArgumentLimit(int limit) {
DEFAULT_LIMIT = limit;
}

private final BreadBotClient client;
private final BreadBot client;
private final boolean isHelpEvent;

protected CommandArgumentList argumentList;

public CommandEvent(JDA api, long responseNumber, BreadBotClient client, boolean isHelpEvent) {
public CommandEvent(JDA api, long responseNumber, BreadBot client, boolean isHelpEvent) {
super(api, responseNumber);
this.client = client;
this.isHelpEvent = isHelpEvent;
}

public BreadBotClient getClient() {
public BreadBot getClient() {
return client;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.github.breadmoirai.breadbot.framework.event;

import com.github.breadmoirai.breadbot.framework.BreadBotClient;
import com.github.breadmoirai.breadbot.framework.BreadBot;
import com.github.breadmoirai.breadbot.framework.event.internal.CommandEventInternal;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.events.message.guild.GenericGuildMessageEvent;
Expand All @@ -26,5 +26,5 @@
*/
public interface CommandEventFactory {

CommandEventInternal createEvent(GenericGuildMessageEvent event, Message message, BreadBotClient client);
CommandEventInternal createEvent(GenericGuildMessageEvent event, Message message, BreadBot client);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.github.breadmoirai.breadbot.framework.event.internal;

import com.github.breadmoirai.breadbot.framework.BreadBotClient;
import com.github.breadmoirai.breadbot.framework.BreadBot;
import com.github.breadmoirai.breadbot.framework.event.CommandEventFactory;
import com.github.breadmoirai.breadbot.plugins.prefix.PrefixPlugin;
import com.github.breadmoirai.breadbot.util.DiscordPatterns;
Expand All @@ -35,7 +35,7 @@ public CommandEventFactoryImpl(PrefixPlugin prefixSupplier) {
}

@Override
public CommandEventInternal createEvent(GenericGuildMessageEvent event, Message message, BreadBotClient client) {
public CommandEventInternal createEvent(GenericGuildMessageEvent event, Message message, BreadBot client) {
String prefix = prefixModule.getPrefix(event.getGuild());
String contentRaw = message.getContentRaw();
final Matcher matcher = DiscordPatterns.USER_MENTION_PREFIX.matcher(contentRaw);
Expand All @@ -58,7 +58,7 @@ private String getMyId(GenericGuildMessageEvent event) {
return myId;
}

private CommandEventInternal parseContent(GenericGuildMessageEvent event, Message message, BreadBotClient client, String prefix, String contentRaw) {
private CommandEventInternal parseContent(GenericGuildMessageEvent event, Message message, BreadBot client, String prefix, String contentRaw) {
final String[] split = splitContent(contentRaw);
final String key = split[0];
final String content = split[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.github.breadmoirai.breadbot.framework.event.internal;

import com.github.breadmoirai.breadbot.framework.BreadBotClient;
import com.github.breadmoirai.breadbot.framework.BreadBot;
import com.github.breadmoirai.breadbot.framework.command.Command;
import com.github.breadmoirai.breadbot.framework.event.CommandEvent;
import com.github.breadmoirai.breadbot.framework.response.CommandResponseManager;
Expand All @@ -31,7 +31,7 @@ public abstract class CommandEventInternal extends CommandEvent {
private Command command;
private CommandResponseManager manager;

public CommandEventInternal(JDA api, long responseNumber, BreadBotClient client, boolean isHelpEvent) {
public CommandEventInternal(JDA api, long responseNumber, BreadBot client, boolean isHelpEvent) {
super(api, responseNumber, client, isHelpEvent);
manager = CommandResponseManager.factory.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.github.breadmoirai.breadbot.framework.event.internal;

import com.github.breadmoirai.breadbot.framework.BreadBotClient;
import com.github.breadmoirai.breadbot.framework.BreadBot;
import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.Member;
Expand All @@ -39,7 +39,7 @@ public class MessageReceivedCommandEvent extends CommandEventInternal {
private String[] key;
private String content;

MessageReceivedCommandEvent(BreadBotClient client, GenericGuildMessageEvent event, Message message, String prefix, String[] key, String content, boolean isHelpEvent) {
MessageReceivedCommandEvent(BreadBot client, GenericGuildMessageEvent event, Message message, String prefix, String[] key, String content, boolean isHelpEvent) {
super(event.getJDA(), event.getResponseNumber(), client, isHelpEvent);
this.event = event;
this.message = message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.github.breadmoirai.breadbot.framework.internal;

import com.github.breadmoirai.breadbot.framework.BreadBotClient;
import com.github.breadmoirai.breadbot.framework.BreadBot;
import com.github.breadmoirai.breadbot.framework.CommandPlugin;
import com.github.breadmoirai.breadbot.framework.command.Command;
import com.github.breadmoirai.breadbot.framework.command.CommandEngine;
Expand Down Expand Up @@ -48,9 +48,9 @@
import java.util.Map;
import java.util.function.Predicate;

public class BreadBotClientImpl implements BreadBotClient, EventListener {
public class BreadBotClientImpl implements BreadBot, EventListener {

private static final Logger LOG = LoggerFactory.getLogger(BreadBotClient.class);
private static final Logger LOG = LoggerFactory.getLogger(BreadBot.class);

private JDA jda;

Expand Down Expand Up @@ -178,12 +178,12 @@ public Map<String, Command> getCommandMap() {
}

@Override
public boolean hasModule(String pluginName) {
public boolean hasPlugin(String pluginName) {
return pluginName != null && modules.stream().map(CommandPlugin::getName).anyMatch(pluginName::equalsIgnoreCase);
}

@Override
public boolean hasModule(Class<? extends CommandPlugin> pluginClass) {
public boolean hasPlugin(Class<? extends CommandPlugin> pluginClass) {
return moduleTypeMap.containsKey(pluginClass);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.github.breadmoirai.breadbot.framework.parameter;

import com.github.breadmoirai.breadbot.framework.BreadBotClient;
import com.github.breadmoirai.breadbot.framework.BreadBot;
import com.github.breadmoirai.breadbot.framework.event.CommandEvent;
import com.github.breadmoirai.breadbot.util.Arguments;
import com.github.breadmoirai.breadbot.util.Emoji;
Expand Down Expand Up @@ -56,7 +56,7 @@ public interface CommandArgument {
*
* @return a BreadBotClient
*/
default BreadBotClient getClient() {
default BreadBot getClient() {
return getEvent().getClient();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.github.breadmoirai.breadbot.framework.parameter.internal.builder;

import com.github.breadmoirai.breadbot.framework.builder.BreadBotClientBuilder;
import com.github.breadmoirai.breadbot.framework.builder.BreadBotBuilder;
import com.github.breadmoirai.breadbot.framework.builder.CommandParameterBuilder;
import com.github.breadmoirai.breadbot.framework.parameter.CommandArgument;
import com.github.breadmoirai.breadbot.framework.parameter.TypeParser;
Expand All @@ -36,7 +36,7 @@ private CollectionTypes() {


private static <T> void setTypeParser(Class<T> type, CommandParameterBuilder builder) {
final BreadBotClientBuilder clientBuilder = builder.getClientBuilder();
final BreadBotBuilder clientBuilder = builder.getClientBuilder();
final TypeParser<T> typeParser = clientBuilder.getTypeParser(type);
builder.setTypeParser(typeParser);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.github.breadmoirai.breadbot.framework.parameter.internal.builder;

import com.github.breadmoirai.breadbot.framework.CommandPlugin;
import com.github.breadmoirai.breadbot.framework.builder.BreadBotClientBuilder;
import com.github.breadmoirai.breadbot.framework.builder.BreadBotBuilder;
import com.github.breadmoirai.breadbot.framework.builder.CommandHandleBuilder;
import com.github.breadmoirai.breadbot.framework.builder.CommandParameterBuilder;
import com.github.breadmoirai.breadbot.framework.command.internal.CommandPropertyMapImpl;
Expand Down Expand Up @@ -52,7 +52,7 @@ public class CommandParameterBuilderImpl implements CommandParameterBuilder {
private final CommandHandleBuilder commandBuilder;
private final Parameter parameter;
private final CommandPropertyMapImpl map;
private final BreadBotClientBuilder clientBuilder;
private final BreadBotBuilder clientBuilder;
private String paramName;
private int index = 0;
private int width = 1;
Expand All @@ -64,7 +64,7 @@ public class CommandParameterBuilderImpl implements CommandParameterBuilder {
private AbsentArgumentHandler absentArgumentHandler = null;
private Predicate<CommandArgument> argumentPredicate;

public CommandParameterBuilderImpl(BreadBotClientBuilder builder, CommandHandleBuilder commandBuilder, Parameter parameter, CommandPropertyMapImpl map) {
public CommandParameterBuilderImpl(BreadBotBuilder builder, CommandHandleBuilder commandBuilder, Parameter parameter, CommandPropertyMapImpl map) {
this.commandBuilder = commandBuilder;
this.parameter = parameter;
this.clientBuilder = builder;
Expand Down Expand Up @@ -170,7 +170,7 @@ public CommandParameterBuilder configure(Consumer<CommandParameterBuilder> confi
}

@Override
public BreadBotClientBuilder getClientBuilder() {
public BreadBotBuilder getClientBuilder() {
return clientBuilder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.github.breadmoirai.breadbot.plugins.admin;

import com.github.breadmoirai.breadbot.framework.CommandPlugin;
import com.github.breadmoirai.breadbot.framework.builder.BreadBotClientBuilder;
import com.github.breadmoirai.breadbot.framework.builder.BreadBotBuilder;
import net.dv8tion.jda.core.entities.Member;

public interface AdminPlugin extends CommandPlugin {
Expand All @@ -30,7 +30,7 @@ default String getName() {
boolean isAdmin(Member member);

@Override
default void initialize(BreadBotClientBuilder builder) {
default void initialize(BreadBotBuilder builder) {
builder.associatePreprocessorPredicate("admin", Admin.class, event -> isAdmin(event.getMember()));
builder.addCommand(AdminCommand.class);
}
Expand Down
Loading

0 comments on commit aeb84b1

Please sign in to comment.