deps update and small code cleanup
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -28,7 +28,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sedmelluq</groupId>
|
<groupId>com.sedmelluq</groupId>
|
||||||
<artifactId>lavaplayer</artifactId>
|
<artifactId>lavaplayer</artifactId>
|
||||||
<version>1.3.49</version>
|
<version>1.3.50</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sedmelluq</groupId>
|
<groupId>com.sedmelluq</groupId>
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import com.typesafe.config.*;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import net.dv8tion.jda.core.OnlineStatus;
|
import net.dv8tion.jda.core.OnlineStatus;
|
||||||
import net.dv8tion.jda.core.entities.Game;
|
import net.dv8tion.jda.core.entities.Game;
|
||||||
|
|
||||||
@@ -138,7 +137,7 @@ public class BotConfig
|
|||||||
if(owner<=0)
|
if(owner<=0)
|
||||||
{
|
{
|
||||||
prompt.alert(Prompt.Level.ERROR, CONTEXT, "Invalid User ID! Exiting.\n\nConfig Location: " + path.toAbsolutePath().toString());
|
prompt.alert(Prompt.Level.ERROR, CONTEXT, "Invalid User ID! Exiting.\n\nConfig Location: " + path.toAbsolutePath().toString());
|
||||||
System.exit(0);
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -147,31 +146,7 @@ public class BotConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(write)
|
if(write)
|
||||||
{
|
writeToFile();
|
||||||
String original = OtherUtil.loadResource(this, "/reference.conf");
|
|
||||||
byte[] bytes;
|
|
||||||
if(original==null)
|
|
||||||
{
|
|
||||||
bytes = ("token = "+token+"\r\nowner = "+owner).getBytes();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bytes = original.substring(original.indexOf(START_TOKEN)+START_TOKEN.length(), original.indexOf(END_TOKEN))
|
|
||||||
.replace("BOT_TOKEN_HERE", token)
|
|
||||||
.replace("0 // OWNER ID", Long.toString(owner))
|
|
||||||
.trim().getBytes();
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Files.write(path, bytes);
|
|
||||||
}
|
|
||||||
catch(IOException ex)
|
|
||||||
{
|
|
||||||
prompt.alert(Prompt.Level.WARNING, CONTEXT, "Failed to write new config options to config.txt: "+ex
|
|
||||||
+ "\nPlease make sure that the files are not on your desktop or some other restricted area.\n\nConfig Location: "
|
|
||||||
+ path.toAbsolutePath().toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we get through the whole config, it's good to go
|
// if we get through the whole config, it's good to go
|
||||||
valid = true;
|
valid = true;
|
||||||
@@ -182,6 +157,33 @@ public class BotConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void writeToFile()
|
||||||
|
{
|
||||||
|
String original = OtherUtil.loadResource(this, "/reference.conf");
|
||||||
|
byte[] bytes;
|
||||||
|
if(original==null)
|
||||||
|
{
|
||||||
|
bytes = ("token = "+token+"\r\nowner = "+owner).getBytes();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bytes = original.substring(original.indexOf(START_TOKEN)+START_TOKEN.length(), original.indexOf(END_TOKEN))
|
||||||
|
.replace("BOT_TOKEN_HERE", token)
|
||||||
|
.replace("0 // OWNER ID", Long.toString(owner))
|
||||||
|
.trim().getBytes();
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Files.write(path, bytes);
|
||||||
|
}
|
||||||
|
catch(IOException ex)
|
||||||
|
{
|
||||||
|
prompt.alert(Prompt.Level.WARNING, CONTEXT, "Failed to write new config options to config.txt: "+ex
|
||||||
|
+ "\nPlease make sure that the files are not on your desktop or some other restricted area.\n\nConfig Location: "
|
||||||
|
+ path.toAbsolutePath().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isValid()
|
public boolean isValid()
|
||||||
{
|
{
|
||||||
return valid;
|
return valid;
|
||||||
|
|||||||
@@ -58,15 +58,6 @@ public class JMusicBot
|
|||||||
Prompt prompt = new Prompt("JMusicBot", "Switching to nogui mode. You can manually start in nogui mode by including the -Dnogui=true flag.",
|
Prompt prompt = new Prompt("JMusicBot", "Switching to nogui mode. You can manually start in nogui mode by including the -Dnogui=true flag.",
|
||||||
"true".equalsIgnoreCase(System.getProperty("nogui", "false")));
|
"true".equalsIgnoreCase(System.getProperty("nogui", "false")));
|
||||||
|
|
||||||
// check deprecated nogui mode (new way of setting it is -Dnogui=true)
|
|
||||||
for(String arg: args)
|
|
||||||
if("-nogui".equalsIgnoreCase(arg))
|
|
||||||
{
|
|
||||||
prompt.alert(Prompt.Level.WARNING, "GUI", "The -nogui flag has been deprecated. "
|
|
||||||
+ "Please use the -Dnogui=true flag before the name of the jar. Example: java -jar -Dnogui=true JMusicBot.jar");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get and check latest version
|
// get and check latest version
|
||||||
String version = OtherUtil.checkVersion(prompt);
|
String version = OtherUtil.checkVersion(prompt);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user