From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Fri, 31 May 2019 21:24:33 -0500
Subject: [PATCH] Advancement API


diff --git a/src/main/java/net/minecraft/advancements/DisplayInfo.java b/src/main/java/net/minecraft/advancements/DisplayInfo.java
index dea17bc7a6e4db470afaaad3c98940297a50e4e4..fcce31f9d575cc7388d8ec4bc2e088c9f4781833 100644
--- a/src/main/java/net/minecraft/advancements/DisplayInfo.java
+++ b/src/main/java/net/minecraft/advancements/DisplayInfo.java
@@ -23,10 +23,11 @@ public class DisplayInfo {
     private final ResourceLocation background;
     private final FrameType frame;
     private final boolean showToast;
-    private final boolean announceChat;
-    private final boolean hidden;
+    private boolean announceChat; // Purpur - un-finalize
+    private boolean hidden; // Purpur - un-finalize
     private float x;
     private float y;
+    public final org.bukkit.advancement.AdvancementDisplay bukkit = new org.bukkit.craftbukkit.advancement.CraftAdvancementDisplay(this); // Purpur
 
     public DisplayInfo(ItemStack icon, Component title, Component description, @Nullable ResourceLocation background, FrameType frame, boolean showToast, boolean announceToChat, boolean hidden) {
         this.title = title;
@@ -85,6 +86,16 @@ public class DisplayInfo {
         return this.hidden;
     }
 
+    // Purpur start
+    public final void shouldAnnounceChat(boolean announceChat) {
+        this.announceChat = announceChat;
+    }
+
+    public final void hidden(boolean hidden) {
+        this.hidden = hidden;
+    }
+    // Purpur end
+
     public static DisplayInfo fromJson(JsonObject obj) {
         Component component = Component.Serializer.fromJson(obj.get("title"));
         Component component2 = Component.Serializer.fromJson(obj.get("description"));
diff --git a/src/main/java/net/minecraft/advancements/FrameType.java b/src/main/java/net/minecraft/advancements/FrameType.java
index 2f90574158e0c742548ef2930a787821bb0ffcd3..28803f5d14e266f7cde3385e3782a7f0646eaadc 100644
--- a/src/main/java/net/minecraft/advancements/FrameType.java
+++ b/src/main/java/net/minecraft/advancements/FrameType.java
@@ -5,16 +5,23 @@ import net.minecraft.network.chat.Component;
 import net.minecraft.network.chat.TranslatableComponent;
 
 public enum FrameType {
-    TASK("task", 0, ChatFormatting.GREEN),
-    CHALLENGE("challenge", 26, ChatFormatting.DARK_PURPLE),
-    GOAL("goal", 52, ChatFormatting.GREEN);
+    // Purpur start
+    TASK("task", 0, ChatFormatting.GREEN, org.bukkit.advancement.FrameType.TASK),
+    CHALLENGE("challenge", 26, ChatFormatting.DARK_PURPLE, org.bukkit.advancement.FrameType.CHALLENGE),
+    GOAL("goal", 52, ChatFormatting.GREEN, org.bukkit.advancement.FrameType.GOAL);
+    // Purpur end
 
     private final String name;
     private final int texture;
     private final ChatFormatting chatColor;
     private final Component displayName;
 
-    private FrameType(String id, int texV, ChatFormatting titleFormat) {
+    // Purpur start
+    public final org.bukkit.advancement.FrameType bukkit;
+
+    FrameType(String id, int texV, ChatFormatting titleFormat, org.bukkit.advancement.FrameType bukkit) {
+        this.bukkit = bukkit;
+        // Purpur end
         this.name = id;
         this.texture = texV;
         this.chatColor = titleFormat;
diff --git a/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java
index 20d51358b4b47cbf43c3d172765243e96aa1966c..5ab7896621911f56ab857e81e11816e1f36d3817 100644
--- a/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java
+++ b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java
@@ -27,4 +27,11 @@ public class CraftAdvancement implements org.bukkit.advancement.Advancement {
     public Collection<String> getCriteria() {
         return Collections.unmodifiableCollection(this.handle.getCriteria().keySet());
     }
+
+    // Purpur start
+    @Override
+    public org.bukkit.advancement.AdvancementDisplay getDisplay() {
+        return getHandle().getDisplay() == null ? null : getHandle().getDisplay().bukkit;
+    }
+    // Purpur end
 }
diff --git a/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancementDisplay.java b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancementDisplay.java
new file mode 100644
index 0000000000000000000000000000000000000000..504c815759c8a515b68b8ddbe9ba5a7941830202
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancementDisplay.java
@@ -0,0 +1,47 @@
+package org.bukkit.craftbukkit.advancement;
+
+import net.minecraft.advancements.DisplayInfo;
+import org.bukkit.advancement.FrameType;
+import org.bukkit.craftbukkit.util.CraftChatMessage;
+
+public class CraftAdvancementDisplay implements org.bukkit.advancement.AdvancementDisplay {
+    private final DisplayInfo handle;
+
+    public CraftAdvancementDisplay(DisplayInfo handle) {
+        this.handle = handle;
+    }
+
+    public DisplayInfo getHandle() {
+        return handle;
+    }
+
+    @Override
+    public String getTitle() {
+        return CraftChatMessage.fromComponent(handle.getTitle());
+    }
+
+    @Override
+    public String getDescription() {
+        return CraftChatMessage.fromComponent(handle.getDescription());
+    }
+
+    @Override
+    public FrameType getFrameType() {
+        return handle.getFrame().bukkit;
+    }
+
+    @Override
+    public boolean shouldAnnounceChat() {
+        return handle.shouldAnnounceChat();
+    }
+
+    @Override
+    public void shouldAnnounceChat(boolean announceChat) {
+        handle.shouldAnnounceChat(announceChat);
+    }
+
+    @Override
+    public boolean isHidden() {
+        return handle.isHidden();
+    }
+}
