Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.hellscoder.gun;
- import java.io.File;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.HashSet;
- import java.util.List;
- import java.util.Map;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import me.hellscoder.HellMessage;
- import me.hellscoder.HellWar;
- import me.hellscoder.Utils;
- public class HellGunParser {
- private static HashSet<FileConfiguration> files = new HashSet<>();
- public static Map<Integer, HellGun> guns = new HashMap<>();
- public static Map<String, HellGun> commands = new HashMap<String, HellGun>();
- public static Map<String, HellGun> gunByName = new HashMap<String, HellGun>();
- public static void parseGun(File folder){
- filesParse(folder);
- for(FileConfiguration c : files){
- HellGun gun = new HellGun();
- gun.setName(Utils.color(c.getString("name")));
- gun.setDescription(Utils.color(c.getString("description-help")));
- gun.setItem(c.getInt("item"));
- gun.setAmmo(c.getInt("ammo"));
- gun.setAmmofire(c.getInt("ammo-fire"));
- gun.setCommand(c.getString("give"));
- gun.setDamagerange(c.getInt("damage-range"));
- gun.setDamage(c.getInt("damage"));
- gun.setSound(c.getInt("sound-tembr"));
- gun.setDistance(c.getInt("shot-distance"));
- gun.setHeadshotRandom(c.getInt("headshot-ignore"));
- gun.setHeadshotMatch(c.getInt("headshot-match"));
- gun.setHeadshotMessage(Utils.color(c.getString("headshot-message")));
- gun.setEffectammo(c.getBoolean("effect-ammo"));
- gun.setOutOfAmmo(Utils.color(c.getString("out-of-ammo")));
- gun.setAmmoscore(c.getInt("ammo-score"));
- gun.setReloadTime(c.getInt("reload-time"));
- gun.setPhyIgnore(c.getBoolean("phy-ignore"));
- gun.setReloadMessage(Utils.color(c.getString("reload-msg")));
- gun.setSniperMode(c.getBoolean("sniper-mode"));
- gun.setExplosionEnable(c.getBoolean("explosion.enabled"));
- gun.setScore(c.getInt("score"));
- gun.setMobVelocity(Utils.config.getBoolean("mobVelocity"));
- gun.setOutSide(Utils.config.getInt("outSide"));
- if(c.getBoolean("explosion.enabled")){
- gun.setExplosionHeadshotEnable(c.getBoolean("explosion.headshot-enabled"));
- gun.setFire(c.getBoolean("explosion.fire"));
- gun.setExplosionRange(c.getInt("explosion.range"));
- }
- gun.setEffectsOnShot(c.getBoolean("effects-on-shot.enabled"));
- if(c.getBoolean("effects-on-shot.enabled")){
- gun.setEffectHeadshot(c.getBoolean("effects-on-shot.headshot-enabled"));
- gun.setEffects(c.getStringList("effects-on-shot.effects"));
- }
- gun.setLore(c.getStringList("lore"));
- if(commands.containsKey(gun.getCommand())){
- HellMessage.errors.add("Guns on folder used the same values of commands! (NOT LOAD)");
- continue;
- }
- commands.put(gun.getCommand(), gun);
- guns.put(gun.getItem(), gun);
- gunByName.put(gun.getName(), gun);
- }
- HellMessage.filesOfGun = guns.size();
- }
- public static void reloadGuns(){
- files.clear();
- commands.clear();
- guns.clear();
- gunByName.clear();
- parseGun(new File(HellWar.plugin.getDataFolder() + "/guns"));
- }
- public static void filesParse(File folder){
- File[] entry = folder.listFiles();
- for(File f : entry){
- if(f.isDirectory()){
- continue;
- }
- files.add(YamlConfiguration.loadConfiguration(f));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement