From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Wed, 30 Jun 2021 17:44:27 -0500
Subject: [PATCH] Fix default permission system


diff --git a/src/main/java/org/bukkit/permissions/PermissibleBase.java b/src/main/java/org/bukkit/permissions/PermissibleBase.java
index c94e4cdb5785d5dfcb704c4adabda0b19a20ec7d..0c154e748fe957152777869679bdbdce1524a5a1 100644
--- a/src/main/java/org/bukkit/permissions/PermissibleBase.java
+++ b/src/main/java/org/bukkit/permissions/PermissibleBase.java
@@ -172,7 +172,7 @@ public class PermissibleBase implements Permissible {
 
         for (Permission perm : defaults) {
             String name = perm.getName().toLowerCase(java.util.Locale.ENGLISH);
-            permissions.put(name, new PermissionAttachmentInfo(parent, name, null, true));
+            permissions.put(name, new PermissionAttachmentInfo(parent, name, null, perm.getDefault().getValue(isOp()))); // Purpur
             Bukkit.getServer().getPluginManager().subscribeToPermission(name, parent);
             calculateChildPermissions(perm.getChildren(), false, null);
         }
@@ -200,7 +200,7 @@ public class PermissibleBase implements Permissible {
             String name = entry.getKey();
 
             Permission perm = Bukkit.getServer().getPluginManager().getPermission(name);
-            boolean value = entry.getValue() ^ invert;
+            boolean value = (entry.getValue() == null && perm != null ? perm.getDefault().getValue(isOp()) : entry.getValue()) ^ invert; // Purpur
             String lname = name.toLowerCase(java.util.Locale.ENGLISH);
 
             permissions.put(lname, new PermissionAttachmentInfo(parent, lname, attachment, value));
diff --git a/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java b/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java
index 8e481e3815f5645ee92f0d229e5ff25c8fc9a6c2..10627d2a11251a8cb01bbc3f6242d66f3505a16e 100644
--- a/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java
+++ b/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java
@@ -31,7 +31,7 @@ public final class DefaultPermissions {
 
         if (withLegacy) {
             Permission legacy = new Permission(LEGACY_PREFIX + result.getName(), result.getDescription(), PermissionDefault.FALSE);
-            legacy.getChildren().put(result.getName(), true);
+            legacy.getChildren().put(result.getName(), null); // Purpur
             registerPermission(perm, false);
         }
 
@@ -40,7 +40,7 @@ public final class DefaultPermissions {
 
     @NotNull
     public static Permission registerPermission(@NotNull Permission perm, @NotNull Permission parent) {
-        parent.getChildren().put(perm.getName(), true);
+        parent.getChildren().put(perm.getName(), null); // Purpur
         return registerPermission(perm);
     }
 
@@ -53,7 +53,7 @@ public final class DefaultPermissions {
     @NotNull
     public static Permission registerPermission(@NotNull String name, @Nullable String desc, @NotNull Permission parent) {
         Permission perm = registerPermission(name, desc);
-        parent.getChildren().put(perm.getName(), true);
+        parent.getChildren().put(perm.getName(), null); // Purpur
         return perm;
     }
 
@@ -66,7 +66,7 @@ public final class DefaultPermissions {
     @NotNull
     public static Permission registerPermission(@NotNull String name, @Nullable String desc, @Nullable PermissionDefault def, @NotNull Permission parent) {
         Permission perm = registerPermission(name, desc, def);
-        parent.getChildren().put(perm.getName(), true);
+        parent.getChildren().put(perm.getName(), null); // Purpur
         return perm;
     }
 
@@ -79,7 +79,7 @@ public final class DefaultPermissions {
     @NotNull
     public static Permission registerPermission(@NotNull String name, @Nullable String desc, @Nullable PermissionDefault def, @Nullable Map<String, Boolean> children, @NotNull Permission parent) {
         Permission perm = registerPermission(name, desc, def, children);
-        parent.getChildren().put(perm.getName(), true);
+        parent.getChildren().put(perm.getName(), null); // Purpur
         return perm;
     }
 
