Esempio n. 1
0
 // Load general configuration for the world
 public void loadGeneralConfiguration(String dataWorld) {
   Properties props = new Properties();
   try {
     File configFile =
         this.getFile(this.getDataWorldFile(dataWorld), "Massive" + dataWorld + "Properties.ini");
     if (!configFile.exists()) {
       configFile.createNewFile();
       props.load(new FileReader(configFile));
       props.setProperty("exp_rate", "1");
       props.setProperty("fire_arrow_delay", "1");
       props.setProperty("default_player_health", "100");
       props.setProperty("default_player_mana", "50");
       props.setProperty("default_mana_regain", "10");
       props.setProperty("default_health_regen", "10");
       props.setProperty("default_max_level", "999");
       props.setProperty("notification_message_color", "YELLOW");
       props.setProperty("error_message_color", "RED");
       props.setProperty("warning_message_color", "GOLD");
       props.setProperty("success_message_color", "GREEN");
       props.setProperty("fall_damage", "1");
       props.setProperty("suffocation_damage", "1");
       props.setProperty("default_attack_damage", "10");
       props.setProperty("default_defense", "2");
       props.setProperty("message_tag", "[MRPG]");
       props.store(
           new FileWriter(configFile), "General Configuration for world '" + dataWorld + "'");
     } else {
       props.load(new FileReader(configFile));
     }
     GeneralData.EXP_RATE = Double.parseDouble(props.getProperty("exp_rate", "1"));
     GeneralData.ARROW_SHOOT_DELAY = Integer.parseInt(props.getProperty("fire_arrow_delay", "1"));
     GeneralData.DEFAULT_PLAYER_HEALTH =
         Integer.parseInt(props.getProperty("default_player_health", "100"));
     GeneralData.DEFAULT_PLAYER_MANA =
         Integer.parseInt(props.getProperty("default_player_mana", "50"));
     GeneralData.DEFAULT_MANA_REGEN =
         Integer.parseInt(props.getProperty("default_mana_regen", "10"));
     GeneralData.DEFAULT_HEALTH_REGEN =
         Integer.parseInt(props.getProperty("default_health_regen", "10"));
     GeneralData.MAX_LEVEL = Integer.parseInt(props.getProperty("default_max_level", "999"));
     GeneralData.NOTIFICATION_COLOR =
         Utils.getColor(props.getProperty("notification_message_color", "YELLOW"));
     GeneralData.ERROR_COLOR = Utils.getColor(props.getProperty("error_message_color", "RED"));
     GeneralData.WARNING_COLOR =
         Utils.getColor(props.getProperty("warning_message_color", "GOLD"));
     GeneralData.SUCCESS_COLOR =
         Utils.getColor(props.getProperty("success_message_color", "GREEN"));
     GeneralData.SUFFOCATION_DAMAGE =
         Integer.parseInt(props.getProperty("suffocation_damage", "1"));
     GeneralData.FALL_DAMAGE = Integer.parseInt(props.getProperty("fall_damage", "1"));
     GeneralData.DEFAULT_ATTACK =
         Integer.parseInt(props.getProperty("default_attack_damage", "10"));
     GeneralData.DEFAULT_DEFENSE = Integer.parseInt(props.getProperty("default_defense", "2"));
     GeneralData.MESSAGE_TAG = props.getProperty("message_tag", "[MRPG]");
   } catch (IOException ex) {
     log.info("Unable to load the general configurations for world '" + dataWorld + "'");
   }
 }
Esempio n. 2
0
 public void addLearningPoints(int newAmount, boolean display) {
   this.LP += newAmount;
   if (display) {
     Utils.sendPrivateMessage(
         CommandLevel.REWARD,
         "You have gained " + newAmount + " learning points.",
         Bukkit.getServer().getPlayer(this.name));
     this.updateLearningPoints();
   }
 }
Esempio n. 3
0
 public void subtractLearningPoints(int subtract, boolean display) {
   this.LP -= subtract;
   if (display) {
     Utils.sendPrivateMessage(
         CommandLevel.WARNING,
         "You have lost " + subtract + " learning points.",
         Bukkit.getServer().getPlayer(this.name));
     this.updateLearningPoints();
   }
 }
Esempio n. 4
0
 // Sets the spell that's cast when it is right clicked.
 public void setQuickSpell(String quickSpell, SpellActions action) {
   // Checks to see if it exists
   for (Spell spell : GeneralData.spells) {
     if (spell.getName().equalsIgnoreCase(quickSpell)) {
       String[] splitted = this.quickSpell.split(",");
       splitted[action.getIndex()] = quickSpell;
       this.quickSpell = Utils.concatStringArray(splitted, ",");
     }
   }
 }
Esempio n. 5
0
 /*
  * Deals damage to a player, based on what happened and what is happening
  */
 public void damage(Entity attacker, DamageCause cause, int damage, boolean isMagic) {
   Player player = Bukkit.getServer().getPlayer(this.name);
   int playerDamage = 0;
   if (attacker != null) {
     if (attacker instanceof Player) {
       Player playerAttacker = (Player) attacker;
       PlayerProfile profile = Users.getUser(playerAttacker);
       playerDamage =
           this.getHealth()
               - ((int)
                   Math.floor(
                       (GeneralData.DEFAULT_ATTACK
                               + (GeneralData.DEFAULT_ATTACK
                                   * profile.getSkillPoints("ATTACKDAMAGE")))
                           - (GeneralData.DEFAULT_DEFENSE
                               + (GeneralData.DEFAULT_DEFENSE * this.getSkillPoints("DEFENSE")))));
       this.setHealth(playerDamage);
     } else if (attacker instanceof Projectile) {
       Projectile projectile = (Projectile) attacker;
       LivingEntity shooter = projectile.getShooter();
       if (shooter != null) {
         if (attacker != null) {
           if (shooter instanceof Player) {
             Player damager = (Player) shooter;
             PlayerProfile shooterProfile = Users.getUser(damager);
             if (isMagic) {
               if (shooterProfile.getCastedSpell() != "") {
                 double spellDamage = 0;
                 // Get the last spell the player casted
                 Spell spell = Spell.getSpell(shooterProfile.getCastedSpell());
                 // Casting a deadly spell
                 if (spell.getSpellType() == SpellType.BLACK_MAGIC) {
                   spellDamage =
                       (this.getSkillPoints("SPELLRESISTANCE")
                               * this.getArmorProtections("SPELLRESISTANCE"))
                           - (damage
                               + (GeneralData.items
                                       .get(Utils.getTypeId(projectile))
                                       .getAttackDamage()
                                   + (GeneralData.items
                                           .get(Utils.getTypeId(projectile))
                                           .getAttackDamage()
                                       * (shooterProfile.getSkillPoints("SPELLATTACK")
                                           + shooterProfile.getArmorProtections("SPELLATTACK")))));
                   this.setHealth((int) (this.getHealth() + spellDamage));
                   // Healing for the the player
                 } else if (spell.getSpellType() == SpellType.WHITE_MAGIC) {
                   this.setHealth(
                       (int)
                           (this.getHealth() + (damage + shooterProfile.getSkillPoints("CHARM"))));
                 }
               }
             }
           }
         }
       }
     }
   } else {
     if (cause == DamageCause.SUFFOCATION) {
       playerDamage = this.getHealth() - GeneralData.SUFFOCATION_DAMAGE;
       this.setHealth(playerDamage);
       player.damage(getConvertedDamage(playerDamage));
     } else if (cause == DamageCause.FALL) {
       playerDamage =
           (this.getHealth()
               + (damage * this.getSkillPoints("ACROBATICS"))
               - ((int) Math.floor(GeneralData.FALL_DAMAGE * damage / 4)));
       this.setHealth(playerDamage);
       player.damage(getConvertedDamage(playerDamage));
     } else {
       this.setHealth(this.getHealth() - ((damage * this.getMaxHealth()) / 20));
     }
   }
 }
Esempio n. 6
0
 // Sends the player the amount of learn points he has.
 public void updateLearningPoints() {
   Utils.sendPrivateMessage(
       CommandLevel.NOTIFICATION,
       "You currently have " + this.getLearningPoints() + " learning points.",
       Bukkit.getServer().getPlayer(this.name));
 }