Пример #1
0
 public boolean exorcise(Player player, Player victim) {
   SuperNPlayer snplayer = SuperNManager.get(player);
   SuperNPlayer snvictim = SuperNManager.get(victim);
   if (!SupernaturalsPlugin.instance.getPvP(victim)) {
     SuperNManager.sendMessage(snplayer, "Cannot cast in a non-PvP zone.");
     return false;
   }
   if (snplayer.getPower() > SNConfigHandler.priestPowerExorcise) {
     if (snvictim.isSuper()) {
       SuperNManager.alterPower(
           snplayer, -SNConfigHandler.priestPowerExorcise, "Exorcised " + victim.getName());
       SuperNManager.sendMessage(
           snvictim,
           "You were exorcised by " + ChatColor.WHITE + snplayer.getName() + ChatColor.RED + "!");
       SuperNManager.cure(snvictim);
       ItemStack item = player.getItemInHand();
       if (item.getAmount() == 1) {
         player.setItemInHand(null);
       } else {
         item.setAmount(player.getItemInHand().getAmount() - 1);
       }
       return true;
     } else {
       SuperNManager.sendMessage(snplayer, "Only supernatural players can be exorcised.");
       return false;
     }
   } else {
     SuperNManager.sendMessage(snplayer, "Not enough power to exorcise.");
     return false;
   }
 }
Пример #2
0
 public boolean heal(Player player, Player victim) {
   SuperNPlayer snplayer = SuperNManager.get(player);
   SuperNPlayer snvictim = SuperNManager.get(victim);
   if (snplayer.getPower() > SNConfigHandler.priestPowerHeal) {
     if (!snvictim.isSuper() && victim.getHealth() < victim.getMaxHealth() && !victim.isDead()) {
       SuperNManager.alterPower(
           snplayer, -SNConfigHandler.priestPowerHeal, "Healed " + victim.getName());
       SuperNManager.sendMessage(
           snvictim,
           "You were healed by " + ChatColor.WHITE + snplayer.getName() + ChatColor.RED + "!");
       double health = victim.getHealth() + SNConfigHandler.priestHealAmount;
       if (health > victim.getMaxHealth()) {
         health = victim.getMaxHealth();
       }
       victim.setHealth(health);
       ItemStack item = player.getItemInHand();
       if (item.getAmount() == 1) {
         player.setItemInHand(null);
       } else {
         item.setAmount(player.getItemInHand().getAmount() - 1);
       }
       return true;
     } else {
       SuperNManager.sendMessage(snplayer, "Player cannot be healed.");
       return false;
     }
   } else {
     SuperNManager.sendMessage(snplayer, "Not enough power to heal.");
     return false;
   }
 }
Пример #3
0
 public boolean banish(Player player, Player victim) {
   SuperNPlayer snplayer = SuperNManager.get(player);
   SuperNPlayer snvictim = SuperNManager.get(victim);
   if (!SupernaturalsPlugin.instance.getPvP(victim)) {
     SuperNManager.sendMessage(snplayer, "Cannot cast in a non-PvP zone.");
     return false;
   }
   if (snplayer.getPower() > SNConfigHandler.priestPowerBanish) {
     if (snvictim.isSuper()) {
       SuperNManager.alterPower(
           snplayer, -SNConfigHandler.priestPowerBanish, "Banished " + victim.getName());
       SuperNManager.sendMessage(
           snvictim,
           "You were banished by " + ChatColor.WHITE + snplayer.getName() + ChatColor.RED + "!");
       victim.teleport(SNConfigHandler.priestBanishLocation);
       ItemStack item = player.getItemInHand();
       if (item.getAmount() == 1) {
         player.setItemInHand(null);
       } else {
         item.setAmount(player.getItemInHand().getAmount() - 1);
       }
       return true;
     }
     SuperNManager.sendMessage(snplayer, "Can only banish supernatural players.");
     return false;
   } else {
     SuperNManager.sendMessage(snplayer, "Not enough power to banish.");
     return false;
   }
 }
Пример #4
0
 public boolean drainPower(Player player, Player victim) {
   SuperNPlayer snplayer = SuperNManager.get(player);
   SuperNPlayer snvictim = SuperNManager.get(victim);
   if (!SupernaturalsPlugin.instance.getPvP(victim)) {
     SuperNManager.sendMessage(snplayer, "Cannot cast in a non-PvP zone.");
     return false;
   }
   if (snplayer.getPower() > SNConfigHandler.priestPowerDrain) {
     if (snvictim.isSuper()) {
       double power = snvictim.getPower();
       power *= SNConfigHandler.priestDrainFactor;
       SuperNManager.alterPower(
           snplayer,
           -SNConfigHandler.priestPowerDrain,
           "Drained  " + snvictim.getName() + "'s power!");
       SuperNManager.alterPower(snvictim, -power, "Drained by " + snplayer.getName());
       ItemStack item = player.getItemInHand();
       if (item.getAmount() == 1) {
         player.setItemInHand(null);
       } else {
         item.setAmount(player.getItemInHand().getAmount() - 1);
       }
       return true;
     } else {
       SuperNManager.sendMessage(snplayer, "Only supernatural players can be power drained.");
       return false;
     }
   } else {
     SuperNManager.sendMessage(snplayer, "Not enough power to drain power.");
     return false;
   }
 }
Пример #5
0
  @Override
  public double damagerEvent(EntityDamageByEntityEvent event, double damage) {
    Player pDamager = (Player) event.getDamager();
    Entity victim = event.getEntity();

    SuperNPlayer snDamager = SuperNManager.get(pDamager);
    ItemStack item = pDamager.getItemInHand();

    if (item != null) {
      if (SNConfigHandler.priestWeapons.contains(item.getType())) {
        SuperNManager.sendMessage(snDamager, "Priests cannot use this weapon!");
        return 0;
      }
    }

    if (victim instanceof Animals && !(victim instanceof Wolf)) {
      SuperNManager.sendMessage(SuperNManager.get(pDamager), "You cannot hurt innocent animals.");
      damage = 0;
    } else if (victim instanceof Player) {
      Player pVictim = (Player) victim;
      if (!SupernaturalsPlugin.instance.getPvP(pVictim)) {
        return damage;
      }
      SuperNPlayer snvictim = SuperNManager.get(pVictim);
      if (snvictim.isSuper()) {
        if (!snvictim.isDemon()) {
          pVictim.setFireTicks(SNConfigHandler.priestFireTicks);
        }
        damage +=
            damage
                * SuperNManager.get(pDamager).scale(SNConfigHandler.priestDamageFactorAttackSuper);
      } else {
        damage +=
            damage
                * SuperNManager.get(pDamager).scale(SNConfigHandler.priestDamageFactorAttackHuman);
      }
    } else if (victim instanceof Monster) {
      Monster mVictim = (Monster) victim;
      mVictim.setFireTicks(SNConfigHandler.priestFireTicks);
    }
    return damage;
  }
Пример #6
0
  public boolean guardianAngel(Player player, Player victim) {
    SuperNPlayer priest = SuperNManager.get(player);
    SuperNPlayer snvictim = SuperNManager.get(victim);

    if (priest.getPower() > SNConfigHandler.priestPowerGuardianAngel) {
      if (!snvictim.isSuper()) {
        if (SupernaturalsPlugin.instance.getDataHandler().hasAngel(priest)) {
          SuperNManager.sendMessage(
              priest,
              "Removed Guardian Angel from "
                  + ChatColor.WHITE
                  + SupernaturalsPlugin.instance.getDataHandler().getAngelPlayer(priest).getName());
          SuperNManager.sendMessage(
              SupernaturalsPlugin.instance.getDataHandler().getAngelPlayer(priest),
              "Guardian Angel removed!");
          SupernaturalsPlugin.instance.getDataHandler().removeAngel(priest);
        }
        SuperNManager.sendMessage(snvictim, "You now have a Guardian Angel!");
        SuperNManager.alterPower(
            priest,
            -SNConfigHandler.priestPowerGuardianAngel,
            "Guardian Angel on " + ChatColor.WHITE + snvictim.getName() + ChatColor.RED + "!");
        SupernaturalsPlugin.instance.getDataHandler().addAngel(priest, snvictim);

        ItemStack item = player.getItemInHand();
        if (item.getAmount() == 1) {
          player.setItemInHand(null);
        } else {
          item.setAmount(player.getItemInHand().getAmount() - 1);
        }
        return true;
      }
      SuperNManager.sendMessage(
          priest, "You cannot set a Guardian Angel on a Supernatural player.");
      return false;
    } else {
      SuperNManager.sendMessage(priest, "Not enough power to cast Guardian Angel.");
      return false;
    }
  }
