Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 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. public void run() {
  28. Location spawnChest = Location(Bukkit.getWorld("world"), x, y, z);
  29. spawnChest.getBlock().setType(Material.AIR);
  30. }
  31. }, 0, ((20 * 10)*1));
  32. Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
  33.  
  34. @Override
  35. public void run() {
  36.  
  37. Random r = new Random();
  38. double x = r.nextInt(15000);
  39. double y = r.nextInt(100);
  40. double z = r.nextInt(15000);
  41.  
  42. Location spawnChest = new Location(Bukkit.getWorld("world"), x, y, z);
  43. spawnChest.getBlock().setType(Material.CHEST);
  44.  
  45. Chest chest = (Chest) spawnChest.getBlock().getState();
  46. Inventory chestMenu = chest.getInventory();
  47.  
  48. if(Math.random() * 10 < 10) {
  49. chestMenu.addItem(new ItemStack(Material.DIAMOND, 7));
  50. chestMenu.addItem(new ItemStack(Material.IRON_INGOT, 5));
  51. chestMenu.addItem(new ItemStack(Material.GOLD_INGOT, 6));
  52. chestMenu.addItem(new ItemStack(Material.EMERALD, 3));
  53. Bukkit.broadcastMessage("§aUn coffre à spawn en §eX : §6" + x + " §eY : §6" + y + " §eZ : §6" + z + "§a!");
  54. }
  55. if(Math.random() * 10 < 0.10) {
  56. ItemStack swordcheater = new ItemStack(Material.DIAMOND_SWORD);
  57. ItemMeta swordC = swordcheater.getItemMeta();
  58. swordC.setDisplayName("§4L'épé du guerrier");
  59. swordC.addEnchant(Enchantment.DAMAGE_ALL, 6, true);
  60. swordC.addEnchant(Enchantment.DAMAGE_ARTHROPODS, 6, true);
  61. swordC.addEnchant(Enchantment.DURABILITY, 4, true);
  62. swordC.addEnchant(Enchantment.FIRE_ASPECT, 3, true);
  63. swordC.addEnchant(Enchantment.LOOT_BONUS_MOBS, 4, true);
  64. swordC.addEnchant(Enchantment.SWEEPING_EDGE, 4, true);
  65. swordC.addItemFlags(ItemFlag.HIDE_ENCHANTS);
  66. swordcheater.setItemMeta(swordC);
  67. chestMenu.addItem(new ItemStack(swordcheater));
  68. chestMenu.addItem(new ItemStack(Material.NETHER_STAR));
  69. Bukkit.broadcastMessage("§aUn coffre §5épique §aà spawn en §eX : §6" + x + " §eY : §6" + y + " §eZ : §6" + z + "§a!");
  70. }
  71. }
  72. }, 0, ((20 * 10)*1));
  73. }
  74.  
  75.  
  76. @Override
  77. public void onDisable() {
  78. System.out.println(">>>[ChestRandom] Le plugin vient de s'éteindre !<<<");
  79. }
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement