use of util.Response in project Botnak by Gocnak.
the class SoundEngine method getSoundState.
public Response getSoundState(String name) {
Response toReturn = new Response();
if ("".equals(name)) {
toReturn.setResponseText(getSoundStateString());
toReturn.wasSuccessful();
} else {
if (soundMap.containsKey(name)) {
Sound toCheck = soundMap.get(name);
toReturn.setResponseText("The sound \"!" + name + "\" is currently turned " + (toCheck.isEnabled() ? "ON" : "OFF"));
toReturn.wasSuccessful();
} else {
toReturn.setResponseText("The sound \"!" + name + "\" does not exist!");
}
}
return toReturn;
}
use of util.Response in project Botnak by Gocnak.
the class SoundEngine method setSoundDelay.
public Response setSoundDelay(String first) {
Response toReturn = new Response();
if (!"".equals(first)) {
int soundTime;
soundTime = Utils.getTime(first);
if (soundTime < 0) {
toReturn.setResponseText("Failed to set sound delay; could not parse the given time!");
return toReturn;
}
soundTime = Utils.handleInt(soundTime);
int delay = soundTime / 1000;
toReturn.setResponseText("Sound delay " + (delay < 2 ? (delay == 0 ? "off." : "is now 1 second.") : ("is now " + delay + " seconds.")));
setDelay(soundTime);
toReturn.wasSuccessful();
} else {
toReturn.setResponseText("Failed to set sound delay, usage: !setsound (time)");
}
return toReturn;
}
use of util.Response in project Botnak by Gocnak.
the class SoundEngine method toggleSound.
public Response toggleSound(String name, boolean individualSound) {
Response toReturn = new Response();
boolean newBool;
if (individualSound) {
if (soundMap.containsKey(name)) {
Sound s = soundMap.get(name);
newBool = !s.isEnabled();
s.setEnabled(newBool);
toReturn.wasSuccessful();
toReturn.setResponseText("The sound " + name + " is now turned " + (newBool ? "ON" : "OFF"));
} else {
toReturn.setResponseText("Cannot toggle sound; the sound \"" + name + "\" does not exist!");
}
} else {
newBool = !shouldPlay();
setShouldPlay(newBool);
GUIMain.instance.updateSoundToggle(newBool);
toReturn.wasSuccessful();
toReturn.setResponseText("Sound is now turned " + (newBool ? "ON" : "OFF"));
}
return toReturn;
}
use of util.Response in project Botnak by Gocnak.
the class SoundEngine method removeSound.
public Response removeSound(String name) {
Response toReturn = new Response();
if (!"".equals(name)) {
if (soundMap.containsKey(name)) {
soundMap.remove(name);
toReturn.wasSuccessful();
toReturn.setResponseText("Successfully removed sound \"!" + name + "\" !");
} else {
toReturn.setResponseText("Failed to remove sound, the sound \"!" + name + "\" does not exist!");
}
} else {
toReturn.setResponseText("Failed to remove sound, no specified name!");
}
return toReturn;
}
Aggregations