Advertisement
roro1506HD

1.8 Vanilla to/from Bukkit 1.8 - Java Code

Sep 1st, 2022
1,202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.67 KB | None | 0 0
  1. package ovh.roro;
  2.  
  3. import com.google.gson.Gson;
  4. import com.google.gson.JsonObject;
  5. import net.minecraft.server.v1_8_R3.Block;
  6. import net.minecraft.server.v1_8_R3.Item;
  7. import org.bukkit.Material;
  8.  
  9. import java.io.PrintWriter;
  10.  
  11. public class ExportMaterials {
  12.  
  13.     public static void run() {
  14.         try {
  15.             JsonObject bukkitToVanilla = new JsonObject();
  16.             JsonObject vanillaToBukkit = new JsonObject();
  17.  
  18.             for (Material material : Material.values()) {
  19.                 String bukkit = material.name();
  20.                 String vanilla = null;
  21.                 Item item = Item.getById(material.getId());
  22.  
  23.                 if (item != null) {
  24.                     vanilla = Item.REGISTRY.c(item).a();
  25.                 }
  26.  
  27.                 if (vanilla == null) {
  28.                     Block block = Block.getById(material.getId());
  29.  
  30.                     if (block == null) {
  31.                         continue;
  32.                     }
  33.  
  34.                     vanilla = Block.REGISTRY.c(block).a();
  35.                 }
  36.  
  37.                 bukkitToVanilla.addProperty(bukkit, vanilla);
  38.                 vanillaToBukkit.addProperty(vanilla, bukkit);
  39.             }
  40.  
  41.             Gson gson = new Gson();
  42.  
  43.             try (PrintWriter writer = new PrintWriter("bukkit_to_vanilla.json")) {
  44.                 gson.toJson(bukkitToVanilla, writer);
  45.                 writer.flush();
  46.             }
  47.  
  48.             try (PrintWriter writer = new PrintWriter("vanilla_to_bukkit.json")) {
  49.                 gson.toJson(vanillaToBukkit, writer);
  50.                 writer.flush();
  51.             }
  52.         } catch (Exception ex) {
  53.             ex.printStackTrace();
  54.         }
  55.     }
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement