Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.tizzletimmz3.KingsLanding;
- import java.util.HashMap;
- import java.util.List;
- import java.util.logging.Logger;
- import org.bukkit.ChatColor;
- import org.bukkit.Effect;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Damageable;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.entity.EntityDamageEvent;
- import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.PlayerInventory;
- import org.bukkit.plugin.PluginDescriptionFile;
- import org.bukkit.plugin.java.JavaPlugin;
- public class KingsLanding extends JavaPlugin implements Listener {
- public final Logger logger = Logger.getLogger("Minecraft");
- HashMap<String, Integer> plrs = new HashMap<String, Integer>();
- @Override
- public void onDisable() {
- PluginDescriptionFile pdfFile = this.getDescription();
- this.logger.info(pdfFile.getName() + " Has Been Disabled!");
- }
- @Override
- public void onEnable() {
- getServer().getPluginManager().registerEvents(this, this);
- PluginDescriptionFile pdfFile = this.getDescription();
- this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion()
- + " Has Been Enabled!");
- getConfig().options().copyDefaults(true);
- saveConfig();
- }
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- Player p = (Player) sender;
- if (!(sender instanceof Player)) {
- return true;
- }
- if (label.equalsIgnoreCase("KingsLanding") || label.equalsIgnoreCase("KL")) {
- if (args.length == 1) {
- if (args[0].equalsIgnoreCase("toggle")) {
- if (p.hasPermission("kingslanding.explosive") || p.isOp()) {
- if (plrs.containsKey(p.getUniqueId().toString())) {
- plrs.remove(p.getUniqueId().toString());
- p.sendMessage(ChatColor.BLUE + "Kingslanding has been toggled off!");
- return true;
- } else {
- plrs.put(p.getUniqueId().toString(), 1);
- p.sendMessage(ChatColor.BLUE + "Kingslanding has been toggled on!");
- return true;
- }
- } else {
- p.sendMessage(ChatColor.RED + "You do not have permission to use this command!");
- return true;
- }
- } else if (args[0].equalsIgnoreCase("enable")) {
- if (p.hasPermission("kingslanding.admin") || p.isOp()) {
- getConfig().set("Enabled", "true");
- saveConfig();
- p.sendMessage(ChatColor.BLUE + "KingsLanding has been enabled!");
- return true;
- } else {
- p.sendMessage(ChatColor.RED + "You do not have permission to use this command!");
- return true;
- }
- } else if (args[0].equalsIgnoreCase("disable")) {
- if (p.hasPermission("kingslanding.admin") || p.isOp()) {
- getConfig().set("Enabled", "false");
- saveConfig();
- p.sendMessage(ChatColor.BLUE + "KingsLanding has been disabled!");
- return true;
- } else {
- p.sendMessage(ChatColor.RED + "You do not have permission to use this command!");
- return true;
- }
- } else {
- p.sendMessage(ChatColor.RED + "Try <" + ChatColor.BLUE + "/kl toggle" + ChatColor.RED + "> or <" + ChatColor.BLUE + "/kl enable:disable" + ChatColor.RED + ">");
- }
- } else {
- p.sendMessage(ChatColor.RED + "Try <" + ChatColor.BLUE + "/kl toggle" + ChatColor.RED + "> or <" + ChatColor.BLUE + "/kl enable:disable" + ChatColor.RED + ">");
- }
- }
- return true;
- }
- @SuppressWarnings("deprecation")
- @EventHandler
- public void onFall(EntityDamageEvent event) {
- if (!(event.getEntity() instanceof Player)) {
- return;
- }
- Player p = (Player) event.getEntity();
- Location location = p.getLocation();
- List<Entity> near = location.getWorld().getEntities();
- int dis = getConfig().getInt("FallDistance");
- int health = getConfig().getInt("Health");
- int ammt = getConfig().getInt("ItemToTake.HowMuch");
- int thin = getConfig().getInt("ItemToTake.ItemID");
- double radius = 4D;
- if (plrs.containsKey(p.getUniqueId().toString())) {
- if (getConfig().getString("Enabled").equals("true")) {
- if (event.getCause() == DamageCause.FALL) {
- if (p.hasPermission("kingslanding.explosive") || p.isOp()) {
- if (p.getFallDistance() >= dis) {
- if (p.getInventory().contains(thin, ammt)) {
- takePowder(p);
- int mat = p.getWorld().getBlockAt((int)p.getLocation().getX(), (int)p.getLocation().getY() - 1, (int)p.getLocation().getZ()).getTypeId();
- int material = getConfig().getInt("Block.ID1");
- int material1 = getConfig().getInt("Block.ID2");
- int material2 = getConfig().getInt("Block.ID3");
- int material3 = getConfig().getInt("Block.ID4");
- int material4 = getConfig().getInt("Block.ID5");
- int material5 = getConfig().getInt("Block.ID6");
- int material6 = getConfig().getInt("Block.ID7");
- int material7 = getConfig().getInt("Block.ID8");
- int material8 = getConfig().getInt("Block.ID9");
- int material9 = getConfig().getInt("Block.ID10");
- if ((mat == material1) || (mat == material2) || (mat == material3) || (mat == material4) || (mat == material5) || (mat == material6) || (mat == material7) || (mat == material8) || (mat == material9) || (mat == material)) {
- int h = (int) p.getLocation().getX() - 1;
- int h1 = (int) p.getLocation().getY();
- int h2 = (int) p.getLocation().getZ() - 1;
- int f = (int) p.getLocation().getX() + 1;
- int f1 = (int) p.getLocation().getY();
- int f2 = (int) p.getLocation().getZ() + 1;
- int b = (int) p.getLocation().getX();
- int b1 = (int) p.getLocation().getY();
- int b2 = (int) p.getLocation().getZ() - 2;
- int k = (int) p.getLocation().getX();
- int k1 = (int) p.getLocation().getY();
- int k2 = (int) p.getLocation().getZ() + 2;
- int i = (int) p.getLocation().getX() + 2;
- int i1 = (int) p.getLocation().getY();
- int i2 = (int) p.getLocation().getZ();
- int o = (int) p.getLocation().getX() - 2;
- int o1 = (int) p.getLocation().getY();
- int o2 = (int) p.getLocation().getZ();
- int l = (int) p.getLocation().getX() + 1;
- int l1 = (int) p.getLocation().getY();
- int l2 = (int) p.getLocation().getZ() - 1;
- int y = (int) p.getLocation().getX() - 1;
- int y1 = (int) p.getLocation().getY();
- int y2 = (int) p.getLocation().getZ() + 1;
- Location loc = new Location (p.getWorld(), h, h1, h2);
- Location loc1 = new Location (p.getWorld(), f, f1, f2);
- Location loc2 = new Location (p.getWorld(), b, b1, b2);
- Location loc3 = new Location (p.getWorld(), l, l1, l2);
- Location loc4 = new Location (p.getWorld(), i, i1, i2);
- Location loc5 = new Location (p.getWorld(), y, y1, y2);
- Location loc6 = new Location (p.getWorld(), o, o1, o2);
- Location loc7 = new Location (p.getWorld(), k, k1, k2);
- p.getWorld().createExplosion(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), 3, false, false);
- p.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES, 10, 10);
- p.getWorld().playEffect(loc, Effect.MOBSPAWNER_FLAMES, 10, 10);
- p.getWorld().playEffect(loc1, Effect.MOBSPAWNER_FLAMES, 10, 10);
- p.getWorld().playEffect(loc2, Effect.MOBSPAWNER_FLAMES, 10, 10);
- p.getWorld().playEffect(loc3, Effect.MOBSPAWNER_FLAMES, 10, 10);
- p.getWorld().playEffect(loc4, Effect.MOBSPAWNER_FLAMES, 10, 10);
- p.getWorld().playEffect(loc5, Effect.MOBSPAWNER_FLAMES, 10, 10);
- p.getWorld().playEffect(loc6, Effect.MOBSPAWNER_FLAMES, 10, 10);
- p.getWorld().playEffect(loc7, Effect.MOBSPAWNER_FLAMES, 10, 10);
- for(Entity e : near) {
- if (e.getLocation().distance(location) <= radius) {
- if (e instanceof Player) {
- Player pl = (Player) e;
- if (!(pl.getName().equals(p.getName()))) {
- pl.setHealth(pl.getHealth() - health);
- return;
- } else {
- return;
- }
- } else if (e instanceof Damageable){
- ((Damageable) e).setHealth(((Damageable) e).getHealth() - health);
- return;
- }
- } else {
- return;
- }
- }
- } else {
- return;
- }
- } else {
- return;
- }
- } else {
- return;
- }
- } else {
- return;
- }
- }
- } else {
- return;
- }
- } else {
- return;
- }
- }
- private void takePowder(Player p) {
- PlayerInventory inventory = p.getInventory();
- for (int i = 0; i < inventory.getSize(); i++) {
- ItemStack item = inventory.getItem(i);
- if (item != null && item.getType() == Material.SULPHUR) {
- ItemStack newItem;
- if (item.getAmount() <= 1) {
- newItem = null;
- } else {
- newItem = item.clone();
- newItem.setAmount(newItem.getAmount() - getConfig().getInt("ItemToTake.HowMuch"));
- }
- inventory.setItem(i, newItem);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement