mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 09:15:38 +00:00
293ea04c56
* rename everything containing staff back to admin (as requested by ryan i've renamed commands like slconfig to saconfig but left "slconfig" as an alias) * format almost every file correctly * a few other improvements
51 lines
1.8 KiB
Java
51 lines
1.8 KiB
Java
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
|
|
|
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
|
@CommandParameters(description = "Check your permissions", usage = "/<command> [prefix | reload]")
|
|
public class Command_permissions extends FreedomCommand
|
|
{
|
|
@Override
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
{
|
|
if (args.length > 0 && args[0].equalsIgnoreCase("reload") && plugin.al.isAdmin(sender))
|
|
{
|
|
plugin.permissions.load();
|
|
plugin.pem.loadPermissionNodes();
|
|
plugin.pem.updatePlayers();
|
|
msg("Reloaded permissions");
|
|
}
|
|
else
|
|
{
|
|
String prefix = "";
|
|
if (args.length > 0)
|
|
{
|
|
prefix = args[0];
|
|
}
|
|
checkPlayer();
|
|
List<String> permissions = new ArrayList<>();
|
|
for (PermissionAttachmentInfo attachmentInfo : playerSender.getEffectivePermissions())
|
|
{
|
|
if (attachmentInfo.getValue())
|
|
{
|
|
String permission = attachmentInfo.getPermission();
|
|
if (!prefix.isEmpty() && !permission.startsWith(prefix))
|
|
{
|
|
continue;
|
|
}
|
|
permissions.add(permission);
|
|
}
|
|
}
|
|
msg(String.join(", ", permissions));
|
|
}
|
|
|
|
return true;
|
|
}
|
|
} |