1. 添加本地化支持 2. 修复 /perm 制定用户错误 3. 修复 UserTencent 不识别是否注册直接设置权限 4. 给 PermissionManager 加上了注解
		
			
				
	
	
		
			56 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
package ren.taske.nativebot.bot.permission;
 | 
						|
 | 
						|
import java.util.HashMap;
 | 
						|
 | 
						|
import ren.taske.nativebot.core.NativeBot;
 | 
						|
 | 
						|
public class Permission {
 | 
						|
 | 
						|
	private static final HashMap<String, Permission> PERMS = new HashMap<>();
 | 
						|
	
 | 
						|
	private static boolean lock;
 | 
						|
	
 | 
						|
	protected final String name;
 | 
						|
	protected final boolean def;
 | 
						|
	
 | 
						|
	private Permission(String name) {
 | 
						|
		this(name, false);
 | 
						|
	}
 | 
						|
	
 | 
						|
	private Permission(String name, boolean def) {
 | 
						|
		this.name = name;
 | 
						|
		this.def  = def;
 | 
						|
	}
 | 
						|
	
 | 
						|
	/**
 | 
						|
	 * <code>null</code>, if locked and un-registered
 | 
						|
	 * @param name
 | 
						|
	 * @return
 | 
						|
	 */
 | 
						|
	public static Permission of(String name) {
 | 
						|
		return of(name, false);
 | 
						|
	}
 | 
						|
	
 | 
						|
	public static Permission of(String name, boolean def) {
 | 
						|
		if(!PERMS.containsKey(name)) {
 | 
						|
			if(lock) return null;
 | 
						|
			PERMS.put(name, new Permission(name, def));
 | 
						|
			NativeBot.logger().info("Register Permission Node "+name + " (def: " + def + ")");
 | 
						|
		}
 | 
						|
		return PERMS.get(name);
 | 
						|
	}
 | 
						|
	
 | 
						|
	public static void lock() {
 | 
						|
		lock = true;
 | 
						|
	}
 | 
						|
	
 | 
						|
	public String getName() {
 | 
						|
		return this.name;
 | 
						|
	}
 | 
						|
	
 | 
						|
	public boolean getDefault() {
 | 
						|
		return this.def;
 | 
						|
	}
 | 
						|
	
 | 
						|
}
 |