1
0
Fork 0
mirror of https://github.com/haselkern/Minecraft-ArmorStand.git synced 2025-05-17 15:05:33 +00:00

Partnering with minecraft-heads.com

This commit is contained in:
Lars Martens 2017-06-14 09:47:14 +02:00
parent 1473d3cebc
commit 7ab69d7a42
2 changed files with 38 additions and 13 deletions

View file

@ -161,6 +161,13 @@
<option value="url">Image URL</option> <option value="url">Image URL</option>
<option value="givecode">Give Code</option> <option value="givecode">Give Code</option>
</select> </select>
<div id="minecraft-heads">
<br>
Shop for some nice heads and then copy the <i>Give Code</i> into the helmet field:
<br>
<a href="http://minecraft-heads.com/" target="_blank"><img src="http://minecraft-heads.com/images/banners/minecraft-heads_halfbanner_234x60.png" alt="minecraft-heads.com" /></a>
</div>
</div> </div>
</div> </div>

View file

@ -362,12 +362,21 @@ function updateUI(){
else else
$("#helmetcolor").slideUp(); $("#helmetcolor").slideUp();
// Link to minecraft-heads.com
if(equipCustomHeadMode == "givecode"){
$("#minecraft-heads").slideDown();
}
else{
$("#minecraft-heads").slideUp();
}
// Show disabled slots
if(useDisabledSlots) if(useDisabledSlots)
$("#disabledslots").slideDown(); $("#disabledslots").slideDown();
else else
$("#disabledslots").slideUp(); $("#disabledslots").slideUp();
// Generate code
$("#code").text(generateCode()); $("#code").text(generateCode());
if(generateCode().length > 100){ if(generateCode().length > 100){
$("#codeinfo").slideDown(); $("#codeinfo").slideDown();
@ -559,25 +568,34 @@ function getHeadItem(){
// Parse give code // Parse give code
else if(equipCustomHeadMode == "givecode"){ else if(equipCustomHeadMode == "givecode"){
var skullOwnerRaw = equipHelmet.substring(equipHelmet.indexOf("SkullOwner"));
var parsed = "";
var bracketCounter = 0;
var bracketsStarted = false;
for(var i = 0; i < skullOwnerRaw.length; i++){ // Give Code in this format: /give @p skull 1 3 {display:{Name:"Some Name"},SkullOwner:{Id:"a74719ce...
var c = skullOwnerRaw[i]; if(equipHelmet.indexOf("SkullOwner:{") >= 0){
var skullOwnerRaw = equipHelmet.substring(equipHelmet.indexOf("SkullOwner"));
var parsed = "";
var bracketCounter = 0;
var bracketsStarted = false;
if(c == "{"){ for(var i = 0; i < skullOwnerRaw.length; i++){
bracketsStarted = true; var c = skullOwnerRaw[i];
bracketCounter++;
if(c == "{") bracketCounter++;
if(c == "}") bracketCounter--;
parsed += c;
if(bracketCounter == 0 && bracketsStarted) break;
if(c == ":") bracketsStarted = true;
} }
if(c == "}") bracketCounter--;
parsed += c; return '{id:"skull",Count:1b,Damage:3b,tag:{'+parsed+'}}';
if(bracketCounter == 0 && bracketsStarted) break; }
// Give Code in this format: /give @p skull 1 3 {SkullOwner:"playername"} (quotes optional)
else{
var skullOwnerRaw = equipHelmet.substring(equipHelmet.indexOf("SkullOwner:"));
skullOwnerRaw = skullOwnerRaw.substring(0, skullOwnerRaw.indexOf("}"));
return '{id:"skull",Count:1b,Damage:3b,tag:{'+skullOwnerRaw+'}}';
} }
return '{id:"skull",Count:1b,Damage:3b,tag:{'+parsed+'}}';
} }
} }