Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

urmumgey

a guest Feb 23rd, 2018 68 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. EZCrates (Main)
  2. package com.Emile2250.ezcrates;
  3.  
  4. import org.bukkit.Bukkit;
  5. import org.bukkit.plugin.PluginDescriptionFile;
  6. import org.bukkit.plugin.PluginManager;
  7. import org.bukkit.plugin.java.JavaPlugin;
  8.  
  9. public class EZCrates extends JavaPlugin {
  10.         public void onEnable()
  11.  
  12.  
  13.         {
  14.             PluginDescriptionFile pdfFile = this.getDescription();
  15.  
  16.             getLogger().info("EZCrates - Starting Up" + pdfFile.getName() + "v" + pdfFile.getVersion());
  17.  
  18.             Bukkit.getPluginManager().registerEvents(new EZCratesHandler(this), this);
  19.  
  20.             saveDefaultConfig();
  21.     }
  22. }
  23. -----------------
  24. EZCratesHandler
  25.  
  26. package com.Emile2250.ezcrates;
  27.  
  28. import org.bukkit.*;
  29. import org.bukkit.block.Block;
  30. import org.bukkit.block.Chest;
  31. import org.bukkit.entity.Player;
  32. import org.bukkit.event.EventHandler;
  33. import org.bukkit.event.Listener;
  34. import org.bukkit.event.block.BlockBreakEvent;
  35. import org.bukkit.inventory.Inventory;
  36. import org.bukkit.inventory.ItemStack;
  37.  
  38. public class EZCratesHandler implements Listener {
  39.  
  40.     private EZCrates plugin;
  41.  
  42.     public EZCratesHandler(EZCrates plugin)
  43.     {
  44.         this.plugin = plugin;
  45.     }
  46.  
  47.     @EventHandler
  48.     public void onBlockBreak(BlockBreakEvent event) {
  49.         Player player = event.getPlayer();
  50.         Block block = event.getBlock();
  51.         Chest chest = (Chest)block.getState();
  52.         Inventory inv = chest.getBlockInventory();
  53.         if (event.getPlayer().getGameMode() != GameMode.CREATIVE) {
  54.             switch (event.getBlock().getType()) {
  55.                 case STONE:
  56.                     if ((int) (Math.random() * (100 / this.plugin.getConfig().getInt("Stone")) + 1.0D) == 1) {
  57.                         event.setCancelled(true);
  58.                         event.getBlock().setType(Material.CHEST);
  59.                         sendCrateMessage(player);
  60.                     }
  61.                 case COAL_ORE:
  62.                     if ((int) (Math.random() * (100 / this.plugin.getConfig().getInt("CoalOre")) + 1.0D) == 1) {
  63.                         event.setCancelled(true);
  64.                         event.getBlock().setType(Material.CHEST);
  65.                         sendCrateMessage(player);
  66.                     }
  67.                     break;
  68.                 case IRON_ORE:
  69.                     if ((int) (Math.random() * (100 / this.plugin.getConfig().getInt("IronOre")) + 1.0D) == 1) {
  70.                         event.setCancelled(true);
  71.                         event.getBlock().setType(Material.CHEST);
  72.                         sendCrateMessage(player);
  73.                     }
  74.                     break;
  75.                 case GOLD_ORE:
  76.                     if ((int) (Math.random() * (100 / this.plugin.getConfig().getInt("GoldOre")) + 1.0D) == 1) {
  77.                         event.setCancelled(true);
  78.                         event.getBlock().setType(Material.CHEST);
  79.                         sendCrateMessage(player);
  80.                     }
  81.                     break;
  82.                 case DIAMOND_ORE:
  83.                     if ((int) (Math.random() * (100 / this.plugin.getConfig().getInt("DiamondOre")) + 1.0D) == 1) {
  84.                         event.setCancelled(true);
  85.                         event.getBlock().setType(Material.CHEST);
  86.                         sendCrateMessage(player);
  87.                     }
  88.                     break;
  89.                 case EMERALD_ORE:
  90.                     if ((int) (Math.random() * (100 / this.plugin.getConfig().getInt("EmeraldOre")) + 1.0D) == 1) {
  91.                         event.setCancelled(true);
  92.                         event.getBlock().setType(Material.CHEST);
  93.                         sendCrateMessage(player);
  94.                     }
  95.                     break;
  96.             }
  97.         }
  98.     }
  99.     private void sendCrateMessage(Player p) {
  100.  
  101.         p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&6EZCrates&8] &bA Random crate has spawned!"));
  102.     }
  103. }
  104.  
  105. -------------------------
  106. Config
  107.  
  108. # For percentages for the chances
  109. # MAKE SURE THERES A SPACE BETWEEN THE COLON AND THE NUMBER
  110. Stone: 100
  111. CoalOre: 50
  112. IronOre: 25
  113. GoldOre: 10
  114. DiamondOre: 5
  115. EmeraldOre: 5
  116.  
  117. -----------------------
  118. Plugin.yml
  119.  
  120. main: com.Emile2250.ezcrates.EZCrates
  121. version: 0.1
  122. name: EZCrates
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top