Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. package me.hellscoder.gun;
  2.  
  3. import java.io.File;
  4. import java.util.ArrayList;
  5. import java.util.HashMap;
  6. import java.util.HashSet;
  7. import java.util.List;
  8. import java.util.Map;
  9.  
  10. import org.bukkit.configuration.file.FileConfiguration;
  11. import org.bukkit.configuration.file.YamlConfiguration;
  12.  
  13. import me.hellscoder.HellMessage;
  14. import me.hellscoder.HellWar;
  15. import me.hellscoder.Utils;
  16.  
  17. public class HellGunParser {
  18.  
  19. private static HashSet<FileConfiguration> files = new HashSet<>();
  20. public static Map<Integer, HellGun> guns = new HashMap<>();
  21. public static Map<String, HellGun> commands = new HashMap<String, HellGun>();
  22. public static Map<String, HellGun> gunByName = new HashMap<String, HellGun>();
  23.  
  24.  
  25.  
  26. public static void parseGun(File folder){
  27. filesParse(folder);
  28. for(FileConfiguration c : files){
  29. HellGun gun = new HellGun();
  30. gun.setName(Utils.color(c.getString("name")));
  31. gun.setDescription(Utils.color(c.getString("description-help")));
  32. gun.setItem(c.getInt("item"));
  33. gun.setAmmo(c.getInt("ammo"));
  34. gun.setAmmofire(c.getInt("ammo-fire"));
  35. gun.setCommand(c.getString("give"));
  36. gun.setDamagerange(c.getInt("damage-range"));
  37. gun.setDamage(c.getInt("damage"));
  38. gun.setSound(c.getInt("sound-tembr"));
  39. gun.setDistance(c.getInt("shot-distance"));
  40. gun.setHeadshotRandom(c.getInt("headshot-ignore"));
  41. gun.setHeadshotMatch(c.getInt("headshot-match"));
  42. gun.setHeadshotMessage(Utils.color(c.getString("headshot-message")));
  43. gun.setEffectammo(c.getBoolean("effect-ammo"));
  44. gun.setOutOfAmmo(Utils.color(c.getString("out-of-ammo")));
  45. gun.setAmmoscore(c.getInt("ammo-score"));
  46. gun.setReloadTime(c.getInt("reload-time"));
  47. gun.setPhyIgnore(c.getBoolean("phy-ignore"));
  48. gun.setReloadMessage(Utils.color(c.getString("reload-msg")));
  49. gun.setSniperMode(c.getBoolean("sniper-mode"));
  50. gun.setExplosionEnable(c.getBoolean("explosion.enabled"));
  51. gun.setScore(c.getInt("score"));
  52. gun.setMobVelocity(Utils.config.getBoolean("mobVelocity"));
  53. gun.setOutSide(Utils.config.getInt("outSide"));
  54. if(c.getBoolean("explosion.enabled")){
  55. gun.setExplosionHeadshotEnable(c.getBoolean("explosion.headshot-enabled"));
  56. gun.setFire(c.getBoolean("explosion.fire"));
  57. gun.setExplosionRange(c.getInt("explosion.range"));
  58. }
  59. gun.setEffectsOnShot(c.getBoolean("effects-on-shot.enabled"));
  60. if(c.getBoolean("effects-on-shot.enabled")){
  61. gun.setEffectHeadshot(c.getBoolean("effects-on-shot.headshot-enabled"));
  62. gun.setEffects(c.getStringList("effects-on-shot.effects"));
  63. }
  64. gun.setLore(c.getStringList("lore"));
  65. if(commands.containsKey(gun.getCommand())){
  66. HellMessage.errors.add("Guns on folder used the same values of commands! (NOT LOAD)");
  67. continue;
  68. }
  69. commands.put(gun.getCommand(), gun);
  70. guns.put(gun.getItem(), gun);
  71. gunByName.put(gun.getName(), gun);
  72. }
  73. HellMessage.filesOfGun = guns.size();
  74. }
  75.  
  76. public static void reloadGuns(){
  77. files.clear();
  78. commands.clear();
  79. guns.clear();
  80. gunByName.clear();
  81. parseGun(new File(HellWar.plugin.getDataFolder() + "/guns"));
  82. }
  83.  
  84.  
  85.  
  86.  
  87. public static void filesParse(File folder){
  88. File[] entry = folder.listFiles();
  89. for(File f : entry){
  90. if(f.isDirectory()){
  91. continue;
  92. }
  93. files.add(YamlConfiguration.loadConfiguration(f));
  94. }
  95. }
  96.  
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement