Minecraft Script that will remember all the items each person in the server has [closed]
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this questionI have a minecraft server, and need to backup all the items people have, I hope to do this by editing the .dat files in world/players. In this file, there are .dat files and their names are the usernames of each player. when I open it with Notepad++, it shows me gibberish like this:
Regular Notepad gives me this:
‹ ãb``bà
ÎIM-ÉÌM-b`àd`óÍ/ÉÌÏcc```¶ÛqæÀÉEÚ“öob=Ô£i×ý‰Ù5S #‡ž{Q~i^
#‡GiQ H?È46ÔÄœ’Œÿÿ™8]€byÅ@Àf¥˜3‹u88=óÊRóJò‹*AœÌùÅ`û˜Û„¥<^$çà ’apˆßñM&ðБŽ%% ‰ÉÙ[€ÖƒÝœ™—4–Å-³(õÿV·Äœ—Ìâ’ļäTˆÉAù%‰ ï°‚\pð²±’ïÌ9L@§¥&–d€M“d íl+
I heard the file is Gzipped. Is 开发者_开发问答this why it is like this? How can I decode this so I can actually read it. I need to decrypt this from a PHP script.
You need to find out what compression it is really but try and open the file with this (gzip):
<?php
$fp = fopen('compress.zlib://yourfile.dat', 'r');
if( $fp ){
while(!feof($fp) ){
echo fread($fp, 2048);
}
fclose($fp);
}
?>
Check out http://www.php.net/manual/en/wrappers.compression.php for more info.
EDIT: You may want to try this:
<?php
$dat = file_get_contents('yourfile.dat');
echo gzdecoder($dat);
function gzdecoder($d){
$f=ord(substr($d,3,1));
$h=10;$e=0;
if($f&4){
$e=unpack('v',substr($d,10,2));
$e=$e[1];$h+=2+$e;
}
if($f&8){
$h=strpos($d,chr(0),$h)+1;
}
if($f&16){
$h=strpos($d,chr(0),$h)+1;
}
if($f&2){
$h+=2;
}
$u = gzinflate(substr($d,$h));
if($u===FALSE){
$u=$d;
}
return $u;
}
?>
Also its not encrypted
, its compressed
. ;-)
精彩评论