Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Matthew Cech
2019-08-07 20:47:31 -07:00
53 changed files with 933 additions and 413 deletions
+51 -10
View File
@@ -1,11 +1,56 @@
package core;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import commands.characters.CommandCharacterMain;
import commands.general.*;
import commands.general.CommandBeansShow;
import commands.general.CommandBenchmark;
import commands.general.CommandBetBeans;
import commands.general.CommandBetHistory;
import commands.general.CommandBlurry;
import commands.general.CommandBoop;
import commands.general.CommandCatch;
import commands.general.CommandChangeIndicator;
import commands.general.CommandChoose;
import commands.general.CommandColiru;
import commands.general.CommandColor;
import commands.general.CommandCrouton;
import commands.general.CommandDBFlush;
import commands.general.CommandDBStats;
import commands.general.CommandDoWork;
import commands.general.CommandEightBall;
import commands.general.CommandFetch;
import commands.general.CommandGiveBeans;
import commands.general.CommandHelp;
import commands.general.CommandHelpBuilder;
import commands.general.CommandInfo;
import commands.general.CommandInvite;
import commands.general.CommandJDoodle;
import commands.general.CommandLeaderboard;
import commands.general.CommandMap;
import commands.general.CommandPerish;
import commands.general.CommandPing;
import commands.general.CommandRPEnd;
import commands.general.CommandRPG;
import commands.general.CommandRPStart;
import commands.general.CommandRating;
import commands.general.CommandRemind;
import commands.general.CommandRole;
import commands.general.CommandRoll;
import commands.general.CommandShutdown;
import commands.general.CommandStark;
import commands.general.CommandStats;
import commands.general.CommandTeey;
import commands.general.CommandTweet;
import commands.general.CommandWolfram;
import commands.general.CommandYeet;
import commands.guildrole.CommandGuildRoleMain;
import commands.mod.CommandModMain;
import commands.music.CommandMusicMain;
import commands.poll.CommandPollMain;
import commands.raffle.CommandRaffleMain;
import dataStructures.KittyChannel;
import dataStructures.KittyGuild;
import dataStructures.KittyRating;
@@ -70,12 +115,9 @@ public class CommandManager
this.register(LocCommands.stub("indicator"), new CommandChangeIndicator(KittyRole.Admin, KittyRating.Safe));
// Mod
this.register(LocCommands.stub("poll"), new CommandPollManage(KittyRole.Mod, KittyRating.Safe));
this.register(LocCommands.stub("givebeans"), new CommandGiveBeans(KittyRole.Mod, KittyRating.Safe));
this.register(LocCommands.stub("rpg"), new CommandRPG(KittyRole.Mod, KittyRating.Safe));
this.register(LocCommands.stub("rafflestart"), new CommandRaffleStart(KittyRole.Mod, KittyRating.Safe));
this.register(LocCommands.stub("rafflespin"), new CommandRaffleSpin(KittyRole.Mod, KittyRating.Safe));
this.register(LocCommands.stub("raffleend"), new CommandRaffleEnd(KittyRole.Mod, KittyRating.Safe));
this.register(LocCommands.stub("mod"), new CommandModMain(KittyRole.Mod, KittyRating.Safe));
// General
this.register(LocCommands.stub("fetch"), new CommandFetch(KittyRole.General, KittyRating.Safe));
@@ -88,9 +130,6 @@ public class CommandManager
this.register(LocCommands.stub("choose"), new CommandChoose(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("help"), new CommandHelp(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("info, about"), new CommandInfo(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("vote"), new CommandPollVote(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("results"), new CommandPollResults(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("showpoll"), new CommandPollShow(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("wolfram"), new CommandWolfram(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("c++, g++, cplus, cpp"), new CommandColiru(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("java, jdoodle"), new CommandJDoodle(KittyRole.General, KittyRating.Safe));
@@ -107,12 +146,14 @@ public class CommandManager
this.register(LocCommands.stub("bethistory"), new CommandBetHistory(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("crouton"), new CommandCrouton(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("benchmark, bench"), new CommandBenchmark(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("rafflejoin"), new CommandRaffleJoin(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("leaderboard"), new CommandLeaderboard(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("color, colour"), new CommandColor(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("remind"), new CommandRemind(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("role"), new CommandGuildRoleMain(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("character"), new CommandCharacterMain(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("raffle"), new CommandRaffleMain(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("poll"), new CommandPollMain(KittyRole.General, KittyRating.Safe));
this.register(LocCommands.stub("music"), new CommandMusicMain(KittyRole.General, KittyRating.Safe));
}
// Allows the command manager to keep track of a command. Takes a pair (the un-localized and localzied commands)
+9 -1
View File
@@ -7,6 +7,9 @@ import java.util.concurrent.Semaphore;
import javax.security.auth.login.LoginException;
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
import com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager;
import core.lua.PluginManager;
import dataStructures.*;
import main.Main;
@@ -17,6 +20,7 @@ import net.dv8tion.jda.core.entities.*;
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
import offline.Ref;
import utils.AdminControl;
import utils.AudioUtils;
import utils.GlobalLog;
import utils.LogFilter;
@@ -50,6 +54,9 @@ public class ObjectBuilderFactory
// Command manager
private static CommandManager commandManager;
//Audio track manager
private static AudioPlayerManager audioPlayer = new DefaultAudioPlayerManager();
// Localization classes - these are singletons, but should be initialized before almost all other
// things so their inclusion in the factory is to ensure they're started at the correct time.
@SuppressWarnings("unused") private static LocStrings locStrings;
@@ -140,7 +147,8 @@ public class ObjectBuilderFactory
else
{
// Construct a new guild with defaults
guild = new KittyGuild(uid, new AdminControl(event.getGuild()), emotesString);
guild = new KittyGuild(uid, new AdminControl(event.getGuild()), emotesString,
new AudioUtils(event.getGuild(), audioPlayer.createPlayer()));
DatabaseManager.instance.globalRegister(guild);
guildCache.put(uid, guild);
}
+4 -4
View File
@@ -42,12 +42,12 @@ public abstract class SubCommand
// Called by the Command manager - this will run the command
// if the issuing user has the permission to do so!
protected final void Invoke(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
protected final SubCommandFormattable Invoke(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
{
if(!CanCall(guild, channel, user))
return;
return null;
OnRun(guild, channel, user, input);
return OnRun(guild, channel, user, input);
}
public KittyRating Rating()
@@ -60,5 +60,5 @@ public abstract class SubCommand
return roleLevel;
}
public abstract SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input);
public abstract SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input);
}
+18 -5
View File
@@ -5,6 +5,7 @@ import java.util.HashMap;
import dataStructures.KittyChannel;
import dataStructures.KittyGuild;
import dataStructures.KittyUser;
import dataStructures.UserInput;
import utils.GlobalLog;
public class SubCommandFramework
@@ -25,10 +26,22 @@ public class SubCommandFramework
GlobalLog.log("Registered SubCommand " + name);
}
public SubCommandFormattable run(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
public SubCommandFormattable run(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input)
{
System.out.print(input);
SubCommandFormattable res = commands.get(input.split(" ")[0].toLowerCase()).OnRun(guild, channel, user, input.substring(input.indexOf(" ")));
return res;
SubCommand res = commands.get(input.args.split(" ")[0].toLowerCase());
try
{
input.args = input.args.substring(input.args.indexOf(' ')).trim();
}
catch(Exception e){}
try
{
return res.Invoke(guild, channel, user, input);
}
catch(Exception e)
{
return new SubCommandFormattable("That's not a valid subcommand!");
}
}
}
}