From 4da74a5419664c4804970c439a3357fbb74b56a1 Mon Sep 17 00:00:00 2001
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Date: Wed, 3 Nov 2021 19:42:18 -0700
Subject: [PATCH] Remove redundant and unneeded repos, reorder repos (#6867)

---
 build.gradle.kts                                 | 16 +++-------------
 patches/server/Basic-PlayerProfile-API.patch     |  2 +-
 patches/server/Build-system-changes.patch        |  1 -
 ...onParseException-in-Entity-and-TE-names.patch |  4 ++--
 ...tacktraces-in-log-messages-crash-report.patch |  2 +-
 patches/server/MC-Utils.patch                    |  7 ++++++-
 6 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/build.gradle.kts b/build.gradle.kts
index 0bcc5758b4..d03a8cacad 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -34,22 +34,14 @@ subprojects {
 
     repositories {
         mavenCentral()
-        maven("https://repo1.maven.org/maven2/")
-        maven("https://oss.sonatype.org/content/groups/public/")
         maven("https://papermc.io/repo/repository/maven-public/")
-        maven("https://ci.emc.gs/nexus/content/groups/aikar/")
-        maven("https://repo.aikar.co/content/groups/aikar")
-        maven("https://repo.md-5.net/content/repositories/releases/")
-        maven("https://hub.spigotmc.org/nexus/content/groups/public/")
     }
 }
 
 repositories {
     mavenCentral()
     maven("https://papermc.io/repo/repository/maven-public/") {
-        content {
-            onlyForConfigurations("paperclip")
-        }
+        content { onlyForConfigurations("paperclip") }
     }
 }
 
@@ -96,12 +88,10 @@ tasks.generateDevelopmentBundle {
     mojangApiCoordinates.set("io.papermc.paper:paper-mojangapi")
     libraryRepositories.set(
         listOf(
+            "https://repo.maven.apache.org/maven2/",
             "https://libraries.minecraft.net/",
-            "https://maven.quiltmc.org/repository/release/",
-            "https://repo.aikar.co/content/groups/aikar",
-            "https://ci.emc.gs/nexus/content/groups/aikar/",
             "https://papermc.io/repo/repository/maven-public/",
-            "https://repo.velocitypowered.com/snapshots/"
+            "https://maven.quiltmc.org/repository/release/",
         )
     )
 }
diff --git a/patches/server/Basic-PlayerProfile-API.patch b/patches/server/Basic-PlayerProfile-API.patch
index a8f1210f37..555ed46933 100644
--- a/patches/server/Basic-PlayerProfile-API.patch
+++ b/patches/server/Basic-PlayerProfile-API.patch
@@ -439,7 +439,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +import com.destroystokyo.paper.profile.PlayerProfile;
  import com.google.common.util.concurrent.ThreadFactoryBuilder;
  import it.unimi.dsi.fastutil.objects.ObjectRBTreeSet;
- import net.minecraft.core.BlockPos;
+ import java.lang.ref.Cleaner;
 @@ -0,0 +0,0 @@ import net.minecraft.world.level.ChunkPos;
  import net.minecraft.world.level.ClipContext;
  import net.minecraft.world.level.Level;
diff --git a/patches/server/Build-system-changes.patch b/patches/server/Build-system-changes.patch
index 65fcfc83b0..df9ea7d488 100644
--- a/patches/server/Build-system-changes.patch
+++ b/patches/server/Build-system-changes.patch
@@ -31,7 +31,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
      runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.0")
      runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.0")
  
-+    implementation("co.aikar:cleaner:1.0-SNAPSHOT") // Paper
 +    implementation("io.netty:netty-all:4.1.65.Final") // Paper
 +
      testImplementation("junit:junit:4.13.1")
diff --git a/patches/server/Catch-JsonParseException-in-Entity-and-TE-names.patch b/patches/server/Catch-JsonParseException-in-Entity-and-TE-names.patch
index 10c9fe210e..bfb53789b3 100644
--- a/patches/server/Catch-JsonParseException-in-Entity-and-TE-names.patch
+++ b/patches/server/Catch-JsonParseException-in-Entity-and-TE-names.patch
@@ -16,8 +16,8 @@ diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/
 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/server/MCUtil.java
 +++ b/src/main/java/net/minecraft/server/MCUtil.java
-@@ -0,0 +0,0 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
- import it.unimi.dsi.fastutil.objects.ObjectRBTreeSet;
+@@ -0,0 +0,0 @@ import it.unimi.dsi.fastutil.objects.ObjectRBTreeSet;
+ import java.lang.ref.Cleaner;
  import net.minecraft.core.BlockPos;
  import net.minecraft.core.Direction;
 +import net.minecraft.nbt.CompoundTag;
diff --git a/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch
index efb3a16dc8..c2d3ee8c31 100644
--- a/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch
+++ b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch
@@ -35,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
  
  dependencies {
 @@ -0,0 +0,0 @@ dependencies {
-     implementation("co.aikar:cleaner:1.0-SNAPSHOT") // Paper
+ 
      implementation("io.netty:netty-all:4.1.65.Final") // Paper
  
 +    implementation("org.quiltmc:tiny-mappings-parser:0.3.0") // Paper - needed to read mappings for stacktrace deobfuscation
diff --git a/patches/server/MC-Utils.patch b/patches/server/MC-Utils.patch
index b336984029..a101a1f015 100644
--- a/patches/server/MC-Utils.patch
+++ b/patches/server/MC-Utils.patch
@@ -4489,6 +4489,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +
 +import com.google.common.util.concurrent.ThreadFactoryBuilder;
 +import it.unimi.dsi.fastutil.objects.ObjectRBTreeSet;
++import java.lang.ref.Cleaner;
 +import net.minecraft.core.BlockPos;
 +import net.minecraft.core.Direction;
 +import net.minecraft.server.level.ServerLevel;
@@ -4561,10 +4562,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    public static Runnable registerCleaner(Object obj, Runnable run) {
 +        // Wrap callback in its own method above or the lambda will leak object
 +        Runnable cleaner = makeCleanerCallback(run);
-+        co.aikar.cleaner.Cleaner.register(obj, cleaner);
++        CleanerHolder.CLEANER.register(obj, cleaner);
 +        return cleaner;
 +    }
 +
++    private static final class CleanerHolder {
++        private static final Cleaner CLEANER = Cleaner.create();
++    }
++
 +    /**
 +     * DANGER WILL ROBINSON: Be sure you do not use a lambda that lives in the object being monitored, or leaky leaky!
 +     * @param obj