Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. package be.seedy.chestrandom;
  2.  
  3. import java.util.Random;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Location;
  7. import org.bukkit.Material;
  8. import org.bukkit.block.Chest;
  9. import org.bukkit.enchantments.Enchantment;
  10. import org.bukkit.inventory.Inventory;
  11. import org.bukkit.inventory.ItemFlag;
  12. import org.bukkit.inventory.ItemStack;
  13. import org.bukkit.inventory.meta.ItemMeta;
  14. import org.bukkit.plugin.java.JavaPlugin;
  15.  
  16. import be.seedy.chestrandom.commands.CommandChestrandom;
  17.  
  18. public class Monplugin extends JavaPlugin {
  19.  
  20.  
  21.  
  22. @Override
  23. public void onEnable() {
  24. System.out.println(">>>[ChestRandom] Le plugin vient de s'allumer !<<<");
  25. getCommand("ChestRandom").setExecutor(new CommandChestrandom(this));
  26. Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
  27.  
  28. @Override
  29. public void run() {
  30.  
  31. Random r = new Random();
  32. double x = r.nextInt(15000);
  33. double y = r.nextInt(100);
  34. double z = r.nextInt(15000);
  35.  
  36. Location spawnChest = new Location(Bukkit.getWorld("world"), x, y, z);
  37. spawnChest.getBlock().setType(Material.CHEST);
  38.  
  39. Chest chest = (Chest) spawnChest.getBlock().getState();
  40. Inventory chestMenu = chest.getInventory();
  41.  
  42. if(Math.random() * 10 < 10) {
  43. chestMenu.addItem(new ItemStack(Material.DIAMOND, 7));
  44. chestMenu.addItem(new ItemStack(Material.IRON_INGOT, 5));
  45. chestMenu.addItem(new ItemStack(Material.GOLD_INGOT, 6));
  46. chestMenu.addItem(new ItemStack(Material.EMERALD, 3));
  47. Bukkit.broadcastMessage("§aUn coffre à spawn en §eX : §6" + x + " §eY : §6" + y + " §eZ : §6" + z + "§a!");
  48. for(int cdrandom = 0; cdrandom ==20; cdrandom++) {
  49. spawnChest.getBlock().setType(Material.AIR);
  50. }
  51. }
  52. if(Math.random() * 10 < 0.10) {
  53. ItemStack swordcheater = new ItemStack(Material.DIAMOND_SWORD);
  54. ItemMeta swordC = swordcheater.getItemMeta();
  55. swordC.setDisplayName("§4L'épé du guerrier");
  56. swordC.addEnchant(Enchantment.DAMAGE_ALL, 6, true);
  57. swordC.addEnchant(Enchantment.DAMAGE_ARTHROPODS, 6, true);
  58. swordC.addEnchant(Enchantment.DURABILITY, 4, true);
  59. swordC.addEnchant(Enchantment.FIRE_ASPECT, 3, true);
  60. swordC.addEnchant(Enchantment.LOOT_BONUS_MOBS, 4, true);
  61. swordC.addEnchant(Enchantment.SWEEPING_EDGE, 4, true);
  62. swordC.addItemFlags(ItemFlag.HIDE_ENCHANTS);
  63. swordcheater.setItemMeta(swordC);
  64. chestMenu.addItem(new ItemStack(swordcheater));
  65. chestMenu.addItem(new ItemStack(Material.NETHER_STAR));
  66. Bukkit.broadcastMessage("§aUn coffre §5épique §aà spawn en §eX : §6" + x + " §eY : §6" + y + " §eZ : §6" + z + "§a!");
  67. Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
  68. public void run() {
  69. spawnChest.getBlock().setType(Material.AIR);
  70. }
  71. }, 0, ((20 * 10)*1));
  72. }
  73. }
  74. }, 0, ((20 * 10)*1));
  75.  
  76. }
  77.  
  78. @Override
  79. public void onDisable() {
  80. System.out.println(">>>[ChestRandom] Le plugin vient de s'éteindre !<<<");
  81. }
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement