Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.75 KB | None | 0 0
  1. package fr.LobbyTest.src;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.Location;
  6. import org.bukkit.Material;
  7. import org.bukkit.block.Block;
  8. import org.bukkit.block.Sign;
  9. import org.bukkit.command.Command;
  10. import org.bukkit.command.CommandSender;
  11. import org.bukkit.entity.Player;
  12. import org.bukkit.event.EventHandler;
  13. import org.bukkit.event.Listener;
  14. import org.bukkit.event.block.Action;
  15. import org.bukkit.event.block.SignChangeEvent;
  16. import org.bukkit.event.player.PlayerInteractEvent;
  17. import org.bukkit.plugin.PluginManager;
  18. import org.bukkit.plugin.java.JavaPlugin;
  19.  
  20. public class MainClass extends JavaPlugin implements Listener {
  21.  
  22.  
  23.  
  24.  
  25.  
  26. @Override
  27. public void onEnable()
  28. {
  29.  
  30.  
  31.  
  32.  
  33.  
  34. getConfig().createSection("Lobby");
  35. getConfig().createSection("Lobby.x");
  36. getConfig().createSection("Lobby.y");
  37. getConfig().createSection("Lobby.z");
  38.  
  39. saveConfig();
  40.  
  41.  
  42.  
  43. PluginManager pm = getServer().getPluginManager();
  44. pm.registerEvents(this, this);
  45.  
  46. }
  47.  
  48. @Override
  49. public void onDisable()
  50. {
  51.  
  52. }
  53.  
  54. //Commande de définition du Lobby
  55.  
  56. public void goTo(Player p){
  57. if(!getConfig().get("Lobby").equals(null)){
  58. int x = getConfig().getConfigurationSection("Lobby").getInt("Lobby"+".x");
  59. int y = getConfig().getConfigurationSection("Lobby").getInt("Lobby"+".y");
  60. int z = getConfig().getConfigurationSection("Lobby").getInt("Lobby"+".z");
  61. String world = getConfig().getConfigurationSection("Lobby").getString("Lobby"+".world");
  62. Location loc = new Location(Bukkit.getWorld(world), x, y, z);
  63. p.teleport(loc);
  64. }else{
  65. p.sendMessage("Aucun lieu ne porte ce nom");
  66. }
  67. }
  68.  
  69.  
  70. public boolean onCommand(CommandSender sender, Command cmd, String label, String[]args)
  71. {
  72. Player p = (Player) sender;
  73.  
  74. if(cmd.getName().equalsIgnoreCase("setlobby"))
  75. {
  76. int locX = p.getLocation().getBlockX();
  77. int locY = p.getLocation().getBlockY();
  78. int locZ = p.getLocation().getBlockZ();
  79. String world = p.getWorld().getName();
  80. getConfig().createSection("Lobby");
  81. getConfig().getConfigurationSection("Lobby").set("Lobby"+".x", locX);
  82. getConfig().getConfigurationSection("Lobby").set("Lobby"+".y", locY);
  83. getConfig().getConfigurationSection("Lobby").set("Lobby"+".z", locZ);
  84. getConfig().getConfigurationSection("Lobby").set("Lobby"+"world", world);
  85.  
  86. saveConfig();
  87. }
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95. return true;
  96. }
  97.  
  98. //@EventHandler
  99. public void LobbySign(PlayerInteractEvent e)
  100. {
  101. Player p = e.getPlayer();
  102. Block b = e.getClickedBlock();
  103.  
  104.  
  105.  
  106. if(e.getAction() == Action.RIGHT_CLICK_BLOCK)
  107. {
  108. p.sendMessage("A");
  109.  
  110. if(b.getType() == Material.SIGN)
  111.  
  112. {
  113. p.sendMessage("B");
  114. }
  115. Sign s = (Sign) b.getState();
  116. if(s.getLine(0).contains(ChatColor.GREEN+"Lobby"))
  117. {
  118. p.sendMessage("C");
  119.  
  120. s.update();
  121. goTo(p);
  122.  
  123. }
  124. }
  125. }
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132. @EventHandler
  133. public void ChangeLobbySign(SignChangeEvent e)
  134. {
  135. if(e.getLine(0).contains("Lobby"))
  136. {
  137. e.setLine(0, ChatColor.GREEN+"Lobby");
  138. e.setLine(1, ChatColor.RED+"Joueurs:");
  139. }
  140. }
  141.  
  142.  
  143.  
  144.  
  145. }
  146.  
  147.  
  148. package fr.test3.src;
  149.  
  150. import java.util.ArrayList;
  151.  
  152. import org.bukkit.Bukkit;
  153. import org.bukkit.ChatColor;
  154. import org.bukkit.Location;
  155. import org.bukkit.Material;
  156. import org.bukkit.block.Block;
  157. import org.bukkit.block.Sign;
  158. import org.bukkit.command.Command;
  159. import org.bukkit.command.CommandSender;
  160. import org.bukkit.entity.Player;
  161. import org.bukkit.event.EventHandler;
  162. import org.bukkit.event.Listener;
  163. import org.bukkit.event.block.Action;
  164. import org.bukkit.event.block.SignChangeEvent;
  165. import org.bukkit.event.entity.PlayerDeathEvent;
  166. import org.bukkit.event.player.PlayerInteractEvent;
  167. import org.bukkit.plugin.java.JavaPlugin;
  168.  
  169. public class MainClass extends JavaPlugin implements Listener {
  170. // < >
  171.  
  172.  
  173. public static ArrayList<String> blue = new ArrayList<>(); // TEAM BLUE LIST
  174. public static ArrayList<String> red = new ArrayList<>(); // TEAM RED LIST
  175.  
  176.  
  177. public void onEnable()
  178.  
  179. {
  180. getServer().getPluginManager().registerEvents(this, this);
  181. System.out.println("TEST3 ENABLED.");
  182.  
  183. getConfig().createSection("Lobby");
  184. getConfig().createSection("Lobby.x");
  185. getConfig().createSection("Lobby.z");
  186. getConfig().createSection("Lobby.z");
  187.  
  188. saveConfig();
  189.  
  190. }
  191.  
  192. public void onDisable()
  193.  
  194. {
  195.  
  196. System.out.println("TEST3 DISABLED");
  197.  
  198.  
  199. }
  200.  
  201. public void goTo(Player p, String lieu)
  202.  
  203. {
  204. int x = getConfig().getConfigurationSection("Lobby").getInt("Lobby"+".x");
  205. int y = getConfig().getConfigurationSection("Lobby").getInt("Lobby"+".y");
  206. int z = getConfig().getConfigurationSection("Lobby").getInt("Lobby"+".z");
  207. String world = getConfig().getConfigurationSection("Lobby").getString("Lobby"+".world");
  208.  
  209. Location loc = new Location(Bukkit.getWorld(world),x ,y ,z);
  210. p.teleport(loc);
  211.  
  212.  
  213.  
  214. }
  215.  
  216.  
  217.  
  218.  
  219.  
  220. //TOUTE LES COMMANDES -------------------------------------------------------------------//
  221. public boolean onCommand(CommandSender sender, Command cmd, String label, String[]args)
  222. {
  223. Player p = (Player) sender;
  224. if(cmd.getName().equalsIgnoreCase("blue")) // JOIN TEAM BLUE
  225. {
  226. if(blue.size() < 3)
  227. {
  228. red.remove(p.getName());
  229. blue.remove(p.getName());
  230. blue.add(p.getName());
  231. p.sendMessage(ChatColor.GREEN+"Vous avez bien rejoins l'équipe §9bleue !");
  232. p.setCustomName(ChatColor.RED+p.getName());
  233. }
  234.  
  235.  
  236. }
  237. if(cmd.getName().equalsIgnoreCase("red")) // JOIN TEAM RED
  238. {
  239. if(red.size() < 3)
  240.  
  241. {
  242. blue.remove(p.getName());
  243. red.remove(p.getName());
  244. red.add(p.getName());
  245. p.sendMessage(ChatColor.GREEN+"Vous avez bien rejoins l'équipe §crouge !");
  246. p.setCustomName(ChatColor.RED+p.getName());
  247. }
  248.  
  249. }
  250. if(cmd.getName().equalsIgnoreCase("setlobby"))
  251. {
  252. int locX = p.getLocation().getBlockX();
  253. int locY = p.getLocation().getBlockY();
  254. int locZ = p.getLocation().getBlockZ();
  255. String world = p.getWorld().getName();
  256. getConfig().getConfigurationSection("Lobby").set(".x", locX);
  257. getConfig().getConfigurationSection("Lobby").set(".y", locY);
  258. getConfig().getConfigurationSection("Lobby").set(".z", locZ);
  259. getConfig().getConfigurationSection("Lobby").set("world", world);
  260.  
  261.  
  262.  
  263. saveConfig();
  264. p.sendMessage(ChatColor.GOLD+"Le lobby a été défini avec succés !");
  265. ///////////////////////////////////////////////////////////////////////// FIN DES COMMANDES //////////////////////////////////////////////////////////////////////////////////////////
  266.  
  267.  
  268. }
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280. return true;
  281. }
  282.  
  283.  
  284.  
  285.  
  286. ////////////////////////////////////////EVENTS/////////////////////////////////////////////////
  287. @EventHandler
  288. public static void mort(PlayerDeathEvent e)
  289. {
  290. Player p = e.getEntity().getPlayer();
  291.  
  292. if(blue.contains(p.getName()))
  293. {
  294.  
  295. Bukkit.broadcastMessage(ChatColor.YELLOW+"Le joueur de l'équipe §9 bleue : "+p.getName()+ " §e est mort.");
  296. blue.remove(p.getName());
  297. if(blue.size() == 0)
  298. {
  299. Bukkit.broadcastMessage(ChatColor.RED+"§eL'équipe §9bleue §ea été exterminé !");
  300. }
  301.  
  302. }
  303. if(red.contains(p.getName()))
  304. {
  305.  
  306. Bukkit.broadcastMessage("§eLe joueur de l'équipe §c rouge : "+p.getName()+ " §e est mort.");
  307. red.remove(p.getName());
  308. if(red.size() == 0)
  309. {
  310. Bukkit.broadcastMessage("§eL'équipe §crouge §ea été exterminé !");
  311. }
  312.  
  313. }
  314.  
  315. }
  316.  
  317. @EventHandler
  318. public void LobbySign(PlayerInteractEvent e)
  319. {
  320. Player p = e.getPlayer();
  321. Block b = e.getClickedBlock();
  322.  
  323. if(e.getAction() == Action.RIGHT_CLICK_BLOCK)
  324. {
  325. if(b.getType() == Material.SIGN)
  326. {
  327. Sign s = (Sign) b.getState();
  328. if(s.getLine(0).contains(ChatColor.GREEN+"Lobby"))
  329. {
  330. goTo(p, "Lobby");
  331. p.sendMessage(ChatColor.YELLOW+"Vous avez été téléporté au lobby.");
  332.  
  333. }
  334.  
  335.  
  336. }
  337.  
  338.  
  339. }
  340.  
  341.  
  342. }
  343.  
  344.  
  345. @EventHandler
  346. public void ChangeLobbySign(SignChangeEvent e)
  347. {
  348. if(e.getLine(0).contains("Lobby"))
  349. {
  350. e.setLine(0, ChatColor.GREEN+"Lobby");
  351. e.setLine(1, ChatColor.BLUE+"JOUEURS:");
  352. }
  353.  
  354.  
  355. }
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement