Skip to content
Snippets Groups Projects
Commit 87df9c6e authored by Sofiane Lasri's avatar Sofiane Lasri
Browse files

1.5

parent 402a4371
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="SLCraftPlugin" />
<module name="SL-Craft Plugin" />
</profile>
</annotationProcessing>
</component>
......
......@@ -88,10 +88,5 @@
<version>2.11.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web</artifactId>
<version>4.2.5</version>
</dependency>
</dependencies>
</project>
......@@ -2,6 +2,10 @@ package com.slprojects.slcraftplugin.tachesParalleles;
import com.slprojects.slcraftplugin.Main;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.io.BufferedReader;
import java.io.IOException;
......@@ -9,6 +13,7 @@ import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URLDecoder;
public class waitForDiscordMsg {
public static void startServer(Main plugin){
......@@ -45,8 +50,38 @@ public class waitForDiscordMsg {
while ((line = in.readLine()) != null) {
if (line.length() == 0)
break;
out.print(line + "\r\n");
plugin.getLogger().info(line);
//out.print(line + "\r\n");
//plugin.getLogger().info(line);
// On va regarder si la ligne commence par GET
if (line.startsWith("GET")) {
// On split par les espaces
String[] split = line.split(" ");
// Et on récupère le nom de la commande
String command = split[1];
// On split par des /
String[] split2 = command.split("/");
// On récupère le nom de la commande
String commandName = split2[1];
switch (commandName) {
case "discordMsg":
// On récupère le message
JSONObject json = (JSONObject) new JSONParser().parse(URLDecoder.decode(split2[2], "UTF-8"));
String message = json.get("message").toString();
String playerName = json.get("playerName").toString();
// On envoie le message aux joueurs
for(Player p : plugin.getServer().getOnlinePlayers()){
p.sendMessage(ChatColor.DARK_PURPLE + playerName + " : " + ChatColor.WHITE + message);
}
out.print("Message envoyé !");
break;
default:
out.print("La commande \""+commandName + "\" n'est pas reconnue.\r\n");
}
}
}
// Close socket, breaking the connection to the client, and
......@@ -58,6 +93,8 @@ public class waitForDiscordMsg {
} catch (IOException e) {
plugin.getLogger().info(ChatColor.RED + "Erreur lors de l'écoute du port " + ChatColor.GOLD + serverPort);
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
}
};
......
#Generated by Maven
#Sun Mar 06 17:00:16 CET 2022
#Sun Mar 06 22:53:05 CET 2022
groupId=com.slprojects
artifactId=SLCraftPlugin
version=1.5
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment