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/Advancement.java b/src/main/java/net/minecraft/advancements/Advancement.java
index e3d5d55a2fe5d86db621d3e0c9322f553386d731..8bfd20ff9a3c96fa9ff5cc618ca7e858e62943a0 100644
--- a/src/main/java/net/minecraft/advancements/Advancement.java
+++ b/src/main/java/net/minecraft/advancements/Advancement.java
@@ -77,7 +77,7 @@ public class Advancement {
     }
 
     @Nullable
-    public AdvancementDisplay c() {
+    public AdvancementDisplay c() { return getDisplay(); } public AdvancementDisplay getDisplay() { // Purpur
         return this.display;
     }
 
diff --git a/src/main/java/net/minecraft/advancements/AdvancementDisplay.java b/src/main/java/net/minecraft/advancements/AdvancementDisplay.java
index 721d7fbab447117349994f710338ca616ab11067..35b84373da154a070f691b0049086cc788f7de4d 100644
--- a/src/main/java/net/minecraft/advancements/AdvancementDisplay.java
+++ b/src/main/java/net/minecraft/advancements/AdvancementDisplay.java
@@ -25,10 +25,11 @@ public class AdvancementDisplay {
     private final MinecraftKey d;
     private final AdvancementFrameType e;
     private final boolean f;
-    private final boolean g;
-    private final boolean h;
+    private boolean g; // Purpur - un-finalize
+    private boolean h; // Purpur - un-finalize
     private float i;
     private float j;
+    public final org.bukkit.advancement.AdvancementDisplay bukkit = new org.bukkit.craftbukkit.advancement.CraftAdvancementDisplay(this); // Purpur
 
     public AdvancementDisplay(ItemStack itemstack, IChatBaseComponent ichatbasecomponent, IChatBaseComponent ichatbasecomponent1, @Nullable MinecraftKey minecraftkey, AdvancementFrameType advancementframetype, boolean flag, boolean flag1, boolean flag2) {
         this.a = ichatbasecomponent;
@@ -46,22 +47,29 @@ public class AdvancementDisplay {
         this.j = f1;
     }
 
+    public IChatBaseComponent getTitle() { return a(); } // Purpur - OBFHELPER
     public IChatBaseComponent a() {
         return this.a;
     }
 
+    public IChatBaseComponent getDescription() { return b(); } // Purpur - OBFHELPER
     public IChatBaseComponent b() {
         return this.b;
     }
 
+    public AdvancementFrameType getFrameType() { return e(); } // Purpur - OBFHELPER
     public AdvancementFrameType e() {
         return this.e;
     }
 
+    public void setShouldAnnounceToChat(boolean announce) { this.g = announce; } // Purpur - OBFHELPER
+    public boolean shouldAnnounceToChat() { return i(); } // Purpur - OBFHELPER
     public boolean i() {
         return this.g;
     }
 
+    public void setHidden(boolean hidden) { this.h = hidden; } // Purpur - OBFHELPER
+    public boolean isHidden() { return j(); } // Purpur - OBFHELPER
     public boolean j() {
         return this.h;
     }
diff --git a/src/main/java/net/minecraft/advancements/AdvancementFrameType.java b/src/main/java/net/minecraft/advancements/AdvancementFrameType.java
index f5d24950d317c78a971472821595fc1b44befc6e..f096ecf8d77b085e6c2ef4c3b64f0b65409bb287 100644
--- a/src/main/java/net/minecraft/advancements/AdvancementFrameType.java
+++ b/src/main/java/net/minecraft/advancements/AdvancementFrameType.java
@@ -4,16 +4,27 @@ import net.minecraft.EnumChatFormat;
 import net.minecraft.network.chat.ChatMessage;
 import net.minecraft.network.chat.IChatBaseComponent;
 
+import org.bukkit.advancement.FrameType; // Purpur
+
 public enum AdvancementFrameType {
 
-    TASK("task", 0, EnumChatFormat.GREEN), CHALLENGE("challenge", 26, EnumChatFormat.DARK_PURPLE), GOAL("goal", 52, EnumChatFormat.GREEN);
+    // Purpur start
+    TASK("task", 0, EnumChatFormat.GREEN, FrameType.TASK),
+    CHALLENGE("challenge", 26, EnumChatFormat.DARK_PURPLE, FrameType.CHALLENGE),
+    GOAL("goal", 52, EnumChatFormat.GREEN, FrameType.GOAL);
+    // Purpur end
 
     private final String d;
     private final int e;
     private final EnumChatFormat f;
     private final IChatBaseComponent g;
 
-    private AdvancementFrameType(String s, int i, EnumChatFormat enumchatformat) {
+    // Purpur start
+    public final FrameType bukkit;
+
+    AdvancementFrameType(String s, int i, EnumChatFormat enumchatformat, FrameType bukkit) {
+        this.bukkit = bukkit;
+        // Purpur end
         this.d = s;
         this.e = i;
         this.f = enumchatformat;
diff --git a/src/main/java/net/minecraft/advancements/CriterionTrigger.java b/src/main/java/net/minecraft/advancements/CriterionTrigger.java
index f2d74473caf96ca6e871311ef87afa128cd4d0bf..851e69a2f5155d9fa2e5652abdea9aee59e4b20a 100644
--- a/src/main/java/net/minecraft/advancements/CriterionTrigger.java
+++ b/src/main/java/net/minecraft/advancements/CriterionTrigger.java
@@ -29,6 +29,7 @@ public interface CriterionTrigger<T extends CriterionInstance> {
             this.c = s;
         }
 
+        public T getInstance() { return a(); } // Purpur - OBFHELPER
         public T a() {
             return this.a;
         }
diff --git a/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java
index 77abcd6de43302985cdbb2085abece4f621068d4..c859fc16c263e0c50cb01fc722b6f6723d682481 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(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..0b4ff544e04ec314e78a7a48b5bf90ee699b2ad6
--- /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.AdvancementDisplay;
+import org.bukkit.advancement.FrameType;
+import org.bukkit.craftbukkit.util.CraftChatMessage;
+
+public class CraftAdvancementDisplay implements org.bukkit.advancement.AdvancementDisplay {
+    private final AdvancementDisplay handle;
+
+    public CraftAdvancementDisplay(AdvancementDisplay handle) {
+        this.handle = handle;
+    }
+
+    public AdvancementDisplay 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.getFrameType().bukkit;
+    }
+
+    @Override
+    public boolean shouldAnnounceToChat() {
+        return handle.shouldAnnounceToChat();
+    }
+
+    @Override
+    public void setShouldAnnounceToChat(boolean announce) {
+        handle.setShouldAnnounceToChat(announce);
+    }
+
+    @Override
+    public boolean isHidden() {
+        return handle.isHidden();
+    }
+}
