HarryPotterSpells

HarryPotterSpells

59.3k Downloads

Unable to edit config with /hps config edit for numeric values

jacklin213 opened this issue ยท 0 comments

commented

Effects all OS, versions of Spigot, all recent versions of HPS

Describe the bug
When trying to edit any configuration using the /hps config edit command, if the desired value to set is a number, it gets written to the config as a string which causes errors.

To Reproduce
Steps to reproduce the behavior:

  1. Run any command to edit a config and provide a numeric value
    eg) /hps config edit spell spells.arania-exumai.knockback 2
  2. Try casting the spell
  3. See error in console

Additional Info
Issue is likely due to how Command handlers will convert all arguments into strings.
For the example provided above, currently is set into config like below:

if (HPS.getConfig(ConfigurationType.SPELL).get().contains(args[3])) {
HPS.getConfig(ConfigurationType.SPELL).get().set(args[3], args[4]);
HPS.getConfig(ConfigurationType.SPELL).save();
HPS.PM.dependantMessagingTell(sender, HPS.Localisation.getTranslation("cmdGenConfigSpellUpdated"));
} else {
HPS.PM.dependantMessagingTell(sender, ChatColor.RED + HPS.Localisation.getTranslation("cmdUnknownConfigPaths"));
}

Will need to detect if args[3] is numeric (int, float, double) and write it to config correctly