Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.35 KB | None | 0 0
  1. package jw.landon.remoraids.implementation.config;
  2.  
  3. import jw.landon.remoraids.RemoRaids;
  4. import net.minecraftforge.common.config.Configuration;
  5.  
  6. import java.util.Objects;
  7.  
  8. /**
  9.  * Holds information from the configuration file BossDefaults.cfg
  10.  * <p>
  11.  *     This configuration holds information regarding defaults for bosses,
  12.  *     which can be applied through the boss builder and spawner builder via their
  13.  *     <code>loadConfigDefaults</code> methods.
  14.  * </p>
  15.  *
  16.  * @author landonjw
  17.  * @since  1.0.0
  18.  */
  19. public class BossDefaults {
  20.  
  21.     /** The configuration data. */
  22.     private Configuration config;
  23.  
  24.     public boolean noRebattles = false;
  25.     public boolean noRebattlesOnRespawn = false;
  26.     public long battleCooldown = 30000;
  27.  
  28.     public float bossScale = 5;
  29.     public float engageRange = 10;
  30.     public int levelDisplay = 100;
  31.     public boolean announcementTeleportable = true;
  32.  
  33.     public long avgTurnSpeedMin = 500;
  34.     public long stDevTurnSpeedMin = 50;
  35.     public long turnTimeMax = 60000;
  36.  
  37.     public boolean banAftermath = true;
  38.     public boolean banImposter = true;
  39.     public boolean banIronBarbs = true;
  40.     public boolean banRockyHelmet = true;
  41.     public boolean banRoughSkin = true;
  42.     public boolean banStickyBarb = true;
  43.  
  44.     public String[] disabledBossMoves = new String[]{
  45.             "Aqua Ring",
  46.             "Ingain",
  47.             "Recover",
  48.             "Rest",
  49.             "Shore Up",
  50.             "Soft-Boiled",
  51.             "Synthesis"
  52.     };
  53.  
  54.     public String[] disabledPlayerMoves = new String[]{
  55.             "Endeavor",
  56.             "Pain Split",
  57.             "Leech Seed",
  58.             "Perish Song",
  59.             "Whirlpool",
  60.             "Constrict",
  61.             "Infestation",
  62.             "Fire Spin",
  63.             "Natures Madness",
  64.             "Super Fang",
  65.             "Sheer Cold",
  66.             "Fissure",
  67.             "Horn Drill",
  68.             "Guillotine",
  69.             "Power Swap",
  70.             "Guard Swap",
  71.             "Heal Pulse",
  72.             "Present",
  73.             "Floral Healing",
  74.             "Spiky Shield",
  75.             "Imprison",
  76.             "Transform",
  77.             "Destiny Bond",
  78.             "Poison Gas",
  79.             "Entrainment",
  80.             "Glare",
  81.             "Grass Whistle",
  82.             "Hypnosis",
  83.             "Lovely Kiss",
  84.             "Poison Powder",
  85.             "Psycho Shift",
  86.             "Roar",
  87.             "Whirlwind",
  88.             "Sing",
  89.             "Skill Swap",
  90.             "Spore",
  91.             "Stun Spore",
  92.             "Thunder Wave",
  93.             "Toxic",
  94.             "Will-O-Wisp",
  95.             "Yawn",
  96.             "Magma Storm",
  97.             "Bind",
  98.             "Clamp",
  99.             "Sand Tomb",
  100.             "Wrap"
  101.     };
  102.  
  103.     public String[] disabledStatus = new String[]{
  104.             "Poison",
  105.             "PoisonBadly",
  106.             "Burn",
  107.             "Paralysis",
  108.             "Freeze",
  109.             "Sleep",
  110.             "GrassyTerrain",
  111.             "Sandstorm",
  112.             "Hail",
  113.             "Cursed",
  114.             "Imprison"
  115.     };
  116.  
  117.     /**
  118.      * Constructor for boss defaults configuration values.
  119.      *
  120.      * @param config the configuration to read from
  121.      */
  122.     public BossDefaults(Configuration config){
  123.         this.config = Objects.requireNonNull(config);
  124.         readConfig();
  125.     }
  126.  
  127.     /**
  128.      * Reads from the configuration.
  129.      */
  130.     public void readConfig(){
  131.         try{
  132.             config.load();
  133.             init();
  134.         }
  135.         catch(Exception e){
  136.             RemoRaids.logger.error("An error occurred during boss default configuration loading.");
  137.         }
  138.         finally{
  139.             if(config.hasChanged()){
  140.                 config.save();
  141.             }
  142.         }
  143.     }
  144.  
  145.     /**
  146.      * Loads all values from the configuration into variables.
  147.      */
  148.     private void init(){
  149.         config.addCustomCategoryComment("Battle-Cooldowns", "Sets the defaults for bosses " +
  150.                 "regarding cooldowns in battle.");
  151.  
  152.         noRebattles = config.getBoolean("No-Rebattles", "Battle-Cooldowns", noRebattles,
  153.                 "Sets so a player may not rebattle the boss if they end battle with it.");
  154.  
  155.         noRebattlesOnRespawn = config.getBoolean("No-Rebattles-On-Respawn", "Battle-Cooldowns",
  156.                 noRebattlesOnRespawn, "Sets so a player may not rebattle the boss if they end " +
  157.                         "battle with it, even across respawns.");
  158.  
  159.         battleCooldown = Long.parseLong(config.getString("Battle-Cooldown", "Battle-Cooldowns",
  160.                 "" + battleCooldown, "Sets the cooldown before a player may rebattle the" +
  161.                         " boss after they end battle with it."));
  162.  
  163.         config.addCustomCategoryComment("Boss-Characteristics", "Sets the defaults for general " +
  164.                 "characteristics about a boss.");
  165.  
  166.         bossScale = config.getFloat("Boss-Scale", "Boss-Characteristics", bossScale, 0,
  167.                 100, "Sets the size the boss model will be upon spawn. This value is multiplicative.");
  168.  
  169.         engageRange = config.getFloat("Engage-Range", "Boss-Characteristics", engageRange,
  170.                 (float) 0.00000001, Float.MAX_VALUE, "Sets the area around a boss in blocks in which" +
  171.                         " a player may automatically engage the boss in battle.");
  172.  
  173.         levelDisplay = config.getInt("Level-Display", "Boss-Characteristics", levelDisplay,
  174.                 1, Short.MAX_VALUE, "The level that will appear for the boss in the battle GUI. " +
  175.                         "This will not affect boss stats, but will affect damage calculation.");
  176.  
  177.         announcementTeleportable = config.getBoolean("Spawn-Announcement-Teleportable", "Boss-Characeristics",
  178.                 announcementTeleportable, "If the spawning announcement for a boss should allow players " +
  179.                         "to teleport to the boss by clicking it. {boss-species} can be used to for boss species, " +
  180.                         "{boss-x}, {boss-y}, {boss-z} can be used for the boss's coordinates.");
  181.  
  182.         config.addCustomCategoryComment("Battle-Kicking", "Sets the defaults bot detection " +
  183.                 "and AFK detection, which will kick a player from battle.");
  184.  
  185.         avgTurnSpeedMin = Long.parseLong(config.getString("Average-Turn-Speed-Min", "Battle-Kicking",
  186.                 "" + avgTurnSpeedMin, "Value in milliseconds that if average turn speed" +
  187.                         " is below, will kick player for botting. 0 to disable."));
  188.  
  189.         stDevTurnSpeedMin = Long.parseLong(config.getString("Turn-Speed-StDev-Min", "Battle-Kicking",
  190.                 "" + stDevTurnSpeedMin, "Value in milliseconds that if turn speed standard" +
  191.                         " deviation is below, will kick player for botting. 0 to disable."));
  192.  
  193.         turnTimeMax = Long.parseLong(config.getString("AFK-Turn-Time-Max", "Battle-Kicking",
  194.                 "" + turnTimeMax, "Amount of time in seconds before a player" +
  195.                         " will be kicked for AFK. 0 to disable."));
  196.  
  197.         config.addCustomCategoryComment("Player-Restraints", "Sets the defaults for restraints " +
  198.                 "on players during battle with the boss.");
  199.  
  200.         banAftermath = config.getBoolean("Ban-Aftermath", "Player-Restraints", banAftermath,
  201.                 "Prevents player from engaging battle with bosses if they have a party " +
  202.                         "member with the ability Aftermath.");
  203.  
  204.         banImposter = config.getBoolean("Ban-Imposter", "Player-Restraints", banImposter,
  205.                 "Prevents player from engaging battle with bosses if they have a party " +
  206.                         "member with the ability Imposter.");
  207.  
  208.         banIronBarbs = config.getBoolean("Ban-Iron-Barbs", "Player-Restraints", banIronBarbs,
  209.                 "Prevents player from engaging battle with bosses if they have a party " +
  210.                         "member with the ability Iron Barbs.");
  211.  
  212.         banRockyHelmet = config.getBoolean("Ban-Rocky-Helmet", "Player-Restraints", banRockyHelmet,
  213.                 "Prevents player from engaging battle with bosses if they have a party " +
  214.                         "member with the item Rocky Helmet.");
  215.  
  216.         banRoughSkin = config.getBoolean("Ban-Rough-Skin", "Player-Restraints", banRoughSkin,
  217.                 "Prevents player from engaging battle with bosses if they have a party " +
  218.                         "member with the ability Rough Skin.");
  219.  
  220.         banStickyBarb = config.getBoolean("Ban-Sticky-Barb", "Player-Restraints", banStickyBarb,
  221.                 "Prevents player from engaging battle with bosses if they have a party " +
  222.                         "member with the ability Sticky Barb.");
  223.  
  224.         disabledPlayerMoves = config.getStringList("Disabled-Player-Moves", "Player-Restraints",
  225.                 disabledPlayerMoves, "Disables moves from being used by a player in battle.");
  226.  
  227.         disabledStatus = config.getStringList("Disabled-Boss-Status", "Player-Restraints",
  228.                 disabledStatus, "Disables status from applying to a boss during battle.");
  229.  
  230.         config.addCustomCategoryComment("Boss-Restraints", "Sets the defaults for restraints " +
  231.                 "on the boss during battle.");
  232.  
  233.         disabledBossMoves = config.getStringList("Disabled-Boss-Moves", "Boss-Restraints",
  234.                 disabledBossMoves, "Disables moves from being used by a boss in  battle.");
  235.     }
  236.  
  237. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement