Skip to content

Commit

Permalink
Merge pull request #4 from Xen0Xys/V2.0.1
Browse files Browse the repository at this point in the history
V2.1.0
  • Loading branch information
Xen0Xys authored Dec 5, 2021
2 parents 8477492 + eae9da7 commit adab914
Show file tree
Hide file tree
Showing 123 changed files with 781 additions and 131 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Server
Libs
.idea
out
DiscordAuth.iml
out
15 changes: 15 additions & 0 deletions DiscordAuth.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
<component name="McpModuleSettings">
<option name="srgType" value="SRG" />
</component>
</module>
Binary file added Libs/JDASpigot.jar
Binary file not shown.
Binary file added Libs/Xen0Lib-1.1.3.jar
Binary file not shown.
83 changes: 66 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
# DiscordAuth
# DiscordAuth V2.0.1
DiscordAuth plugin permit Discord server's owners to manage access to their Minecraft server:

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


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

### Configuration:
## Configuration:

```yaml
#
# THANKS FOR USING DISCORDAUTH!
#
# Notes: certain settings need to be changed, there are noted by "#*"

# If MySQL is disabled, plugin will use SQLite
mysql:
enable: false
host: 0.0.0.0
port: 3306
user: username
password: password
database: database_name

discord:
# Put here your bot token
#* Put here your bot token
token: token
# Disable discord part of the plugin, but keep server's safety and account management
only_safety: false
# Put here your discord guild id
guild_id: 0
# Put here the id of the message to which you want people to react to access the server
Expand All @@ -33,28 +44,66 @@ discord:
enable_connection_message: true
# When a player send message on Minecraft or Discord server, send message on Discord or Minecraft server respectively
enable_shared_chat: true
# Send DM to unregister user who has react
# Send DM to unregister user who has reacted (useful to disable new players joining)
send_message_to_unregister_users: true
# Send advancements in main channel
send_advancements: true
# Send message in main channel when a player die (with his dye reason)
send_death_messages: true
# Add logo to private messages response
logo:
enable: false
url: null
# Set bot status here
activity:
enable: false
# Can be PLAYING, STREAMING, LISTENING or WATCHING
type: PLAYING
text: DiscordAuth V2.0!
# Only for streaming
url: null

encryption:
# If you want to encrypt ip too (ip encryption use same encryption string)
encrypt_ip: false
# 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!)
# 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!)
# This function is also known as "salt"
additional_encryption_string:
enable: false
string: null

# Only use for first spawn
# Spawn point settings
spawnpoint:
world_name: world
x: 0
y: 80
z: 0
facing:
pitch: 0
yaw: 0
# Enable first time spawn point
first_time_tp: false
# Tp player at spawn point on login
tp_on_login: false
# Respawn settings
respawn:
# Tp player to spawn point if his die
enable: false
# If enabled, player will be tp at death even if his had a bed respawn
even_with_bed: false
# Spawn point location settings
infos:
world_name: world
x: 0
y: 80
z: 0
facing:
pitch: 0
yaw: 0

other:
# Language file that will be used (can be custom file name in DiscordAuth/resources folder)
# Can be "en_EN" or "fr_FR"
language: en_EN
# Determine if server use UUID or Username
premium: true
# Session duration in seconds, set 0 to disable
session_duration: 3600
# Set if login window is displayed when player connect or logout
aggressive_login: true
```
Spigot page: https://www.spigotmc.org/resources/discordauth.92286/
63 changes: 63 additions & 0 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.xen0xys</groupId>
<artifactId>DiscordAuth</artifactId>
<name>${project.groupId}:${project.artifactId}</name>
<version>2.0.1</version>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<outputDirectory>Server/plugins</outputDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>fr.xen0xys</groupId>
<artifactId>Xen0Lib</artifactId>
<version>1.1.3</version>
<scope>system</scope>
<systemPath>${basedir}/Libs/Xen0Lib-1.1.3.jar</systemPath>
</dependency>
<dependency>
<groupId>me.Porama6400</groupId>
<artifactId>JDASpigot</artifactId>
<version>4.3.0</version>
<scope>system</scope>
<systemPath>${basedir}/Libs/JDASpigot.jar</systemPath>
</dependency>
</dependencies>
<properties>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
</properties>
</project>
73 changes: 73 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>fr.xen0xys</groupId>
<artifactId>DiscordAuth</artifactId>
<version>2.0.1</version>
<name>${project.groupId}:${project.artifactId}</name>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>

<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>fr.xen0xys</groupId>
<artifactId>Xen0Lib</artifactId>
<version>1.1.3</version>
<scope>system</scope>
<systemPath>${basedir}/Libs/Xen0Lib-1.1.3.jar</systemPath>
</dependency>
<dependency>
<groupId>me.Porama6400</groupId>
<artifactId>JDASpigot</artifactId>
<version>4.3.0</version>
<scope>system</scope>
<systemPath>${basedir}/Libs/JDASpigot.jar</systemPath>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<outputDirectory>Server/plugins</outputDirectory>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
29 changes: 0 additions & 29 deletions src/fr/xen0xys/discordauth/models/Logger.java

This file was deleted.

26 changes: 0 additions & 26 deletions src/fr/xen0xys/discordauth/plugin/events/OnAsyncPlayerChat.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@

public class DiscordAuth extends JavaPlugin {

// createaccount Xen0Xys 266646920473214978 test

private static Plugin instance;
private static Logger logger;
private static CustomConfiguration configuration;
private static Language language;
private static Database database;
private static PluginAsyncLoop pluginAsyncLoop;
private static HashMap<String, User> users = new HashMap<>();
private static final HashMap<String, User> users = new HashMap<>();

//BOT
private static JDA bot;
Expand Down Expand Up @@ -104,9 +106,9 @@ public void onEnable() {
Integer.parseInt(String.valueOf(databaseInfos.get("port"))),
String.valueOf(databaseInfos.get("user")),
String.valueOf(databaseInfos.get("password")),
String.valueOf(databaseInfos.get("database")));
String.valueOf(databaseInfos.get("database")), logger);
}else{
database = new Database(this.getDataFolder().getPath(), "DiscordAuth");
database = new Database(this.getDataFolder().getPath(), "DiscordAuth", logger);
}

if(database.connect() != Status.Success){
Expand Down Expand Up @@ -263,7 +265,6 @@ public static HashMap<String, User> getUsers() {
public static JDA getBot() {
return bot;
}

public static AccountTable getAccountTable() {
return accountTable;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,8 @@ public static String[] getCommandArgs(String command){
return new String[]{};
}

public static PrivateChannel getUserPrivateChannelFromId(long id){
return DiscordAuth.getBot().getSelfUser().getJDA().openPrivateChannelById(id).complete();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void onMessageReceived(@NotNull MessageReceivedEvent event) {
super.onMessageReceived(event);
if(!event.getAuthor().getId().equals(event.getJDA().getSelfUser().getId())){
// Check if shared chat is enabled
if(DiscordAuth.getConfiguration().getEnableSharedChat()){
if(DiscordAuth.getConfiguration().getEnableSharedChat() && !event.getAuthor().isBot()){
if(event.getChannelType() == ChannelType.TEXT){
TextChannel channel = (TextChannel) event.getChannel();
if(channel.getIdLong() == DiscordAuth.getConfiguration().getChannelId()){
Expand Down
Loading

0 comments on commit adab914

Please sign in to comment.