Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.49 KB | None | 0 0
  1. JOIN:
  2.     @EventHandler
  3.     public void onJoin(PlayerJoinEvent e) {
  4.         final Player p = e.getPlayer();
  5.         Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(this, new Runnable() {
  6.         for(Player po : Bukkit.getOnlinePlayers()) {
  7.             if(po.hasPermission("bookchecker.check")) {
  8.                 Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
  9.                     @Override
  10.                     public void run() {
  11.                         String targetName = null;
  12.                         UUID targetUUID = null;
  13.                         if(e.getPlayer().getName().matches("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}")) {
  14.                             targetUUID = UUID.fromString(e.getPlayer().getName());
  15.                         } else {
  16.                             targetName = e.getPlayer().getName();
  17.                         }
  18.                         HashMap<String, List<String>> alts = new HashMap();
  19.                         if(targetUUID == null) {
  20.                             alts = Main.this.getAlts1(e.getPlayer(), targetName);
  21.                         } else if (targetName == null) {
  22.                             alts = Main.this.getAlts1(e.getPlayer(), targetUUID);
  23.                         }
  24.                         for (Map.Entry<String, List<String>> entry : alts.entrySet()) {
  25.                             po.sendMessage("§cNick'i, z ktorych sie logowal gracz §4[" + e.getPlayer().getName() + "]§c: §4" + ((List)entry.getValue()).toString());
  26.                         }
  27.                     }
  28.                 }, 1L);
  29.             }
  30.         }
  31.     }
  32. GETALTS1:
  33.     public HashMap<String, List<String>> getAlts1(Player p, String name) {
  34.         UUID uuid = null;
  35.         HashMap<String, List<String>> toReturn = new HashMap();
  36.         String foundName;
  37.         for(String s : Main.this.getConfig().getConfigurationSection("players.").getKeys(false)) {
  38.             foundName = Main.this.getConfig().getString("players." + s + ".name");
  39.             if(foundName.equalsIgnoreCase(name)) {
  40.                 uuid = UUID.fromString(s);
  41.                 break;
  42.             }
  43.         }
  44.         if (uuid == null) {
  45.             return toReturn;
  46.         }
  47.         List<String> ips = getConfig().getStringList("players." + uuid.toString() + ".ips");
  48.         if ((getConfig().getBoolean("players." + uuid.toString() + ".allowChecks")) && (!p.hasPermission("bookchecker.bypass"))) {
  49.             return toReturn;
  50.         }
  51.         for(String ip : ips) {
  52.             toReturn.put(ip, findNames(ip));
  53.         }
  54.         return toReturn;
  55.     }
  56.    
  57.     public HashMap<String, List<String>> getAlts1(Player p, UUID uuid) {
  58.         HashMap<String, List<String>> toReturn = new HashMap();
  59.         List<String> ips = getConfig().getStringList("players." + uuid.toString() + ".ips");
  60.         if ((getConfig().getBoolean("players." + uuid.toString() + ".allowChecks")) && (!p.hasPermission("bookchecker.bypass"))) {
  61.             return toReturn;
  62.         }
  63.         for(String ip : ips) {
  64.             toReturn.put(ip, findNames(ip));
  65.         }
  66.         return toReturn;
  67.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement