Skip to content

Commit adab914

Browse files
authored
Merge pull request #4 from Xen0Xys/V2.0.1
V2.1.0
2 parents 8477492 + eae9da7 commit adab914

File tree

123 files changed

+781
-131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+781
-131
lines changed

.gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
Server
2-
Libs
32
.idea
4-
out
5-
DiscordAuth.iml
3+
out

DiscordAuth.iml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module version="4">
3+
<component name="FacetManager">
4+
<facet type="minecraft" name="Minecraft">
5+
<configuration>
6+
<autoDetectTypes>
7+
<platformType>SPIGOT</platformType>
8+
</autoDetectTypes>
9+
</configuration>
10+
</facet>
11+
</component>
12+
<component name="McpModuleSettings">
13+
<option name="srgType" value="SRG" />
14+
</component>
15+
</module>

Libs/JDASpigot.jar

10.2 MB
Binary file not shown.

Libs/Xen0Lib-1.1.3.jar

341 KB
Binary file not shown.

README.md

+66-17
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
1-
# DiscordAuth
1+
# DiscordAuth V2.0.1
22
DiscordAuth plugin permit Discord server's owners to manage access to their Minecraft server:
33

4-
First create a channel and post a message, and a reaction.
5-
People who react to this message can create an account from their DM (stored in MySQL).
6-
Player can connect to Minecraft server and do "/login <password>"
7-
You can also setup a channel for sending informations like player's connections, disconnections and advancements! (configurable)
4+
- First create a channel and post a message, and a reaction.
5+
- People who react to this message can create an account from their DM (stored in MySQL).
6+
- Player can connect to Minecraft server and do "/login"
7+
- You can also setup a channel for sending informations like player's connections, disconnections and advancements! (configurable)
88

9+
10+
## Warning!
911
**This plugin need JDASpigot plugin to work: https://www.spigotmc.org/resources/jdaspigot.41074/**
1012

11-
### Configuration:
13+
## Configuration:
1214

1315
```yaml
16+
#
17+
# THANKS FOR USING DISCORDAUTH!
18+
#
19+
# Notes: certain settings need to be changed, there are noted by "#*"
20+
21+
# If MySQL is disabled, plugin will use SQLite
1422
mysql:
23+
enable: false
1524
host: 0.0.0.0
1625
port: 3306
1726
user: username
1827
password: password
1928
database: database_name
2029

2130
discord:
22-
# Put here your bot token
31+
#* Put here your bot token
2332
token: token
33+
# Disable discord part of the plugin, but keep server's safety and account management
34+
only_safety: false
2435
# Put here your discord guild id
2536
guild_id: 0
2637
# Put here the id of the message to which you want people to react to access the server
@@ -33,28 +44,66 @@ discord:
3344
enable_connection_message: true
3445
# When a player send message on Minecraft or Discord server, send message on Discord or Minecraft server respectively
3546
enable_shared_chat: true
36-
# Send DM to unregister user who has react
47+
# Send DM to unregister user who has reacted (useful to disable new players joining)
3748
send_message_to_unregister_users: true
3849
# Send advancements in main channel
3950
send_advancements: true
51+
# Send message in main channel when a player die (with his dye reason)
52+
send_death_messages: true
53+
# Add logo to private messages response
54+
logo:
55+
enable: false
56+
url: null
57+
# Set bot status here
58+
activity:
59+
enable: false
60+
# Can be PLAYING, STREAMING, LISTENING or WATCHING
61+
type: PLAYING
62+
text: DiscordAuth V2.0!
63+
# Only for streaming
64+
url: null
4065

4166
encryption:
4267
# If you want to encrypt ip too (ip encryption use same encryption string)
4368
encrypt_ip: false
44-
# If you want to add an additional string to prevent bruteforce hack (if you change it after there is passwords, You will not be able to log in!)
69+
# If you want to add a string to prevent bruteforce hack (if you change it after there is passwords, You will not be able to log in!)
70+
# This function is also known as "salt"
4571
additional_encryption_string:
4672
enable: false
4773
string: null
4874

49-
# Only use for first spawn
75+
# Spawn point settings
5076
spawnpoint:
51-
world_name: world
52-
x: 0
53-
y: 80
54-
z: 0
55-
facing:
56-
pitch: 0
57-
yaw: 0
77+
# Enable first time spawn point
78+
first_time_tp: false
79+
# Tp player at spawn point on login
80+
tp_on_login: false
81+
# Respawn settings
82+
respawn:
83+
# Tp player to spawn point if his die
84+
enable: false
85+
# If enabled, player will be tp at death even if his had a bed respawn
86+
even_with_bed: false
87+
# Spawn point location settings
88+
infos:
89+
world_name: world
90+
x: 0
91+
y: 80
92+
z: 0
93+
facing:
94+
pitch: 0
95+
yaw: 0
96+
97+
other:
98+
# Language file that will be used (can be custom file name in DiscordAuth/resources folder)
99+
# Can be "en_EN" or "fr_FR"
100+
language: en_EN
101+
# Determine if server use UUID or Username
102+
premium: true
103+
# Session duration in seconds, set 0 to disable
104+
session_duration: 3600
105+
# Set if login window is displayed when player connect or logout
106+
aggressive_login: true
58107
```
59108
60109
Spigot page: https://www.spigotmc.org/resources/discordauth.92286/

dependency-reduced-pom.xml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>fr.xen0xys</groupId>
5+
<artifactId>DiscordAuth</artifactId>
6+
<name>${project.groupId}:${project.artifactId}</name>
7+
<version>2.0.1</version>
8+
<build>
9+
<plugins>
10+
<plugin>
11+
<artifactId>maven-jar-plugin</artifactId>
12+
<version>3.2.0</version>
13+
<configuration>
14+
<outputDirectory>Server/plugins</outputDirectory>
15+
</configuration>
16+
</plugin>
17+
<plugin>
18+
<artifactId>maven-shade-plugin</artifactId>
19+
<version>3.2.4</version>
20+
<executions>
21+
<execution>
22+
<phase>package</phase>
23+
<goals>
24+
<goal>shade</goal>
25+
</goals>
26+
</execution>
27+
</executions>
28+
</plugin>
29+
</plugins>
30+
</build>
31+
<repositories>
32+
<repository>
33+
<id>spigot-repo</id>
34+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
35+
</repository>
36+
</repositories>
37+
<dependencies>
38+
<dependency>
39+
<groupId>org.spigotmc</groupId>
40+
<artifactId>spigot</artifactId>
41+
<version>1.18-R0.1-SNAPSHOT</version>
42+
<scope>provided</scope>
43+
</dependency>
44+
<dependency>
45+
<groupId>fr.xen0xys</groupId>
46+
<artifactId>Xen0Lib</artifactId>
47+
<version>1.1.3</version>
48+
<scope>system</scope>
49+
<systemPath>${basedir}/Libs/Xen0Lib-1.1.3.jar</systemPath>
50+
</dependency>
51+
<dependency>
52+
<groupId>me.Porama6400</groupId>
53+
<artifactId>JDASpigot</artifactId>
54+
<version>4.3.0</version>
55+
<scope>system</scope>
56+
<systemPath>${basedir}/Libs/JDASpigot.jar</systemPath>
57+
</dependency>
58+
</dependencies>
59+
<properties>
60+
<maven.compiler.target>17</maven.compiler.target>
61+
<maven.compiler.source>17</maven.compiler.source>
62+
</properties>
63+
</project>

