Last active
June 26, 2018 17:27
-
-
Save Pokechu22/404a3e401c66336a5592dac415bfaaf6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.gson.Gson; | |
import java.io.FileReader; | |
import java.util.Map; | |
import org.bukkit.Material; | |
public class MaterialChecker { | |
private static Burger burger; | |
public static void main(String[] args) throws Exception { | |
try (FileReader reader = new FileReader(args[0])) { | |
// Burger files contain an array of verisons; we want the first version | |
burger = new Gson().fromJson(reader, Burger[].class)[0]; | |
} | |
System.out.println("Using burger data for " + burger.source.file); | |
// OK, now that we've got the item table; look through materials. | |
System.out.printf("|%s|%s|%s|%s|%n", "Bukkit name", "ID", "Vanilla name", "Display name"); | |
System.out.println("|-|-|-|-|"); | |
for (Material material : Material.values()) { | |
String crapName = material.name(); | |
int id = material.getId(); | |
String text_id = null, display_name = null; | |
for (ItemOrBlock item : burger.items.item.values()) { | |
if (item.numeric_id == id) { | |
text_id = item.text_id; | |
display_name = item.display_name; | |
break; | |
} | |
} | |
for (ItemOrBlock block : burger.blocks.block.values()) { | |
if (block.numeric_id == id) { | |
text_id = block.text_id; | |
display_name = block.display_name; | |
break; | |
} | |
} | |
System.out.printf("|`%s`|%s|`%s`|%s|%n", crapName, id, "minecraft:" + text_id, display_name); | |
} | |
} | |
private static class Burger { | |
public Items items; | |
public Blocks blocks; | |
public Source source; | |
} | |
private static class Items { | |
public Map<String, ItemOrBlock> item; | |
} | |
private static class Blocks { | |
public Map<String, ItemOrBlock> block; | |
} | |
private static class ItemOrBlock { | |
public String text_id; | |
public int numeric_id; | |
public String display_name; | |
} | |
private static class Source { | |
public String file; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
New home for this file (apparently; going through old stuff): https://github.com/Pokechu22/minecraft-tweak-scripts/blob/master/MaterialChecker.java