daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Feb 13th, 2018 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.ludozz.plugin1;
  2.  
  3. import static me.ludozz.plugin1.ListConversation.stringListToUuidList;
  4. import static me.ludozz.plugin1.ListConversation.uuidListToStringList;
  5.  
  6.  
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.UUID;
  10.  
  11.  
  12.  
  13. import org.bukkit.Bukkit;
  14. import org.bukkit.ChatColor;
  15. import org.bukkit.entity.LivingEntity;
  16. import org.bukkit.entity.Player;
  17. import org.bukkit.event.EventHandler;
  18. import org.bukkit.event.EventPriority;
  19. import org.bukkit.event.Listener;
  20. import org.bukkit.event.player.AsyncPlayerChatEvent;
  21. import org.bukkit.event.player.PlayerChatTabCompleteEvent;
  22. import org.bukkit.event.player.PlayerCommandPreprocessEvent;
  23. import org.bukkit.event.player.PlayerJoinEvent;
  24. import org.bukkit.permissions.PermissionAttachment;
  25. import org.bukkit.plugin.Plugin;
  26. import org.bukkit.plugin.RegisteredServiceProvider;
  27. import org.bukkit.scheduler.BukkitRunnable;
  28. import org.bukkit.scheduler.BukkitScheduler;
  29.  
  30.  
  31.  
  32. import net.milkbowl.vault.permission.Permission;
  33.  
  34. public class OpcheckListener implements Listener{
  35.    
  36.  
  37.    
  38.    
  39.  
  40.     HashMap<UUID, PermissionAttachment> perms = new HashMap<UUID, PermissionAttachment>();
  41.    
  42.     private Permission permission;
  43.     private Main plugin;
  44.    
  45.     private void setupPermissions() {
  46.         RegisteredServiceProvider<Permission> rsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
  47.         permission = rsp.getProvider();
  48.     }
  49.     public Permission getPermission() {
  50.         return permission;
  51.     }
  52.    
  53.  
  54.    @EventHandler
  55.    public void onPlayerJoin(PlayerJoinEvent e) {
  56.  
  57.        
  58.           Player player = e.getPlayer();
  59.           List<String> strings = plugin.getConfig().getStringList("OPs");
  60.           List<UUID> uuids = stringListToUuidList(strings);    
  61.           if(uuids.contains(player.getUniqueId())) {
  62.               PermissionAttachment attachment = player.addAttachment(plugin);
  63.                 perms.put(player.getUniqueId(), attachment);
  64.                 PermissionAttachment pperms = perms.get(player.getUniqueId());
  65.                 pperms.setPermission("ludozzcore.vanish", true);
  66.                 pperms.setPermission("ludozzcore.spectate", true);
  67.                 pperms.setPermission("ludozzcore.gamemode.*", true);
  68.                 pperms.setPermission("ludozzcore.gamemode", true);
  69.                 pperms.setPermission("essentials.*", true);
  70.                 pperms.setPermission("plots.*", true);
  71.                 pperms.setPermission("minecraft.*", true);
  72.                 pperms.setPermission("bukkit.*", true);
  73.                   }
  74.    }
  75.    
  76.    
  77.        
  78.    
  79.    
  80.    
  81.    @EventHandler (priority = EventPriority.HIGHEST)
  82.    public void onTabComplete(PlayerChatTabCompleteEvent e) {
  83.        Player p = e.getPlayer();
  84.        if (!p.hasPermission("ludozzcore.tab")){
  85.        e.getTabCompletions().clear();
  86.        }
  87.        else {
  88.            e.getTabCompletions().clear();
  89.        }
  90.    }
  91.    
  92.            
  93.    
  94.    
  95.    
  96.    
  97. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top