Working on permissions handling
This commit is contained in:
		@@ -56,7 +56,7 @@ public class Factions extends JavaPlugin {
 | 
				
			|||||||
	private final FactionsEntityListener entityListener = new FactionsEntityListener();
 | 
						private final FactionsEntityListener entityListener = new FactionsEntityListener();
 | 
				
			||||||
	private final FactionsBlockListener blockListener = new FactionsBlockListener();
 | 
						private final FactionsBlockListener blockListener = new FactionsBlockListener();
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	private static PermissionHandler Permissions;
 | 
						public static PermissionHandler Permissions;
 | 
				
			||||||
	private static EssentialsChat essChat;
 | 
						private static EssentialsChat essChat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Commands
 | 
						// Commands
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										55
									
								
								src/com/massivecraft/factions/struct/Permission.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								src/com/massivecraft/factions/struct/Permission.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,55 @@
 | 
				
			|||||||
 | 
					package com.massivecraft.factions.struct;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.command.CommandSender;
 | 
				
			||||||
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.massivecraft.factions.Factions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public enum Permission
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						PARTICIPATE("factions.participate"),
 | 
				
			||||||
 | 
						CREATE("factions.create"),
 | 
				
			||||||
 | 
						VIEW_ANY_POWER("factions.viewAnyPower"),
 | 
				
			||||||
 | 
						PEACEFUL_EXPLOTION_TOGGLE("factions.peacefulExplosionToggle"),
 | 
				
			||||||
 | 
						ADMIN_BYPASS("factions.adminBypass"),
 | 
				
			||||||
 | 
						CONFIG("factions.config"),
 | 
				
			||||||
 | 
						DISBAN("factions.disband"),
 | 
				
			||||||
 | 
						LOCK("factions.lock"),
 | 
				
			||||||
 | 
						MANAGE_SAFE_ZONE("factions.manageSafeZone"),
 | 
				
			||||||
 | 
						MANAGE_WAR_ZONE("factions.manageWarZone"),
 | 
				
			||||||
 | 
						OWNERSHIP_BYPASS("factions.ownershipBypass"),
 | 
				
			||||||
 | 
						RELOAD("factions.reload"),
 | 
				
			||||||
 | 
						SAVE_ALL("factions.saveall"),
 | 
				
			||||||
 | 
						SET_PEACEFUL("factions.setPeaceful"),
 | 
				
			||||||
 | 
						;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public final String node;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						Permission(final String node)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.node = node;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public boolean has(CommandSender sender)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							//return CreativeGates.p.perm.has(sender, this.node);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public static boolean isCommandDisabled(CommandSender sender, String command)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return (hasPerm(sender, "factions.commandDisable."+command) && !hasPerm(sender, "factions.commandDisable.none"));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						private static boolean hasPerm(CommandSender sender, String permNode)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (Factions.Permissions == null || ! (sender instanceof Player))
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return sender.isOp() || sender.hasPermission(permNode);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							Player player = (Player)sender;
 | 
				
			||||||
 | 
							return Factions.Permissions.has(player, permNode); 
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user