File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed
src/main/java/systems/kinau/fishingbot Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -64,10 +64,10 @@ public void onPosLookChange(PosLookChangeEvent event) {
6464
6565 @ EventHandler
6666 public void onUpdateXP (UpdateExperienceEvent event ) {
67- if (getLevels () >= 0 && getLevels () < event .getLevel ()) {
68- if (FishingBot .getInstance ().getConfig ().getAnnounceTypeConsole () != AnnounceType .NONE )
67+ if (getLevels () >= 0 && getLevels () < event .getLevel ()) {
68+ if (FishingBot .getInstance ().getConfig ().getAnnounceTypeConsole () != AnnounceType .NONE )
6969 FishingBot .getI18n ().info ("announce-level-up" , String .valueOf (event .getLevel ()));
70- if (FishingBot .getInstance ().getConfig ().isAnnounceLvlUp () && !FishingBot .getInstance ().getConfig ().getAnnounceLvlUpText ().equalsIgnoreCase ("false" ))
70+ if (FishingBot .getInstance ().getConfig ().isAnnounceLvlUp () && !FishingBot .getInstance ().getConfig ().getAnnounceLvlUpText ().equalsIgnoreCase ("false" ))
7171 FishingBot .getInstance ().getNet ().sendPacket (new PacketOutChat (FishingBot .getInstance ().getConfig ().getAnnounceLvlUpText ().replace ("%lvl%" , String .valueOf (event .getLevel ()))));
7272 }
7373
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ public class SettingsConfig implements Config {
5252 @ Property (key = "announces.discord.announce-type-discord" ) private AnnounceType announceTypeDiscord = AnnounceType .ONLY_ENCHANTED ;
5353 @ Property (key = "announces.discord.alert-on-attack" ) private boolean alertOnAttack = true ;
5454 @ Property (key = "announces.discord.alert-on-respawn" ) private boolean alertOnRespawn = true ;
55+ @ Property (key = "announces.discord.alert-on-level-update" ) private boolean alertOnLevelUpdate = true ;
5556 @ Property (key = "announces.discord.ping-on-enchantment.enabled" ) private boolean pingOnEnchantmentEnabled = false ;
5657 @ Property (key = "announces.discord.ping-on-enchantment.mention" ) private String pingOnEnchantmentMention = "<@USER_ID>" ;
5758 @ Property (key = "announces.discord.ping-on-enchantment.items" ) private List <String > pingOnEnchantmentItems = Collections .singletonList ("enchanted_book" );
Original file line number Diff line number Diff line change 77import systems .kinau .fishingbot .event .Listener ;
88import systems .kinau .fishingbot .event .custom .FishCaughtEvent ;
99import systems .kinau .fishingbot .event .custom .RespawnEvent ;
10+ import systems .kinau .fishingbot .event .play .UpdateExperienceEvent ;
1011import systems .kinau .fishingbot .event .play .UpdateHealthEvent ;
1112import systems .kinau .fishingbot .io .discord .DiscordDetails ;
1213import systems .kinau .fishingbot .io .discord .DiscordMessageDispatcher ;
@@ -22,6 +23,7 @@ public class DiscordModule extends Module implements Listener {
2223 @ Getter private DiscordMessageDispatcher discord ;
2324
2425 @ Getter @ Setter private float health = -1 ;
26+ @ Getter @ Setter private int level = -1 ;
2527
2628 @ Override
2729 public void onEnable () {
@@ -86,6 +88,13 @@ public void onUpdateHealth(UpdateHealthEvent event) {
8688 this .health = event .getHealth ();
8789 }
8890
91+ @ EventHandler
92+ public void onXP (UpdateExperienceEvent event ) {
93+ if (getLevel () != event .getLevel () && FishingBot .getInstance ().getConfig ().isAlertOnLevelUpdate ())
94+ getDiscord ().dispatchMessage (FishingBot .getI18n ().t ("announce-level-up" , String .valueOf (event .getLevel ())), DISCORD_DETAILS );
95+ this .level = event .getLevel ();
96+ }
97+
8998 @ EventHandler
9099 public void onRespawn (RespawnEvent event ) {
91100 if (FishingBot .getInstance ().getConfig ().isAlertOnRespawn ()) {
You can’t perform that action at this time.
0 commit comments