Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SL-Craft Plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SL-Projects
SL-Craft Plugin
Commits
76cb9bf4
Commit
76cb9bf4
authored
3 years ago
by
Sofiane Lasri
Browse files
Options
Downloads
Patches
Plain Diff
Problème réglé, reste incompatible en https.
parent
1591cf89
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1
Problème réglé, reste incompatible en https.
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/com/slprojects/slcraftplugin/tachesParalleles/internalWebServer.java
+46
-49
46 additions, 49 deletions
...cts/slcraftplugin/tachesParalleles/internalWebServer.java
target/maven-archiver/pom.properties
+1
-1
1 addition, 1 deletion
target/maven-archiver/pom.properties
with
47 additions
and
50 deletions
src/main/java/com/slprojects/slcraftplugin/tachesParalleles/internalWebServer.java
+
46
−
49
View file @
76cb9bf4
...
...
@@ -19,6 +19,7 @@ public class internalWebServer {
int
serverPort
=
plugin
.
getConfig
().
getInt
(
"internal-webserver-port"
);
plugin
.
getServer
().
getConsoleSender
().
sendMessage
(
"Lancement du serveur web intégré sur le port "
+
ChatColor
.
GOLD
+
serverPort
);
plugin
.
getServer
().
getConsoleSender
().
sendMessage
(
ChatColor
.
YELLOW
+
"Attention! Le serveur ne fonctionne pas avec les requêtes https!"
);
// On fait un thread pour écouter le port
Runnable
serverThread
=
()
->
{
try
{
...
...
@@ -46,13 +47,12 @@ public class internalWebServer {
// reading. This means we don't mirror the contents of POST
// requests, for example. Note that the readLine() method
// works with Unix, Windows, and Mac line terminators.
String
line
;
String
line
,
commandName
=
""
;
String
[]
aliases
=
new
String
[
0
];
while
((
line
=
in
.
readLine
())
!=
null
)
{
if
(
line
.
length
()
==
0
)
if
(
line
.
equals
(
""
))
{
break
;
//out.print(line + "\r\n");
//plugin.getServer().getConsoleSender().sendMessage(line);
}
// On va regarder si la ligne commence par GET
if
(
line
.
startsWith
(
"GET"
))
{
// On split par les espaces
...
...
@@ -61,14 +61,18 @@ public class internalWebServer {
String
command
=
split
[
1
];
// On split par des /
String
[]
split2
=
command
.
split
(
"/"
);
aliases
=
command
.
split
(
"/"
);
// On récupère le nom de la commande
String
commandName
=
split2
[
1
];
commandName
=
aliases
[
1
];
// On ne process pas la commande ici car ça cause des problèmes vu qu'on va renvoyer le résultat avant que le client n'écoute
}
}
JSONObject
answer
=
new
JSONObject
();
switch
(
commandName
)
{
case
"discordMsg"
:
JSONObject
json
=
(
JSONObject
)
new
JSONParser
().
parse
(
URLDecoder
.
decode
(
split2
[
2
],
"UTF-8"
));
JSONObject
json
=
(
JSONObject
)
new
JSONParser
().
parse
(
URLDecoder
.
decode
(
aliases
[
2
],
"UTF-8"
));
String
message
=
json
.
get
(
"message"
).
toString
();
String
playerName
=
json
.
get
(
"playerName"
).
toString
();
...
...
@@ -81,14 +85,10 @@ public class internalWebServer {
out
.
print
(
answer
.
toJSONString
());
break
;
case
"getPlayers"
:
plugin
.
getServer
().
getConsoleSender
().
sendMessage
(
"getPlayers"
);
// On renvoie la liste des joueurs
JSONObject
listToReturn
=
new
JSONObject
();
JSONObject
players
=
new
JSONObject
();
// On vérifie qu'il y a des joueurs -> pas vraiment utile vu que le timeout ne viens pas d'ici
//TODO: Corriger le timeout et supprimer la condition
if
(
plugin
.
getServer
().
getOnlinePlayers
().
size
()
>
0
)
{
for
(
Player
p
:
plugin
.
getServer
().
getOnlinePlayers
())
{
JSONObject
playerInfos
=
new
JSONObject
();
playerInfos
.
put
(
"username"
,
p
.
getName
());
...
...
@@ -96,7 +96,6 @@ public class internalWebServer {
players
.
put
(
p
.
getName
(),
playerInfos
);
}
}
listToReturn
.
put
(
"players"
,
players
);
out
.
print
(
listToReturn
.
toJSONString
());
break
;
...
...
@@ -106,8 +105,6 @@ public class internalWebServer {
out
.
print
(
answer
.
toJSONString
());
break
;
}
}
}
// Close socket, breaking the connection to the client, and
// closing the input and output streams
...
...
This diff is collapsed.
Click to expand it.
target/maven-archiver/pom.properties
+
1
−
1
View file @
76cb9bf4
#Generated by Maven
#
Mon
May 0
2 23
:0
5
:52 CEST 2022
#
Tue
May 0
3 14
:0
3
:52 CEST 2022
groupId
=
com.slprojects
artifactId
=
SLCraftPlugin
version
=
1.6.0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment