Skip to content

Commit

Permalink
Actually add custom permissions to avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Nov 20, 2024
1 parent 926b125 commit c18f497
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions common/src/main/java/org/figuramc/figura/avatar/Avatar.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Instructions> customInstructions = new HashMap<>();
public final RefilledNumber particlesRemaining, soundsRemaining;
private Avatar(UUID owner, EntityType<?> type, String name) {
this.owner = owner;
Expand All @@ -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<Permissions> pluginPermissions : PermissionManager.CUSTOM_PERMISSIONS.values()) {
for (Permissions customPermission : pluginPermissions) {
customInstructions.putIfAbsent(customPermission.name, new Instructions(permissions.get(customPermission)));
}
}
}

public Avatar(UUID owner) {
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/java/org/figuramc/figura/config/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -270,6 +271,7 @@ public void onChange() {
super.onChange();
PermissionManager.reinit();
LocalAvatarFetcher.reinit();
EntryPointManager.reinit();
}
};
public static final ConfigType.IPConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T> Set<T> load(String name, Class<T> clazz) {
throw new AssertionError();
Expand Down

0 comments on commit c18f497

Please sign in to comment.