Skip to content

Commit

Permalink
Fixed major issue with cooldown exempt permission
Browse files Browse the repository at this point in the history
  • Loading branch information
Picono435 committed Aug 10, 2021
1 parent 4fd7d8e commit 57856bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerPlayer;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -15,4 +16,8 @@ public static boolean hasPermission(CommandSourceStack source, String permission
return Permissions.check(source, permission, registeredNodes.get(permission));
}

public static boolean hasPermission(ServerPlayer player, String permission) {
return Permissions.check(player, permission, registeredNodes.get(permission));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void onInitialize() {

RandomTPAPIImpl.registeredNodes.put("randomtp.command.basic", 0);
RandomTPAPIImpl.registeredNodes.put("randomtp.command.interdim", 0);
RandomTPAPIImpl.registeredNodes.put("randomtp.command.exempt", 1);
RandomTPAPIImpl.registeredNodes.put("randomtp.cooldown.exempt", 1);

RandomTP.getLogger().info("RandomTP successfully loaded.");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.server.permission.PermissionAPI;

public class RandomTPAPIImpl {

public static boolean hasPermission(CommandSourceStack source, String permission) {
try {
return PermissionAPI.hasPermission(source.getPlayerOrException(), permission);
Expand All @@ -14,4 +15,8 @@ public static boolean hasPermission(CommandSourceStack source, String permission
}
}

public static boolean hasPermission(ServerPlayer player, String permission) {
return PermissionAPI.hasPermission(player, permission);
}

}

0 comments on commit 57856bb

Please sign in to comment.