Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
"Type","Key","Value"
|
"Type","Key","Value"
|
||||||
|
"Globals","mode (dev or release)","dev"
|
||||||
"Localized Commands","beans",""
|
"Localized Commands","beans",""
|
||||||
"Localized Commands","benchmark, bench",""
|
"Localized Commands","benchmark, bench",""
|
||||||
"Localized Commands","bet",""
|
"Localized Commands","bet",""
|
||||||
|
|||||||
|
@@ -106,6 +106,8 @@ public class CommandManager
|
|||||||
this.register(LocCommands.stub("raffle"), new CommandRaffleMain(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("poll"), new CommandPollMain(KittyRole.General, KittyRating.Safe));
|
||||||
this.register(LocCommands.stub("music"), new CommandMusicMain(KittyRole.General, KittyRating.Safe));
|
this.register(LocCommands.stub("music"), new CommandMusicMain(KittyRole.General, KittyRating.Safe));
|
||||||
|
this.register(LocCommands.stub("defaultdance"), new CommandDefaultDance(KittyRole.General, KittyRating.Safe));
|
||||||
|
this.register(LocCommands.stub("getsauce"), new CommandGetSauce(KittyRole.General, KittyRating.Safe));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allows the command manager to keep track of a command. Takes a pair (the un-localized and localzied commands)
|
// Allows the command manager to keep track of a command. Takes a pair (the un-localized and localzied commands)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class Config
|
|||||||
sections = new Vector<IConfigSection>();
|
sections = new Vector<IConfigSection>();
|
||||||
|
|
||||||
// Add all sections
|
// Add all sections
|
||||||
|
sections.add(new ConfigGlobals());
|
||||||
sections.add(new LocCommands());
|
sections.add(new LocCommands());
|
||||||
sections.add(new LocStrings());
|
sections.add(new LocStrings());
|
||||||
sections.add(new CommandEnabler());
|
sections.add(new CommandEnabler());
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package core;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import dataStructures.KittyStartupMode;
|
||||||
|
import utils.GlobalLog;
|
||||||
|
|
||||||
|
// Want to add a single item to the config file? This is where that lives.
|
||||||
|
public class ConfigGlobals implements IConfigSection
|
||||||
|
{
|
||||||
|
// Defined const variables
|
||||||
|
public static final String header = "Globals";
|
||||||
|
public static ConfigGlobals instance;
|
||||||
|
|
||||||
|
|
||||||
|
// A pile of variables being manually tracked/serialized to the config file
|
||||||
|
private static final String startupStyleKey = "mode (dev or release)";
|
||||||
|
private KittyStartupMode startupStyleValue = KittyStartupMode.Dev;
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
public ConfigGlobals()
|
||||||
|
{
|
||||||
|
if(instance == null)
|
||||||
|
instance = this;
|
||||||
|
else
|
||||||
|
GlobalLog.error("Attempted to initialize a second config globals! Probably don't do this!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSectionTitle()
|
||||||
|
{
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static KittyStartupMode getStartupMode()
|
||||||
|
{
|
||||||
|
return instance.startupStyleValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void consume(List<ConfigItem> pairs)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < pairs.size(); ++i)
|
||||||
|
{
|
||||||
|
String key = pairs.get(i).key;
|
||||||
|
String value = pairs.get(i).value;
|
||||||
|
|
||||||
|
// Parse startup style
|
||||||
|
if(key.equalsIgnoreCase(startupStyleKey))
|
||||||
|
{
|
||||||
|
startupStyleValue = KittyStartupMode.Dev;
|
||||||
|
|
||||||
|
if(value.equalsIgnoreCase(KittyStartupMode.Release.name()))
|
||||||
|
startupStyleValue = KittyStartupMode.Release;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ConfigItem> produce()
|
||||||
|
{
|
||||||
|
List<ConfigItem> items = new ArrayList<ConfigItem>();
|
||||||
|
items.add(new ConfigItem(getSectionTitle(), startupStyleKey, startupStyleValue.name().toLowerCase()));
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,9 +6,9 @@ import utils.StringUtils;
|
|||||||
// perform any parsing past naming columns, and just holds the raw data.
|
// perform any parsing past naming columns, and just holds the raw data.
|
||||||
public class ConfigItem
|
public class ConfigItem
|
||||||
{
|
{
|
||||||
public String type;
|
public String type; // The section this specific key/value pair belongs to. This almost certainly will appear in multiple places.
|
||||||
public String key;
|
public String key; // A unique key for a given lookup value for the specified section. Keys, within sections, are unique.
|
||||||
public String value;
|
public String value; // The value assocaited with the key.
|
||||||
public static final int items = 3;
|
public static final int items = 3;
|
||||||
public static final String[] header = {"Type","Key","Value"};
|
public static final String[] header = {"Type","Key","Value"};
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import dataStructures.Pair;
|
|||||||
public class LocCommands extends BaseLocFile implements IConfigSection
|
public class LocCommands extends BaseLocFile implements IConfigSection
|
||||||
{
|
{
|
||||||
// Defined const variables
|
// Defined const variables
|
||||||
public static final String HeaderName = "Localized Commands";
|
public static final String header = "Localized Commands";
|
||||||
public static final String function = "LocCommands.stub";
|
public static final String function = "LocCommands.stub";
|
||||||
|
|
||||||
// Instance
|
// Instance
|
||||||
@@ -20,7 +20,7 @@ public class LocCommands extends BaseLocFile implements IConfigSection
|
|||||||
// Constructor
|
// Constructor
|
||||||
public LocCommands()
|
public LocCommands()
|
||||||
{
|
{
|
||||||
super(HeaderName, function);
|
super(header, function);
|
||||||
|
|
||||||
GlobalLog.log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName());
|
GlobalLog.log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName());
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import dataStructures.KittyCore;
|
|||||||
import dataStructures.KittyGuild;
|
import dataStructures.KittyGuild;
|
||||||
import dataStructures.KittyRating;
|
import dataStructures.KittyRating;
|
||||||
import dataStructures.KittyRole;
|
import dataStructures.KittyRole;
|
||||||
|
import dataStructures.KittyStartupMode;
|
||||||
import dataStructures.KittyUser;
|
import dataStructures.KittyUser;
|
||||||
import main.Main;
|
import main.Main;
|
||||||
import net.dv8tion.jda.core.AccountType;
|
import net.dv8tion.jda.core.AccountType;
|
||||||
@@ -382,9 +383,15 @@ public class ObjectBuilderFactory
|
|||||||
{
|
{
|
||||||
lazyInit();
|
lazyInit();
|
||||||
|
|
||||||
|
// Determine token based on config. Default to test token.
|
||||||
|
String tokenToUse = Ref.TestToken;
|
||||||
|
if(ConfigGlobals.getStartupMode() == KittyStartupMode.Release)
|
||||||
|
tokenToUse = Ref.Token;
|
||||||
|
|
||||||
|
// Construct bot based on token
|
||||||
kitty = new JDABuilder(AccountType.BOT)
|
kitty = new JDABuilder(AccountType.BOT)
|
||||||
.setToken(Ref.TestToken).buildBlocking();
|
.setToken(tokenToUse).buildBlocking();
|
||||||
kitty.getPresence().setGame(Game.playing("with digital yarn"));
|
kitty.getPresence().setGame(Game.playing("with a laser pointer"));
|
||||||
kitty.addEventListener(new Main());
|
kitty.addEventListener(new Main());
|
||||||
|
|
||||||
return new KittyCore(kitty);
|
return new KittyCore(kitty);
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package dataStructures;
|
||||||
|
|
||||||
|
public enum KittyStartupMode
|
||||||
|
{
|
||||||
|
Dev(1), Release(2);
|
||||||
|
|
||||||
|
private final int value;
|
||||||
|
private KittyStartupMode(int value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue()
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user