mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Admin notifications convenience methods handled by NotificationManager
This commit is contained in:
parent
b0dc41b4d9
commit
04c6bd8750
@ -1,16 +1,20 @@
|
|||||||
Version 2.1.62
|
Version 2.1.62
|
||||||
|
Added a new admin notification system, sensitive commands will print chat messages to "admins" (players with either Operator status or admin chat permission)
|
||||||
|
Added a setting to disable the new admin notifications to config.yml 'General.AdminNotifications' (this will be more configurable in 2.2)
|
||||||
OPs and players with the admin chat permission will now see details about XP rate event commands regardless of whether or not the XP rate event messages are enabled
|
OPs and players with the admin chat permission will now see details about XP rate event commands regardless of whether or not the XP rate event messages are enabled
|
||||||
Updated hu_HU locale (thanks andris155)
|
Updated hu_HU locale (thanks andris155)
|
||||||
Added XP for mining Magma_Block (default 30 XP - Update your config, see notes)
|
Added XP for mining Magma_Block (default 30 XP - Update your config, see notes)
|
||||||
Diamond tools & armor in the repair config now have a minimum level of 0 (Update your config, temporary hotfix, 2.2 addresses this issue, see notes)
|
Diamond tools & armor in the repair config now have a minimum level of 0 (Update your config, temporary hotfix, 2.2 addresses this issue, see notes)
|
||||||
Guardian default combat XP multiplier reduced from 3.0 to 1.0 (update config if you want this change)
|
Guardian default combat XP multiplier reduced from 3.0 to 1.0 (update config if you want this change)
|
||||||
New locale string - 'XPRate.Modified' sent to the user who modifies the XP rate regardless of whether or not messages for the event are enabled
|
|
||||||
New locale string - 'XPRate.End' sent to the user who ended the XP rate event regardless of whether or not messages for the event are enabled
|
|
||||||
New locale string - 'XPRate.AdminDetails.End' details of who ended an XP rate event are sent to players who have Operator status or admin chat permission when the command to end the event has been issued
|
|
||||||
New locale string - 'XPRate.AdminDetails.Start' details of who started an XP rate event are sent to players who have Operator status or admin chat permission when the command to start or modify XP of an event has been issued
|
|
||||||
New locale string - 'Server.ConsoleName' the name of the server console, this will be used in place of player names when sending admin notifications out if the command was used from console
|
New locale string - 'Server.ConsoleName' the name of the server console, this will be used in place of player names when sending admin notifications out if the command was used from console
|
||||||
|
New locale string - 'Notifications.Admin.Format' style formatting + prefix for admin notifications used in the other new strings below
|
||||||
|
New locale string - 'Notifications.Admin.XPRate.Start.Self' sent to the user who modifies the XP rate regardless of whether or not messages for the event are enabled
|
||||||
|
New locale string - 'Notifications.Admin.XPRate.Start.Others' details of who started an XP rate event are sent to players who have Operator status or admin chat permission when the command to start or modify XP of an event has been issued
|
||||||
|
New locale string - 'Notifications.Admin.XPRate.End.Self' sent to the user who ended the XP rate event regardless of whether or not messages for the event are enabled
|
||||||
|
New locale string - 'Notifications.Admin.XPRate.End.Others' details of who ended an XP rate event are sent to players who have Operator status or admin chat permission when the command to end the event has been issued
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
|
Admin notifications currently only reports use of the XP rate command, it will be expanded to support other commands in upcoming patches
|
||||||
Add an entry of 'Magma_Block: 30' under Mining in experience.yml section titled "Experience_Values" (or you can delete the file to generate a new one with default values, 2.2 is coming soon which will have brand new configs so you could just wait for that
|
Add an entry of 'Magma_Block: 30' under Mining in experience.yml section titled "Experience_Values" (or you can delete the file to generate a new one with default values, 2.2 is coming soon which will have brand new configs so you could just wait for that
|
||||||
2.2 is the config rewrite, in this rewrite Repair and Salvage configs have been partially rewritten, it is not intended for Diamond Repair to take until level 50 in Standard level scaling to be available, since it'd be redundant to fix this in 2.1.X when 2.2 fixes it and its about to come out, the minimum level has temporarily been changed to 0. You can either update your repair.vanilla.yml config manually or delete it to generate a new one.
|
2.2 is the config rewrite, in this rewrite Repair and Salvage configs have been partially rewritten, it is not intended for Diamond Repair to take until level 50 in Standard level scaling to be available, since it'd be redundant to fix this in 2.1.X when 2.2 fixes it and its about to come out, the minimum level has temporarily been changed to 0. You can either update your repair.vanilla.yml config manually or delete it to generate a new one.
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.commands;
|
|||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.notifications.SensitiveCommandType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -52,15 +53,8 @@ public class XprateCommand implements TabExecutor {
|
|||||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop.Subtitle"));
|
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop.Subtitle"));
|
||||||
}
|
}
|
||||||
|
|
||||||
String senderName = LocaleLoader.getString("Server.ConsoleName");
|
NotificationManager.processSensitiveCommandNotification(sender, SensitiveCommandType.XPRATE_END);
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Notifications.Admin.XPRate.End.Self"));
|
||||||
if(sender instanceof Player)
|
|
||||||
{
|
|
||||||
senderName = ((Player) sender).getDisplayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
NotificationManager.sendAdminNotification(LocaleLoader.getString("XPRate.AdminDetails.End", senderName));
|
|
||||||
sender.sendMessage(LocaleLoader.getString("XPRate.End"));
|
|
||||||
|
|
||||||
mcMMO.p.toggleXpEventEnabled();
|
mcMMO.p.toggleXpEventEnabled();
|
||||||
}
|
}
|
||||||
@ -112,16 +106,9 @@ public class XprateCommand implements TabExecutor {
|
|||||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate));
|
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate));
|
||||||
}
|
}
|
||||||
|
|
||||||
String senderName = LocaleLoader.getString("Server.ConsoleName");
|
|
||||||
|
|
||||||
if(sender instanceof Player)
|
|
||||||
{
|
|
||||||
senderName = ((Player) sender).getDisplayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Admin notification
|
//Admin notification
|
||||||
NotificationManager.sendAdminNotification(LocaleLoader.getString("XPRate.AdminDetails.Start", senderName, newXpRate));
|
NotificationManager.processSensitiveCommandNotification(sender, SensitiveCommandType.XPRATE_MODIFY, String.valueOf(newXpRate));
|
||||||
sender.sendMessage(LocaleLoader.getString("XPRate.Modified", newXpRate));
|
sender.sendMessage(LocaleLoader.getString("Notifications.Admin.XPRate.Start.Self", newXpRate));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -570,4 +570,6 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
public boolean broadcastEventMessages() { return config.getBoolean("General.EventBroadcasts", true);}
|
public boolean broadcastEventMessages() { return config.getBoolean("General.EventBroadcasts", true);}
|
||||||
public boolean playerJoinEventInfo() { return config.getBoolean("General.EventInfoOnPlayerJoin", true);}
|
public boolean playerJoinEventInfo() { return config.getBoolean("General.EventInfoOnPlayerJoin", true);}
|
||||||
|
public boolean adminNotifications() { return config.getBoolean("General.AdminNotifications", true);}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.gmail.nossr50.datatypes.notifications;
|
||||||
|
|
||||||
|
public enum SensitiveCommandType {
|
||||||
|
XPRATE_MODIFY,
|
||||||
|
XPRATE_END,
|
||||||
|
MMOEDIT
|
||||||
|
}
|
@ -1,7 +1,9 @@
|
|||||||
package com.gmail.nossr50.util.player;
|
package com.gmail.nossr50.util.player;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||||
|
import com.gmail.nossr50.datatypes.notifications.SensitiveCommandType;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
@ -19,6 +21,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.SoundCategory;
|
import org.bukkit.SoundCategory;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class NotificationManager {
|
public class NotificationManager {
|
||||||
@ -163,7 +166,7 @@ public class NotificationManager {
|
|||||||
* Admins are currently players with either Operator status or Admin Chat permission
|
* Admins are currently players with either Operator status or Admin Chat permission
|
||||||
* @param msg message contents
|
* @param msg message contents
|
||||||
*/
|
*/
|
||||||
public static void sendAdminNotification(String msg) {
|
private static void sendAdminNotification(String msg) {
|
||||||
for(Player player : Bukkit.getServer().getOnlinePlayers())
|
for(Player player : Bukkit.getServer().getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if(player.isOp() || Permissions.adminChat(player))
|
if(player.isOp() || Permissions.adminChat(player))
|
||||||
@ -175,4 +178,36 @@ public class NotificationManager {
|
|||||||
//Copy it out to Console too
|
//Copy it out to Console too
|
||||||
mcMMO.p.getLogger().info(LocaleLoader.getString("Notifications.Admin", msg));
|
mcMMO.p.getLogger().info(LocaleLoader.getString("Notifications.Admin", msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method to report info about a command sender using a sensitive command
|
||||||
|
* @param commandSender the command user
|
||||||
|
* @param sensitiveCommandType type of command issued
|
||||||
|
*/
|
||||||
|
public static void processSensitiveCommandNotification(CommandSender commandSender, SensitiveCommandType sensitiveCommandType, String... args) {
|
||||||
|
//If its not enabled exit
|
||||||
|
if(!Config.getInstance().adminNotifications())
|
||||||
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Determine the 'identity' of the one who executed the command to pass as a parameters
|
||||||
|
*/
|
||||||
|
String senderName = LocaleLoader.getString("Server.ConsoleName");
|
||||||
|
|
||||||
|
if(commandSender instanceof Player)
|
||||||
|
{
|
||||||
|
senderName = ((Player) commandSender).getDisplayName();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Send the notification
|
||||||
|
switch(sensitiveCommandType)
|
||||||
|
{
|
||||||
|
case XPRATE_MODIFY:
|
||||||
|
sendAdminNotification(LocaleLoader.getString("Notifications.Admin.XPRate.Start.Others", senderName, args));
|
||||||
|
break;
|
||||||
|
case XPRATE_END:
|
||||||
|
sendAdminNotification(LocaleLoader.getString("Notifications.Admin.XPRate.End.Others", senderName, args));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ General:
|
|||||||
MOTD_Enabled: true
|
MOTD_Enabled: true
|
||||||
EventBroadcasts: true
|
EventBroadcasts: true
|
||||||
EventInfoOnPlayerJoin: true
|
EventInfoOnPlayerJoin: true
|
||||||
|
AdminNotifications: true
|
||||||
# Send a message to the player when his profile was successfully loaded
|
# Send a message to the player when his profile was successfully loaded
|
||||||
Show_Profile_Loaded: false
|
Show_Profile_Loaded: false
|
||||||
# Amount of time (in minutes) to wait between saves of player information
|
# Amount of time (in minutes) to wait between saves of player information
|
||||||
|
@ -826,13 +826,17 @@ Commands.Event.Stop.Subtitle=[[GREEN]]I hope you had fun!
|
|||||||
Commands.Event.XP=[[DARK_AQUA]]XP Rate is now [[GOLD]]{0}[[DARK_AQUA]]x
|
Commands.Event.XP=[[DARK_AQUA]]XP Rate is now [[GOLD]]{0}[[DARK_AQUA]]x
|
||||||
Commands.xprate.started.0=[[GOLD]]XP EVENT FOR mcMMO HAS STARTED!
|
Commands.xprate.started.0=[[GOLD]]XP EVENT FOR mcMMO HAS STARTED!
|
||||||
Commands.xprate.started.1=[[GOLD]]mcMMO XP RATE IS NOW {0}x!
|
Commands.xprate.started.1=[[GOLD]]mcMMO XP RATE IS NOW {0}x!
|
||||||
XPRate.Modified=[[GREEN]]You have set the XP rate to [[GOLD]]{0}[[GREEN]]x!
|
|
||||||
XPRate.End=[[GRAY]]You ended the XP rate event.
|
# Admin Notifications
|
||||||
XPRate.Event= [[GOLD]]mcMMO is currently in an XP rate event! XP rate is {0}x!
|
|
||||||
XPRate.AdminDetails.End=The user {0} [[GRAY]]has ended the XP rate event
|
|
||||||
XPRate.AdminDetails.Start=The user {0} [[GRAY]]has started an XP rate event of {1}x
|
|
||||||
Server.ConsoleName=[Server Console]
|
Server.ConsoleName=[Server Console]
|
||||||
Notifications.Admin=[[GOLD]]([[GREEN]]mcMMO [[DARK_AQUA]]Admin Notification[[GOLD]]) [[GRAY]]{0}
|
Notifications.Admin.XPRate.Start.Self=[[GREEN]]You have set the XP rate to [[GOLD]]{0}[[GREEN]]x!
|
||||||
|
Notifications.Admin.XPRate.End.Self=[[GRAY]]You ended the XP rate event.
|
||||||
|
Notifications.Admin.XPRate.End.Others=The user {0} [[GRAY]]has ended the XP rate event
|
||||||
|
Notifications.Admin.XPRate.Start.Others=The user {0} [[GRAY]]has started or modified an XP rate event with properties: {1}x
|
||||||
|
Notifications.Admin.Format=[[GOLD]]([[GREEN]]mcMMO [[DARK_AQUA]]Admin Notification[[GOLD]]) [[GRAY]]{0}
|
||||||
|
|
||||||
|
# Event
|
||||||
|
XPRate.Event=[[GOLD]]mcMMO is currently in an XP rate event! XP rate is {0}x!
|
||||||
|
|
||||||
#GUIDES
|
#GUIDES
|
||||||
Guides.Available=[[GRAY]]Guide for {0} available - type /{1} ? [page]
|
Guides.Available=[[GRAY]]Guide for {0} available - type /{1} ? [page]
|
||||||
|
Loading…
Reference in New Issue
Block a user