forked from rodel77/MarketPlace-Web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
items.php
67 lines (58 loc) · 1.97 KB
/
items.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
// MCGSoft Addition New Parsing NBT
function getlore($nbt){
preg_match("(({Lore:)\[(.*?)\])",$nbt,$firstmatch,PREG_OFFSET_CAPTURE);
if(sizeof($firstmatch)>2){
preg_match_all('("(.*?)")',$firstmatch[2][0],$secondmatch);
return $secondmatch[1];
}
return array();
}
function getname($nbt){
preg_match('({Name:"(.*?)")',$nbt,$name,PREG_OFFSET_CAPTURE);
if (empty($name)){
preg_match('(Name:"(.*?)")',$nbt,$name,PREG_OFFSET_CAPTURE);
}
return sizeof($name)<2 ? "" : filtercolorcodes($name[1])[0];
}
function filtercolorcodes($nbt){
return preg_replace("(§[a-z,0-9])","",$nbt);
}
function getMaxdurability($tools,$material) {
foreach ($tools as $tool){
$exp = explode('#',$tool);
if ($material == $exp[0]){
return $exp[1];
}
}
return 0;
}
function isTool($tools, $material) {
foreach ($tools as $tool){
$toolID = explode('#', $tool);
if ($material == $toolID[0]){
return true;
}
}
return false;
}
// MCGSoft Addition New SkullBuilder from NBT
function getimgtodb($url,$name){
if (file_exists('imgcache/'.$name.'.png')){
return $name.'.png';
}else {
copy($url, 'imgcache/'.$name.'.png');
return $name.'.png';
}
}
function ConvertTextureData($nbt){
preg_match('(Value:"(.*?)")',$nbt,$texturedata,PREG_OFFSET_CAPTURE);
$decoded = base64_decode($texturedata[1][0]);
preg_match('(url":"(.*?)")',$decoded,$textureurl,PREG_OFFSET_CAPTURE);
if (empty($textureurl)){
$decoded = base64_decode($texturedata[1][0]);
preg_match('(url:"(.*?)")',$decoded,$textureurl,PREG_OFFSET_CAPTURE);
}
return $textureurl[1][0];
}
?>