Skip to content

Commit 5196cb4

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents ef5d9a7 + e155908 commit 5196cb4

File tree

6 files changed

+161
-26
lines changed

6 files changed

+161
-26
lines changed

pom.xml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>de.presti.ree6</groupId>
88
<artifactId>Ree6-SQL</artifactId>
99
<description>This is the SQL-Module for Ree6!</description>
10-
<version>1.3.0</version>
10+
<version>1.4.1</version>
1111

1212
<properties>
1313
<sonar.organization>ree6-applications</sonar.organization>
@@ -27,7 +27,8 @@
2727

2828
<dependencies>
2929

30-
<!-- Database -->
30+
31+
<!-- Hibernate -->
3132
<dependency>
3233
<groupId>org.hibernate.orm</groupId>
3334
<artifactId>hibernate-core</artifactId>
@@ -38,26 +39,22 @@
3839
<artifactId>hibernate-community-dialects</artifactId>
3940
<version>6.1.6.Final</version>
4041
</dependency>
41-
<dependency>
42-
<groupId>org.hibernate.orm</groupId>
43-
<artifactId>hibernate-hikaricp</artifactId>
44-
<version>6.1.6.Final</version>
45-
</dependency>
42+
43+
<!-- Hikari -->
44+
4645
<dependency>
4746
<groupId>com.zaxxer</groupId>
4847
<artifactId>HikariCP</artifactId>
4948
<version>5.0.1</version>
5049
</dependency>
5150
<dependency>
52-
<groupId>org.mariadb.jdbc</groupId>
53-
<artifactId>mariadb-java-client</artifactId>
54-
<version>3.1.1</version>
55-
</dependency>
56-
<dependency>
57-
<groupId>org.xerial</groupId>
58-
<artifactId>sqlite-jdbc</artifactId>
59-
<version>3.40.0.0</version>
51+
<groupId>org.hibernate.orm</groupId>
52+
<artifactId>hibernate-hikaricp</artifactId>
53+
<version>6.1.6.Final</version>
6054
</dependency>
55+
56+
<!-- Jakarta -->
57+
6158
<dependency>
6259
<groupId>jakarta.persistence</groupId>
6360
<artifactId>jakarta.persistence-api</artifactId>
@@ -74,6 +71,18 @@
7471
<version>4.0.0</version>
7572
</dependency>
7673

74+
<!-- JDBC -->
75+
<dependency>
76+
<groupId>org.mariadb.jdbc</groupId>
77+
<artifactId>mariadb-java-client</artifactId>
78+
<version>3.1.2</version>
79+
</dependency>
80+
<dependency>
81+
<groupId>org.xerial</groupId>
82+
<artifactId>sqlite-jdbc</artifactId>
83+
<version>3.40.0.0</version>
84+
</dependency>
85+
7786
<!-- Utility -->
7887
<dependency>
7988
<groupId>org.reflections</groupId>
@@ -105,7 +114,7 @@
105114
<dependency>
106115
<groupId>io.sentry</groupId>
107116
<artifactId>sentry</artifactId>
108-
<version>6.11.0</version>
117+
<version>6.13.0</version>
109118
</dependency>
110119
</dependencies>
111120

src/main/java/de/presti/ree6/sql/SQLSession.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ public SQLSession(String databaseUser, String databaseName, String databasePassw
119119
});
120120
}
121121

122+
if (databaseTyp == DatabaseTyp.SQLite) {
123+
try {
124+
Class.forName("org.sqlite.JDBC");
125+
} catch (ClassNotFoundException e) {
126+
// Somehow this fixes Issues?
127+
log.error("Couldn't load SQLite Driver!", e);
128+
}
129+
}
130+
122131
setMaxPoolSize(maxPoolSize);
123132
setDatabaseTyp(databaseTyp);
124133
setJdbcURL(buildConnectionURL());
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package de.presti.ree6.sql.entities;
2+
3+
import com.google.gson.JsonElement;
4+
import de.presti.ree6.sql.converter.JsonAttributeConverter;
5+
import jakarta.persistence.*;
6+
import lombok.Getter;
7+
import lombok.Setter;
8+
9+
@Getter
10+
@Setter
11+
@Entity
12+
@Table(name = "StreamActions")
13+
public class StreamAction {
14+
15+
/**
16+
* The ID of the Guild.
17+
*/
18+
@Id
19+
@Column(name = "guildId")
20+
long guildId;
21+
22+
/**
23+
* The name of the action.
24+
*/
25+
@Column(name = "actionName")
26+
String actionName;
27+
28+
/**
29+
* The related Twitch Auth.
30+
*/
31+
@ManyToOne(optional = false)
32+
@JoinColumn(name="auth_id", nullable=false, updatable=false)
33+
TwitchIntegration integration;
34+
35+
/**
36+
* Typ of the Listener
37+
*/
38+
@Column(name = "listener")
39+
StreamListener listener;
40+
41+
/**
42+
* Extra Arguments used on the listeners.
43+
*/
44+
@Column(name = "argument")
45+
String argument;
46+
47+
/**
48+
* The Actions that are to be executed.
49+
*/
50+
@Column(name = "actions")
51+
@Convert(converter = JsonAttributeConverter.class)
52+
JsonElement actions;
53+
54+
public enum StreamListener {
55+
REDEMPTION, FOLLOW,
56+
}
57+
}

src/main/java/de/presti/ree6/sql/entities/Tickets.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package de.presti.ree6.sql.entities;
22

3-
import jakarta.persistence.Column;
4-
import jakarta.persistence.Entity;
5-
import jakarta.persistence.Id;
6-
import jakarta.persistence.Table;
3+
import com.google.gson.JsonElement;
4+
import de.presti.ree6.sql.converter.JsonAttributeConverter;
5+
import jakarta.persistence.*;
76
import lombok.Getter;
87
import lombok.Setter;
98
import org.hibernate.annotations.ColumnDefault;
@@ -37,10 +36,17 @@ public class Tickets {
3736
long ticketCategory;
3837

3938
/**
40-
* The Category ID of the Archive category.
39+
* The ID of the channel that is used to send the transcripts to.
4140
*/
42-
@Column(name = "archiveCategory")
43-
long archiveCategory;
41+
@Column(name = "logChannelId")
42+
long logChannelId;
43+
44+
/**
45+
* The Token for the Webhook.
46+
*/
47+
@Column(name = "logChannelToken")
48+
String logChannelWebhookToken;
49+
4450

4551
/**
4652
* The Ticket counter.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package de.presti.ree6.sql.entities;
2+
3+
import jakarta.persistence.*;
4+
import lombok.Getter;
5+
import lombok.Setter;
6+
7+
/**
8+
* SQL Entity for the Twitch Integration.
9+
*/
10+
@Getter
11+
@Setter
12+
@Entity
13+
@Table(name = "TwitchIntegration")
14+
public class TwitchIntegration {
15+
16+
/**
17+
* The ID of the Twitch Channel.
18+
*/
19+
@Id
20+
@Column(name = "channel_id")
21+
String channelId;
22+
23+
/**
24+
* The ID of the Discord User its linked to.
25+
*/
26+
@Column(name = "user_id")
27+
long userId;
28+
29+
/**
30+
* The Access Token.
31+
*/
32+
@Column(name = "token")
33+
String token;
34+
35+
/**
36+
* The Refresh Token.
37+
*/
38+
@Column(name = "refresh")
39+
String refresh;
40+
41+
/**
42+
* The Name of the Twitch Channel.
43+
*/
44+
@Column(name = "channel_name")
45+
String name;
46+
47+
/**
48+
* The expiration time of the token.
49+
*/
50+
@Column(name = "expires")
51+
int expiresIn;
52+
}

src/main/java/de/presti/ree6/sql/util/LevelUtil.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,15 @@ public static float[] getLevelingValues(UserLevel userLevel) {
8787
* @return the Progress.
8888
*/
8989
public static double getProgress(UserLevel userLevel) {
90-
long currentLevelXP = getTotalExperienceForLevel(userLevel.getLevel(), userLevel);
91-
long nextLevelXP = getTotalExperienceForLevel(userLevel.getLevel() + 1, userLevel);
90+
double currentLevelXP = (double)getTotalExperienceForLevel(userLevel.getLevel(), userLevel);
91+
double nextLevelXP = (double)getTotalExperienceForLevel(userLevel.getLevel() + 1, userLevel);
9292

9393
double neededXP = nextLevelXP - currentLevelXP;
9494
double earnedXP = nextLevelXP - userLevel.getExperience();
9595

96-
return 100 - (int) Math.ceil((earnedXP / neededXP) * 100);
96+
if (neededXP <= 0) return 0;
97+
98+
return 100 - Math.ceil((earnedXP / neededXP) * 100);
9799
}
98100

99101
/**

0 commit comments

Comments
 (0)