Files
KittyBot/src/core/LocCommands.java
T

59 lines
1.4 KiB
Java

package core;
import java.util.ArrayList;
import utils.GlobalLog;
import utils.LogFilter;
import utils.io.FileMonitor;
import dataStructures.Pair;
// Performs the same localization for the strings associated with command names as
// is performed with general strings in the application
public class LocCommands extends BaseLocFile
{
public static final String fileName = "locCommands.config";
public static final String function = "LocCommands.stub";
private static LocCommands instance;
public LocCommands()
{
super(fileName, function);
GlobalLog.log(LogFilter.Core, "Initializing " + this.getClass().getSimpleName());
if(instance == null)
{
instance = this;
updateLocFromDisk();
scrapeAll();
saveLocToDisk();
fileMonitor = new FileMonitor(filename);
}
else
{
GlobalLog.error(LogFilter.Core, "You can't have two of the following: " + this.getClass().getSimpleName());
}
}
// Returns a pair, the raw key and the stub key
public static Pair<String, String> stub(String toStub)
{
return new Pair<String, String>(toStub, instance.getKey(toStub));
}
// Gets all of the un-translated defaults in the commands list.
public static ArrayList<String> getUnlocalizedCommands()
{
ArrayList<String> raw = new ArrayList<>();
instance.stringStore.forEach((pair) -> raw.add((String)((Pair<?, ?>)pair).First ));
return raw;
}
public static void upkeep()
{
instance.update();
}
}