Пример #7
0
 public boolean cure(Player player, Player victim, Material material) {
   SuperNPlayer snplayer = SuperNManager.get(player);
   SuperNPlayer snvictim = SuperNManager.get(victim);
   if (snplayer.getPower() > SNConfigHandler.priestPowerCure) {
     if (snvictim.isSuper()) {
       if (victim.getItemInHand().getType().equals(material)) {
         SuperNManager.alterPower(
             snplayer, -SNConfigHandler.priestPowerCure, "Cured " + victim.getName());
         SuperNManager.sendMessage(
             snvictim,
             ChatColor.WHITE + snplayer.getName() + ChatColor.RED + " has restored your humanity");
         SuperNManager.cure(snvictim);
         ItemStack item = player.getItemInHand();
         ItemStack item2 = victim.getItemInHand();
         if (item.getAmount() == 1) {
           player.setItemInHand(null);
         } else {
           item.setAmount(player.getItemInHand().getAmount() - 1);
         }
         if (item2.getAmount() == 1) {
           victim.setItemInHand(null);
         } else {
           item2.setAmount(victim.getItemInHand().getAmount() - 1);
         }
         return true;
       } else {
         SuperNManager.sendMessage(
             snplayer,
             ChatColor.WHITE
                 + snvictim.getName()
                 + ChatColor.RED
                 + " is not holding "
                 + ChatColor.WHITE
                 + material.toString()
                 + ChatColor.RED
                 + ".");
         return false;
       }
     } else {
       SuperNManager.sendMessage(snplayer, "You can only cure supernatural players.");
       return false;
     }
   } else {
     SuperNManager.sendMessage(snplayer, "Not enough power to cure.");
     return false;
   }
 }
Пример #8
0
 @SuppressWarnings("deprecation")
 public void useAltar(Player player) {
   Location location = player.getLocation();
   World world = location.getWorld();
   int locX = location.getBlockX();
   int locY = location.getBlockY();
   int locZ = location.getBlockZ();
   SuperNPlayer snplayer = SuperNManager.get(player);
   int amount = 0;
   int delta = 0;
   if (world.getName().equalsIgnoreCase(SNConfigHandler.priestChurchWorld)) {
     if (Math.abs(locX - SNConfigHandler.priestChurchLocationX) <= 10) {
       if (Math.abs(locY - SNConfigHandler.priestChurchLocationY) <= 10) {
         if (Math.abs(locZ - SNConfigHandler.priestChurchLocationZ) <= 10) {
           if (snplayer.isPriest()) {
             if (player.getItemInHand().getType().equals(Material.COAL)) {
               SuperNManager.sendMessage(snplayer, "The Church excommunicates you!");
               SuperNManager.cure(snplayer);
             } else {
               PlayerInventory inv = player.getInventory();
               ItemStack[] items = inv.getContents();
               for (Material mat : SNConfigHandler.priestDonationMap.keySet()) {
                 for (ItemStack itemStack : items) {
                   if (itemStack != null) {
                     if (itemStack.getType().equals(mat)) {
                       amount += itemStack.getAmount();
                     }
                   }
                 }
                 delta += amount * SNConfigHandler.priestDonationMap.get(mat);
                 amount = 0;
               }
               for (Material mat : SNConfigHandler.priestDonationMap.keySet()) {
                 inv.remove(mat);
               }
               player.updateInventory();
               SuperNManager.sendMessage(
                   snplayer,
                   "The Church accepts your gracious donations of Bread, Fish, Grilled Pork and Apples.");
               SuperNManager.alterPower(snplayer, delta, "Donations!");
             }
           } else {
             SuperNManager.sendMessage(snplayer, "The Church Altar radiates holy power.");
             if (snplayer.isSuper()) {
               SuperNManager.sendMessage(
                   snplayer, "The holy power of the Church tears you asunder!");
               EntityDamageEvent event =
                   new EntityDamageEvent(player, DamageCause.BLOCK_EXPLOSION, 20);
               player.setLastDamageCause(event);
               player.setHealth(0);
               if (snplayer.isGhoul()) {
                 double random = Math.random();
                 if (random < SNConfigHandler.ghoulCureChance - 0.1) {
                   SuperNManager.cure(snplayer);
                 }
               }
               return;
             }
             if (SNConfigHandler.priestAltarRecipe.playerHasEnough(player)) {
               if (!SupernaturalsPlugin.hasPermissions(
                   player, "supernatural.player.shrineuse.priest")) {
                 SuperNManager.sendMessage(snplayer, "You cannot use priest altars.");
                 return;
               }
               SuperNManager.sendMessage(snplayer, "You donate these items to the Church:");
               SuperNManager.sendMessage(
                   snplayer, SNConfigHandler.priestAltarRecipe.getRecipeLine());
               SuperNManager.sendMessage(
                   snplayer,
                   "The Church recognizes your holy spirit and accepts you into the priesthood.");
               SNConfigHandler.priestAltarRecipe.removeFromPlayer(player);
               SuperNManager.convert(snplayer, "priest", SNConfigHandler.priestPowerStart);
             } else {
               SuperNManager.sendMessage(
                   snplayer,
                   "The Church judges your intended donate insufficient.  You must gather the following: ");
               SuperNManager.sendMessage(
                   snplayer, SNConfigHandler.priestAltarRecipe.getRecipeLine());
             }
           }
         }
       }
     }
   }
 }