Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package be.seedy.chestrandom;
- import java.util.Random;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.block.Chest;
- import org.bukkit.enchantments.Enchantment;
- import org.bukkit.inventory.Inventory;
- import org.bukkit.inventory.ItemFlag;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.plugin.java.JavaPlugin;
- import be.seedy.chestrandom.commands.CommandChestrandom;
- public class Monplugin extends JavaPlugin {
- @Override
- public void onEnable() {
- System.out.println(">>>[ChestRandom] Le plugin vient de s'allumer !<<<");
- getCommand("ChestRandom").setExecutor(new CommandChestrandom(this));
- Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
- public void run() {
- Location spawnChest = Location(Bukkit.getWorld("world"), x, y, z);
- spawnChest.getBlock().setType(Material.AIR);
- }
- }, 0, ((20 * 10)*1));
- Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
- @Override
- public void run() {
- Random r = new Random();
- double x = r.nextInt(15000);
- double y = r.nextInt(100);
- double z = r.nextInt(15000);
- Location spawnChest = new Location(Bukkit.getWorld("world"), x, y, z);
- spawnChest.getBlock().setType(Material.CHEST);
- Chest chest = (Chest) spawnChest.getBlock().getState();
- Inventory chestMenu = chest.getInventory();
- if(Math.random() * 10 < 10) {
- chestMenu.addItem(new ItemStack(Material.DIAMOND, 7));
- chestMenu.addItem(new ItemStack(Material.IRON_INGOT, 5));
- chestMenu.addItem(new ItemStack(Material.GOLD_INGOT, 6));
- chestMenu.addItem(new ItemStack(Material.EMERALD, 3));
- Bukkit.broadcastMessage("§aUn coffre à spawn en §eX : §6" + x + " §eY : §6" + y + " §eZ : §6" + z + "§a!");
- }
- if(Math.random() * 10 < 0.10) {
- ItemStack swordcheater = new ItemStack(Material.DIAMOND_SWORD);
- ItemMeta swordC = swordcheater.getItemMeta();
- swordC.setDisplayName("§4L'épé du guerrier");
- swordC.addEnchant(Enchantment.DAMAGE_ALL, 6, true);
- swordC.addEnchant(Enchantment.DAMAGE_ARTHROPODS, 6, true);
- swordC.addEnchant(Enchantment.DURABILITY, 4, true);
- swordC.addEnchant(Enchantment.FIRE_ASPECT, 3, true);
- swordC.addEnchant(Enchantment.LOOT_BONUS_MOBS, 4, true);
- swordC.addEnchant(Enchantment.SWEEPING_EDGE, 4, true);
- swordC.addItemFlags(ItemFlag.HIDE_ENCHANTS);
- swordcheater.setItemMeta(swordC);
- chestMenu.addItem(new ItemStack(swordcheater));
- chestMenu.addItem(new ItemStack(Material.NETHER_STAR));
- Bukkit.broadcastMessage("§aUn coffre §5épique §aà spawn en §eX : §6" + x + " §eY : §6" + y + " §eZ : §6" + z + "§a!");
- }
- }
- }, 0, ((20 * 10)*1));
- }
- @Override
- public void onDisable() {
- System.out.println(">>>[ChestRandom] Le plugin vient de s'éteindre !<<<");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement