Ejemplo n.º 1
0
 // loadConfig. Called onEnable in main class.
 public void loadConfig() {
   // Create new properties file with the file string.
   Properties properties = new Properties(plugin.ConfigurationFileString);
   try {
     // Try to load it. If not return an error.
     properties.load();
   } catch (IOException e) {
     plugin.logger.log(Level.SEVERE, "[LC] " + e);
   }
   // Set variables for TOOLS
   this.ToolLevels.put(Material.WOOD_SWORD.getId(), properties.getInteger("WoodenSwordLevel", 0));
   this.ToolLevels.put(Material.STONE_SWORD.getId(), properties.getInteger("StoneSwordLevel", 5));
   this.ToolLevels.put(Material.IRON_SWORD.getId(), properties.getInteger("IronSwordLevel", 10));
   this.ToolLevels.put(Material.GOLD_SWORD.getId(), properties.getInteger("GoldSwordLevel", 20));
   this.ToolLevels.put(
       Material.DIAMOND_SWORD.getId(), properties.getInteger("DiamondSwordLevel", 30));
   this.ToolLevels.put(Material.WOOD_AXE.getId(), properties.getInteger("WoodenBAxeLevel", 0));
   this.ToolLevels.put(Material.STONE_AXE.getId(), properties.getInteger("StoneBAxeLevel", 5));
   this.ToolLevels.put(Material.IRON_AXE.getId(), properties.getInteger("IronBAxeLevel", 10));
   this.ToolLevels.put(Material.GOLD_AXE.getId(), properties.getInteger("GoldBAxeLevel", 20));
   this.ToolLevels.put(
       Material.DIAMOND_AXE.getId(), properties.getInteger("DiamondBAxeLevel", 30));
   // Set variables for EXP PER
   this.ExpPerDamage = properties.getDouble("ExpPerDamage", 5);
   this.Baxes = properties.getBoolean("EnableBattleAxes", true);
   //
   this.pvpRangeEnable = properties.getBoolean("EnablePvpOnlyRange", false);
   this.pvpRange = properties.getInteger("PvpRange", 5);
 }
Ejemplo n.º 2
0
 public void loadPreferences(String name) {
   File pref = new File(root + File.separator + name + ".pref");
   Configuration c = new Configuration(pref);
   c.load();
   armourType.put(name.toString(), getArmour(c.getString("Preferences.ArmourType", "NONE")));
   blockHead.put(
       name.toString(),
       new ItemStack((Material.getMaterial(c.getString("Preferences.BlockOnHead", "AIR"))), 1));
   swordType.put(
       name.toString(),
       Material.getMaterial(c.getString("Preferences.Sword", Material.WOOD_SWORD.toString())));
 }
Ejemplo n.º 3
0
 public void createPreferenceFile(String name) {
   File pref = new File(root + File.separator + name + ".pref");
   Configuration c = new Configuration(pref);
   if (!doesPlayerHavePreferenceFile(name)) {
     try {
       pref.createNewFile();
     } catch (IOException e) {
       e.printStackTrace();
     }
     c.setProperty("Preferences.ArmourType", "NONE");
     c.setProperty("Preferences.BlockOnHead", "AIR");
     c.setProperty("Preferences.Sword", Material.WOOD_SWORD.toString());
     c.save();
   }
 }
Ejemplo n.º 4
0
 public void modifyBlockOnHead(Player p, int material) {
   int level = Statistics.playerLevel.get(p.getName());
   File pref = new File(root + File.separator + p.getName() + ".pref");
   Configuration c = new Configuration(pref);
   c.load();
   Material m = Material.getMaterial(material);
   if (level >= 40) {
     if (m == null || m == Material.AIR) {
       p.sendMessage(ChatColor.RED + "[Warzone] " + Warzone.li.getObj("Invalid Material Type!"));
       return;
     }
     c.setProperty("Preferences.ArmourType", c.getString("Preferences.ArmourType", "NONE"));
     c.setProperty(
         "Preferences.BlockOnHead",
         c.getString("Preferences.BlockOnHead", m.toString().toUpperCase()));
     c.setProperty(
         "Preferences.Sword", c.getString("Preferences.Sword", Material.WOOD_SWORD.toString()));
     blockHead.put(p.getName(), new ItemStack(m, 1));
     p.sendMessage(
         ChatColor.RED
             + "[Warzone] "
             + ChatColor.GREEN
             + "Block preference changed to "
             + ChatColor.DARK_AQUA
             + m.toString().toUpperCase()
             + ChatColor.GREEN
             + " successfully!");
     c.save();
   } else {
     p.sendMessage(
         ChatColor.RED
             + "[Warzone] "
             + Warzone.li.getObj("You must be level")
             + "40"
             + Warzone.li.getObj("or above to do this")
             + "!");
     return;
   }
 }
Ejemplo n.º 5
0
  public void modifyArmourPreference(Player p, Armour a) {
    int level = Statistics.playerLevel.get(p.getName());
    File pref = new File(root + File.separator + p.getName() + ".pref");
    Configuration c = new Configuration(pref);
    c.load();
    if (a != null) {
      boolean canusearmour = false;
      int l = 0;
      switch (a) {
        case LEATHER:
          if (level >= 10) {
            canusearmour = true;
            break;
          } else {
            l = 10;
            break;
          }
        case IRON:
          if (level >= 20) {
            canusearmour = true;
            break;
          } else {
            l = 20;
            break;
          }
        case GOLD:
          if (level >= 30) {
            canusearmour = true;
            break;
          } else {
            l = 30;
            break;
          }
        case DIAMOND:
          if (level >= 40) {
            canusearmour = true;
            break;
          } else {
            l = 40;
            break;
          }
      }

      if (canusearmour) {
        c.setProperty("Preferences.ArmourType", a.toString());
        c.setProperty("Preferences.BlockOnHead", c.getString("Preferences.BlockOnHead", "AIR"));
        c.setProperty(
            "Preferences.Sword", c.getString("Preferences.Sword", Material.WOOD_SWORD.toString()));
        c.save();
        p.sendMessage(
            ChatColor.RED
                + "[Warzone]"
                + ChatColor.GREEN
                + " "
                + Warzone.li.getObj("Armour type changed to")
                + " "
                + ChatColor.DARK_AQUA
                + a.toString()
                + ChatColor.GREEN
                + " "
                + Warzone.li.getObj("sucessfully!"));
        armourType.put(p.getName(), a);
      } else {
        p.sendMessage(
            ChatColor.RED
                + "[Warzone] "
                + Warzone.li.getObj("You must be level")
                + " "
                + ChatColor.DARK_AQUA
                + l
                + ChatColor.RED
                + " "
                + Warzone.li.getObj("to wield this armour!"));
      }
    } else {
      p.sendMessage(
          ChatColor.RED
              + "[Warzone] "
              + Warzone.li.getObj("Error : Armour type can only be")
              + " NONE, LEATHER,    IRON, GOLD or DIAMOND.");
      return;
    }
  }