/** Main method to assign values to every field. */
  public void Setup() {
    CustomConfig conf = plugin.configManager.getConfig("GunConfig");
    MultiBox = plugin.getConfig().getBoolean("config.gameSettings.MultipleMysteryBoxes");
    doublePointsTimer = plugin.getConfig().getInt("config.gameSettings.doublePointsTimer");
    instaKillTimer = plugin.getConfig().getInt("config.gameSettings.instaKillTimer");
    fireSaleTimer = plugin.getConfig().getInt("config.gameSettings.fireSaleTimer");
    maxZombies = (int) plugin.getConfig().getDouble("config.gameSettings.maxZombies");
    waveSpawnInterval = (int) plugin.getConfig().getDouble("config.gameSettings.waveSpawnInterval");
    pointsOnHit = plugin.getConfig().getInt("config.gameSettings.defaultPointsOnHit");
    pointsOnKill = plugin.getConfig().getInt("config.gameSettings.defaultPointsOnKill");
    maxWave = plugin.getConfig().getInt("config.gameSettings.maxWave");
    reviveTimer = plugin.getConfig().getInt("config.ReviveSettings.ReviveTimer");
    configVersion = plugin.getConfig().getString("vID");
    reloadTime = plugin.getConfig().getInt("config.gameSettings.reloadTime");
    if (plugin.possibleGuns.size() != 0) {
      plugin.possibleGuns.clear();
    }

    Material m = Material.getMaterial(conf.getString("PistolsMaterial", "WOOD_HOE"));
    if (m != null) {
      GunTypeEnum.Pistols.setMaterial(m);
      System.out.println(COMZombies.consoleprefix + "Set pistol gun material to " + m.toString());
    } else
      Bukkit.broadcastMessage(
          COMZombies.prefix
              + "Unable to change the material for pistols! "
              + conf.getString("PistolsMaterial")
              + " Is not a valid material!!!");

    m = Material.getMaterial(conf.getString("ShotgunsMaterial", "STONE_HOE"));
    if (m != null) {
      GunTypeEnum.Shotguns.setMaterial(m);
      System.out.println(COMZombies.consoleprefix + "Set shotgun gun material to " + m.toString());
    } else
      Bukkit.broadcastMessage(
          COMZombies.prefix
              + "Unable to change the material for shotguns! "
              + conf.getString("ShotgunsMaterial")
              + " Is not a valid material!!!");

    m = Material.getMaterial(conf.getString("AssaultRiflesMaterial", "GOLD_HOE"));
    if (m != null) {
      GunTypeEnum.AssaultRifles.setMaterial(m);
      System.out.println(
          COMZombies.consoleprefix + "Set assault rifle material to " + m.toString());
    } else
      Bukkit.broadcastMessage(
          COMZombies.prefix
              + "Unable to change the material for assault rifles! "
              + conf.getString("AssaultRiflesMaterial")
              + " Is not a valid material!!!");

    m = Material.getMaterial(conf.getString("LightMachineGunsMaterial", "IRON_HOE"));
    if (m != null) {
      GunTypeEnum.LightMachineGuns.setMaterial(m);
      System.out.println(
          COMZombies.consoleprefix + "Set light machinegun material to " + m.toString());
    } else
      Bukkit.broadcastMessage(
          COMZombies.prefix
              + "Unable to change the material for light machineguns! "
              + conf.getString("LightMachineGunsMaterial")
              + " Is not a valid material!!!");

    m = Material.getMaterial(conf.getString("SubMachineGunsMaterial", "STICK"));
    if (m != null) {
      GunTypeEnum.SubMachineGuns.setMaterial(m);
      System.out.println(
          COMZombies.consoleprefix + "Set sub machinegun material to " + m.toString());
    } else
      Bukkit.broadcastMessage(
          COMZombies.prefix
              + "Unable to change the material for sub machineguns! "
              + conf.getString("SubMachineGunsMaterial")
              + " Is not a valid material!!!");

    m = Material.getMaterial(conf.getString("SniperRiflesMaterial", "BLAZE_ROD"));
    if (m != null) {
      GunTypeEnum.SniperRifles.setMaterial(m);
      System.out.println(COMZombies.consoleprefix + "Set sniper rifle material to " + m.toString());
    } else
      Bukkit.broadcastMessage(
          COMZombies.prefix
              + "Unable to change the material for sniper rifles! "
              + conf.getString("SniperRiflesMaterial")
              + " Is not a valid material!!!");

    m = Material.getMaterial(conf.getString("OthersMaterial", "DIAMOND_HOE"));
    if (m != null) {
      GunTypeEnum.Others.setMaterial(m);
      System.out.println(COMZombies.consoleprefix + "Set other's gun material to " + m.toString());
    } else
      Bukkit.broadcastMessage(
          COMZombies.prefix
              + "Unable to change the material for others! "
              + conf.getString("OthersMaterial")
              + " Is not a valid material!!!");

    for (String group : conf.getConfigurationSection("Guns").getKeys(false)) {
      for (String gun : conf.getConfigurationSection("Guns." + group).getKeys(false)) {
        String ammo = conf.getString("Guns." + group + "." + gun + ".Ammo");
        String packAmmo = conf.getString("Guns." + group + "." + gun + ".PackAPunch.Ammo");
        int clipAmmo = Integer.parseInt(ammo.substring(0, ammo.indexOf("/")));
        int totalAmmo = Integer.parseInt(ammo.substring(ammo.indexOf("/") + 1));
        int damage = conf.getInt("Guns." + group + "." + gun + ".Damage");
        int fireDelay = conf.getInt("Guns." + group + "." + gun + ".FireDelay", 5);
        double speed = conf.getDouble("Guns." + group + "." + gun + ".ProjectileSpeed", 3);
        int pClip = Integer.parseInt(packAmmo.substring(0, packAmmo.indexOf("/")));
        int pTotal = Integer.parseInt(packAmmo.substring(packAmmo.indexOf("/") + 1));
        int packDamage = conf.getInt("Guns." + group + "." + gun + ".PackAPunch.Damage");
        String packGunName = conf.getString("Guns." + group + "." + gun + ".PackAPunch.Name");
        plugin.possibleGuns.add(
            new GunType(
                GunTypeEnum.getGun(group),
                gun,
                damage,
                fireDelay,
                speed,
                clipAmmo,
                totalAmmo,
                pClip,
                pTotal,
                packDamage,
                packGunName));
      }
    }
    maxAmmo = plugin.getConfig().getBoolean("config.Perks.MaxAmmo");
    instaKill = plugin.getConfig().getBoolean("config.Perks.InstaKill");
    carpenter = plugin.getConfig().getBoolean("config.Perks.Carpenter");
    nuke = plugin.getConfig().getBoolean("config.Perks.Nuke");
    if (!MultiBox) fireSale = plugin.getConfig().getBoolean("config.Perks.FireSale");
    else fireSale = false;
    doublePoints = plugin.getConfig().getBoolean("config.Perks.DoublePoints");
    arenaStartTime = plugin.getConfig().getInt("config.gameSettings.arenaStartTime");
    maxPerks = plugin.getConfig().getInt("config.Perks.maxPerks");
    KillMoney = plugin.getConfig().getInt("config.Economy.MoneyPerKill");
    // PistolMaterial = plugin.getConfig().getInt("config.Guns.PistolMaterial");

    try {
      CustomConfig killsconf = plugin.configManager.getConfig("kills");
      for (String a : killsconf.getConfigurationSection("Kills").getKeys(true)) {
        PlayerStats stat = new PlayerStats(a, killsconf.getInt("Kills." + a));
        plugin.leaderboards.addPlayerStats(stat);
      }
    } catch (NullPointerException e) {

    }
  }
Esempio n. 2
0
 public void wdgmsg(Widget sender, String msg, Object... args) {
   if (sender == in) {
     if (args[0] != null || ((String) args[0]).length() > 0) {
       String cmdText = ((String) args[0]).trim().toUpperCase();
       String cmd =
           cmdText.contains(" ") ? cmdText.substring(0, cmdText.indexOf(" ")).trim() : cmdText;
       cmdText = cmdText.contains(" ") ? cmdText.substring(cmdText.indexOf(" ")).trim() : "";
       append("Command: " + cmd + "\nArguments: " + cmdText, Color.BLUE.darker());
       String[] cmdArgs = cmdText.split(" ");
       in.settext("");
       if (cmd.equals("NIGHTVISION")) {
         if (!cmdArgs[0].trim().equals("")) {
           if (cmdArgs[0].equals("ON") || cmdArgs[0].equals("TRUE"))
             CustomConfig.hasNightVision = true;
           if (cmdArgs[0].equals("OFF") || cmdArgs[0].equals("FALSE"))
             CustomConfig.hasNightVision = false;
         } else {
           append("NIGHTVISION - " + (CustomConfig.hasNightVision ? "ON" : "OFF"));
         }
       } else if (cmd.equals("IRC")) {
         if (!cmdArgs[0].trim().equals("")) {
           if (cmdArgs[0].equals("ON") || cmdArgs[0].equals("TRUE")) CustomConfig.isIRCOn = true;
           if (cmdArgs[0].equals("OFF") || cmdArgs[0].equals("FALSE"))
             CustomConfig.isIRCOn = false;
         } else {
           append("IRC - " + (CustomConfig.isIRCOn ? "ON" : "OFF"));
         }
       }
       if (cmd.equals("SCREENSIZE") || cmd.equals("WINDOWSIZE")) {
         if (!cmdArgs[0].trim().equals("") && cmdArgs.length >= 2) {
           try {
             int x = Integer.parseInt(cmdArgs[0]);
             int y = Integer.parseInt(cmdArgs[1]);
             if (x >= 800 && y >= 600) {
               CustomConfig.setWindowSize(x, y);
             }
             CustomConfig.saveSettings();
             append(
                 "Client must be restarted for new settings to take effect.", Color.RED.darker());
           } catch (NumberFormatException e) {
             append("Dimensions must be numbers");
           }
         } else {
           append("SCREENSIZE = " + CustomConfig.windowSize.toString());
         }
       } else if (cmd.equals("SOUND")) {
         int vol = 0;
         if (!cmdArgs[0].trim().equals("")) {
           try {
             if (cmdArgs[0].equals("ON") || cmdArgs[0].equals("TRUE")) {
               CustomConfig.isSoundOn = true;
             } else if (cmdArgs[0].equals("OFF") || cmdArgs[0].equals("FALSE")) {
               CustomConfig.isSoundOn = false;
             } else if ((vol = Integer.parseInt(cmdArgs[0])) >= 0 && vol <= 100) {
               CustomConfig.sfxVol = vol;
             } else throw new NumberFormatException("vol = " + vol);
           } catch (NumberFormatException e) {
             append("Volume must be an integer between 0-100");
           }
         } else {
           append(
               "SOUND = "
                   + (CustomConfig.isSoundOn ? "ON  " : "OFF ")
                   + "VOLUME = "
                   + CustomConfig.sfxVol);
         }
       } else if (cmd.equals("MUSIC")) {
         int vol = 0;
         if (!cmdArgs[0].trim().equals("")) {
           try {
             if (cmdArgs[0].equals("ON") || cmdArgs[0].equals("TRUE")) {
               CustomConfig.isMusicOn = true;
             } else if (cmdArgs[0].equals("OFF") || cmdArgs[0].equals("FALSE")) {
               CustomConfig.isMusicOn = false;
             } else if ((vol = Integer.parseInt(cmdArgs[0])) >= 0 && vol <= 100) {
               CustomConfig.musicVol = vol;
             } else throw new NumberFormatException("vol = " + vol);
           } catch (NumberFormatException e) {
             append("Volume must be an integer between 0-100");
           }
         } else {
           append(
               "MUSIC = "
                   + (CustomConfig.isMusicOn ? "ON  " : "OFF ")
                   + "VOLUME = "
                   + CustomConfig.musicVol);
         }
       } else if (cmd.equals("SAVE")) {
         CustomConfig.saveSettings();
       } else if (cmd.equals("FORCESAVE")) {
         CustomConfig.isSaveable = true;
         CustomConfig.saveSettings();
       } else if (cmd.equals("DEBUG")) {
         if (!cmdArgs[0].trim().equals("")) {
           if (cmdArgs[0].equals("IRC")) {
             if (cmdArgs.length >= 2) {
               if (cmdArgs[1].equals("ON") || cmdArgs[1].equals("TRUE")) {
                 CustomConfig.logIRC = true;
               } else if (cmdArgs[1].equals("OFF") || cmdArgs[1].equals("FALSE")) {
                 CustomConfig.logIRC = false;
               }
             } else {
               append("DEBUG LOGS", Color.BLUE.darker());
               append("IRC - " + (CustomConfig.logIRC ? "ON" : "OFF"), Color.GREEN.darker());
             }
           } else if (cmdArgs[0].equals("SRVMSG")) {
             if (cmdArgs.length >= 2) {
               if (cmdArgs[1].equals("ON") || cmdArgs[1].equals("TRUE")) {
                 CustomConfig.logServerMessages = true;
               } else if (cmdArgs[1].equals("OFF") || cmdArgs[1].equals("FALSE")) {
                 CustomConfig.logServerMessages = false;
               }
             } else {
               append("DEBUG LOGS", Color.BLUE.darker());
               append(
                   "SRVMSG - " + (CustomConfig.logServerMessages ? "ON" : "OFF"),
                   Color.GREEN.darker());
             }
           }
           if (cmdArgs[0].equals("LOAD")) {
             if (cmdArgs.length >= 2) {
               if (cmdArgs[1].equals("ON") || cmdArgs[1].equals("TRUE")) {
                 CustomConfig.logLoad = true;
               } else if (cmdArgs[1].equals("OFF") || cmdArgs[1].equals("FALSE")) {
                 CustomConfig.logLoad = false;
               }
             } else {
               append("DEBUG LOGS", Color.BLUE.darker());
               append("LOAD - " + (CustomConfig.logLoad ? "ON" : "OFF"), Color.GREEN.darker());
             }
           }
         } else {
           append("DEBUG LOGS", Color.BLUE.darker());
           append("IRC - " + (CustomConfig.logIRC ? "ON" : "OFF"), Color.GREEN.darker());
           append("LOAD - " + (CustomConfig.logLoad ? "ON" : "OFF"), Color.GREEN.darker());
           append(
               "SRVMSG - " + (CustomConfig.logServerMessages ? "ON" : "OFF"),
               Color.GREEN.darker());
         }
       } else if (cmd.equals("HELP")) {
         append(
             "You can check the current status of each variable by "
                 + "typing the command without arguments.",
             Color.RED.darker());
         append("NIGHTVISION TRUE | FALSE | ON | OFF - Turns nightvision on or off");
         append("SCREENSIZE #### #### - Sets the screensize to the specified size.");
         append(
             "SOUND TRUE | FALSE | ON | OFF | 0-100 - Turns the sound effects on/off, or sets "
                 + "the volume to the specified level");
         append(
             "MUSIC TRUE | FALSE | ON | OFF | 0-100 - Turns the music on/off, or sets "
                 + "the volume to the specified level");
         append("SAVE - Saves the current settings if they are saveable.");
         append(
             "FORCESAVE - Saves the current settings whether or not they are "
                 + "saveable (Might cause errors).");
         append(
             "DEBUG IRC | LOAD   ON | OFF - Enables/disables debug text being dumped into the console "
                 + "for the specified system.");
         append("HELP - Shows this text.");
       } else {
         append("Command not recognized.  Type /help to see a list of commands.");
       }
     }
   } else {
     super.wdgmsg(sender, msg, args);
   }
 }
 public static void play(byte[] clip) {
   play(clip, CustomConfig.getSFXVolume(), 1.0);
 }