pom.xml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>fr.xen0xys</groupId>
8+
<artifactId>DiscordAuth</artifactId>
9+
<version>2.0.1</version>
10+
<name>${project.groupId}:${project.artifactId}</name>
11+
12+
<properties>
13+
<maven.compiler.source>17</maven.compiler.source>
14+
<maven.compiler.target>17</maven.compiler.target>
15+
</properties>
16+
17+
<repositories>
18+
<repository>
19+
<id>spigot-repo</id>
20+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
21+
</repository>
22+
</repositories>
23+
<dependencies>
24+
<dependency>
25+
<groupId>org.spigotmc</groupId>
26+
<artifactId>spigot</artifactId>
27+
<version>1.18-R0.1-SNAPSHOT</version>
28+
<scope>provided</scope>
29+
</dependency>
30+
<dependency>
31+
<groupId>fr.xen0xys</groupId>
32+
<artifactId>Xen0Lib</artifactId>
33+
<version>1.1.3</version>
34+
<scope>system</scope>
35+
<systemPath>${basedir}/Libs/Xen0Lib-1.1.3.jar</systemPath>
36+
</dependency>
37+
<dependency>
38+
<groupId>me.Porama6400</groupId>
39+
<artifactId>JDASpigot</artifactId>
40+
<version>4.3.0</version>
41+
<scope>system</scope>
42+
<systemPath>${basedir}/Libs/JDASpigot.jar</systemPath>
43+
</dependency>
44+
</dependencies>
45+
46+
<build>
47+
<plugins>
48+
<plugin>
49+
<groupId>org.apache.maven.plugins</groupId>
50+
<artifactId>maven-jar-plugin</artifactId>
51+
<version>3.2.0</version>
52+
<configuration>
53+
<outputDirectory>Server/plugins</outputDirectory>
54+
</configuration>
55+
</plugin>
56+
57+
<plugin>
58+
<groupId>org.apache.maven.plugins</groupId>
59+
<artifactId>maven-shade-plugin</artifactId>
60+
<version>3.2.4</version>
61+
<executions>
62+
<execution>
63+
<phase>package</phase>
64+
<goals>
65+
<goal>shade</goal>
66+
</goals>
67+
</execution>
68+
</executions>
69+
</plugin>
70+
</plugins>
71+
</build>
72+
73+
</project>

src/fr/xen0xys/discordauth/models/Logger.java

-29
This file was deleted.

src/fr/xen0xys/discordauth/plugin/events/OnAsyncPlayerChat.java

-26
This file was deleted.

src/fr/xen0xys/discordauth/DiscordAuth.java src/main/java/fr/xen0xys/discordauth/DiscordAuth.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@
3232

3333
public class DiscordAuth extends JavaPlugin {
3434

35+
// createaccount Xen0Xys 266646920473214978 test
36+
3537
private static Plugin instance;
3638
private static Logger logger;
3739
private static CustomConfiguration configuration;
3840
private static Language language;
3941
private static Database database;
4042
private static PluginAsyncLoop pluginAsyncLoop;
41-
private static HashMap<String, User> users = new HashMap<>();
43+
private static final HashMap<String, User> users = new HashMap<>();
4244

4345
//BOT
4446
private static JDA bot;
@@ -104,9 +106,9 @@ public void onEnable() {
104106
Integer.parseInt(String.valueOf(databaseInfos.get("port"))),
105107
String.valueOf(databaseInfos.get("user")),
106108
String.valueOf(databaseInfos.get("password")),
107-
String.valueOf(databaseInfos.get("database")));
109+
String.valueOf(databaseInfos.get("database")), logger);
108110
}else{
109-
database = new Database(this.getDataFolder().getPath(), "DiscordAuth");
111+
database = new Database(this.getDataFolder().getPath(), "DiscordAuth", logger);
110112
}
111113

112114
if(database.connect() != Status.Success){
@@ -263,7 +265,6 @@ public static HashMap<String, User> getUsers() {
263265
public static JDA getBot() {
264266
return bot;
265267
}
266-
267268
public static AccountTable getAccountTable() {
268269
return accountTable;
269270
}

src/fr/xen0xys/discordauth/discord/BotUtils.java src/main/java/fr/xen0xys/discordauth/discord/BotUtils.java

+4
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,8 @@ public static String[] getCommandArgs(String command){
158158
return new String[]{};
159159
}
160160

161+
public static PrivateChannel getUserPrivateChannelFromId(long id){
162+
return DiscordAuth.getBot().getSelfUser().getJDA().openPrivateChannelById(id).complete();
163+
}
164+
161165
}

src/fr/xen0xys/discordauth/discord/events/OnMessageReceived.java src/main/java/fr/xen0xys/discordauth/discord/events/OnMessageReceived.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public void onMessageReceived(@NotNull MessageReceivedEvent event) {
1515
super.onMessageReceived(event);
1616
if(!event.getAuthor().getId().equals(event.getJDA().getSelfUser().getId())){
1717
// Check if shared chat is enabled
18-
if(DiscordAuth.getConfiguration().getEnableSharedChat()){
18+
if(DiscordAuth.getConfiguration().getEnableSharedChat() && !event.getAuthor().isBot()){
1919
if(event.getChannelType() == ChannelType.TEXT){
2020
TextChannel channel = (TextChannel) event.getChannel();
2121
if(channel.getIdLong() == DiscordAuth.getConfiguration().getChannelId()){

0 commit comments

Comments
 (0)