Skip to content

Commit

Permalink
Merge pull request #53 from CallVDois/52-fix-gui
Browse files Browse the repository at this point in the history
52 fix gui
  • Loading branch information
needkg authored Jun 21, 2024
2 parents 1980971 + 279a826 commit df0ea52
Show file tree
Hide file tree
Showing 20 changed files with 416 additions and 144 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.needkg</groupId>
<artifactId>DayNightPvP</artifactId>
<name>DayNightPvP</name>
<version>1.2.5.2</version>
<version>1.2.5.3</version>
<packaging>jar</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
if (args.length == 1) {
if (args[0].equals("reload")) {
filesManager.reloadPlugin();
PlayerUtils.sendMessageToPlayer(player, langManager.getString("feedback-reload-plugin"));
PlayerUtils.sendMessageToPlayer(player, langManager.getFeedbackReloadPlugin());
return true;
} else {
PlayerUtils.sendMessageToPlayer(player, langManager.getString("feedback-non-existent-command"));
PlayerUtils.sendMessageToPlayer(player, langManager.getFeedbackNonExistentCommand());
return false;
}
}
Expand Down
127 changes: 99 additions & 28 deletions src/main/java/org/callvdois/daynightpvp/config/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,124 @@

public class ConfigManager {

public static File configFile;
public static FileConfiguration configFileConfig;
public static File file;
public static FileConfiguration fileConfiguration;

public String getString(String path) {
return configFileConfig.getString(path);
public void saveConfig() {
try {
fileConfiguration.save(file);
} catch (Exception ignore) {

}
}

public int getInt(String path) {
return configFileConfig.getInt(path);
public void addWorld(String world) {
List<String> worldList = getDayNightPvpWorlds();
worldList.add(world);
fileConfiguration.set("daynightpvp.worlds", worldList);
saveConfig();
}

public boolean getBoolean(String path) {
return configFileConfig.getBoolean(path);
public void removeWorld(String world) {
List<String> worldList = getDayNightPvpWorlds();
worldList.remove(world);
fileConfiguration.set("daynightpvp.worlds", worldList);
saveConfig();
}

public List<String> getList(String path) {
return configFileConfig.getStringList(path);
public void setValue(String path, String value) {
fileConfiguration.set(path, value);
}

public int getVersion() {
return getInt("version");
return fileConfiguration.getInt("version");
}

public void saveConfig() {
try {
configFileConfig.save(configFile);
} catch (Exception ignore) {
public boolean getUpdateChecker() {
return fileConfiguration.getBoolean("update-checker");
}

}
public String getLanguage() {
return fileConfiguration.getString("language");
}

public void addToList(String world, String path) {
List<String> list = getList(path);
list.add(world);
configFileConfig.set(path, list);
saveConfig();
public List<String> getDayNightPvpWorlds() {
return fileConfiguration.getStringList("daynightpvp.worlds");
}

public void removeFromList(String world, String path) {
List<String> list = getList(path);
list.remove(world);
configFileConfig.set(path, list);
saveConfig();
public int getDayNightPvpDayEnd() {
return fileConfiguration.getInt("daynightpvp.day-end");
}

public void setValue(String path, String value) {
configFileConfig.set(path, value);
public boolean getDayNightPvpAutomaticDifficultyEnabled() {
return fileConfiguration.getBoolean("daynightpvp.automatic-difficulty.enabled");
}

public String getDayNightPvpAutomaticDifficultyDay() {
return fileConfiguration.getString("daynightpvp.automatic-difficulty.day");
}

public String getDayNightPvpAutomaticDifficultyNight() {
return fileConfiguration.getString("daynightpvp.automatic-difficulty.night");
}

public boolean getNotifyPlayersChatDayNightStarts() {
return fileConfiguration.getBoolean("notify-players.chat.day-night-starts");
}

public boolean getNotifyPlayersChatHitAnotherPlayerDuringTheDay() {
return fileConfiguration.getBoolean("notify-players.chat.hit-another-player-during-the-day");
}

public boolean getNotifyPlayersTitleEnabled() {
return fileConfiguration.getBoolean("notify-players.title.enabled");
}

public int getNotifyPlayersTitleFadeIn() {
return fileConfiguration.getInt("notify-players.title.fade-in");
}

public int getNotifyPlayersTitleStay() {
return fileConfiguration.getInt("notify-players.title.stay");
}

public int getNotifyPlayersTitleFadeOut() {
return fileConfiguration.getInt("notify-players.title.fade-out");
}

public boolean getNotifyPlayersSoundEnabled() {
return fileConfiguration.getBoolean("notify-players.sound.enabled");
}

public String getNotifyPlayersSoundDay() {
return fileConfiguration.getString("notify-players.sound.day");
}

public String getNotifyPlayersSoundNight() {
return fileConfiguration.getString("notify-players.sound.night");
}

public boolean getPvpKeepInventoryWhenKilledByPlayer() {
return fileConfiguration.getBoolean("pvp.keep-inventory-when-killed-by-player");
}

public boolean getVaultLoseMoneyOnDeathEnabled() {
return fileConfiguration.getBoolean("vault.lose-money-on-death.enabled");
}

public boolean getVaultLoseMoneyOnDeathOnlyAtNight() {
return fileConfiguration.getBoolean("vault.lose-money-on-death.only-at-night");
}

public boolean getVaultLoseMoneyOnDeathOnlyInConfiguredWorlds() {
return fileConfiguration.getBoolean("vault.lose-money-on-death.only-in-configured-worlds");
}

public boolean getVaultLoseMoneyOnDeathKillerRewardMoney() {
return fileConfiguration.getBoolean("vault.lose-money-on-death.killer-reward-money");
}

public boolean getGriefPreventionPvpInLandEnabled() {
return fileConfiguration.getBoolean("griefprevention.pvp-in-land");
}
}
10 changes: 5 additions & 5 deletions src/main/java/org/callvdois/daynightpvp/config/FilesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public FilesManager() {
langManager = new LangManager();
fileOutdated = "[DayNightPvP] The {0} file was an outdated version. it has been replaced by the new version.";

configVersion = 14;
configVersion = 15;
langVersion = 12;
langFiles = Arrays.asList("lang/en-US.yml", "lang/pt-BR.yml", "lang/es-ES.yml", "lang/ru-RU.yml");
}
Expand All @@ -48,7 +48,7 @@ public void verifyConfigVersion() {
if (!(configVersion == configManager.getVersion())) {
resetFile("config.yml");
ConsoleUtils.warning(fileOutdated.replace("{0}", "config.yml"));
ConfigManager.configFileConfig = YamlConfiguration.loadConfiguration(ConfigManager.configFile);
ConfigManager.fileConfiguration = YamlConfiguration.loadConfiguration(ConfigManager.file);
}
}

Expand All @@ -74,11 +74,11 @@ public void reloadPlugin() {
}

public void createFiles() {
ConfigManager.configFile = new File(DayNightPvP.getInstance().getDataFolder(), "config.yml");
if (!ConfigManager.configFile.exists()) {
ConfigManager.file = new File(DayNightPvP.getInstance().getDataFolder(), "config.yml");
if (!ConfigManager.file.exists()) {
DayNightPvP.getInstance().saveResource("config.yml", false);
}
ConfigManager.configFileConfig = YamlConfiguration.loadConfiguration(ConfigManager.configFile);
ConfigManager.fileConfiguration = YamlConfiguration.loadConfiguration(ConfigManager.file);
verifyConfigVersion();

for (String fileName : langFiles) {
Expand Down
Loading

0 comments on commit df0ea52

Please sign in to comment.