From c18f497aa0d96ce8b89b9d92e9580f9f049266de Mon Sep 17 00:00:00 2001 From: UnlikePaladin <36827970+UnlikePaladin@users.noreply.github.com> Date: Wed, 20 Nov 2024 02:24:15 -0600 Subject: [PATCH] Actually add custom permissions to avatar --- .../src/main/java/org/figuramc/figura/avatar/Avatar.java | 7 +++++++ .../src/main/java/org/figuramc/figura/config/Configs.java | 2 ++ .../org/figuramc/figura/entries/EntryPointManager.java | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/common/src/main/java/org/figuramc/figura/avatar/Avatar.java b/common/src/main/java/org/figuramc/figura/avatar/Avatar.java index 66b5f3a9f..fbad4a74e 100644 --- a/common/src/main/java/org/figuramc/figura/avatar/Avatar.java +++ b/common/src/main/java/org/figuramc/figura/avatar/Avatar.java @@ -130,6 +130,7 @@ public class Avatar { public int animationComplexity; public final Instructions complexity; public final Instructions init, render, worldRender, tick, worldTick, animation; + public final Map customInstructions = new HashMap<>(); public final RefilledNumber particlesRemaining, soundsRemaining; private Avatar(UUID owner, EntityType type, String name) { this.owner = owner; @@ -146,6 +147,12 @@ private Avatar(UUID owner, EntityType type, String name) { this.particlesRemaining = new RefilledNumber(permissions.get(Permissions.PARTICLES)); this.soundsRemaining = new RefilledNumber(permissions.get(Permissions.SOUNDS)); this.entityName = name == null ? "" : name; + + for (Collection pluginPermissions : PermissionManager.CUSTOM_PERMISSIONS.values()) { + for (Permissions customPermission : pluginPermissions) { + customInstructions.putIfAbsent(customPermission.name, new Instructions(permissions.get(customPermission))); + } + } } public Avatar(UUID owner) { diff --git a/common/src/main/java/org/figuramc/figura/config/Configs.java b/common/src/main/java/org/figuramc/figura/config/Configs.java index e9b9769a4..2de5d5e2f 100644 --- a/common/src/main/java/org/figuramc/figura/config/Configs.java +++ b/common/src/main/java/org/figuramc/figura/config/Configs.java @@ -8,6 +8,7 @@ import org.figuramc.figura.avatar.local.CacheAvatarLoader; import org.figuramc.figura.avatar.local.LocalAvatarFetcher; import org.figuramc.figura.backend2.NetworkStuff; +import org.figuramc.figura.entries.EntryPointManager; import org.figuramc.figura.gui.FiguraToast; import org.figuramc.figura.gui.screens.ConfigScreen; import org.figuramc.figura.lua.FiguraLuaPrinter; @@ -270,6 +271,7 @@ public void onChange() { super.onChange(); PermissionManager.reinit(); LocalAvatarFetcher.reinit(); + EntryPointManager.reinit(); } }; public static final ConfigType.IPConfig diff --git a/common/src/main/java/org/figuramc/figura/entries/EntryPointManager.java b/common/src/main/java/org/figuramc/figura/entries/EntryPointManager.java index b32b54ff8..05cc383a6 100644 --- a/common/src/main/java/org/figuramc/figura/entries/EntryPointManager.java +++ b/common/src/main/java/org/figuramc/figura/entries/EntryPointManager.java @@ -25,6 +25,10 @@ public static void init() { EventsAPI.initEntryPoints(load("figura_event", FiguraEvent.class)); } + public static void reinit() { + PermissionManager.initEntryPoints(load("figura_permissions", FiguraPermissions.class)); + } + @ExpectPlatform private static Set load(String name, Class clazz) { throw new AssertionError();