Skip to content

Commit 063c683

Browse files
committed
Oxygen | v1.5
- Moved messages to lang.yml. - Social commands and more can now be configured in lang.yml. - Added PING-LORE-ENABLED option to maintenance mode ping text. - Ping text can now be enabled and disabled via yml. - Added DAY, HOUR, MINUTE and SECOND so they can be set via yml. - This option was not there, so now when the number is "1" it will say 1 minute instead of 1 minutes. - Theme system has been updated. - There is now a middle color option. - Updated Themes system variables - Now is %primary%, %secondary% and %middle%. - Fixed configuration error when deactivating the plugin. - On deactivating, the plugin did not save the config yml.
1 parent 7d9f5ee commit 063c683

File tree

19 files changed

+218
-120
lines changed

19 files changed

+218
-120
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44

5-
# Oxygen | v1.4
5+
# Oxygen | v1.5
66
* By LiteClubDevelopment, Traduciendo
77
* Available for download on [BuiltByBit](https://builtbybit.com/resources/oxygen-modern-bungee-core.54077/) and [GitHub](https://github.com/HCFAlerts/Oxygen/releases)
88
---

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>me.traduciendo.oxygen</groupId>
88
<artifactId>Oxygen</artifactId>
9-
<version>1.4</version>
9+
<version>1.5</version>
1010

1111
<url>https://dsc.gg/liteclubdevelopment</url>
1212
<description>Bungee Core</description>

src/main/java/me/traduciendo/oxygen/Oxygen.java

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ public class Oxygen extends Plugin implements Listener {
4545
private BungeeHandler bungeeHandler;
4646
private ScheduledTask scheduledTask;
4747
private CreatorYML configYML;
48+
private CreatorYML langYML;
4849
private Configuration config;
50+
private Configuration langConfig;
4951
private ScheduledTask countdown;
5052

5153
public void onEnable() {
@@ -54,6 +56,7 @@ public void onEnable() {
5456
this.handlers();
5557
this.listeners();
5658
this.loadConfig();
59+
this.loadLangConfig();
5760
Theme.loadColors();
5861
this.commands();
5962
this.getProxy().getPluginManager().registerListener(this, this);
@@ -80,16 +83,34 @@ public Configuration getConfiguration() {
8083
return this.config;
8184
}
8285

86+
protected Configuration getLangConfig() {
87+
return this.langConfig;
88+
}
89+
90+
public Configuration getLangConfiguration() {
91+
return this.langConfig;
92+
}
93+
8394
public void reloadConfig() {
8495
this.loadConfig();
8596
this.saveConfig();
97+
this.loadLangConfig();
98+
this.saveLangConfig();
8699
}
87100

88101
protected void saveConfig() {
89102
try {
90103
ConfigurationProvider.getProvider(YamlConfiguration.class).save(this.getConfig(), new File(this.getDataFolder(), "config.yml"));
91104
} catch (IOException e) {
92-
throw new RuntimeException("Unable to save configuration", e);
105+
throw new RuntimeException("Unable to save main configuration", e);
106+
}
107+
}
108+
109+
protected void saveLangConfig() {
110+
try {
111+
ConfigurationProvider.getProvider(YamlConfiguration.class).save(this.getLangConfig(), new File(this.getDataFolder(), "lang.yml"));
112+
} catch (IOException e) {
113+
throw new RuntimeException("Unable to save lang configuration", e);
93114
}
94115
}
95116

@@ -112,8 +133,28 @@ private void loadConfig() {
112133
}
113134
}
114135

136+
private void loadLangConfig() {
137+
File file = new File(this.getDataFolder(), "lang.yml");
138+
if (!file.exists()) {
139+
if (!this.getDataFolder().exists()) {
140+
this.getDataFolder().mkdir();
141+
}
142+
try (InputStream in = this.getResourceAsStream("lang.yml")) {
143+
Files.copy(in, file.toPath());
144+
} catch (IOException e) {
145+
e.printStackTrace();
146+
}
147+
}
148+
try {
149+
this.langConfig = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
150+
} catch (IOException e) {
151+
e.printStackTrace();
152+
}
153+
}
154+
115155
private void files() {
116156
this.configYML = new CreatorYML(this, "config.yml");
157+
this.langYML = new CreatorYML(this, "lang.yml");
117158
}
118159

119160
private void handlers() {
@@ -181,22 +222,22 @@ public String getTime() {
181222
StringBuilder sb = new StringBuilder();
182223

183224
if (days > 0) {
184-
sb.append(days).append(config.getString("TIMER.DAYS"));
225+
sb.append(days).append(config.getString(days == 1 ? "TIMER.DAY" : "TIMER.DAYS"));
185226
}
186227

187228
if (hours > 0) {
188229
if (sb.length() > 0) sb.append(" ");
189-
sb.append(hours).append(config.getString("TIMER.HOURS"));
230+
sb.append(hours).append(config.getString(hours == 1 ? "TIMER.HOUR" : "TIMER.HOURS"));
190231
}
191232

192233
if (minutes > 0) {
193234
if (sb.length() > 0) sb.append(" ");
194-
sb.append(minutes).append(config.getString("TIMER.MINUTES"));
235+
sb.append(minutes).append(config.getString(minutes == 1 ? "TIMER.MINUTE" : "TIMER.MINUTES"));
195236
}
196237

197238
if (seconds > 0) {
198239
if (sb.length() > 0) sb.append(" ");
199-
sb.append(seconds).append(config.getString("TIMER.SECONDS"));
240+
sb.append(seconds).append(config.getString(seconds == 1 ? "TIMER.SECOND" : "TIMER.SECONDS"));
200241
}
201242

202243
return sb.toString();
@@ -238,6 +279,6 @@ public void onDisable() {
238279
BungeeCord.getInstance().getConsole().sendMessage(CC.translate("&7&oThank you for using Oxygen Bungee Core"));
239280
BungeeCord.getInstance().getConsole().sendMessage(CC.translate("&7&oJoin our Discord dsc.gg/liteclubdevelopment"));
240281
BungeeCord.getInstance().getConsole().sendMessage(CC.translate(Theme.getSecondaryColor() + "&m=============================="));
241-
this.saveConfig();
282+
this.reloadConfig();
242283
}
243284
}

src/main/java/me/traduciendo/oxygen/OxygenCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void execute(CommandSender sender, String[] args) {
4343
plugin.reloadConfig();
4444
sender.sendMessage(CC.translate(Theme.getSecondaryColor() + "&m=============================="));
4545
sender.sendMessage(CC.translate(Theme.getPrimaryColor() + "Oxygen&7 &areloaded successfully!"));
46-
sender.sendMessage(CC.translate(Theme.getSecondaryColor() + "┃ &7Reloaded files: &fconfig.yml"));
46+
sender.sendMessage(CC.translate(Theme.getSecondaryColor() + "┃ &7Reloaded files: &fconfig.yml&7, &flang.yml"));
4747
sender.sendMessage(CC.translate(Theme.getSecondaryColor() + "&m=============================="));
4848
} else {
4949
sender.sendMessage(CC.translate("&cInvalid command. Use /oxygen reload."));

src/main/java/me/traduciendo/oxygen/Theme.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,23 @@
1111

1212
public class Theme {
1313
private static String primaryColor;
14+
private static String middleColor;
1415
private static String secondaryColor;
1516

1617
public static void loadColors() {
1718
primaryColor = Oxygen.getInstance().getConfig().getString("GENERAL.PRIMARY_COLOR", "&b");
19+
middleColor = Oxygen.getInstance().getConfig().getString("GENERAL.MIDDLE_COLOR", "&f");
1820
secondaryColor = Oxygen.getInstance().getConfig().getString("GENERAL.SECONDARY_COLOR", "&3");
1921
}
2022

2123
public static String getPrimaryColor() {
2224
return ChatColor.translateAlternateColorCodes('&', primaryColor);
2325
}
2426

27+
public static String getMiddleColor() {
28+
return ChatColor.translateAlternateColorCodes('&', middleColor);
29+
}
30+
2531
public static String getSecondaryColor() {
2632
return ChatColor.translateAlternateColorCodes('&', secondaryColor);
2733
}

src/main/java/me/traduciendo/oxygen/bungeecore/commands/media/DiscordCommand.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ public void execute(CommandSender sender, String[] args) {
4141
return;
4242
}
4343

44-
config.getConfiguration().getStringList("DISCORD.MESSAGE").stream()
44+
Oxygen.getInstance().getLangConfiguration().getStringList("SOCIAL.DISCORD.MESSAGE").stream()
4545
.map(msg -> CC.translate(
46-
msg.replace("%theme_primary%", Theme.getPrimaryColor())
47-
.replace("%theme_secondary%", Theme.getSecondaryColor())
46+
msg.replace("%primary%", Theme.getPrimaryColor())
47+
.replace("%secondary%", Theme.getSecondaryColor())
48+
.replace("%middle%", Theme.getMiddleColor())
4849
))
4950
.forEach(sender::sendMessage);
5051
}

src/main/java/me/traduciendo/oxygen/bungeecore/commands/media/StoreCommand.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ public void execute(CommandSender sender, String[] args) {
3838
return;
3939
}
4040

41-
config.getConfiguration().getStringList("STORE.MESSAGE").stream()
41+
Oxygen.getInstance().getLangConfiguration().getStringList("SOCIAL.STORE.MESSAGE").stream()
4242
.map(msg -> CC.translate(
43-
msg.replace("%theme_primary%", Theme.getPrimaryColor())
44-
.replace("%theme_secondary%", Theme.getSecondaryColor())
43+
msg.replace("%primary%", Theme.getPrimaryColor())
44+
.replace("%secondary%", Theme.getSecondaryColor())
45+
.replace("%middle%", Theme.getMiddleColor())
4546
))
4647
.forEach(sender::sendMessage);
4748
}

src/main/java/me/traduciendo/oxygen/bungeecore/commands/media/TeamSpeakCommand.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ public void execute(CommandSender sender, String[] args) {
3838
return;
3939
}
4040

41-
config.getConfiguration().getStringList("TEAMSPEAK.MESSAGE").stream()
41+
Oxygen.getInstance().getLangConfiguration().getStringList("SOCIAL.TEAMSPEAK.MESSAGE").stream()
4242
.map(msg -> CC.translate(
43-
msg.replace("%theme_primary%", Theme.getPrimaryColor())
44-
.replace("%theme_secondary%", Theme.getSecondaryColor())
43+
msg.replace("%primary%", Theme.getPrimaryColor())
44+
.replace("%secondary%", Theme.getSecondaryColor())
45+
.replace("%middle%", Theme.getMiddleColor())
4546
))
4647
.forEach(sender::sendMessage);
4748
}

src/main/java/me/traduciendo/oxygen/bungeecore/commands/media/TwitterCommand.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ public void execute(CommandSender sender, String[] args) {
3838
return;
3939
}
4040

41-
config.getConfiguration().getStringList("TWITTER.MESSAGE").stream()
41+
Oxygen.getInstance().getLangConfiguration().getStringList("SOCIAL.TWITTER.MESSAGE").stream()
4242
.map(msg -> CC.translate(
43-
msg.replace("%theme_primary%", Theme.getPrimaryColor())
44-
.replace("%theme_secondary%", Theme.getSecondaryColor())
43+
msg.replace("%primary%", Theme.getPrimaryColor())
44+
.replace("%secondary%", Theme.getSecondaryColor())
45+
.replace("%middle%", Theme.getMiddleColor())
4546
))
4647
.forEach(sender::sendMessage);
4748
}

src/main/java/me/traduciendo/oxygen/bungeecore/commands/media/WebsiteCommand.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ public void execute(CommandSender sender, String[] args) {
3737
return;
3838
}
3939

40-
config.getConfiguration().getStringList("WEBSITE.MESSAGE").stream()
40+
Oxygen.getInstance().getLangConfiguration().getStringList("SOCIAL.WEBSITE.MESSAGE").stream()
4141
.map(msg -> CC.translate(
42-
msg.replace("%theme_primary%", Theme.getPrimaryColor())
43-
.replace("%theme_secondary%", Theme.getSecondaryColor())
42+
msg.replace("%primary%", Theme.getPrimaryColor())
43+
.replace("%secondary%", Theme.getSecondaryColor())
44+
.replace("%middle%", Theme.getMiddleColor())
4445
))
4546
.forEach(sender::sendMessage);
4647
}

0 commit comments

Comments
 (0)