anpasssung DB Verbindung und Ini ausgabe
This commit is contained in:
1
build.gradle
Normal file → Executable file
1
build.gradle
Normal file → Executable file
@ -25,6 +25,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile "net.dv8tion:JDA:$jdaVersion"
|
compile "net.dv8tion:JDA:$jdaVersion"
|
||||||
compile "org.slf4j:slf4j-simple:1.6.1"
|
compile "org.slf4j:slf4j-simple:1.6.1"
|
||||||
|
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.6'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|||||||
8
shadowrun.cfg
Normal file → Executable file
8
shadowrun.cfg
Normal file → Executable file
@ -14,3 +14,11 @@ en.error2=\ I don't understanding %command%
|
|||||||
en.noNegativ=\ there must not be a negative throw
|
en.noNegativ=\ there must not be a negative throw
|
||||||
en.language= I write now English, maybe
|
en.language= I write now English, maybe
|
||||||
en.emptyCommand=\ The %command% command need a Value
|
en.emptyCommand=\ The %command% command need a Value
|
||||||
|
|
||||||
|
db.on=true
|
||||||
|
db.typ=mysql
|
||||||
|
db.host=localhost
|
||||||
|
db.port=3306
|
||||||
|
db.database=shadowrun_log
|
||||||
|
db.name=root
|
||||||
|
db.pw=root
|
||||||
@ -34,7 +34,7 @@ public class base {
|
|||||||
try {
|
try {
|
||||||
input = new FileInputStream("shadowrun.cfg");
|
input = new FileInputStream("shadowrun.cfg");
|
||||||
config.load(input);
|
config.load(input);
|
||||||
if(!config.containsKey("db.typ")) {
|
if(!config.containsKey("db.typ") || (config.containsKey("db.on") && !config.getProperty("db.on").equals("true"))) {
|
||||||
active = false;
|
active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,8 @@ import java.sql.*;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class db_connect extends DB.base {
|
public class db_connect extends DB.base {
|
||||||
|
|
||||||
@ -50,7 +52,41 @@ public class db_connect extends DB.base {
|
|||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param channelId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Map<String, String> getChannelSettings(String channelId) {
|
||||||
|
Map<String, String> result = new HashMap<>();
|
||||||
|
result.put("lang", "de");
|
||||||
|
|
||||||
|
if(!isActive()) {
|
||||||
|
result.put("sqlActive", "0");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
open();
|
||||||
|
try {
|
||||||
|
conn = getConn();
|
||||||
|
String SQL_SELECT = "SELECT * FROM shadowrun_channelSettings where channelId = ?";
|
||||||
|
|
||||||
|
PreparedStatement preparedStatement = conn.prepareStatement(SQL_SELECT);
|
||||||
|
preparedStatement.setString(1, channelId);
|
||||||
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
result.remove("lang");
|
||||||
|
result.put("lang", rs.getString("lang"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -65,5 +101,15 @@ public class db_connect extends DB.base {
|
|||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
)
|
)
|
||||||
COLLATE='utf8_general_ci'
|
COLLATE='utf8_general_ci'
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE TABLE `shadowrun_log` (
|
||||||
|
`id` INT NOT NULL AUTO_INCREMENT,
|
||||||
|
`zeitstempel` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
`channelId` VARCHAR(50) NOT NULL DEFAULT '0',
|
||||||
|
`lang` VARCHAR(255) NOT NULL DEFAULT 'de'
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
)
|
||||||
|
COLLATE='utf8_general_ci'
|
||||||
;
|
;
|
||||||
*/
|
*/
|
||||||
@ -21,6 +21,7 @@ public class dice extends ListenerAdapter {
|
|||||||
private String prefixIni;
|
private String prefixIni;
|
||||||
private String prefixZitat;
|
private String prefixZitat;
|
||||||
private String prefixTest;
|
private String prefixTest;
|
||||||
|
private String prefixCId;
|
||||||
|
|
||||||
private language langDe = new language("de");
|
private language langDe = new language("de");
|
||||||
private language langEn = new language("en");
|
private language langEn = new language("en");
|
||||||
@ -38,6 +39,7 @@ public class dice extends ListenerAdapter {
|
|||||||
this.prefixIni = "/ini";
|
this.prefixIni = "/ini";
|
||||||
this.prefixTest = "/rollTest";
|
this.prefixTest = "/rollTest";
|
||||||
this.prefixZitat = "/zitat";
|
this.prefixZitat = "/zitat";
|
||||||
|
this.prefixCId = "/cid";
|
||||||
this.db = new db_connect();
|
this.db = new db_connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +48,8 @@ public class dice extends ListenerAdapter {
|
|||||||
if ((!event.getMessage().getContentRaw().startsWith(this.prefixSr)
|
if ((!event.getMessage().getContentRaw().startsWith(this.prefixSr)
|
||||||
&& !event.getMessage().getContentRaw().startsWith(this.prefixIni)
|
&& !event.getMessage().getContentRaw().startsWith(this.prefixIni)
|
||||||
&& !event.getMessage().getContentRaw().startsWith(this.prefixZitat)
|
&& !event.getMessage().getContentRaw().startsWith(this.prefixZitat)
|
||||||
&& !event.getMessage().getContentRaw().startsWith(this.prefixTest))
|
&& !event.getMessage().getContentRaw().startsWith(this.prefixTest)
|
||||||
|
&& !event.getMessage().getContentRaw().startsWith(this.prefixCId))
|
||||||
|| (event.getChannelType() != ChannelType.TEXT && event.getChannelType() != ChannelType.PRIVATE)) {
|
|| (event.getChannelType() != ChannelType.TEXT && event.getChannelType() != ChannelType.PRIVATE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -78,6 +81,8 @@ public class dice extends ListenerAdapter {
|
|||||||
this.rollTest(event);
|
this.rollTest(event);
|
||||||
else if (event.getMessage().getContentRaw().startsWith(this.prefixZitat))
|
else if (event.getMessage().getContentRaw().startsWith(this.prefixZitat))
|
||||||
this.zitat(event);
|
this.zitat(event);
|
||||||
|
else if (event.getMessage().getContentRaw().startsWith(this.prefixCId))
|
||||||
|
this.cid(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,6 +453,9 @@ public class dice extends ListenerAdapter {
|
|||||||
int dice = new Random().nextInt(600);
|
int dice = new Random().nextInt(600);
|
||||||
event.getChannel().sendMessage(quotes[dice%6]).queue();
|
event.getChannel().sendMessage(quotes[dice%6]).queue();
|
||||||
}
|
}
|
||||||
|
private void cid(MessageReceivedEvent event) {
|
||||||
|
event.getChannel().sendMessage(getAsMention(event) + " " + event.getChannel().getId()).queue();
|
||||||
|
}
|
||||||
|
|
||||||
private String getEffectiveName(MessageReceivedEvent event) {
|
private String getEffectiveName(MessageReceivedEvent event) {
|
||||||
if(event.getMember() == null) {
|
if(event.getMember() == null) {
|
||||||
|
|||||||
@ -139,19 +139,33 @@ public class shadowrun implements Runnable{
|
|||||||
EmbedBuilder outputBox = new EmbedBuilder();
|
EmbedBuilder outputBox = new EmbedBuilder();
|
||||||
outputBox.setColor(Color.BLACK);
|
outputBox.setColor(Color.BLACK);
|
||||||
outputBox.setTitle("Initiative:");
|
outputBox.setTitle("Initiative:");
|
||||||
|
String channelId = "542202034330271759";
|
||||||
|
|
||||||
while (in.hasNextLine()) {
|
while (in.hasNextLine()) {
|
||||||
message = in.nextLine().trim();
|
message = in.nextLine().trim();
|
||||||
if(message.trim().equals("FIN")) {
|
if(message.trim().equals("FIN")) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
String[] msgParts = message.split("\\|",3);
|
if(message.startsWith("out:")) {
|
||||||
//jda.getUserById(msgParts[0]).getName();
|
String[] msgParts = message.split(":", 2);
|
||||||
|
if(!msgParts[1].equals(""))
|
||||||
|
channelId = msgParts[1];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
outputBox.addField( msgParts[0], msgParts[1], false);
|
String[] msgParts = message.split("\\|");
|
||||||
|
//jda.getUserById(msgParts[0]).getName();
|
||||||
|
StringBuilder iniTicks = new StringBuilder();
|
||||||
|
iniTicks.append(msgParts[1]);
|
||||||
|
for(int i = 2; i < msgParts.length; i++) {
|
||||||
|
iniTicks.append("\t - \t ");
|
||||||
|
iniTicks.append(msgParts[i]);
|
||||||
|
}
|
||||||
|
outputBox.addField(msgParts[0], iniTicks.toString(), false);
|
||||||
|
}
|
||||||
out.println("ACKSend");
|
out.println("ACKSend");
|
||||||
}
|
}
|
||||||
jda.getTextChannelById("542202034330271759").sendMessage(outputBox.build()).queue();
|
jda.getTextChannelById(channelId).sendMessage(outputBox.build()).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
src/main/java/core/Controller.java
Executable file
4
src/main/java/core/Controller.java
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
package core;
|
||||||
|
|
||||||
|
public class Controller {
|
||||||
|
}
|
||||||
8
src/main/java/core/sample.fxml
Executable file
8
src/main/java/core/sample.fxml
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<GridPane fx:controller="core.Controller"
|
||||||
|
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
|
||||||
|
</GridPane>
|
||||||
Reference in New Issue
Block a user