Skip to content

Commit

Permalink
v1.7.4-pre-release.13 hex color bugfix and added display command
Browse files Browse the repository at this point in the history
  • Loading branch information
jonagamerpro1234 committed Jan 26, 2022
1 parent 7e8de9f commit 23f5efc
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public FileConfiguration getlang(final String localeName) {

public void reloadlang(final String localeName) {
final File localeDir = new File(plugin.getDataFolder() + File.separator + "lang");

if (!localeDir.exists()) {
localeDir.mkdir();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
import org.bukkit.configuration.file.FileConfiguration;

import jss.customjoinandquitmessages.CustomJoinAndQuitMessages;
import jss.customjoinandquitmessages.utils.EventUtils;
import jss.customjoinandquitmessages.utils.Logger;
import jss.customjoinandquitmessages.utils.Settings;
import jss.customjoinandquitmessages.utils.Utils;

public class PreConfigLoader {

private CustomJoinAndQuitMessages plugin;
private EventUtils EventsUtils = new EventUtils(plugin);

public PreConfigLoader(CustomJoinAndQuitMessages plugin) {
this.plugin = plugin;
Expand All @@ -22,28 +21,60 @@ public PreConfigLoader(CustomJoinAndQuitMessages plugin) {
public void loadConfig() {
FileConfiguration config = plugin.getConfigFile().getConfig();
try {
Settings.boolean_join = config.getString("Join.Enabled").equals("true");
Settings.boolean_quit = config.getString("Quit.Enabled").equals("true");
Settings.boolean_welcome = config.getString("Welcome.Enabled").equals("true");
Settings.boolean_update = config.getString("Config.Update").equals("true");

//Other
Settings.update = config.getString("Config.Update").equals("true");
Settings.c_type = config.getString("Config.Type");
Settings.message_join = config.getString("Join.Text");
Settings.is_Group_Display = config.getString("Config.Type").equalsIgnoreCase("group");

//Join
Settings.join = config.getString("Join.Enabled").equals("true");
Settings.join_message = config.getString("Join.Text");
Settings.join_type = config.getString("Join.Type");
Settings.boolean_firstjoin = config.getString("Join.First-Join.Enabled").equals("true");
Settings.message_first_join = config.getString("Join.First-Join.Text");

Settings.firstjoin = config.getString("Join.First-Join.Enabled").equals("true");
Settings.join_message_first = config.getString("Join.First-Join.Text");

Settings.join_actionbar = config.getString("Join.ActionBar.Enabled").equals("true");
Settings.join_message_actionbar_text = config.getString("Join.ActionBar.Text");

Settings.join_message_title_title = config.getString("Join.Title.Title");
Settings.join_message_title_subtitle = config.getString("Join.Title.SubTitle");

Settings.join_title_fadein = config.getInt("Join.Title.FadeIn");
Settings.join_title_stay = config.getInt("Join.Title.Stay");
Settings.join_title_fadeout = config.getInt("Join.Title.FadeOut");

Settings.join_sound = config.getString("Join.Sound.Enabled").equals("true");
Settings.join_sound_name = config.getString("Join.Sound.Name");
Settings.join_sound_pitch = Float.valueOf(config.getString("Join.Sound.Pitch"));
Settings.join_sound_vol = config.getInt("Join.Sound.Volume");

//Quit
Settings.quit = config.getString("Quit.Enabled").equals("true");
Settings.quit_type = config.getString("Quit.Type");
Settings.message_quit = config.getString("Quit.Text");
Settings.quit_message = config.getString("Quit.Text");

//Welcome
Settings.welcome = config.getString("Welcome.Enabled").equals("true");
Settings.list_welcome = config.getStringList("Welcome.Text");

//Hooks
Settings.hook_discordsrv = config.getString("Hooks.DiscordSRV.Enabled").equals("true");
Settings.hook_discordsrv_channelid = config.getString("Hooks.DiscordSRV.Channel-ID");

Settings.hook_essentialsDiscord = config.getString("Hooks.EssentialsDiscord.Enabled").equals("true");
Settings.hook_essentialsDiscord_channelid = config.getString("Hooks.EssentialsDiscord.Channel-ID");
Settings.hook_essentialsDiscord_use_default_channel = config.getString("Hooks.EssentialsDiscord.Use-Default-Channel").equals("true");

Settings.hook_vault = config.getString("Hooks.Vault.Enabled").equals("true");
Settings.hook_vault_use_group = config.getString("Hooks.Vault.Use-Vault-In-Groups").equals("true");

Settings.hook_luckperms = config.getString("Hooks.LuckPerms.Enabled").equals("true");
Settings.hook_luckperms_use_group = config.getString("Hooks.LuckPerms.Use-Luckperms-In-Groups").equals("true");

}catch(Exception e) {
Logger.error("&cThere was an error loading the &b[PreConfigLoader]&7, please reload the plugin");
e.printStackTrace();
}
}
Expand All @@ -61,7 +92,7 @@ public boolean loadLangs() {
plugin.getLogger().severe("Could not add locales!");
}
if (!availableLocales.containsKey(Settings.defaultLanguage)) {
Utils.sendColorMessage(EventsUtils.getConsoleSender(), Utils.getPrefix() + "&eLoad File: " + Settings.defaultLanguage + ".yml' not found in /locale folder. Using /locale/en-US.yml");
Logger.warning(Utils.getPrefix() + "&eLoad File: " + Settings.defaultLanguage + ".yml' not found in /locale folder. Using /locale/en-US.yml");
Settings.defaultLanguage = "en-US";
availableLocales.put(Settings.defaultLanguage, new Lang(plugin, Settings.defaultLanguage, 0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,35 +60,24 @@ public void onJoin(PlayerJoinEvent e) {
boolean isGroup = Settings.c_type.equalsIgnoreCase("group");
boolean isNone = Settings.c_type.equalsIgnoreCase("none");

if (Settings.boolean_welcome) {


if (Settings.welcome) {
Settings.list_welcome.forEach( (text) -> {
Utils.sendColorMessage(p, Utils.getVar(p, text));
});

/*/List<String> List_Text = config.getStringList("Welcome.Text");
for (int i = 0; i < List_Text.size(); i++) {
String text = (String) List_Text.get(i);
text = Utils.color(text);
text = Utils.getVar(p, text);
Utils.sendColorMessage(p, text);
}*/
}

if (Settings.boolean_join) {
if (Settings.join) {
if (isDefault) {
return;
} else if (isNormal) {
e.setJoinMessage(null);

String join = Settings.message_join;
String firstjoin = Settings.message_first_join;
String join = Settings.join_message;
String firstjoin = Settings.join_message_first;

String text = "";

if(Settings.boolean_firstjoin) {
if(Settings.firstjoin) {
if (!p.hasPlayedBefore()) {
text = firstjoin;
} else {
Expand Down Expand Up @@ -237,7 +226,7 @@ public void onJoin(PlayerJoinEvent e) {
}
}

if (Settings.boolean_update) {
if (Settings.update) {
if ((p.isOp()) || (p.hasPermission("Cjm.Update.Notify"))) {
new UpdateChecker(CustomJoinAndQuitMessages.getInstance(), UpdateSettings.ID)
.getUpdateVersion(version -> {
Expand Down Expand Up @@ -268,7 +257,7 @@ public void onQuit(PlayerQuitEvent e) {
boolean isGroup = Settings.c_type.equalsIgnoreCase("group");
boolean isNone = Settings.c_type.equalsIgnoreCase("none");

if (Settings.boolean_quit) {
if (Settings.quit) {
if (isDefault) {
return;
} else if (isNormal) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public DisplayManager(Player player) {
}

public void showFirstJoinMessage() {
if(!Settings.boolean_firstjoin) {
Utils.sendColorMessage(player, "&e[showFirstJoinMessage] &b-> &7This feature is disabled and you will not be able to see the preview");
if(!Settings.firstjoin) {
Logger.warning("&e[showFirstJoinMessage] &b-> &7This feature is disabled and you will not be able to see the preview");
return;
}
Expand All @@ -33,7 +32,7 @@ public void showFirstJoinMessage() {
if (Settings.is_Group_Display) {

} else {
text = Settings.message_first_join;
text = Settings.join_message_first;
}

boolean isNormalType = Settings.join_type.equalsIgnoreCase("normal");
Expand Down Expand Up @@ -85,7 +84,7 @@ public void showFirstJoinMessage() {
}

public void showJoinMessage() {
if(!Settings.boolean_join) {
if(!Settings.join) {
Logger.warning("&e[showJoinMessage] &b-> &7This feature is disabled and you will not be able to see the preview");
return;
}
Expand All @@ -94,7 +93,7 @@ public void showJoinMessage() {
if (Settings.is_Group_Display) {

} else {
text = Settings.message_join;
text = Settings.join_message;
}

boolean isNormalType = Settings.join_type.equalsIgnoreCase("normal");
Expand Down Expand Up @@ -146,7 +145,7 @@ public void showJoinMessage() {
}

public void showQuitMessage() {
if(!Settings.boolean_quit) {
if(!Settings.quit) {
Logger.warning("&e[showQuitMessage] &b-> &7This feature is disabled and you will not be able to see the preview");
return;
}
Expand All @@ -156,7 +155,7 @@ public void showQuitMessage() {
if (Settings.is_Group_Display) {

} else {
text = Settings.message_quit;
text = Settings.quit_message;
}

boolean isNormalType = Settings.quit_type.equalsIgnoreCase("normal");
Expand Down Expand Up @@ -208,7 +207,7 @@ public void showQuitMessage() {
}

public void showWelcomeMessage() {
if(!Settings.boolean_welcome) {
if(!Settings.welcome) {
Logger.warning("&e[showWelcomeMessage] &b-> &7This feature is disabled and you will not be able to see the preview");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,53 @@

public class Settings {

//Others
public static String defaultLanguage;
public static boolean is_Group_Display;
public static boolean update;
public static String c_type;

public static boolean is_Group_Display = false;
//Join section
public static String join_type;

public static boolean boolean_update;
public static boolean boolean_join;
public static boolean boolean_firstjoin;
public static boolean boolean_quit;
public static boolean boolean_welcome;
public static boolean message_join_title;
public static boolean message_join_actionbar;
public static List<String> list_welcome;
public static boolean join;
public static String join_message;

public static boolean firstjoin;
public static String join_message_first;

public static boolean join_title;
public static String join_message_title_title;
public static String join_message_title_subtitle;
public static int join_title_fadein;
public static int join_title_stay;
public static int join_title_fadeout;

public static boolean join_actionbar;
public static String join_message_actionbar_text;

public static boolean join_sound;
public static String join_sound_name;
public static float join_sound_pitch;
public static int join_sound_vol;

//Quit section

public static String c_type;
public static String join_type;
public static String quit_type;
public static String message_join;
public static String message_join_title_title;
public static String message_join_title_suttitle;
public static String message_join_actionbar_text;
public static String message_first_join;
public static String message_quit;

public static int int_join_title_fadein;
public static int int_join_title_stay;
public static int int_join_title_fadeout;
public static boolean quit;
public static String quit_message;

public static boolean quit_sound;
public static String quit_sound_name;
public static float quit_sound_pitch;
public static int quit_sound_vol;

//Welcome section
public static boolean welcome;
public static List<String> list_welcome;

//Hooks section
public static boolean hook_discordsrv;
public static boolean hook_discordsrv_use_message;
public static String hook_discordsrv_channelid;
Expand Down

0 comments on commit 23f5efc

Please sign in to comment.