mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 16:46:46 +01:00
ActionBar messages can now have copies sent to chat
This commit is contained in:
parent
ee04bebcd9
commit
ed2c3975d8
@ -696,10 +696,15 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
return config.getDouble("Skills."+abstractSubSkill.getPrimaryKeyName()+"."+abstractSubSkill.getConfigKeyName()+".ChanceMax", 100.0D);
|
return config.getDouble("Skills."+abstractSubSkill.getPrimaryKeyName()+"."+abstractSubSkill.getConfigKeyName()+".ChanceMax", 100.0D);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Interaction Settings */
|
/* Notification Settings */
|
||||||
public boolean doesNotificationUseActionBar(NotificationType notificationType)
|
public boolean doesNotificationUseActionBar(NotificationType notificationType)
|
||||||
{
|
{
|
||||||
return config.getBoolean("Feedback.ActionBarNotifications."+notificationType.toString(), true);
|
return config.getBoolean("Feedback.ActionBarNotifications."+notificationType.toString()+".Enabled", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean doesNotificationSendCopyToChat(NotificationType notificationType)
|
||||||
|
{
|
||||||
|
return config.getBoolean("Feedback.ActionBarNotifications."+notificationType.toString()+".SendCopyOfMessageToChat", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -5,6 +5,7 @@ package com.gmail.nossr50.datatypes.interactions;
|
|||||||
*/
|
*/
|
||||||
public enum NotificationType {
|
public enum NotificationType {
|
||||||
XP_GAIN("ExperienceGain"),
|
XP_GAIN("ExperienceGain"),
|
||||||
|
HARDCORE_MODE("HardcoreMode"),
|
||||||
NO_PERMISSION("NoPermission"),
|
NO_PERMISSION("NoPermission"),
|
||||||
SUBSKILL_UNLOCKED("SubSkillUnlocked"),
|
SUBSKILL_UNLOCKED("SubSkillUnlocked"),
|
||||||
LEVEL_UP_MESSAGE("LevelUps"),
|
LEVEL_UP_MESSAGE("LevelUps"),
|
||||||
|
@ -13,17 +13,25 @@ import org.bukkit.event.player.PlayerEvent;
|
|||||||
*/
|
*/
|
||||||
public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancellable {
|
public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancellable {
|
||||||
private boolean isCancelled;
|
private boolean isCancelled;
|
||||||
|
/*
|
||||||
|
* Messages can be sent to both places, as configured in advanced.yml
|
||||||
|
* If isBeingSentToActionBar is false, then messages will ALWAYS be sent to the chat bar
|
||||||
|
* isMessageAlsoBeingSentToChat just indicates a copy of that message will be sent to chat
|
||||||
|
*/
|
||||||
|
private boolean isMessageAlsoBeingSentToChat;
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
protected ChatMessageType chatMessageType;
|
protected ChatMessageType chatMessageType;
|
||||||
|
|
||||||
protected TextComponent notificationTextComponent;
|
protected TextComponent notificationTextComponent;
|
||||||
protected final NotificationType notificationType;
|
protected final NotificationType notificationType;
|
||||||
|
|
||||||
public McMMOPlayerNotificationEvent(Player who, NotificationType notificationType, TextComponent notificationTextComponent, ChatMessageType chatMessageType) {
|
public McMMOPlayerNotificationEvent(Player who, NotificationType notificationType, TextComponent notificationTextComponent, ChatMessageType chatMessageType, boolean isMessageAlsoBeingSentToChat) {
|
||||||
super(who);
|
super(who);
|
||||||
this.notificationType = notificationType;
|
this.notificationType = notificationType;
|
||||||
this.notificationTextComponent = notificationTextComponent;
|
this.notificationTextComponent = notificationTextComponent;
|
||||||
this.chatMessageType = chatMessageType;
|
this.chatMessageType = chatMessageType;
|
||||||
|
this.isMessageAlsoBeingSentToChat = isMessageAlsoBeingSentToChat;
|
||||||
isCancelled = false;
|
isCancelled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +39,14 @@ public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancell
|
|||||||
* Getters & Setters
|
* Getters & Setters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
public boolean isMessageAlsoBeingSentToChat() {
|
||||||
|
return isMessageAlsoBeingSentToChat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessageAlsoBeingSentToChat(boolean messageAlsoBeingSentToChat) {
|
||||||
|
isMessageAlsoBeingSentToChat = messageAlsoBeingSentToChat;
|
||||||
|
}
|
||||||
|
|
||||||
public TextComponent getNotificationTextComponent() {
|
public TextComponent getNotificationTextComponent() {
|
||||||
return notificationTextComponent;
|
return notificationTextComponent;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,10 @@ package com.gmail.nossr50.util;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
|
import com.gmail.nossr50.util.player.NotificationManager;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
@ -52,7 +55,7 @@ public final class HardcoreManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PlayerDeath", totalLevelsLost));
|
NotificationManager.sendPlayerInformation(player, NotificationType.HARDCORE_MODE, "Hardcore.DeathStatLoss.PlayerDeath", String.valueOf(totalLevelsLost));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void invokeVampirism(Player killer, Player victim) {
|
public static void invokeVampirism(Player killer, Player victim) {
|
||||||
|
@ -66,13 +66,25 @@ public class NotificationManager {
|
|||||||
if (customEvent.isCancelled())
|
if (customEvent.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
player.spigot().sendMessage(customEvent.getChatMessageType(), customEvent.getNotificationTextComponent());
|
//If the message is being sent to the action bar we need to check if the copy if a copy is sent to the chat system
|
||||||
|
if(customEvent.getChatMessageType() == ChatMessageType.ACTION_BAR)
|
||||||
|
{
|
||||||
|
player.spigot().sendMessage(customEvent.getChatMessageType(), customEvent.getNotificationTextComponent());
|
||||||
|
|
||||||
|
if(customEvent.isMessageAlsoBeingSentToChat())
|
||||||
|
{
|
||||||
|
//Send copy to chat system
|
||||||
|
player.spigot().sendMessage(ChatMessageType.SYSTEM, customEvent.getNotificationTextComponent());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
player.spigot().sendMessage(customEvent.getChatMessageType(), customEvent.getNotificationTextComponent());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static McMMOPlayerNotificationEvent checkNotificationEvent(Player player, NotificationType notificationType, ChatMessageType destination, TextComponent message) {
|
private static McMMOPlayerNotificationEvent checkNotificationEvent(Player player, NotificationType notificationType, ChatMessageType destination, TextComponent message) {
|
||||||
//Init event
|
//Init event
|
||||||
McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(player,
|
McMMOPlayerNotificationEvent customEvent = new McMMOPlayerNotificationEvent(player,
|
||||||
notificationType, message, destination);
|
notificationType, message, destination, AdvancedConfig.getInstance().doesNotificationSendCopyToChat(notificationType));
|
||||||
|
|
||||||
//Call event
|
//Call event
|
||||||
Bukkit.getServer().getPluginManager().callEvent(customEvent);
|
Bukkit.getServer().getPluginManager().callEvent(customEvent);
|
||||||
|
@ -14,23 +14,57 @@
|
|||||||
# Settings for the Skills
|
# Settings for the Skills
|
||||||
###
|
###
|
||||||
Feedback:
|
Feedback:
|
||||||
# Turning these to false will have them printed in chat instead
|
#The actionbar is the message location right above the health bar
|
||||||
|
## If you disable the action bar messages, mcMMO will send the message to the chat system instead
|
||||||
ActionBarNotifications:
|
ActionBarNotifications:
|
||||||
AbilityOff: true
|
AbilityOff:
|
||||||
RequirementsNotMet: true
|
Enabled: true
|
||||||
AbilityCoolDown: true
|
SendCopyOfMessageToChat: false
|
||||||
LevelUps: true
|
HardcoreMode:
|
||||||
Holiday: true
|
Enabled: true
|
||||||
ToolReady: true
|
SendCopyOfMessageToChat: false
|
||||||
SubSkillInteraction: true
|
RequirementsNotMet:
|
||||||
SubSkillFailure: true
|
Enabled: true
|
||||||
SubSkillUnlocked: true
|
SendCopyOfMessageToChat: false
|
||||||
SuperAbilityInteraction: true
|
AbilityCoolDown:
|
||||||
SuperAbilityAlertOthers: true
|
Enabled: true
|
||||||
ExperienceGain: true
|
SendCopyOfMessageToChat: false
|
||||||
ItemMessage: true
|
LevelUps:
|
||||||
NoPermission: true
|
Enabled: true
|
||||||
PartyMessage: true
|
SendCopyOfMessageToChat: false
|
||||||
|
Holiday:
|
||||||
|
Enabled: true
|
||||||
|
SendCopyOfMessageToChat: true
|
||||||
|
ToolReady:
|
||||||
|
Enabled: true
|
||||||
|
SendCopyOfMessageToChat: false
|
||||||
|
SubSkillInteraction:
|
||||||
|
Enabled: true
|
||||||
|
SendCopyOfMessageToChat: false
|
||||||
|
SubSkillFailure:
|
||||||
|
Enabled: true
|
||||||
|
SendCopyOfMessageToChat: false
|
||||||
|
SubSkillUnlocked:
|
||||||
|
Enabled: true
|
||||||
|
SendCopyOfMessageToChat: true
|
||||||
|
SuperAbilityInteraction:
|
||||||
|
Enabled: true
|
||||||
|
SendCopyOfMessageToChat: false
|
||||||
|
SuperAbilityAlertOthers:
|
||||||
|
Enabled: true
|
||||||
|
SendCopyOfMessageToChat: false
|
||||||
|
ExperienceGain:
|
||||||
|
Enabled: true
|
||||||
|
SendCopyOfMessageToChat: false
|
||||||
|
ItemMessage:
|
||||||
|
Enabled: true
|
||||||
|
SendCopyOfMessageToChat: false
|
||||||
|
NoPermission:
|
||||||
|
Enabled: true
|
||||||
|
SendCopyOfMessageToChat: false
|
||||||
|
PartyMessage:
|
||||||
|
Enabled: true
|
||||||
|
SendCopyOfMessageToChat: true
|
||||||
Skills:
|
Skills:
|
||||||
General:
|
General:
|
||||||
Ability:
|
Ability:
|
||||||
|
Loading…
Reference in New Issue
Block a user