Skip to content

Commit ec5dece

Browse files
author
Hubert
authored
Created in v1.10
1 parent df0c16d commit ec5dece

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed

Scripts/mcchat

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
. .minecraft-library
4+
5+
if [ "$#" = 0 ]
6+
then DisplayChat ${SERVER_ROOT}/logs/latest.log
7+
else while [ "$#" != 0 ]
8+
do
9+
if [ -f "$1" ]
10+
then DisplayChat $1
11+
fi
12+
shift
13+
done
14+
fi

Scripts/mclast

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/bin/sh
2+
# @(#) mclast v1.00 (2016-09-29) / Hubert Tournier
3+
4+
. .minecraft-library
5+
6+
ProcessLogfile( )
7+
{
8+
FILENAME=`basename $1`
9+
case ${FILENAME} in
10+
[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9]*.log.gz) CMD=zcat
11+
TODAY=`echo ${FILENAME} | cut -c1-10`
12+
YEAR=`echo ${FILENAME} | cut -c1-4`
13+
MONTH=`echo ${FILENAME} | cut -c6-7`
14+
DAY=`echo ${FILENAME} | cut -c9-10`
15+
YESTERDAY=`date -v${YEAR}y -v${MONTH}m -v${DAY}d -v-1d "+%F"`
16+
;;
17+
*.log) CMD=cat
18+
TODAY=`date "+%F"`
19+
YESTERDAY=`date -v-1d "+%F"`
20+
;;
21+
esac
22+
23+
${CMD} $1 \
24+
| egrep "( UUID of player | Client attempting to join with | logged in with entity id | left the game\.)" \
25+
| awk -v "YESTERDAY=${YESTERDAY}" -v "TODAY=${TODAY}" '
26+
{
27+
gsub(/^\[/, "")
28+
}
29+
/ UUID of player / {
30+
gsub(/\] \[User Authenticator \#[0-9]*\/INFO\]: UUID of player /, " ")
31+
gsub(/ is /, " ")
32+
TIME_IN=$1
33+
PLAYER=$2
34+
UUID=$3
35+
}
36+
/ Client attempting to join with / {
37+
gsub(/^.* Client attempting to join with [0-9]* mods : /, "")
38+
gsub(/ /, "_")
39+
MODS=$0
40+
}
41+
/ logged in with entity id / {
42+
gsub(/^.*Server thread.INFO.: [^\[]*../, "")
43+
gsub(/:[0-9]*. logged in with entity id [0-9]* at \(/, "")
44+
IP=$0
45+
gsub(/\[.*/, "", IP)
46+
COORD=$0
47+
gsub(/^.*\[/, "", COORD)
48+
gsub(/\] /, ":", COORD)
49+
gsub(/, /, ":", COORD)
50+
gsub(/\.[0-9]*/, "", COORD)
51+
gsub(/\)/, "", COORD)
52+
53+
players[PLAYER,"time-in"] = TIME_IN
54+
players[PLAYER,"uuid"] = UUID
55+
players[PLAYER,"ip"] = IP
56+
players[PLAYER,"coord"] = COORD
57+
players[PLAYER,"mods"] = MODS
58+
}
59+
/ left the game\./ {
60+
gsub(/\] \[Server thread.INFO.: /, " ")
61+
gsub(/ left the game\./, "")
62+
TIME_OUT=$1
63+
PLAYER=$2
64+
65+
if ((PLAYER,"uuid") in players)
66+
{
67+
printf "%s %s %s %s %s %s %s %s %s\n", TODAY, players[PLAYER,"time-in"], TODAY, TIME_OUT, PLAYER, players[PLAYER,"uuid"], players[PLAYER,"ip"], players[PLAYER,"coord"], players[PLAYER,"mods"]
68+
delete players[PLAYER,"time-in"]
69+
delete players[PLAYER,"uuid"]
70+
delete players[PLAYER,"ip"]
71+
delete players[PLAYER,"coord"]
72+
delete players[PLAYER,"mods"]
73+
}
74+
else
75+
{
76+
printf "%s %s %s %s %s %s %s %s %s\n", YESTERDAY, "??:??:??", TODAY, TIME_OUT, PLAYER, "?", "?", "?", "?"
77+
}
78+
}
79+
END {
80+
for (i in players)
81+
{
82+
split(i,sep,SUBSEP)
83+
printf "%s %s %s %s %s %s %s %s %s\n", TODAY, players[sep[1],"time-in"], TODAY, "ONLINE", sep[1], players[sep[1],"uuid"], players[sep[1],"ip"], players[sep[1],"coord"], players[sep[1],"mods"]
84+
delete players[sep[1],"time-in"]
85+
delete players[sep[1],"uuid"]
86+
delete players[sep[1],"ip"]
87+
delete players[sep[1],"coord"]
88+
delete players[sep[1],"mods"]
89+
}
90+
}
91+
' \
92+
| sort
93+
}
94+
95+
if [ "$#" = 0 ]
96+
then ProcessLogfile ${SERVER_ROOT}/logs/latest.log
97+
else while [ "$#" != 0 ]
98+
do
99+
if [ -f "$1" ]
100+
then ProcessLogfile $1
101+
fi
102+
shift
103+
done
104+
fi
105+

0 commit comments

Comments
 (0)