Advertisement
Guest User

Untitled

a guest
May 20th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. package fr.natsu.plist;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Arrays;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.GameMode;
  8. import org.bukkit.Material;
  9. import org.bukkit.command.Command;
  10. import org.bukkit.command.CommandExecutor;
  11. import org.bukkit.command.CommandSender;
  12. import org.bukkit.entity.Player;
  13. import org.bukkit.inventory.Inventory;
  14. import org.bukkit.inventory.ItemStack;
  15. import org.bukkit.inventory.meta.SkullMeta;
  16.  
  17. public class ListCommand implements CommandExecutor
  18. {
  19.  
  20. public String commandName = "playerslist";
  21.  
  22. @Override
  23. public boolean onCommand(CommandSender sender, Command cmd, String msg, String[] args)
  24. {
  25. if(!(sender instanceof Player))
  26. {
  27. return false;
  28. }
  29.  
  30. else if(sender instanceof Player)
  31. {
  32. if(cmd.getName().equalsIgnoreCase(commandName))
  33. {
  34. Player player = (Player)sender;
  35.  
  36. Inventory inv = Bukkit.createInventory(null, 45, "§7> §9Liste des joueurs");
  37. ItemStack skull = new ItemStack(Material.SKULL_ITEM ,1 , (byte) 3);
  38. SkullMeta sM = (SkullMeta)skull.getItemMeta();
  39. int place = 0;
  40.  
  41. ArrayList<Player> joueurs = new ArrayList<>();
  42.  
  43. for(Player pl : Bukkit.getOnlinePlayers())
  44. {
  45. joueurs.add(pl);
  46. }
  47.  
  48. for(Player pl : joueurs)
  49. {
  50. sM.setOwner(pl.getName());
  51. sM.setDisplayName(pl.getName());
  52. if(pl.isOp())
  53. {
  54. if(pl.getGameMode().equals(GameMode.CREATIVE))
  55. {
  56. if(pl.getHealth() > 10)
  57. {
  58. sM.setLore(Arrays.asList(new String[] {"§9", "§7>§9 OP: §aOui", "§7> §9Gamemode: §aCréatif", "§7> §9Vie: §a"+pl.getHealth(),"§8", "§7§oCliquez pour vous téléporter!"}));
  59. }
  60. else
  61. {
  62. sM.setLore(Arrays.asList(new String[] {"§9", "§7>§9 OP: §aOui", "§7> §9Gamemode: §aCréatif", "§7> §9Vie:§c "+pl.getHealth(),"§8", "§7§oCliquez pour vous téléporter!"}));
  63. }
  64. }
  65. else if(pl.getGameMode().equals(GameMode.SURVIVAL))
  66. {
  67. if(pl.getHealth() > 10)
  68. {
  69. sM.setLore(Arrays.asList(new String[] {"§9", "§7>§9 OP: §aOui", "§7> §9Gamemode: §aSurvie", "§7> §9Vie: §a"+pl.getHealth(),"§8", "§7oCliquez pour vous téléporter!"}));
  70. }
  71. else
  72. {
  73. sM.setLore(Arrays.asList(new String[] {"§9", "§7>§9 OP: §aOui", "§7> §9Gamemode: §aSurvie", "§7> §9Vie:§c "+pl.getHealth(), "§8", "§7§oCliquez pour vous téléporter!"}));
  74. }
  75. }
  76. else if(pl.getGameMode().equals(GameMode.ADVENTURE))
  77. {
  78. if(pl.getHealth() > 10)
  79. {
  80. sM.setLore(Arrays.asList(new String[] {"§9", "§7>§9 OP: §aOui", "§7> §9Gamemode: §aAventure", "§7> §9Vie: §a"+pl.getHealth(), "§8", "§7§oCliquez pour vous téléporter!"}));
  81. }
  82. else
  83. {
  84. sM.setLore(Arrays.asList(new String[] {"§9", "§7>§9 OP: §aOui", "§7> §9Gamemode: §aAventure", "§7> §9Vie:§c "+pl.getHealth(), "§8", "§7§oCliquez pour vous téléporter!"}));
  85. }
  86. }
  87. }
  88. else if(!pl.isOp())
  89. {
  90. if(pl.getGameMode().equals(GameMode.CREATIVE))
  91. {
  92. if(pl.getHealth() > 10)
  93. {
  94. sM.setLore(Arrays.asList(new String[] {"§9", "§7>§9 OP: §cNon", "§7> §9Gamemode: §aCréatif", "§7> §9Vie: §a"+pl.getHealth(), "§8", "§7§oCliquez pour vous téléporter!"}));
  95. }
  96. else
  97. {
  98. sM.setLore(Arrays.asList(new String[] {"§9", "§7>§9 OP: §cNon", "§7> §9Gamemode: §aCréatif", "§7> §9Vie:§c "+pl.getHealth(), "§8", "§7§oCliquez pour vous téléporter!"}));
  99. }
  100. }
  101. else if(pl.getGameMode().equals(GameMode.SURVIVAL))
  102. {
  103. if(pl.getHealth() > 10)
  104. {
  105. sM.setLore(Arrays.asList(new String[] {"§9", "§7>§9 OP: §cNon", "§7> §9Gamemode: §aSurvie", "§7> §9Vie: §a"+pl.getHealth(), "§8", "§7§oCliquez pour vous téléporter!"}));
  106. }
  107. else
  108. {
  109. sM.setLore(Arrays.asList(new String[] {"§9", "§7>§9 OP: §cNon", "§7> §9Gamemode: §aSurvie", "§7> §9Vie:§c "+pl.getHealth(),"§8", "§7§oCliquez pour vous téléporter!"}));
  110. }
  111. }
  112. else if(pl.getGameMode().equals(GameMode.ADVENTURE))
  113. {
  114. if(pl.getHealth() > 10)
  115. {
  116. sM.setLore(Arrays.asList(new String[] {"§9", "§7>§9 OP: §cNon", "§7> §9Gamemode: §aAventure", "§7> §9Vie: §a"+pl.getHealth(), "§8", "§7§oCliquez pour vous téléporter!"}));
  117. }
  118. else
  119. {
  120. sM.setLore(Arrays.asList(new String[] {"§9", "§7>§9 OP: §cNon", "§7> §9Gamemode: §aAventure", "§7> §9Vie:§c "+pl.getHealth(),"§8", "§7§oCliquez pour vous téléporter!"}));
  121. }
  122. }
  123. }
  124.  
  125. skull.setItemMeta(sM);
  126.  
  127. inv.setItem(place, skull);
  128. place++;
  129. }
  130.  
  131. player.closeInventory();
  132. player.openInventory(inv);
  133. player.updateInventory();
  134.  
  135.  
  136.  
  137. }
  138. }
  139.  
  140. return false;
  141. }
  142.  
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement