Skip to content

Commit

Permalink
Fixed issue with the reload command resetting config
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacxk committed Sep 29, 2019
1 parent f1e6728 commit e488ef8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/me/jackint0sh/timedfly/commands/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void permissions(CommandSender sender) {
private void reload(CommandSender sender) {
try {
for (Config config : Config.getConfigs().values()) {
config.reload();
config.reload(false);
if (config.getName().equals("items.yml")) {
config.get().getConfigurationSection("Items").getKeys(false).forEach(FlyItem::new);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import me.jackint0sh.timedfly.utilities.Languages;
import me.jackint0sh.timedfly.utilities.MessageUtil;
import org.bukkit.Material;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
Expand Down Expand Up @@ -88,7 +89,7 @@ private static void handleSave(Player player) {
FlyItem.setConfigItem(flyItem);

try {
config.reload();
config.reload(true);
} catch (IOException e) {
MessageUtil.sendError(player, e);
}
Expand All @@ -101,7 +102,7 @@ private static void handleDelete(Player player) {
config.get().set("Items." + flyItem.getKey(), null);
FlyItem.removeConfigItem(flyItem.getKey());
try {
config.reload();
config.reload(true);
} catch (IOException e) {
MessageUtil.sendError(player, e);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/me/jackint0sh/timedfly/utilities/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void save() throws IOException {
fileConfiguration.save(file);
}

public void reload() throws IOException {
save();
public void reload(boolean save) throws IOException {
if (save) save();
fileConfiguration = YamlConfiguration.loadConfiguration(file);
Config.configMap.put(name, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public static void sendTranslation(Player to, String path, String[][] replace) {
if (replace != null) {
for (String[] strings : replace) translation = translation.replace(strings[0], strings[1]);
}
sendMessage(to, translation, true);
sendMessage(to, replacePlaceholders(to, translation), true);
}

public static void sendTranslation(CommandSender to, String path, String[][] replace) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ Messages:
# A list of world in which you want the plugin to be Enable.
World-List:
# Available types:
# enable: the plugin will work in worlds listed
# disable: the plugin will not work in worlds listed
# all: the plugin will work in all worlds
# enable: the plugin will work in worlds listed
# disable: the plugin will not work in worlds listed
# all: the plugin will work in all worlds
Type: 'all'
Worlds:
- 'world'
Expand Down

0 comments on commit e488ef8

Please sign in to comment.