forked from CodyScheer/NetherWater
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed style of working with config file
- Loading branch information
Showing
5 changed files
with
30 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 18 additions & 15 deletions
33
src/com/leetzilantonis/netherwater/config/ConfigManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,63 @@ | ||
package com.leetzilantonis.netherwater.config; | ||
|
||
import com.leetzilantonis.netherwater.NetherWater; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.configuration.file.FileConfiguration; | ||
import org.bukkit.configuration.file.YamlConfiguration; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
public class ConfigManager { | ||
private final NetherWater plugin; | ||
|
||
private FileConfiguration configData; | ||
|
||
public ConfigManager(NetherWater plugin) { | ||
this.plugin = plugin; | ||
|
||
this.loadConfig(); | ||
} | ||
|
||
private void loadConfig() { | ||
public void loadConfig() { | ||
if (!this.plugin.getDataFolder().exists()) { | ||
this.plugin.getDataFolder().mkdir(); | ||
} | ||
|
||
if (!new File(this.plugin.getDataFolder(), "config.yml").exists()) { | ||
this.plugin.saveDefaultConfig(); | ||
File configFile = new File(this.plugin.getDataFolder(), "config.yml"); | ||
|
||
if (!configFile.exists()) { | ||
this.plugin.saveResource("config.yml", false); | ||
} else { | ||
this.reloadConfig(); | ||
this.configData = YamlConfiguration.loadConfiguration(configFile); | ||
} | ||
} | ||
|
||
public void reloadConfig() { | ||
this.plugin.reloadConfig(); | ||
} | ||
|
||
public boolean isDebugOn() { | ||
return this.plugin.getConfig().getBoolean("debug"); | ||
return this.configData.getBoolean("debug"); | ||
} | ||
|
||
public List<String> getDisabledWorlds() { | ||
return this.plugin.getConfig().getStringList("disabled-worlds"); | ||
return this.configData.getStringList("disabled-worlds"); | ||
} | ||
|
||
public String getMessage(String name) { | ||
return this.plugin.getConfig().getString("messages." + name); | ||
return this.configData.getString("messages." + name); | ||
} | ||
|
||
public int getMinHeight() { | ||
return this.plugin.getConfig().getInt("min-height"); | ||
return this.configData.getInt("min-height"); | ||
} | ||
|
||
public int getMaxHeight() { | ||
return this.plugin.getConfig().getInt("max-height"); | ||
return this.configData.getInt("max-height"); | ||
} | ||
|
||
public boolean isSpreadBypassEnabled() { | ||
return this.plugin.getConfig().getBoolean("spread-bypass"); | ||
return this.configData.getBoolean("spread-bypass"); | ||
} | ||
|
||
public boolean isSpreadEnabled() { | ||
return this.plugin.getConfig().getBoolean("spread-enabled"); | ||
return this.configData.getBoolean("spread-enabled"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters