Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.minenite.warzairdrops;
- import java.util.Random;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.block.Block;
- import org.bukkit.block.Chest;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.scheduler.BukkitRunnable;
- public class MainClass
- extends JavaPlugin {
- public static MainClass instance;
- public static final Logger log = Logger.getLogger("Minecraft");
- public static Integer item1c1;
- public static Integer item2c1;
- public static Integer item3c1;
- public static Integer item4c1;
- public static Integer item5c1;
- public static Integer item1c1a;
- public static Integer item2c1a;
- public static Integer item3c1a;
- public static Integer item4c1a;
- public static Integer item5c1a;
- public static Integer item1c2;
- public static Integer item2c2;
- public static Integer item3c2;
- public static Integer item4c2;
- public static Integer item5c2;
- public static Integer item1c2a;
- public static Integer item2c2a;
- public static Integer item3c2a;
- public static Integer item4c2a;
- public static Integer item5c2a;
- public static Integer item1c3;
- public static Integer item2c3;
- public static Integer item3c3;
- public static Integer item4c3;
- public static Integer item5c3;
- public static Integer item1c3a;
- public static Integer item2c3a;
- public static Integer item3c3a;
- public static Integer item4c3a;
- public static Integer item5c3a;
- public static Integer item1c4;
- public static Integer item2c4;
- public static Integer item3c4;
- public static Integer item4c4;
- public static Integer item5c4;
- public static Integer item1c4a;
- public static Integer item2c4a;
- public static Integer item3c4a;
- public static Integer item4c4a;
- public static Integer item5c4a;
- public static Integer item1c5;
- public static Integer item2c5;
- public static Integer item3c5;
- public static Integer item4c5;
- public static Integer item5c5;
- public static Integer item1c5a;
- public static Integer item2c5a;
- public static Integer item3c5a;
- public static Integer item4c5a;
- public static Integer item5c5a;
- public static Double chest1Chance;
- public static Double chest2Chance;
- public static Double chest3Chance;
- public static Double chest4Chance;
- public static Double chest5Chance;
- public static Integer ZRange;
- public static Integer XRange;
- public static Integer TBD;
- public static Integer centerX;
- public static Integer centerZ;
- public static Integer dLX;
- public static Integer dLZ;
- public static Integer dLY;
- public static String dropWorld;
- public static Boolean enabled;
- protected static Plugin plugin;
- public void onEnable() {
- enabled = Boolean.valueOf(true);
- getCommand("ad").setExecutor(new CommandsClass());
- loadConfiguration();
- if (chest1Chance.doubleValue() + chest2Chance.doubleValue() + chest3Chance.doubleValue() + chest4Chance.doubleValue() + chest5Chance.doubleValue() != 1.0D) {
- Bukkit.getServer().broadcastMessage(ChatColor.RED + "[Airdrop+] The drop chances do not add up to 1 (100%).");
- Bukkit.getServer().broadcastMessage(ChatColor.RED + "All chest chances have been set to 0.2 (20%)");
- chest1Chance = Double.valueOf(0.2D);
- chest2Chance = Double.valueOf(0.2D);
- chest3Chance = Double.valueOf(0.2D);
- chest4Chance = Double.valueOf(0.2D);
- chest5Chance = Double.valueOf(0.2D);
- log("WARNING WARNING WARNING. CHEST DROP CHANCES DO NOT ADD UP. RESETTING TO 20% ON ALL CHESTS.", Level.INFO);
- }
- log("AirDropsPlus has been enabled!", Level.INFO);
- plugin = this;
- (new BukkitRunnable() {
- public void run() {
- if (!MainClass.enabled.booleanValue()) {
- return;
- }
- if (Bukkit.getServer().getOnlinePlayers().size() == 0) {
- return;
- }
- Random rand = new Random();
- int coordx = rand.nextInt(MainClass.XRange.intValue() * 2) - MainClass.XRange.intValue() + MainClass.centerX.intValue();
- Random randc = new Random();
- int chance1Hundred = randc.nextInt(100);
- int chestNumber = 1;
- Random rand1 = new Random();
- int coordz = rand1.nextInt(MainClass.ZRange.intValue() * 2) - MainClass.ZRange.intValue() + MainClass.centerZ.intValue();
- double luckofthedraw = chance1Hundred / 100.0D;
- if (luckofthedraw <= MainClass.chest1Chance.doubleValue()) {
- chestNumber = 1;
- } else if (MainClass.chest1Chance.doubleValue() < luckofthedraw && luckofthedraw <= MainClass.chest2Chance.doubleValue() + MainClass.chest1Chance.doubleValue()) {
- chestNumber = 2;
- } else if (MainClass.chest2Chance.doubleValue() + MainClass.chest1Chance.doubleValue() < luckofthedraw && luckofthedraw <= MainClass.chest1Chance.doubleValue() + MainClass.chest2Chance.doubleValue() + MainClass.chest3Chance.doubleValue()) {
- chestNumber = 3;
- } else if (MainClass.chest1Chance.doubleValue() + MainClass.chest2Chance.doubleValue() + MainClass.chest3Chance.doubleValue() < luckofthedraw && luckofthedraw <= MainClass.chest1Chance.doubleValue() + MainClass.chest2Chance.doubleValue() + MainClass.chest3Chance.doubleValue() + MainClass.chest4Chance.doubleValue()) {
- chestNumber = 4;
- } else if (MainClass.chest1Chance.doubleValue() + MainClass.chest2Chance.doubleValue() + MainClass.chest3Chance.doubleValue() + MainClass.chest4Chance.doubleValue() < luckofthedraw && luckofthedraw <= MainClass.chest1Chance.doubleValue() + MainClass.chest2Chance.doubleValue() + MainClass.chest3Chance.doubleValue() + MainClass.chest4Chance.doubleValue() + MainClass.chest5Chance.doubleValue()) {
- chestNumber = 5;
- }
- World world1 = Bukkit.getServer().getWorld(MainClass.dropWorld);
- int coordy = world1.getHighestBlockYAt(coordx, coordz);
- Block cBlock = world1.getBlockAt(coordx, coordy, coordz);
- Bukkit.getServer().broadcastMessage(ChatColor.RED + "Previous Airdrop has timed out.");
- MainClass.dLX = Integer.valueOf(MainClass.this.getConfig().getInt("dropLocationX"));
- MainClass.dLY = Integer.valueOf(MainClass.this.getConfig().getInt("dropLocationY"));
- MainClass.dLZ = Integer.valueOf(MainClass.this.getConfig().getInt("dropLocationZ"));
- if (world1.getBlockAt(MainClass.dLX.intValue(), MainClass.dLY.intValue(), MainClass.dLZ.intValue()).getType().equals(Material.CHEST)) {
- Chest chestDel = (Chest) world1.getBlockAt(MainClass.dLX.intValue(), MainClass.dLY.intValue(), MainClass.dLZ.intValue()).getState();
- chestDel.getBlockInventory().clear();
- world1.getBlockAt(MainClass.dLX.intValue(), MainClass.dLY.intValue(), MainClass.dLZ.intValue()).setType(Material.AIR);
- }
- cBlock.setType(Material.CHEST);
- Chest chest = (Chest) cBlock.getState();
- MainClass.this.getConfig().set("dropLocationX", Integer.valueOf(coordx));
- MainClass.this.getConfig().set("dropLocationY", Integer.valueOf(coordy));
- MainClass.this.getConfig().set("dropLocationZ", Integer.valueOf(coordz));
- MainClass.this.saveConfig();
- MainClass.this.reloadConfig();
- if (chestNumber == 1) {
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item1c1.intValue(), MainClass.item1c1a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item2c1.intValue(), MainClass.item2c1a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item3c1.intValue(), MainClass.item3c1a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item4c1.intValue(), MainClass.item4c1a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item5c1.intValue(), MainClass.item5c1a.intValue())});
- } else if (chestNumber == 2) {
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item1c2.intValue(), MainClass.item1c2a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item2c2.intValue(), MainClass.item2c2a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item3c2.intValue(), MainClass.item3c2a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item4c2.intValue(), MainClass.item4c2a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item5c2.intValue(), MainClass.item5c2a.intValue())});
- } else if (chestNumber == 3) {
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item1c3.intValue(), MainClass.item1c3a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item2c3.intValue(), MainClass.item2c3a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item3c3.intValue(), MainClass.item3c3a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item4c3.intValue(), MainClass.item4c3a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item5c3.intValue(), MainClass.item5c3a.intValue())});
- } else if (chestNumber == 4) {
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item1c4.intValue(), MainClass.item1c4a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item2c4.intValue(), MainClass.item2c4a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item3c4.intValue(), MainClass.item3c4a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item4c4.intValue(), MainClass.item4c4a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item5c4.intValue(), MainClass.item5c4a.intValue())});
- } else if (chestNumber == 5) {
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item1c5.intValue(), MainClass.item1c5a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item2c5.intValue(), MainClass.item2c5a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item3c5.intValue(), MainClass.item3c5a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item4c5.intValue(), MainClass.item4c5a.intValue())});
- chest.getInventory().addItem(new ItemStack[]{new ItemStack(MainClass.item5c5.intValue(), MainClass.item5c5a.intValue())});
- }
- Bukkit.getServer().broadcastMessage(ChatColor.BLUE + "Airdrop at location: " + ChatColor.GOLD + coordx + ", " + coordz);
- Bukkit.getServer().broadcastMessage(ChatColor.BLUE + "You have " + MainClass.TBD + " minutes to retrieve the object before it self-destructs.");
- }
- }).runTaskTimer(plugin, 100L, (TBD.intValue() * 20 * 60));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement