diff --git a/CustomJoinAndQuitMessages/config.yml b/CustomJoinAndQuitMessages/config.yml index 862351b..acceed5 100644 --- a/CustomJoinAndQuitMessages/config.yml +++ b/CustomJoinAndQuitMessages/config.yml @@ -3,10 +3,19 @@ # | Version 1.7.0 | # |__________________________| # -# There are two variables that show the name of the player in a message and that are | , | these two variables can also be in lowercase. +# A simple plugin for personalization of the join and quit messages and more... +# +# |Links| +# -> Spigot: https://www.spigotmc.org/resources/custom-join-and-quit-message-1-7-x-1-17-x.57006/ +# -> Discord: https://discord.gg/c5GhQDQCK5 +# -> Issue Tracker: https://github.com/jonagamerpro1234/CustomJoinAndQuitMessages/issues +# -> Plugin Statistics: https://bstats.org/plugin/bukkit/CustomJoinAndQuitMessages/6318 # Config: + # |Config-Version|I would not change anything + Config-Verion: 1 + # |Lang| you can use the available languages of the plugin or you can add your own translations [ Default = en-US ] Lang: en-US @@ -16,111 +25,174 @@ Config: # |Debug| shows you important information about the plugin loading Debug: false - # |Type| the type is a way of knowing what is being used whether in the [ normal ] or [ group ] format + # |Type| the type is a way of knowing what is being used whether in the [normal] | [group] | [default] | [none] format Type: normal # # | Join | -# Join: + # |Enabled| Here you can enable or disable this feature + Enabled: true + # |Text| This is where Join customizable message is located - Text: '&b[&a+&b] ' + Text: '&b[<#83FF6F>+&b] <#A157FF>' - # |Type| + # |Type| Here you can find two types that are [ normal | modify ] Type: normal + # |HoverEvent| This section allows you to modify the hover events in the chat HoverEvent: # |Enabled| Here you can enable or disable this feature Enabled: true - Hover: - - '&6hello &b' - + # |Hover| This section allows you to define the hover text + Hover: + - '&6> &aHello &b' + - '&6> &e%player_exp_to_level%' + - '&6> &dadd more lines like these' + + # |ClickEvent| This section allows you to modify chat click events ClickEvent: - + # |Enabled| Here you can enable or disable this feature Enabled: true + # |Mode| there are three different modes which are [ command | suggest | url ] Mode: command + # |Actions| This is where are the available events that you can use Actions: - Command: 'tell hello player' + # |Command| Clicking on the chat will execute the command defined in the config + Command: '/say hello server' - Url: '' + # |Url| Clicking on the chat opens a link + Url: 'https://www.spigotmc.org/resources/custom-join-and-quit-message-1-7-x-1-17-x.57006/' + # |Suggest-Command| Clicking on the chat suggests a command that you define in the config Suggest-Command: '/msg ' + # |Sound| In this section you can configure the sound of the join + # |Sound list: https://www.spigotmc.org/wiki/cc-sounds-list/ Sound: # |Enabled| Here you can enable or disable this feature Enabled: true - Sound: 'BLOCK_NOTE_BLOCK_PLING' + # |Send-To-All| When active, the sound will be sent to all players connected to the server + Send-To-All: true + + # |Name| This is the name of the sound you will hear when it is mentioned to you in chat. + Name: 'BLOCK_NOTE_BLOCK_PLING' + # |Pitch| This is the pitch of the sound that you will hear when mentioned in the chat Pitch: 1 + # |Volume| This is the volume of the sound that you will hear when the chat mentions it Volume: 10 - + # |Title| In this section you can configure the title of the join Title: # |Enabled| Here you can enable or disable this feature Enabled: true + + # |Title| here you can set the title text + Title: 'Welcome to Server' - Title: '' - - SubTitle: '' + # |SubTitle| here you can set the subtitle text + SubTitle: '' + # |FadeIn| here you can set the input time of the title FadeIn: 20 + # |Stay| here you can set how long the title stays Stay: 40 + # |FadeOut| here you can set the title output time FadeOut: 20 + # |ActionBar| In this section you can configure the Actionbar of the join ActionBar: # |Enabled| Here you can enable or disable this feature Enabled: true - Text: '' - + # |Text| + Text: 'Welcome to the server' +# +# | Quit | Quit: + + # |Enabled| Here you can enable or disable this feature Enabled: true - Text: '&b[&c-&b] ' #|, | -# |Type| -# |> [ Custom | Double | Hover | Click | None | Group ] - Type: Custom - Hover: - Text: - - '&6bay &c' -# |Mode| -# |> [TEXT] show hover text - Mode: TEXT -# |Legacy-Color| -# |> the legacy color mode is used to activate the old color system for hover event -# |> legay color does not need to use the color format, for example [ &6 ] -# |> Colors [RED] | [AQUA] | [BLUE] | [GREED] | [GOlD] | ....etc - Legacy-Color: false - Color: AQUA - Click: - Action: 'say hello' -# |Mode| -# |> [URL] open a link -# |> [CMD] run a command - Mode: CMD -# -# |Welcome| -# Here you can customize the welcome message for players when entering the server -# | Vars | there are variables that only work in certain functions -# <0> leave an empty line + + # |Text| This is where Join customizable message is located + Text: '&b[<#83FF6F>+&b] <#A157FF>' + + # |Type| Here you can find two types that are [ normal | modify ] + Type: normal + + # |HoverEvent| This section allows you to modify the hover events in the chat + HoverEvent: + + # |Enabled| Here you can enable or disable this feature + Enabled: true + + # |Hover| This section allows you to define the hover text + Hover: + - '&6> &aHello &b' + - '&6> &e%player_exp_to_level%' + - '&6> &dadd more lines like these' + + # |ClickEvent| This section allows you to modify chat click events + ClickEvent: + + # |Enabled| Here you can enable or disable this feature + Enabled: true + + # |Mode| there are three different modes which are [ command | suggest | url ] + Mode: command + + # |Actions| This is where are the available events that you can use + Actions: + + # |Command| Clicking on the chat will execute the command defined in the config + Command: '/say hello server' + + # |Url| Clicking on the chat opens a link + Url: 'https://www.spigotmc.org/resources/custom-join-and-quit-message-1-7-x-1-17-x.57006/' + + # |Suggest-Command| Clicking on the chat suggests a command that you define in the config + Suggest-Command: '/msg ' + + # |Sound| In this section you can configure the sound of the join + # |Sound list: https://www.spigotmc.org/wiki/cc-sounds-list/ + Sound: + + # |Enabled| Here you can enable or disable this feature + Enabled: true + + # |Send-To-All| When active, the sound will be sent to all players connected to the server + Send-To-All: true + + # |Name| This is the name of the sound you will hear when it is mentioned to you in chat. + Name: 'BLOCK_NOTE_BLOCK_PLING' + + # |Pitch| This is the pitch of the sound that you will hear when mentioned in the chat + Pitch: 1 + + # |Volume| This is the volume of the sound that you will hear when the chat mentions it + Volume: 10 + Welcome: -# |Enabled| turn the welcome message on and off [ Default | true ] + + # |Enabled| Here you can enable or disable this feature Enabled: true -# |Max Line| is the maximum number of lines allowed to avoid a bug [Default | 8] - Max-Line: 8 + + # |Text| Text: - '&b&m=========================================&r' - '<0>' @@ -130,106 +202,103 @@ Welcome: - '&e> &7Use &b/skin to put on a skin' - '<0>' - '&b&m=========================================&r' -# -# |Title| -# |> Here you can customize the title for the players when entering the server for more help with the ticks, enter this link -# |> https://github.com/jonagamerpro1234/MultiOptions/wiki/Ticks-in-Minecraft -Title: - Enabled: true #|Enabled| here you can activate and deactivate the title in this option [Default | true] - Text: - Title: '&a&lWelcome to the server' - SubTitle: '&b' - Settings: - Time: - FadeIn: 20 #| Default 20 ticks | 20 ticks = 1s - Stay: 40 #| Default 40 ticks | 40 ticks = 2s - FadeOut: 20 #| Default 20 ticks | 20 ticks = 1s -# -# |Actionbar| -# |> Here you can customize the Actionbar for the players when entering the server -Actionbar: - Enabled: true #|Enabled| here you can activate and deactivate the actionbar in this option [Default | true] - Text: 'Welcome to the server ' -# -# |Sounds| -# -# Format: ;; -# Ej 1.9. BLOCK_NOTE_PLING;10;2 -# Sound list: https://www.spigotmc.org/wiki/cc-sounds-list/ -Sounds: - Enabled: true - Type: Normal #| Normal | Group | - Settings: - Send-All-Sounds: true - Join: - Enabled: true - Sound: BLOCK_NOTE_PLING;10;1 - Enabled-Permission: false - Custom-Permission: 'Cjm.join' - Quit: - Enabled: true - Sound: BLOCK_NOTE_PLING;10;1 - Enabled-Permission: false - Custom-Permission: 'Cjm.quit' # # |Groups| -# |> currently only join and quit functions are available for the group system -# |> to be able to use the group system properly it is necessary to have a permissions plugin with [LuckPerm or others] -# -# |Groups: -# | : -# | Join: -# | Text: 'hello' -# | Permission: 'my.permission' -# | Enabled-Sound: true -# | Sound: ;; -# | Send-All-Sound: true -# | Quit: -# | Text: 'hello' -# | Permission: 'my.permission' -# | Enabled-Sound: true -# | Sound: ;; -# | Send-All-Sound: true +# currently only join and quit functions are available for the group system +# to be able to use the group system properly it is necessary to have a permissions plugin with [LuckPerm or others] Groups: Default: - Join: - Text: '&6[&a+&6] &7' - Permission: 'cjm.group.join.default' - Enabled-Sound: true - Sound: BLOCK_NOTE_PLING;10;1 - Send-All-Sound: true - Quit: - Text: '&6[&c-&6] &7' - Permission: 'cjm.group.quit.default' - Enabled-Sound: true - Sound: BLOCK_NOTE_PLING;10;1 - Send-All-Sound: true - Vip: - Join: - Text: '&6[&a+&6] &eWelcome to server &a[&b&a]' - Permission: 'cjm.group.join.vip' - Enabled-Sound: true - Sound: BLOCK_NOTE_PLING;10;1 - Send-All-Sound: true - Quit: - Text: '&6[&c-&6] &eSee you soon &a[&b&a]' - Permission: 'cjm.group.quit.vip' - Enabled-Sound: true - Sound: BLOCK_NOTE_PLING;10;1 - Send-All-Sound: true - Admin: - Join: - Text: '&bThe admin &6[&c&6] &bjoined the server' - Permission: 'cjm.group.join.admin' - Enabled-Sound: true - Sound: BLOCK_NOTE_PLING;10;1 - Send-All-Sound: true - Quit: - Text: 'The admin [] quit of server' - Permission: 'cjm.group.quit.admin' - Enabled-Sound: true - Sound: BLOCK_NOTE_PLING;10;1 - Send-All-Sound: true + + # |Join-Text| This is where Join customizable message is located + Join-Text: '' + + # |Quit-Text| This is where Quit customizable message is located + Quit-Text: '' + + # |Type| Here you can find two types that are [ normal | modify ] + Type: normal + + # |HoverEvent| This section allows you to modify the hover events in the chat + HoverEvent: + + # |Enabled| Here you can enable or disable this feature + Enabled: true + + # |Hover| This section allows you to define the hover text + Hover: + - '&6> &aHello &b' + - '&6> &e%player_exp_to_level%' + - '&6> &dadd more lines like these' + + # |ClickEvent| This section allows you to modify chat click events + ClickEvent: + + # |Enabled| Here you can enable or disable this feature + Enabled: true + + # |Mode| there are three different modes which are [ command | suggest | url ] + Mode: command + + # |Actions| This is where are the available events that you can use + Actions: + + # |Command| Clicking on the chat will execute the command defined in the config + Command: '/say hello server' + + # |Url| Clicking on the chat opens a link + Url: 'https://www.spigotmc.org/resources/custom-join-and-quit-message-1-7-x-1-17-x.57006/' + + # |Suggest-Command| Clicking on the chat suggests a command that you define in the config + Suggest-Command: '/msg ' + + # |Sound| In this section you can configure the sound of the join + # |Sound list: https://www.spigotmc.org/wiki/cc-sounds-list/ + Sound: + + # |Enabled| Here you can enable or disable this feature + Enabled: true + + # |Send-To-All| When active, the sound will be sent to all players connected to the server + Send-To-All: true + + # |Name| This is the name of the sound you will hear when it is mentioned to you in chat. + Name: 'BLOCK_NOTE_BLOCK_PLING' + + # |Pitch| This is the pitch of the sound that you will hear when mentioned in the chat + Pitch: 1 + + # |Volume| This is the volume of the sound that you will hear when the chat mentions it + Volume: 10 + + # |Title| In this section you can configure the title of the join + Title: + + # |Enabled| Here you can enable or disable this feature + Enabled: true + + # |Title| here you can set the title text + Title: 'Welcome to Server' + + # |SubTitle| here you can set the subtitle text + SubTitle: '' + + # |FadeIn| here you can set the input time of the title + FadeIn: 20 + + # |Stay| here you can set how long the title stays + Stay: 40 + + # |FadeOut| here you can set the title output time + FadeOut: 20 + + # |ActionBar| In this section you can configure the Actionbar of the join + ActionBar: + + # |Enabled| Here you can enable or disable this feature + Enabled: true + + # |Text| + Text: 'Welcome to the server' # # |> This is the end of the configuration ... [-_-] more things coming soon # diff --git a/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/IridiumColorAPI.java b/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/IridiumColorAPI.java index 355dda2..60ea95a 100644 --- a/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/IridiumColorAPI.java +++ b/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/IridiumColorAPI.java @@ -2,9 +2,15 @@ import com.google.common.collect.ImmutableMap; import com.iridium.iridiumcolorapi.patterns.GradientPattern; -import com.iridium.iridiumcolorapi.patterns.Pattern; +import com.iridium.iridiumcolorapi.patterns.IPattern; import com.iridium.iridiumcolorapi.patterns.RainbowPattern; import com.iridium.iridiumcolorapi.patterns.SolidPattern; + +import jss.customjoinandquitmessages.patterns.GradientPattern2; +import jss.customjoinandquitmessages.patterns.PadPattern; +import jss.customjoinandquitmessages.patterns.PadPattern2; +import jss.customjoinandquitmessages.patterns.PadPattern3; +import jss.customjoinandquitmessages.patterns.RainbowPattern2; import net.md_5.bungee.api.ChatColor; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; @@ -63,7 +69,8 @@ public class IridiumColorAPI { * * @since 1.0.2 */ - private static final List PATTERNS = Arrays.asList(new GradientPattern(), new SolidPattern(), new RainbowPattern()); + private static final List PATTERNS = Arrays.asList(new GradientPattern(), new SolidPattern(), new RainbowPattern(), + new PadPattern(), new PadPattern2(), new PadPattern3(), new RainbowPattern2(), new GradientPattern2()); /** * Processes a string to add color to it. @@ -74,7 +81,7 @@ public class IridiumColorAPI { */ @Nonnull public static String process(@Nonnull String string) { - for (Pattern pattern : PATTERNS) { + for (IPattern pattern : PATTERNS) { string = pattern.process(string); } string = ChatColor.translateAlternateColorCodes('&', string); diff --git a/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/GradientPattern.java b/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/GradientPattern.java index 482d991..953bd26 100644 --- a/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/GradientPattern.java +++ b/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/GradientPattern.java @@ -2,24 +2,14 @@ import com.iridium.iridiumcolorapi.IridiumColorAPI; -import java.awt.*; +import java.awt.Color; import java.util.regex.Matcher; +import java.util.regex.Pattern; -/** - * Represents a gradient color pattern which can be applied to a String. - */ -public class GradientPattern implements Pattern { +public class GradientPattern implements IPattern { - java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("(.*?)"); + Pattern pattern = Pattern.compile("<#:([0-9A-Fa-f]{6})>(.*?)"); - - /** - * Applies a gradient pattern to the provided String. - * Output might me the same as the input if this pattern is not present. - * - * @param string The String to which this pattern should be applied to - * @return The new String with applied pattern - */ public String process(String string) { Matcher matcher = pattern.matcher(string); while (matcher.find()) { diff --git a/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/Pattern.java b/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/IPattern.java similarity index 93% rename from CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/Pattern.java rename to CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/IPattern.java index 2f955af..48edaf3 100644 --- a/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/Pattern.java +++ b/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/IPattern.java @@ -3,7 +3,7 @@ /** * Represents a color pattern which can be applied to a String. */ -public interface Pattern { +public interface IPattern { /** * Applies this pattern to the provided String. diff --git a/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/RainbowPattern.java b/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/RainbowPattern.java index 0ef199c..765f85a 100644 --- a/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/RainbowPattern.java +++ b/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/RainbowPattern.java @@ -3,18 +3,12 @@ import com.iridium.iridiumcolorapi.IridiumColorAPI; import java.util.regex.Matcher; +import java.util.regex.Pattern; -public class RainbowPattern implements Pattern { +public class RainbowPattern implements IPattern { - java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("(.*?)"); + Pattern pattern = Pattern.compile("(.*?)"); - /** - * Applies a rainbow pattern to the provided String. - * Output might me the same as the input if this pattern is not present. - * - * @param string The String to which this pattern should be applied to - * @return The new String with applied pattern - */ public String process(String string) { Matcher matcher = pattern.matcher(string); while (matcher.find()) { diff --git a/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/SolidPattern.java b/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/SolidPattern.java index 1444be5..97193b6 100644 --- a/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/SolidPattern.java +++ b/CustomJoinAndQuitMessages/src/com/iridium/iridiumcolorapi/patterns/SolidPattern.java @@ -3,18 +3,12 @@ import com.iridium.iridiumcolorapi.IridiumColorAPI; import java.util.regex.Matcher; +import java.util.regex.Pattern; -public class SolidPattern implements Pattern { +public class SolidPattern implements IPattern { - java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(""); + Pattern pattern = Pattern.compile("<#([0-9A-Fa-f]{6})>"); - /** - * Applies a solid RGB color to the provided String. - * Output might me the same as the input if this pattern is not present. - * - * @param string The String to which this pattern should be applied to - * @return The new String with applied pattern - */ public String process(String string) { Matcher matcher = pattern.matcher(string); while (matcher.find()) { diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/CustomJoinAndQuitMessages.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/CustomJoinAndQuitMessages.java index 7246ad9..7fb5ce7 100644 --- a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/CustomJoinAndQuitMessages.java +++ b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/CustomJoinAndQuitMessages.java @@ -11,8 +11,7 @@ import jss.customjoinandquitmessages.config.ConfigFile; import jss.customjoinandquitmessages.config.Lang; import jss.customjoinandquitmessages.config.PreConfigLoader; -import jss.customjoinandquitmessages.events.old.JoinListener; -import jss.customjoinandquitmessages.events.old.SoundsListener; +import jss.customjoinandquitmessages.events.JoinListener; import jss.customjoinandquitmessages.hook.HooksManager; import jss.customjoinandquitmessages.utils.EventsUtils; import jss.customjoinandquitmessages.utils.Logger; @@ -103,7 +102,7 @@ public void setupCommands() { public void setupEvents() { new JoinListener(this); - new SoundsListener(this); + //new SoundsListener(this); } public static CustomJoinAndQuitMessages getPlugin() { diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/events/JoinListener.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/events/JoinListener.java index d276002..46b2648 100644 --- a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/events/JoinListener.java +++ b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/events/JoinListener.java @@ -1,9 +1,31 @@ package jss.customjoinandquitmessages.events; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import com.cryptomorin.xseries.messages.ActionBar; +import com.cryptomorin.xseries.messages.Titles; import jss.customjoinandquitmessages.CustomJoinAndQuitMessages; +import jss.customjoinandquitmessages.json.Json; import jss.customjoinandquitmessages.utils.EventsUtils; +import jss.customjoinandquitmessages.utils.UpdateChecker; +import jss.customjoinandquitmessages.utils.UpdateSettings; +import jss.customjoinandquitmessages.utils.Utils; +import net.md_5.bungee.api.chat.ClickEvent; +import net.md_5.bungee.api.chat.ComponentBuilder; +import net.md_5.bungee.api.chat.HoverEvent; +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.chat.ClickEvent.Action; public class JoinListener implements Listener { @@ -16,6 +38,457 @@ public JoinListener(CustomJoinAndQuitMessages plugin) { } + @SuppressWarnings("deprecation") + @EventHandler + public void onJoin(PlayerJoinEvent e) { + FileConfiguration config = plugin.getConfigFile().getConfig(); + Player p = e.getPlayer(); + + boolean isDefault = config.getString("Config.Type").equalsIgnoreCase("default"); + boolean isNormal = config.getString("Config.Type").equalsIgnoreCase("normal"); + boolean isGroup = config.getString("Config.Type").equalsIgnoreCase("group"); + boolean isEnabled = config.getString("Join.Enabled").equals("true"); + boolean isNone = config.getString("Config.Type").equalsIgnoreCase("none"); + boolean isUpdate = config.getString("Config.Update").equals("true"); + boolean isWelcome = config.getString("Welcome.Enabled").equals("true"); + + if(isWelcome) { + + List 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(text); + } + + } + + if(isEnabled) { + if(isDefault) { + return; + }else if(isNormal) { + e.setJoinMessage(null); + + boolean isNormalType = config.getString("Join.Type").equalsIgnoreCase("normal"); + boolean isModifyType = config.getString("Join.Type").equalsIgnoreCase("modify"); + + String text = config.getString("Join.Text"); + + text = Utils.color(text); + text = Utils.getVar(p, text); + + Json json = new Json(p, text); + + if(isNormalType) { + json.sendToAll(); + return; + }else if(isModifyType) { + + boolean isHover = config.getString("Join.HoverEvent.Enabled").equals("true"); + boolean isClick = config.getString("Join.ClickEvent.Enabled").equals("true"); + boolean isTitle = config.getString("Join.Title.Enabled").equals("true"); + boolean isSound = config.getString("Join.Sound.Enabled").equals("true"); + boolean isActionBar = config.getString("Join.ActionBar").equals("true"); + boolean isSoundAll = config.getString("Join.Sound.Send-To-All").equals("true"); + + List Hover_Text = config.getStringList("Join.HoverEvent.Hover"); + + String isClick_Mode = config.getString("Join.ClickEvent.Mode"); + String Action_Command = config.getString("Join.ClickEvent.Actions.Command"); + String Action_Url = config.getString("Join.ClickEvent.Actions.Url"); + String Action_Suggest= config.getString("Join.ClickEvent.Actions.Suggest-Command"); + String Title_Text = config.getString("Join.Title.Title"); + String SubTitle_Text = config.getString("Join.Title.SubTitle"); + String Actionbar_Text = config.getString("Join.ActionBar.Text"); + String Sound_Name = config.getString("Join.Sound.Name"); + + int FadeIn = config.getInt("Join.Title.FadeIn"); + int Stay = config.getInt("Join.Title.Stay"); + int FadeOut = config.getInt("Join.Title.FadeOut"); + int Sound_Volume = config.getInt("Join.Sound.Volume"); + + float Sound_Pitch = Float.valueOf(config.getString("Join.Sound.Pitch")); + + if(isHover) { + if(isClick) { + if(isClick_Mode.equalsIgnoreCase("command")) { + json.setHover(Hover_Text).setExecuteCommand(Action_Command).sendToAll(); + }else if(isClick_Mode.equalsIgnoreCase("url")) { + json.setHover(Hover_Text).setOpenURL(Action_Url).sendToAll(); + }else if(isClick_Mode.equalsIgnoreCase("suggest")) { + json.setHover(Hover_Text).setSuggestCommand(Action_Suggest).sendToAll(); + } + }else { + json.setHover(Hover_Text).sendToAll(); + } + }else{ + if(isClick) { + if(isClick_Mode.equalsIgnoreCase("command")) { + json.setExecuteCommand(Action_Command).sendToAll(); + }else if(isClick_Mode.equalsIgnoreCase("url")) { + json.setOpenURL(Action_Url).sendToAll(); + }else if(isClick_Mode.equalsIgnoreCase("suggest")) { + json.setSuggestCommand(Action_Suggest).sendToAll(); + } + }else { + json.sendToAll(); + } + } + + if(isTitle) { + Titles.sendTitle(p, FadeIn, Stay, FadeOut, Utils.color(Utils.getVar(p, Title_Text)), Utils.color(Utils.getVar(p, SubTitle_Text))); + } + + if(isActionBar) { + ActionBar.sendActionBar(p, Utils.color(Utils.getVar(p, Actionbar_Text))); + } + + if(isSound) { + if(isSoundAll) { + Location location = p.getLocation(); + p.playSound(location, Sound.valueOf(Sound_Name), Sound_Volume, Sound_Pitch); + }else { + for(Player pp : Bukkit.getOnlinePlayers()) { + Location location = p.getLocation(); + pp.playSound(location, Sound.valueOf(Sound_Name), Sound_Volume, Sound_Pitch); + } + } + } + } + + return; + }else if(isGroup) { + e.setJoinMessage(null); + + for(String key : config.getConfigurationSection("Groups").getKeys(false)) { + + boolean isNormalType = config.getString("Groups." + key + ".Type").equalsIgnoreCase("normal"); + boolean isModifyType = config.getString("Groups." + key + ".Type").equalsIgnoreCase("modify"); + + String text = config.getString("Groups." + key + ".Join-Text"); + String isPermission = config.getString("Groups." + key + ".Permission"); + + text = Utils.color(text); + text = Utils.getVar(p, text); + + Json json = new Json(p, text); + + if(isNormalType) { + + if(p.hasPermission(isPermission)); + + json.sendToAll(); + return; + }else if(isModifyType) { + + boolean isHover = config.getString("Groups." + key + ".HoverEvent.Enabled").equals("true"); + boolean isClick = config.getString("Groups." + key + ".ClickEvent.Enabled").equals("true"); + boolean isTitle = config.getString("Groups." + key + ".Title.Enabled").equals("true"); + boolean isSound = config.getString("Groups." + key + ".Sound.Enabled").equals("true"); + boolean isActionBar = config.getString("Groups." + key + ".ActionBar").equals("true"); + boolean isSoundAll = config.getString("Groups." + key + ".Sound.Send-To-All").equals("true"); + + List Hover_Text = config.getStringList("Groups." + key + ".HoverEvent.Hover"); + + String isClick_Mode = config.getString("Groups." + key + ".ClickEvent.Mode"); + String Action_Command = config.getString("Groups." + key + ".ClickEvent.Actions.Command"); + String Action_Url = config.getString("Groups." + key + ".ClickEvent.Actions.Url"); + String Action_Suggest= config.getString("Groups." + key + ".ClickEvent.Actions.Suggest-Command"); + String Title_Text = config.getString("Groups." + key + ".Title.Title"); + String SubTitle_Text = config.getString("Groups." + key + ".Title.SubTitle"); + String Actionbar_Text = config.getString("Groups." + key + ".ActionBar.Text"); + String Sound_Name = config.getString("Groups." + key + ".Sound.Name"); + + int FadeIn = config.getInt("Groups." + key + ".Title.FadeIn"); + int Stay = config.getInt("Groups." + key + ".Title.Stay"); + int FadeOut = config.getInt("Groups." + key + ".Title.FadeOut"); + int Sound_Volume = config.getInt("Groups." + key + ".Sound.Volume"); + + float Sound_Pitch = Float.valueOf(config.getString("Groups." + key + ".Sound.Pitch")); + + if(p.hasPermission(isPermission)); + + if(isHover) { + if(isClick) { + if(isClick_Mode.equalsIgnoreCase("command")) { + json.setHover(Hover_Text).setExecuteCommand(Action_Command).sendToAll(); + }else if(isClick_Mode.equalsIgnoreCase("url")) { + json.setHover(Hover_Text).setOpenURL(Action_Url).sendToAll(); + }else if(isClick_Mode.equalsIgnoreCase("suggest")) { + json.setHover(Hover_Text).setSuggestCommand(Action_Suggest).sendToAll(); + } + }else { + json.setHover(Hover_Text).sendToAll(); + } + }else{ + if(isClick) { + if(isClick_Mode.equalsIgnoreCase("command")) { + json.setExecuteCommand(Action_Command).sendToAll(); + }else if(isClick_Mode.equalsIgnoreCase("url")) { + json.setOpenURL(Action_Url).sendToAll(); + }else if(isClick_Mode.equalsIgnoreCase("suggest")) { + json.setSuggestCommand(Action_Suggest).sendToAll(); + } + }else { + json.sendToAll(); + } + } + + if(isTitle) { + Titles.sendTitle(p, FadeIn, Stay, FadeOut, Utils.color(Utils.getVar(p, Title_Text)), Utils.color(Utils.getVar(p, SubTitle_Text))); + } + + if(isActionBar) { + ActionBar.sendActionBar(p, Utils.color(Utils.getVar(p, Actionbar_Text))); + } + + if(isSound) { + if(isSoundAll) { + Location location = p.getLocation(); + p.playSound(location, Sound.valueOf(Sound_Name), Sound_Volume, Sound_Pitch); + }else { + for(Player pp : Bukkit.getOnlinePlayers()) { + Location location = p.getLocation(); + pp.playSound(location, Sound.valueOf(Sound_Name), Sound_Volume, Sound_Pitch); + } + } + } + } + + } + return; + }else if(isNone) { + e.setJoinMessage(null); + return; + } + } + + if(isUpdate) { + if(p.isOp() || p.hasPermission("Cjm.Update.Notify")) { + new UpdateChecker(CustomJoinAndQuitMessages.getPlugin(), UpdateSettings.ID).getUpdateVersion(version ->{ + if(!CustomJoinAndQuitMessages.getPlugin().getDescription().getVersion().equalsIgnoreCase(version)) { + TextComponent component = new TextComponent(Utils.color(Utils.getPrefixPlayer() + " &aThere is a new version available for download")); + component.setClickEvent(new ClickEvent(Action.OPEN_URL, UpdateSettings.URL_PlUGIN[0])); + component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Utils.color("&6Click on this message to copy the link")).create())); + p.spigot().sendMessage(component); + } + }); + } + } + } + + @EventHandler + public void onQuit(PlayerQuitEvent e) { + FileConfiguration config = plugin.getConfigFile().getConfig(); + Player p = e.getPlayer(); + + boolean isDefault = config.getString("Config.Type").equalsIgnoreCase("default"); + boolean isNormal = config.getString("Config.Type").equalsIgnoreCase("normal"); + boolean isGroup = config.getString("Config.Type").equalsIgnoreCase("group"); + boolean isEnabled = config.getString("Quit.Enabled").equals("true"); + boolean isNone = config.getString("Config.Type").equalsIgnoreCase("none"); + + if(isEnabled) { + if(isDefault) { + return; + }else if(isNormal) { + e.setQuitMessage(null); + + boolean isNormalType = config.getString("Quit.Type").equalsIgnoreCase("normal"); + boolean isModifyType = config.getString("Quit.Type").equalsIgnoreCase("modify"); + + String text = config.getString("Quit.Text"); + + text = Utils.color(text); + text = Utils.getVar(p, text); + + Json json = new Json(p, text); + + if(isNormalType) { + json.sendToAll(); + return; + }else if(isModifyType) { + + boolean isHover = config.getString("Quit.HoverEvent.Enabled").equals("true"); + boolean isClick = config.getString("Quit.ClickEvent.Enabled").equals("true"); + //boolean isTitle = config.getString("Quit.Title.Enabled").equals("true"); + boolean isSound = config.getString("Quit.Sound.Enabled").equals("true"); + //boolean isActionBar = config.getString("Quit.ActionBar").equals("true"); + boolean isSoundAll = config.getString("Quit.Sound.Send-To-All").equals("true"); + + List Hover_Text = config.getStringList("Quit.HoverEvent.Hover"); + + String isClick_Mode = config.getString("Quit.ClickEvent.Mode"); + String Action_Command = config.getString("Quit.ClickEvent.Actions.Command"); + String Action_Url = config.getString("Quit.ClickEvent.Actions.Url"); + String Action_Suggest= config.getString("Quit.ClickEvent.Actions.Suggest-Command"); + //String Title_Text = config.getString("Quit.Title.Title"); + //String SubTitle_Text = config.getString("Quit.Title.SubTitle"); + //String Actionbar_Text = config.getString("Quit.ActionBar.Text"); + String Sound_Name = config.getString("Quit.Sound.Name"); + + //int FadeIn = config.getInt("Quit.Title.FadeIn"); + //int Stay = config.getInt("Quit.Title.Stay"); + //int FadeOut = config.getInt("Quit.Title.FadeOut"); + int Sound_Volume = config.getInt("Quit.Sound.Volume"); + + float Sound_Pitch = Float.valueOf(config.getString("Quit.Sound.Pitch")); + + if(isHover) { + if(isClick) { + if(isClick_Mode.equalsIgnoreCase("command")) { + json.setHover(Hover_Text).setExecuteCommand(Action_Command).sendToAll(); + }else if(isClick_Mode.equalsIgnoreCase("url")) { + json.setHover(Hover_Text).setOpenURL(Action_Url).sendToAll(); + }else if(isClick_Mode.equalsIgnoreCase("suggest")) { + json.setHover(Hover_Text).setSuggestCommand(Action_Suggest).sendToAll(); + } + }else { + json.setHover(Hover_Text).sendToAll(); + } + }else{ + if(isClick) { + if(isClick_Mode.equalsIgnoreCase("command")) { + json.setExecuteCommand(Action_Command).sendToAll(); + }else if(isClick_Mode.equalsIgnoreCase("url")) { + json.setOpenURL(Action_Url).sendToAll(); + }else if(isClick_Mode.equalsIgnoreCase("suggest")) { + json.setSuggestCommand(Action_Suggest).sendToAll(); + } + }else { + json.sendToAll(); + } + } + + //if(isTitle) { + // Titles.sendTitle(p, FadeIn, Stay, FadeOut, Utils.color(Utils.getVar(p, Title_Text)), Utils.color(Utils.getVar(p, SubTitle_Text))); + //} + + //if(isActionBar) { + // ActionBar.sendActionBar(p, Utils.color(Utils.getVar(p, Actionbar_Text))); + //} + + if(isSound) { + if(isSoundAll) { + Location location = p.getLocation(); + p.playSound(location, Sound.valueOf(Sound_Name), Sound_Volume, Sound_Pitch); + }else { + for(Player pp : Bukkit.getOnlinePlayers()) { + Location location = p.getLocation(); + pp.playSound(location, Sound.valueOf(Sound_Name), Sound_Volume, Sound_Pitch); + } + } + } + } + + return; + }else if(isGroup) { + e.setQuitMessage(null); + + for(String key : config.getConfigurationSection("Groups").getKeys(false)) { + + boolean isNormalType = config.getString("Groups." + key + ".Type").equalsIgnoreCase("normal"); + boolean isModifyType = config.getString("Groups." + key + ".Type").equalsIgnoreCase("modify"); + + String text = config.getString("Groups." + key + ".Quit-Text"); + String isPermission = config.getString("Groups." + key + ".Permission"); + + text = Utils.color(text); + text = Utils.getVar(p, text); + + Json json = new Json(p, text); + + if(isNormalType) { + + if(p.hasPermission(isPermission)); + + json.sendToAll(); + return; + }else if(isModifyType) { + + boolean isHover = config.getString("Groups." + key + ".HoverEvent.Enabled").equals("true"); + boolean isClick = config.getString("Groups." + key + ".ClickEvent.Enabled").equals("true"); + //boolean isTitle = config.getString("Groups." + key + ".Title.Enabled").equals("true"); + boolean isSound = config.getString("Groups." + key + ".Sound.Enabled").equals("true"); + //boolean isActionBar = config.getString("Groups." + key + ".ActionBar").equals("true"); + boolean isSoundAll = config.getString("Groups." + key + ".Sound.Send-To-All").equals("true"); + + List Hover_Text = config.getStringList("Groups." + key + ".HoverEvent.Hover"); + + String isClick_Mode = config.getString("Groups." + key + ".ClickEvent.Mode"); + String Action_Command = config.getString("Groups." + key + ".ClickEvent.Actions.Command"); + String Action_Url = config.getString("Groups." + key + ".ClickEvent.Actions.Url"); + String Action_Suggest= config.getString("Groups." + key + ".ClickEvent.Actions.Suggest-Command"); + //String Title_Text = config.getString("Groups." + key + ".Title.Title"); + //String SubTitle_Text = config.getString("Groups." + key + ".Title.SubTitle"); + //String Actionbar_Text = config.getString("Groups." + key + ".ActionBar.Text"); + String Sound_Name = config.getString("Groups." + key + ".Sound.Name"); + + //int FadeIn = config.getInt("Groups." + key + ".Title.FadeIn"); + //int Stay = config.getInt("Groups." + key + ".Title.Stay"); + //int FadeOut = config.getInt("Groups." + key + ".Title.FadeOut"); + int Sound_Volume = config.getInt("Groups." + key + ".Sound.Volume"); + + float Sound_Pitch = Float.valueOf(config.getString("Groups." + key + ".Sound.Pitch")); + + if(p.hasPermission(isPermission)); + + if(isHover) { + if(isClick) { + if(isClick_Mode.equalsIgnoreCase("command")) { + json.setHover(Hover_Text).setExecuteCommand(Action_Command).sendToAll(); + }else if(isClick_Mode.equalsIgnoreCase("url")) { + json.setHover(Hover_Text).setOpenURL(Action_Url).sendToAll(); + }else if(isClick_Mode.equalsIgnoreCase("suggest")) { + json.setHover(Hover_Text).setSuggestCommand(Action_Suggest).sendToAll(); + } + }else { + json.setHover(Hover_Text).sendToAll(); + } + }else{ + if(isClick) { + if(isClick_Mode.equalsIgnoreCase("command")) { + json.setExecuteCommand(Action_Command).sendToAll(); + }else if(isClick_Mode.equalsIgnoreCase("url")) { + json.setOpenURL(Action_Url).sendToAll(); + }else if(isClick_Mode.equalsIgnoreCase("suggest")) { + json.setSuggestCommand(Action_Suggest).sendToAll(); + } + }else { + json.sendToAll(); + } + } + + //if(isTitle) { + // Titles.sendTitle(p, FadeIn, Stay, FadeOut, Utils.color(Utils.getVar(p, Title_Text)), Utils.color(Utils.getVar(p, SubTitle_Text))); + //} + + //if(isActionBar) { + // ActionBar.sendActionBar(p, Utils.color(Utils.getVar(p, Actionbar_Text))); + //} + + if(isSound) { + if(isSoundAll) { + Location location = p.getLocation(); + p.playSound(location, Sound.valueOf(Sound_Name), Sound_Volume, Sound_Pitch); + }else { + for(Player pp : Bukkit.getOnlinePlayers()) { + Location location = p.getLocation(); + pp.playSound(location, Sound.valueOf(Sound_Name), Sound_Volume, Sound_Pitch); + } + } + } + } + } + return; + }else if(isNone) { + e.setQuitMessage(null); + return; + } + } + } } diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/events/custom/ActionbarEvent.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/events/custom/ActionbarEvent.java deleted file mode 100644 index 5ec98f3..0000000 --- a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/events/custom/ActionbarEvent.java +++ /dev/null @@ -1,47 +0,0 @@ -package jss.customjoinandquitmessages.events.custom; - -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -public class ActionbarEvent extends Event implements Cancellable{ - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled = false; - private Player player; - private String title; - - public ActionbarEvent(Player player, String title) { - this.player = player; - this.title = title; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public Player getPlayer() { - return player; - } - - public boolean isCancelled() { - return cancelled; - } - - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } -} diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/events/custom/TitleEvent.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/events/custom/TitleEvent.java deleted file mode 100644 index 917a87a..0000000 --- a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/events/custom/TitleEvent.java +++ /dev/null @@ -1,89 +0,0 @@ -package jss.customjoinandquitmessages.events.custom; - -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -public class TitleEvent extends Event implements Cancellable{ - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled = false; - private Player player; - private String title; - private String subtitle; - private int fadeIn; - private int stay; - private int fadeOut; - - public TitleEvent(Player player, String title, String subtitle, int fadeIn, int stay, int fadeOut) { - super(); - this.player = player; - this.title = title; - this.subtitle = subtitle; - this.fadeIn = fadeIn; - this.stay = stay; - this.fadeOut = fadeOut; - } - - public int getFadeIn() { - return fadeIn; - } - - public void setFadeIn(int fadeIn) { - this.fadeIn = fadeIn; - } - - public int getStay() { - return stay; - } - - public void setStay(int stay) { - this.stay = stay; - } - - public int getFadeOut() { - return fadeOut; - } - - public void setFadeOut(int fadeOut) { - this.fadeOut = fadeOut; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getSubtitle() { - return subtitle; - } - - public void setSubtitle(String subtitle) { - this.subtitle = subtitle; - } - - public Player getPlayer() { - return player; - } - - public boolean isCancelled() { - return cancelled; - } - - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - public HandlerList getHandlers() { - return handlers; - } - - public static HandlerList getHandlerList() { - return handlers; - } - -} diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/events/old/JoinListener.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/events/old/JoinListener.java deleted file mode 100644 index bad4d20..0000000 --- a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/events/old/JoinListener.java +++ /dev/null @@ -1,273 +0,0 @@ -package jss.customjoinandquitmessages.events.old; - -import java.util.List; - -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import com.cryptomorin.xseries.messages.ActionBar; -import com.cryptomorin.xseries.messages.Titles; - -import jss.customjoinandquitmessages.CustomJoinAndQuitMessages; -import jss.customjoinandquitmessages.config.ConfigFile; -import jss.customjoinandquitmessages.json.Json; -import jss.customjoinandquitmessages.utils.EventsUtils; -import jss.customjoinandquitmessages.utils.UpdateChecker; -import jss.customjoinandquitmessages.utils.UpdateSettings; -import jss.customjoinandquitmessages.utils.Utils; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.TextComponent; -import net.md_5.bungee.api.chat.ClickEvent.Action; - -public class JoinListener implements Listener{ - - private CustomJoinAndQuitMessages plugin; - private EventsUtils EventsUtils = new EventsUtils(plugin); - - public JoinListener(CustomJoinAndQuitMessages plugin) { - this.plugin = plugin; - EventsUtils.getEventManager().registerEvents(this, plugin); - } - - @EventHandler - public void onJoin(PlayerJoinEvent e) { - ConfigFile configFile = plugin.getConfigFile(); - FileConfiguration config = configFile.getConfig(); - Player j = e.getPlayer(); - @SuppressWarnings("unused") - String path = "Join.Enabled"; - String text = config.getString("Join.Text"); - - text = Utils.getVar(j,text); - Json json = new Json(j, text); - - if(config.getConfigurationSection("Join.Hover") != null) { - List hovertext = config.getStringList("Join.Hover.Text"); - json.setHover(hovertext); - }else { - Utils.sendColorMessage(EventsUtils.getConsoleSender(), "No exist hover path"); - } - if(config.getConfigurationSection("Join.Click") != null) { - if(config.getConfigurationSection("Join.Click.Command") != null) { - String action = config.getString("Join.Click.Command"); - json.setExecuteCommand(action); - }else if(config.getConfigurationSection("Join.Click.SuggestCommand") != null) { - String action = config.getString("Join.Click.SuggestCommand"); - json.setSuggestCommand(action); - }else if(config.getConfigurationSection("Join.Click.Open-Url") != null) { - String action = config.getString("Join.Click.Open-Url"); - json.setOpenURL(action); - }else { - Utils.sendColorMessage(EventsUtils.getConsoleSender(), "No exist click subpath"); - } - - }else { - Utils.sendColorMessage(EventsUtils.getConsoleSender(), "No exist click path"); - } - - json.sendToAll(); - - /*if(config.getString(path).equals("true")) { - if(config.getString(type).equals("Custom")) { - e.setJoinMessage(Utils.hexcolor(text)); - }else if (config.getString(type).equals("Double")){ - e.setJoinMessage(null); - for(int i = 0; i < hovertext.size(); i++) { - String a = (String) hovertext.get(i); - Utils.sendTextComponentDouble(j, text, a, hovermode, clickmode, clickaction); - if(i == hovertext.size()) { - break; - } - } - }else if (config.getString(type).equals("Hover")){ - if(config.getString("Join.Hover.Legacy-Color").equals("true")) { - e.setJoinMessage(null); - for(int i = 0; i < hovertext.size(); i++) { - String a = (String) hovertext.get(i); - Utils.sendTextComponentHover(j, hovermode, text, a, hovercolor); - if(i == hovertext.size()) break; - } - }else if(config.getString("Join.Hover.Legacy-Color").equals("false")) { - e.setJoinMessage(null); - String a = ""; - for(int i = 0; i < hovertext.size(); i++) { - a = (String) hovertext.get(i); - - } - Utils.sendTextComponent116Hover(j, hovermode, text, a); - } - }else if(config.getString(type).equals("Click")) { - e.setJoinMessage(null); - Utils.sendTextComponentClick(j, clickmode, text, clickaction); - }else if(config.getString(type).equals("None")){ - e.setJoinMessage(null); - }else if(config.getString(type).equals("Group")) { - for(String key : config.getConfigurationSection("Groups").getKeys(false)) { - - String jointext = config.getString("Groups."+key+".Join.Text"); - String joinperm = config.getString("Groups."+key+".Join.Permission"); - if(j.hasPermission(joinperm)){} - e.setJoinMessage(null); - Utils.sendColorMessage(j, jointext); - } - } - } */ - } - - @EventHandler - public void onJoinWelcome(PlayerJoinEvent e) { - FileConfiguration config = plugin.getConfig(); - Player j = e.getPlayer(); - try { - String path = "Welcome.Enabled"; - int max = config.getInt("Welcome.Max-Line"); - List list = config.getStringList("Welcome.Text"); - if(config.getString(path).equals("true")) { - for(int i = 0; i < list.size(); i++){ - String text = (String) list.get(i); - Utils.sendColorMessage(j, text.replace("<0>", " ")); - if(i == max) { - break; - } - } - } - }catch(NullPointerException ex) { - Utils.sendColorMessage(EventsUtils.getConsoleSender(), Utils.getPrefix() + " " + "&cError-Path: Welcome section ?"); - } - } - - @EventHandler - public void onTitle(PlayerJoinEvent e) { - FileConfiguration config = plugin.getConfig(); - Player j = e.getPlayer(); - - String path = "Title.Enabled"; - String title = config.getString("Title.Text.Title"); - String subtitle = config.getString("Title.Text.SubTitle"); - int fadeIn = config.getInt("Title.Settings.Time.FadeIn"); - int stay = config.getInt("Title.Settings.Time.Stay"); - int fadeOut = config.getInt("Title.Settings.Time.FadeOut"); - - title = Utils.hexcolor(title); - title = Utils.getVar(j, title); - subtitle = Utils.hexcolor(subtitle); - subtitle = Utils.getVar(j, subtitle); - if(config.getString(path).equals("true")) { - Titles.sendTitle(j, fadeIn, stay, fadeOut, title, subtitle); - } - } - - @EventHandler - public void onActionBar(PlayerJoinEvent e) { - FileConfiguration config = plugin.getConfigFile().getConfig(); - Player j = e.getPlayer(); - - String path = "Actionbar.Enabled"; - String text = config.getString("Actionbar.Text"); - - text = Utils.hexcolor(text); - text = Utils.getVar(j, text); - if(config.getString(path).equals("true")) { - ActionBar.sendActionBar(j, text); - } - } - - @SuppressWarnings("deprecation") - @EventHandler - public void onUpdate(PlayerJoinEvent e) { - FileConfiguration config = plugin.getConfigFile().getConfig(); - Player j = e.getPlayer(); - String path = "Config.Update"; - - if(config.getString(path).equals("true")) { - if(j.isOp() || j.hasPermission("Cjm.Update.Notify")) { - new UpdateChecker(CustomJoinAndQuitMessages.getPlugin(), UpdateSettings.ID).getUpdateVersion(version ->{ - if(!CustomJoinAndQuitMessages.getPlugin().getDescription().getVersion().equalsIgnoreCase(version)) { - TextComponent component = new TextComponent(Utils.color(Utils.getPrefixPlayer() + " &aThere is a new version available for download")); - component.setClickEvent(new ClickEvent(Action.OPEN_URL, UpdateSettings.URL_PlUGIN[0])); - component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Utils.color("&6Click on this message to copy the link")).create())); - j.spigot().sendMessage(component); - } - }); - } - } - } - - @EventHandler - public void onQuit(PlayerQuitEvent e) { - FileConfiguration config = plugin.getConfig(); - Player j = e.getPlayer(); - - String path = "Quit.Enabled"; - String text = config.getString("Quit.Text"); - String type = "Quit.Type"; - List hovertext = config.getStringList("Quit.Hover.Text"); - String hovercolor = config.getString("Quit.Hover.Color"); - String hovermode = config.getString("Quit.Hover.Mode"); - String clickaction = config.getString("Quit.Click.Action"); - String clickmode = config.getString("Quit.Click.Mode"); - - text = Utils.getVar(j, text); - text = Utils.hexcolor(text); - - if(config.getString(path).equals("true")) { - if(config.getString(type).equals("Custom")) { - e.setQuitMessage(Utils.hexcolor(text)); - }else if (config.getString(type).equals("Double")){ - e.setQuitMessage(null); - - for(int i = 0; i < hovertext.size(); i++) { - String a = (String) hovertext.get(i); - Utils.sendTextComponentDouble(j, text, a, hovermode, clickmode, clickaction); - if(i == hovertext.size()) { - break; - } - } - }else if (config.getString(type).equals("Hover")){ - if(config.getString("Quit.HoverEvent.Legacy-Color").equals("true")) { - e.setQuitMessage(null); - for(int i = 0; i < hovertext.size(); i++) { - String a = (String) hovertext.get(i); - Utils.sendTextComponentHover(j, hovermode, text, a, hovercolor); - if(i == hovertext.size()) { - break; - } - } - }else if(config.getString("Quit.HoverEvent.Legacy-Color").equals("false")) { - e.setQuitMessage(null); - for(int i = 0; i < hovertext.size(); i++) { - String a = (String) hovertext.get(i); - Utils.sendTextComponent116Hover(j, hovermode, text, a); - if(i == hovertext.size()) { - break; - } - } - } - }else if(config.getString(type).equals("Click")) { - e.setQuitMessage(null); - Utils.sendTextComponentClick(j, clickmode, text, clickaction); - }else if(config.getString(type).equals("None")){ - e.setQuitMessage(null); - }else if(config.getString(type).equals("Group")) { - for(String key : config.getConfigurationSection("Groups").getKeys(false)) { - - String quittext = config.getString("Groups."+key+".Quit.Text"); - String quitperm = config.getString("Groups."+key+".Quit.Permission"); - - if(j.hasPermission(quitperm)){} - - Utils.sendColorMessage(j, quittext); - } - } - } - } - - - -} diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/events/old/SoundsListener.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/events/old/SoundsListener.java deleted file mode 100644 index 676c304..0000000 --- a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/events/old/SoundsListener.java +++ /dev/null @@ -1,219 +0,0 @@ -package jss.customjoinandquitmessages.events.old; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import com.cryptomorin.xseries.XSound; - -import jss.customjoinandquitmessages.CustomJoinAndQuitMessages; -import jss.customjoinandquitmessages.utils.EventsUtils; -import jss.customjoinandquitmessages.utils.Utils; - -public class SoundsListener implements Listener{ - - private CustomJoinAndQuitMessages plugin; - private EventsUtils eventUtils = new EventsUtils(plugin); - - public SoundsListener(CustomJoinAndQuitMessages plugin) { - this.plugin = plugin; - eventUtils.getEventManager().registerEvents(this, plugin); - } - - @EventHandler - public void onJoin(PlayerJoinEvent e) { - Player j = e.getPlayer(); - FileConfiguration config = plugin.getConfigFile().getConfig(); - String path = "Sounds.Enabled"; - String slipsound = config.getString("Sounds.Join.Sound"); - String useperm = config.getString("Sounds.Join.Enabled-Permission"); - String perm = config.getString("Sounds.Join.Custom-Permission"); - String sap = config.getString("Sounds.Settings.Send-All-Sounds"); - String je = config.getString("Sounds.Join.Enabled"); - String[] split = slipsound.split(";"); - - try { - if(config.getString(path).equals("true")) { - if(config.getString("Sounds.Type").equals("Normal")) { - if(je.equals("true")) { - if(useperm.equals("true")) { - if(!(j.hasPermission(perm)) || !(j.isOp())) { - Sound sound = XSound.valueOf(split[0]).parseSound(); - int vol = Integer.valueOf(split[1]); - float pitch = Float.valueOf(split[2]); - if(sap.equals("true")) { - for(Player p : Bukkit.getOnlinePlayers()) { - Location l = p.getLocation(); - p.playSound(l, sound, vol, pitch); - - } - }else if(sap.equals("false")) { - Location l = j.getLocation(); - j.playSound(l, sound, vol, pitch); - } - } - }else if(useperm.equals("false")){ - Sound sound = XSound.valueOf(split[0]).parseSound(); - int vol = Integer.valueOf(split[1]); - float pitch = Float.valueOf(split[2]); - if(sap.equals("true")) { - for(Player p : Bukkit.getOnlinePlayers()) { - Location l = p.getLocation(); - p.playSound(l, sound, vol, pitch); - } - }else if(sap.equals("false")) { - Location l = j.getLocation(); - j.playSound(l, sound, vol, pitch); - } - } - } - }else if(config.getString("Sounds.Type").equals("Group")) { - for(String key : config.getConfigurationSection("Groups").getKeys(false)) { - String gslipsound = config.getString("Groups."+key+".Join.Sound"); - String gperm = config.getString("Groups."+key+".Join.Permission"); - String gsap = config.getString("Groups."+key+".Join.Send-All-Sound"); - String gqe = config.getString("Groups."+key+".Join.Enabled-Sound"); - String[] gsplit = gslipsound.split(";"); - - Sound sound = XSound.valueOf(split[0]).parseSound(); - int vol = Integer.valueOf(gsplit[1]); - float pitch = Float.valueOf(gsplit[2]); - - if(gqe.equals("true")) { - if(j.isOp() || j.hasPermission(gperm)) { - if(gsap.equals("true")) { - for(Player p : Bukkit.getOnlinePlayers()) { - Location l = p.getLocation(); - p.playSound(l, sound, vol, pitch); - } - }else if(gsap.equals("false")) { - Location l = j.getLocation(); - j.playSound(l, sound, vol, pitch); - } - } - } - } - } - - } - }catch(IllegalArgumentException ex) { - Utils.sendColorMessage(eventUtils.getConsoleSender(), Utils.getPrefix() + " " + "&cError: &b Sounds.Enabled &9== &eNull &d?"); - Utils.sendColorMessage(eventUtils.getConsoleSender(), Utils.getPrefix() + " " + plugin.Locale().Error_Sound); - ex.printStackTrace(); - }catch(NullPointerException ex){ - Utils.sendColorMessage(eventUtils.getConsoleSender(), Utils.getPrefix() + " " + "&cError: &b Sounds.Enabled &9== &eNull &d?"); - ex.printStackTrace(); - if(split[0].isEmpty()) { - Utils.sendColorMessage(eventUtils.getConsoleSender(), Utils.getPrefix() + " " + "&cError: &b Sounds.Enabled &9== &eNull 0 &d?"); - } - if(split[1].isEmpty()) { - Utils.sendColorMessage(eventUtils.getConsoleSender(), Utils.getPrefix() + " " + "&cError: &b Sounds.Enabled &9== &eNull 1 &d?"); - } - if(split[2].isEmpty()) { - Utils.sendColorMessage(eventUtils.getConsoleSender(), Utils.getPrefix() + " " + "&cError: &b Sounds.Enabled &9== &eNull 2 &d?"); - } - if(split[0].isEmpty() || split[1].isEmpty() || split[2].isEmpty()) { - Utils.sendColorMessage(eventUtils.getConsoleSender(), Utils.getPrefix() + " " + "&cError: &b Sounds.Enabled &9== &eNull all &d?"); - } - } - } - - @EventHandler - public void onQuit(PlayerQuitEvent e) { - Player j = e.getPlayer(); - FileConfiguration config = plugin.getConfig(); - String path = "Sounds.Enabled"; - String slipsound = config.getString("Sounds.Quit.Sound"); - String useperm = config.getString("Sounds.Quit.Enabled-Permission"); - String perm = config.getString("Sounds.Quit.Custom-Permission"); - String sap = config.getString("Sounds.Settings.Send-All-Sounds"); - String qe = config.getString("Sounds.Quit.Enabled"); - String[] split = slipsound.split(";"); - try { - if(config.getString(path).equals("true")) { - if(config.getString("Sounds.Type").equals("Normal")) { - if(qe.equals("true")) { - if(useperm.equals("true")) { - if(!(j.hasPermission(perm)) || !(j.isOp())) { - Sound sound = XSound.valueOf(split[0]).parseSound(); - int vol = Integer.valueOf(split[1]); - float pitch = Float.valueOf(split[2]); - if(sap.equals("true")) { - for(Player p : Bukkit.getOnlinePlayers()) { - Location l = p.getLocation(); - p.playSound(l, sound, vol, pitch); - } - }else if(sap.equals("false")) { - Location l = j.getLocation(); - j.playSound(l, sound, vol, pitch); - } - } - }else if(useperm.equals("false")){ - Sound sound = XSound.valueOf(split[0]).parseSound(); - int vol = Integer.valueOf(split[1]); - float pitch = Float.valueOf(split[2]); - if(sap.equals("true")) { - for(Player p : Bukkit.getOnlinePlayers()) { - Location l = p.getLocation(); - p.playSound(l, sound, vol, pitch); - } - }else if(sap.equals("false")) { - Location l = j.getLocation(); - j.playSound(l, sound, vol, pitch); - } - } - } - }else if(config.getString("Sounds.Type").equals("Group")) { - for(String key : config.getConfigurationSection("Groups").getKeys(false)) { - String gslipsound = config.getString("Groups."+key+".Quit.Sound"); - String gperm = config.getString("Groups."+key+".Quit.Permission"); - String gsap = config.getString("Groups."+key+".Quit.Send-All-Sound"); - String gqe = config.getString("Groups."+key+".Quit.Enabled-Sound"); - String[] gsplit = gslipsound.split(";"); - - Sound sound = XSound.valueOf(split[0]).parseSound(); - int vol = Integer.valueOf(gsplit[1]); - float pitch = Float.valueOf(gsplit[2]); - - if(gqe.equals("true")) { - if(j.isOp() || j.hasPermission(gperm)) { - if(gsap.equals("true")) { - for(Player p : Bukkit.getOnlinePlayers()) { - Location l = p.getLocation(); - p.playSound(l, sound, vol, pitch); - } - }else if(gsap.equals("false")) { - Location l = j.getLocation(); - j.playSound(l, sound, vol, pitch); - } - } - } - } - } - } - }catch(IllegalArgumentException ex) { - Utils.sendColorMessage(eventUtils.getConsoleSender(), Utils.getPrefix() + " " + "&cError: &b Sounds.Enabled &9== &eNull &d?"); - Utils.sendColorMessage(eventUtils.getConsoleSender(), Utils.getPrefix() + " " + plugin.Locale().Error_Sound); - }catch(NullPointerException ex){ - Utils.sendColorMessage(eventUtils.getConsoleSender(), Utils.getPrefix() + " " + "&cError: &b Sounds.Enabled &9== &aNull &d?"); - if(split[0] == null) { - Utils.sendColorMessage(eventUtils.getConsoleSender(), Utils.getPrefix() + " " + "&cError: &b Sounds.Enabled &9== &eNull 0 &d?"); - } - if(split[1] == null) { - Utils.sendColorMessage(eventUtils.getConsoleSender(), Utils.getPrefix() + " " + "&cError: &b Sounds.Enabled &9== &eNull 1 &d?"); - } - if(split[2] == null) { - Utils.sendColorMessage(eventUtils.getConsoleSender(), Utils.getPrefix() + " " + "&cError: &b Sounds.Enabled &9== &eNull 2 &d?"); - } - if(split[0] == null || split[1] == null || split[2] == null) { - Utils.sendColorMessage(eventUtils.getConsoleSender(), Utils.getPrefix() + " " + "&cError: &b Sounds.Enabled &9== &eNull all &d?"); - } - } - } -} diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/hook/HooksManager.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/hook/HooksManager.java index 2c01614..c7ea108 100644 --- a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/hook/HooksManager.java +++ b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/hook/HooksManager.java @@ -7,7 +7,6 @@ public class HooksManager { private CustomJoinAndQuitMessages plugin; private HooksManager manager; - private VaultHook vaultHook; private PlaceholderApiHook placeholderApiHook; public HooksManager(CustomJoinAndQuitMessages plugin) { @@ -15,8 +14,7 @@ public HooksManager(CustomJoinAndQuitMessages plugin) { } public void load() { - initHooks(new VaultHook(this), - new PlaceholderApiHook(this)); + initHooks( new PlaceholderApiHook(this)); } private void initHooks(LoaderHook... hooks) { @@ -37,7 +35,4 @@ public PlaceholderApiHook getPlaceholderApiHook() { return placeholderApiHook; } - public VaultHook getVaultHook() { - return vaultHook; - } } diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/hook/VaultHook.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/hook/VaultHook.java deleted file mode 100644 index 016d8be..0000000 --- a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/hook/VaultHook.java +++ /dev/null @@ -1,68 +0,0 @@ -package jss.customjoinandquitmessages.hook; - -import org.bukkit.Bukkit; -import org.bukkit.plugin.RegisteredServiceProvider; - -import jss.customjoinandquitmessages.CustomJoinAndQuitMessages; -import jss.customjoinandquitmessages.utils.EventsUtils; -import jss.customjoinandquitmessages.utils.Logger; -import jss.customjoinandquitmessages.utils.Logger.Level; -import jss.customjoinandquitmessages.utils.Utils; -import jss.customjoinandquitmessages.utils.interfaces.LoaderHook; -import net.milkbowl.vault.chat.Chat; -import net.milkbowl.vault.economy.Economy; -import net.milkbowl.vault.permission.Permission; - -public class VaultHook implements LoaderHook{ - - private CustomJoinAndQuitMessages plugin = CustomJoinAndQuitMessages.getPlugin(); - private HooksManager hooksManager; - private EventsUtils EventsUtils = new EventsUtils(plugin); - private Logger logger = new Logger(plugin); - private Economy economy; - private Permission permission; - private Chat chat; - - public VaultHook(HooksManager hooksManager) { - this.hooksManager = hooksManager; - } - - public void load() { - if(!Bukkit.getPluginManager().isPluginEnabled("Vault")) { - logger.Log(Level.WARNING, "vault not enabled! - Disable Features..."); - return; - } - - Utils.sendColorMessage(EventsUtils.getConsoleSender(), Utils.getPrefix() + " " + "&aLoading vault features..."); - RegisteredServiceProvider rspE = Bukkit.getServer().getServicesManager().getRegistration(Economy.class); - RegisteredServiceProvider rspP = Bukkit.getServer().getServicesManager().getRegistration(Permission.class); - RegisteredServiceProvider rspC = Bukkit.getServer().getServicesManager().getRegistration(Chat.class); - - if(rspE != null) { - economy = rspE.getProvider(); - } - if(rspP != null) { - permission = rspP.getProvider(); - } - if(rspC != null) { - chat = rspC.getProvider(); - } - } - - - public Economy getEconomy() { - return economy; - } - - public Chat getChat() { - return chat; - } - - public Permission getPermission() { - return permission; - } - - public HooksManager getHooksManager() { - return hooksManager; - } -} diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/json/Json.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/json/Json.java index 52bca18..e95ffcb 100644 --- a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/json/Json.java +++ b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/json/Json.java @@ -32,37 +32,42 @@ public String getText() { return text; } - public void setText(String text) { + public Json setText(String text) { this.text = text; + return this; } - public void setHover(List hover) { + public Json setHover(List hover) { this.hoverText = new BaseComponent[hover.size()]; for(int i = 0; i < hover.size(); i++) { TextComponent component = new TextComponent(); if(i == hover.size() -1) { - component.setText(Utils.hexcolor(Utils.getVar(this.player, (String)hover.get(i)))); + component.setText(Utils.color(Utils.getVar(this.player, (String)hover.get(i)))); }else { - component.setText(Utils.hexcolor(Utils.getVar(this.player, (String)hover.get(i)) + "\n")); + component.setText(Utils.color(Utils.getVar(this.player, (String)hover.get(i)) + "\n")); } this.hoverText[i] = component; } + return this; } - public void setSuggestCommand(String suggestCommand) { + public Json setSuggestCommand(String suggestCommand) { this.suggestCommand = suggestCommand; + return this; } - public void setExecuteCommand(String executeCommand) { + public Json setExecuteCommand(String executeCommand) { this.executeCommand = executeCommand; + return this; } - public void setOpenURL(String url) { + public Json setOpenURL(String url) { this.openUrl = url; + return this; } public void send() { - TextComponent component = new TextComponent(Utils.hexcolor(this.text)); + TextComponent component = new TextComponent(Utils.color(this.text)); if(this.hoverText != null) { component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, this.hoverText)); } @@ -79,7 +84,7 @@ public void send() { } public void sendToAll() { - TextComponent component = new TextComponent(Utils.hexcolor(this.text)); + TextComponent component = new TextComponent(Utils.color(this.text)); if(this.hoverText != null) { component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, this.hoverText)); } diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/patterns/GradientPattern2.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/patterns/GradientPattern2.java new file mode 100644 index 0000000..aa59a71 --- /dev/null +++ b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/patterns/GradientPattern2.java @@ -0,0 +1,25 @@ +package jss.customjoinandquitmessages.patterns; + +import com.iridium.iridiumcolorapi.IridiumColorAPI; +import com.iridium.iridiumcolorapi.patterns.IPattern; + +import java.awt.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class GradientPattern2 implements IPattern { + + Pattern pattern = Pattern.compile("(.*?)"); + + public String process(String string) { + Matcher matcher = pattern.matcher(string); + while (matcher.find()) { + String start = matcher.group(1); + String end = matcher.group(3); + String content = matcher.group(2); + string = string.replace(matcher.group(), IridiumColorAPI.color(content, new Color(Integer.parseInt(start, 16)), new Color(Integer.parseInt(end, 16)))); + } + return string; + } + +} diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/patterns/PadPattern.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/patterns/PadPattern.java new file mode 100644 index 0000000..f5e0215 --- /dev/null +++ b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/patterns/PadPattern.java @@ -0,0 +1,22 @@ +package jss.customjoinandquitmessages.patterns; + +import com.iridium.iridiumcolorapi.IridiumColorAPI; +import com.iridium.iridiumcolorapi.patterns.IPattern; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class PadPattern implements IPattern { + + Pattern pattern = Pattern.compile("<#([0-9A-Fa-f]{6})>"); + + public String process(String string) { + Matcher matcher = pattern.matcher(string); + while (matcher.find()) { + String color = matcher.group(1); + string = string.replace(matcher.group(), IridiumColorAPI.getColor(color) + ""); + } + return string; + } + +} diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/patterns/PadPattern2.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/patterns/PadPattern2.java new file mode 100644 index 0000000..49cc273 --- /dev/null +++ b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/patterns/PadPattern2.java @@ -0,0 +1,22 @@ +package jss.customjoinandquitmessages.patterns; + +import com.iridium.iridiumcolorapi.IridiumColorAPI; +import com.iridium.iridiumcolorapi.patterns.IPattern; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class PadPattern2 implements IPattern { + + Pattern pattern = Pattern.compile("<#:([0-9A-Fa-f]{6})>"); + + public String process(String string) { + Matcher matcher = pattern.matcher(string); + while (matcher.find()) { + String color = matcher.group(1); + string = string.replace(matcher.group(), IridiumColorAPI.getColor(color) + ""); + } + return string; + } + +} diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/patterns/PadPattern3.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/patterns/PadPattern3.java new file mode 100644 index 0000000..e35d67f --- /dev/null +++ b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/patterns/PadPattern3.java @@ -0,0 +1,22 @@ +package jss.customjoinandquitmessages.patterns; + +import com.iridium.iridiumcolorapi.IridiumColorAPI; +import com.iridium.iridiumcolorapi.patterns.IPattern; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class PadPattern3 implements IPattern { + + Pattern pattern = Pattern.compile("#([0-9A-Fa-f]{6})"); + + public String process(String string) { + Matcher matcher = pattern.matcher(string); + while (matcher.find()) { + String color = matcher.group(1); + string = string.replace(matcher.group(), IridiumColorAPI.getColor(color) + ""); + } + return string; + } + +} diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/patterns/RainbowPattern2.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/patterns/RainbowPattern2.java new file mode 100644 index 0000000..5a67841 --- /dev/null +++ b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/patterns/RainbowPattern2.java @@ -0,0 +1,23 @@ +package jss.customjoinandquitmessages.patterns; + +import com.iridium.iridiumcolorapi.IridiumColorAPI; +import com.iridium.iridiumcolorapi.patterns.IPattern; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class RainbowPattern2 implements IPattern { + + Pattern pattern = Pattern.compile("(.*?)"); + + public String process(String string) { + Matcher matcher = pattern.matcher(string); + while (matcher.find()) { + String saturation = matcher.group(1); + String content = matcher.group(2); + string = string.replace(matcher.group(), IridiumColorAPI.rainbow(content, Float.parseFloat(saturation))); + } + return string; + } + +} diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/EventsUtils.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/EventsUtils.java index 979a1bf..6ad93d7 100644 --- a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/EventsUtils.java +++ b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/EventsUtils.java @@ -29,4 +29,7 @@ public ConsoleCommandSender getConsoleSender() { return Bukkit.getConsoleSender(); } + public static ConsoleCommandSender getStaticConsoleSender() { + return Bukkit.getConsoleSender(); + } } diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/Logger.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/Logger.java index 7185765..c380f97 100644 --- a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/Logger.java +++ b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/Logger.java @@ -5,7 +5,7 @@ public class Logger { private CustomJoinAndQuitMessages plugin; - private EventsUtils EventsUtils = new EventsUtils(plugin); + private EventsUtils eventsUtils = new EventsUtils(plugin); public Logger(CustomJoinAndQuitMessages plugin) { this.plugin = plugin; @@ -17,27 +17,74 @@ public void Log(Level level, String msg) { } switch (level) { case ERROR: - Utils.sendColorMessage(EventsUtils.getConsoleSender(), "&e[&cERROR&e]&7" + " " + msg); + Utils.sendColorMessage(eventsUtils.getConsoleSender(), "&e[&cERROR&e]&7" + " " + msg); break; case WARNING: - Utils.sendColorMessage(EventsUtils.getConsoleSender(), "&e[&dWARNING&e]&7" + " " + msg); + Utils.sendColorMessage(eventsUtils.getConsoleSender(), "&e[&dWARNING&e]&7" + " " + msg); break; case INFO: - Utils.sendColorMessage(EventsUtils.getConsoleSender(), "&e[&9INFO&e]&7" + " " + msg); + Utils.sendColorMessage(eventsUtils.getConsoleSender(), "&e[&9INFO&e]&7" + " " + msg); break; case OUTLINE: - Utils.sendColorMessage(EventsUtils.getConsoleSender(), "&e[&bOUTLINE&e]&7" + " " + msg); + Utils.sendColorMessage(eventsUtils.getConsoleSender(), "&e[&bOUTLINE&e]&7" + " " + msg); break; case SUCCESS: - Utils.sendColorMessage(EventsUtils.getConsoleSender(), "&e[&aSUCCESS&e]&7" + " " + msg); + Utils.sendColorMessage(eventsUtils.getConsoleSender(), "&e[&aSUCCESS&e]&7" + " " + msg); break; case DEBUG: - Utils.sendColorMessage(EventsUtils.getConsoleSender(), "&e[&dDEBUG&e]&7" + " " + msg); + Utils.sendColorMessage(eventsUtils.getConsoleSender(), "&e[&dDEBUG&e]&7" + " " + msg); break; } } + public static void error(String msg) { + Utils.sendColorConsoleMessage(EventsUtils.getStaticConsoleSender(), ERRORPrefix() + " " + msg); + } + + public static void warning(String msg) { + Utils.sendColorConsoleMessage(EventsUtils.getStaticConsoleSender(), WARNINGPrefix() + " " + msg); + } + + public static void info(String msg) { + Utils.sendColorConsoleMessage(EventsUtils.getStaticConsoleSender(), INFOPrefix() + " " + msg); + } + + public static void outLine(String msg) { + Utils.sendColorConsoleMessage(EventsUtils.getStaticConsoleSender(), OUTLINEPrefix() + " " + msg); + } + + public static void success(String msg) { + Utils.sendColorConsoleMessage(EventsUtils.getStaticConsoleSender(), SUCCESSPrefix() + " " + msg); + } + + public static void debug(String msg) { + Utils.sendColorConsoleMessage(EventsUtils.getStaticConsoleSender(), DEBUGPrefix() + " " + msg); + } + + public static void defaultMessage(String msg) { + Utils.sendColorConsoleMessage(EventsUtils.getStaticConsoleSender(), Utils.getPrefix() + msg); + } + + private static String ERRORPrefix() { + return Utils.color("&e[&cERROR&e]&7"); + } + private static String WARNINGPrefix() { + return Utils.color("&e[&dWARNING&e]&7"); + } + private static String INFOPrefix() { + return Utils.color("&e[&9INFO&e]&7"); + } + private static String OUTLINEPrefix() { + return Utils.color("&e[&bOUTLINE&e]&7"); + } + private static String SUCCESSPrefix() { + return Utils.color("&e[&aSUCCESS&e]&7"); + } + private static String DEBUGPrefix() { + return Utils.color("&e[&dDEBUG&e]&7"); + } + public enum Level { ERROR, WARNING, INFO, SUCCESS, OUTLINE, DEBUG } diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/Utils.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/Utils.java index 77bb07b..922c8fa 100644 --- a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/Utils.java +++ b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/Utils.java @@ -12,6 +12,8 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import com.iridium.iridiumcolorapi.IridiumColorAPI; + import me.clip.placeholderapi.PlaceholderAPI; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.BaseComponent; @@ -35,7 +37,7 @@ public static String hexcolor(String text) { match = hex.matcher(text); } } - return color(text); + return legacycolor(text); } public static String setCustomLine(String arg, String color) { @@ -55,9 +57,18 @@ public static String setLine() { } public static String color(String text) { + if(text == null || text.isEmpty()) return ""; + return IridiumColorAPI.process(text); + } + + public static String legacycolor(String text) { return ChatColor.translateAlternateColorCodes('&', text); } + public static void sendColorConsoleMessage(CommandSender sender, String text) { + sender.sendMessage(color(text)); + } + public static String colorless(String text) { return ChatColor.stripColor(text); } diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/nms/Actionbar.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/nms/Actionbar.java deleted file mode 100644 index f71f039..0000000 --- a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/nms/Actionbar.java +++ /dev/null @@ -1,66 +0,0 @@ -package jss.customjoinandquitmessages.utils.nms; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import jss.customjoinandquitmessages.CustomJoinAndQuitMessages; -import jss.customjoinandquitmessages.events.custom.ActionbarEvent; - -public class Actionbar { - - private CustomJoinAndQuitMessages plugin; - - public void sendActionBar(Player player, String message) { - if (!player.isOnline()) { - return; - } - ActionbarEvent actionBarMessageEvent = new ActionbarEvent(player, message); - Bukkit.getPluginManager().callEvent(actionBarMessageEvent); - if (actionBarMessageEvent.isCancelled()) - return; - try { - Class craftPlayerClass = Class.forName("org.bukkit.craftbukkit." + plugin.nmsversion + ".entity.CraftPlayer"); - Object craftPlayer = craftPlayerClass.cast(player); - Object packet; - Class packetPlayOutChatClass = Class.forName("net.minecraft.server." + plugin.nmsversion + ".PacketPlayOutChat"); - Class packetClass = Class.forName("net.minecraft.server." + plugin.nmsversion + ".Packet"); - if (plugin.useLegacyversions) { - Class chatSerializerClass = Class.forName("net.minecraft.server." + plugin.nmsversion + ".ChatSerializer"); - Class iChatBaseComponentClass = Class.forName("net.minecraft.server." + plugin.nmsversion + ".IChatBaseComponent"); - Method m3 = chatSerializerClass.getDeclaredMethod("a", String.class); - Object cbc = iChatBaseComponentClass.cast(m3.invoke(chatSerializerClass, "{\"text\": \"" + message + "\"}")); - packet = packetPlayOutChatClass.getConstructor(new Class[]{iChatBaseComponentClass, byte.class}).newInstance(cbc, (byte) 2); - } else { - Class chatComponentTextClass = Class.forName("net.minecraft.server." + plugin.nmsversion + ".ChatComponentText"); - Class iChatBaseComponentClass = Class.forName("net.minecraft.server." + plugin.nmsversion + ".IChatBaseComponent"); - try { - Class chatMessageTypeClass = Class.forName("net.minecraft.server." + plugin.nmsversion + ".ChatMessageType"); - Object[] chatMessageTypes = chatMessageTypeClass.getEnumConstants(); - Object chatMessageType = null; - for (Object obj : chatMessageTypes) { - if (obj.toString().equals("GAME_INFO")) { - chatMessageType = obj; - } - } - Object chatCompontentText = chatComponentTextClass.getConstructor(new Class[]{String.class}).newInstance(message); - packet = packetPlayOutChatClass.getConstructor(new Class[]{iChatBaseComponentClass, chatMessageTypeClass}).newInstance(chatCompontentText, chatMessageType); - } catch (ClassNotFoundException cnfe) { - Object chatCompontentText = chatComponentTextClass.getConstructor(new Class[]{String.class}).newInstance(message); - packet = packetPlayOutChatClass.getConstructor(new Class[]{iChatBaseComponentClass, byte.class}).newInstance(chatCompontentText, (byte) 2); - } - } - Method craftPlayerHandleMethod = craftPlayerClass.getDeclaredMethod("getHandle"); - Object craftPlayerHandle = craftPlayerHandleMethod.invoke(craftPlayer); - Field playerConnectionField = craftPlayerHandle.getClass().getDeclaredField("playerConnection"); - Object playerConnection = playerConnectionField.get(craftPlayerHandle); - Method sendPacketMethod = playerConnection.getClass().getDeclaredMethod("sendPacket", packetClass); - sendPacketMethod.invoke(playerConnection, packet); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - -} diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/nms/Nms.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/nms/Nms.java deleted file mode 100644 index b4b41a8..0000000 --- a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/nms/Nms.java +++ /dev/null @@ -1,60 +0,0 @@ -package jss.customjoinandquitmessages.utils.nms; - -import java.lang.reflect.InvocationTargetException; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import jss.customjoinandquitmessages.CustomJoinAndQuitMessages; - -public class Nms { - - private static CustomJoinAndQuitMessages plugin = CustomJoinAndQuitMessages.getPlugin(); - private static String nmsname = "net.minecraft.server."; - public final static String PacketPlayOutTitle = "PacketPlayOutTitle"; - public final static String IChatBaseComponent = "IChatBaseComponent"; - public static String nmsversion = plugin.getNmsversion(); - public static boolean useLegacyversions = plugin.isUseLegacyversions(); - public static final String NMS_VERSION = Bukkit.getServer().getClass().getPackage().getName().substring(23); - - - public static void sendPacket(Player player, Object object) { - try { - getPlayerConnection(player).getClass().getMethod("sendPacket", getNMSClass("Packet")).invoke(getPlayerConnection(player), object); - }catch(Exception e) { - e.printStackTrace(); - } - } - - public static Class getNMSClass(String packet){ - String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; - try { - return Class.forName(nmsname + version + "." + packet); - } catch (ClassCastException |ClassNotFoundException e) { - throw new Error(e); - } - } - - public static Object getPlayerConnection(Player player) { - try { - Object object = getHandle(player).getClass().getField("playerConnection").get(getHandle(player)); - return object; - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { - throw new Error(e); - } - } - - public static Object getHandle(Player player) { - try { - Object object = player.getClass().getMethod("").invoke(player); - return object; - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { - throw new Error(e); - } - } - - public static CustomJoinAndQuitMessages getPlugin() { - return plugin; - } - -} diff --git a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/nms/Title.java b/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/nms/Title.java deleted file mode 100644 index de6cc14..0000000 --- a/CustomJoinAndQuitMessages/src/jss/customjoinandquitmessages/utils/nms/Title.java +++ /dev/null @@ -1,70 +0,0 @@ -package jss.customjoinandquitmessages.utils.nms; - -import java.lang.reflect.Constructor; - -import org.bukkit.entity.Player; - -import jss.customjoinandquitmessages.CustomJoinAndQuitMessages; -import jss.customjoinandquitmessages.events.custom.TitleEvent; -import jss.customjoinandquitmessages.utils.EventsUtils; -import jss.customjoinandquitmessages.utils.Utils; - - -public class Title extends Nms { - - private static CustomJoinAndQuitMessages plugin = CustomJoinAndQuitMessages.getPlugin(); - - public static void sendTitle(Player player ,String title, String subtitle, int fadeIn, int stay, int fadeOut) { - TitleEvent titleEvent = new TitleEvent(player, title, subtitle, fadeIn, stay, fadeOut); - EventsUtils EventsUtils = new EventsUtils(plugin); - EventsUtils.getEventManager().callEvent(titleEvent); - if(titleEvent.isCancelled()) { - return; - } - try { - Object e; - Object chatTitle; - Object chatSubTitle; - Constructor subtitleConstructor; - Object titlePacket; - Object subtitlePacket; - - if(title != null) { - title = Utils.color(title); - title = Utils.hexcolor(title); - e = getNMSClass(PacketPlayOutTitle).getDeclaredClasses()[0].getField("TIMES").get((Object) null); - chatTitle = getNMSClass(IChatBaseComponent).getDeclaredClasses()[0].getMethod("a", new Class[]{String.class}).invoke((Object) null, new Object[]{"{\"text\":\"" + title + "\"}"}); - subtitleConstructor = getNMSClass(PacketPlayOutTitle).getConstructor(new Class[]{getNMSClass(PacketPlayOutTitle).getDeclaredClasses()[0], getNMSClass(IChatBaseComponent), Integer.TYPE, Integer.TYPE, Integer.TYPE}); - titlePacket = subtitleConstructor.newInstance(new Object[]{e, chatTitle, fadeIn, stay, fadeOut}); - sendPacket(player, titlePacket); - e = getNMSClass(PacketPlayOutTitle).getDeclaredClasses()[0].getField("TITLE").get((Object) null); - chatTitle = getNMSClass(IChatBaseComponent).getDeclaredClasses()[0].getMethod("a", new Class[]{String.class}).invoke((Object) null, new Object[]{"{\"text\":\"" + title + "\"}"}); - subtitleConstructor = getNMSClass(PacketPlayOutTitle).getConstructor(new Class[]{getNMSClass(PacketPlayOutTitle).getDeclaredClasses()[0], getNMSClass(IChatBaseComponent)}); - titlePacket = subtitleConstructor.newInstance(new Object[]{e, chatTitle}); - sendPacket(player, titlePacket); - } - if (subtitle != null) { - subtitle = Utils.color(subtitle); - subtitle = Utils.hexcolor(subtitle); - e = getNMSClass(PacketPlayOutTitle).getDeclaredClasses()[0].getField("TIMES").get((Object) null); - chatSubTitle = getNMSClass(IChatBaseComponent).getDeclaredClasses()[0].getMethod("a", new Class[]{String.class}).invoke((Object) null, new Object[]{"{\"text\":\"" + title + "\"}"}); - subtitleConstructor = getNMSClass(PacketPlayOutTitle).getConstructor(new Class[]{getNMSClass(PacketPlayOutTitle).getDeclaredClasses()[0], getNMSClass(IChatBaseComponent), Integer.TYPE, Integer.TYPE, Integer.TYPE}); - subtitlePacket = subtitleConstructor.newInstance(new Object[]{e, chatSubTitle, fadeIn, stay, fadeOut}); - sendPacket(player, subtitlePacket); - - e = getNMSClass(PacketPlayOutTitle).getDeclaredClasses()[0].getField("SUBTITLE").get((Object) null); - chatSubTitle = getNMSClass(IChatBaseComponent).getDeclaredClasses()[0].getMethod("a", new Class[]{String.class}).invoke((Object) null, new Object[]{"{\"text\":\"" + subtitle + "\"}"}); - subtitleConstructor = getNMSClass(PacketPlayOutTitle).getConstructor(new Class[]{getNMSClass(PacketPlayOutTitle).getDeclaredClasses()[0], getNMSClass(IChatBaseComponent), Integer.TYPE, Integer.TYPE, Integer.TYPE}); - subtitlePacket = subtitleConstructor.newInstance(new Object[]{e, chatSubTitle, fadeIn, stay, fadeOut}); - sendPacket(player, subtitlePacket); - } - }catch(Exception ex) { - ex.printStackTrace(); - } - } - - public static void clearTitle(Player player) { - sendTitle(player, "", "", 0, 0, 0); - } - -}