mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Confirmation messages for admin commands are now moved into the
convenience methods in NotificationManager
This commit is contained in:
parent
04c6bd8750
commit
1ced5d8ffc
@ -7,7 +7,8 @@ Version 2.1.62
|
|||||||
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 - '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.Format.Others' style formatting + prefix for admin notifications used in the other new strings below
|
||||||
|
New locale string - 'Notifications.Admin.Format.Self' style formatting + prefix for admin command confirmations send to the user who executed the command
|
||||||
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.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.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.Self' sent to the user who ended the XP rate event regardless of whether or not messages for the event are enabled
|
||||||
|
@ -54,7 +54,6 @@ public class XprateCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NotificationManager.processSensitiveCommandNotification(sender, SensitiveCommandType.XPRATE_END);
|
NotificationManager.processSensitiveCommandNotification(sender, SensitiveCommandType.XPRATE_END);
|
||||||
sender.sendMessage(LocaleLoader.getString("Notifications.Admin.XPRate.End.Self"));
|
|
||||||
|
|
||||||
mcMMO.p.toggleXpEventEnabled();
|
mcMMO.p.toggleXpEventEnabled();
|
||||||
}
|
}
|
||||||
@ -108,7 +107,6 @@ public class XprateCommand implements TabExecutor {
|
|||||||
|
|
||||||
//Admin notification
|
//Admin notification
|
||||||
NotificationManager.processSensitiveCommandNotification(sender, SensitiveCommandType.XPRATE_MODIFY, String.valueOf(newXpRate));
|
NotificationManager.processSensitiveCommandNotification(sender, SensitiveCommandType.XPRATE_MODIFY, String.valueOf(newXpRate));
|
||||||
sender.sendMessage(LocaleLoader.getString("Notifications.Admin.XPRate.Start.Self", newXpRate));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import com.gmail.nossr50.util.Permissions;
|
|||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
import com.gmail.nossr50.util.TextComponentFactory;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
import com.gmail.nossr50.util.player.NotificationManager;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
@ -268,21 +269,11 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
return LocaleLoader.getString(templateKey, LocaleLoader.getString(statDescriptionKey, vars));
|
return LocaleLoader.getString(templateKey, LocaleLoader.getString(statDescriptionKey, vars));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String[] mergedList = addItemToFirstPositionOfArray(LocaleLoader.getString(statDescriptionKey), vars);
|
String[] mergedList = NotificationManager.addItemToFirstPositionOfArray(LocaleLoader.getString(statDescriptionKey), vars);
|
||||||
return LocaleLoader.getString(templateKey, mergedList);
|
return LocaleLoader.getString(templateKey, mergedList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String[] addItemToFirstPositionOfArray(String itemToAdd, String... existingArray) {
|
|
||||||
String[] newArray = new String[existingArray.length + 1];
|
|
||||||
newArray[0] = itemToAdd;
|
|
||||||
|
|
||||||
System.arraycopy(existingArray, 0, newArray, 1, existingArray.length);
|
|
||||||
|
|
||||||
return newArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void dataCalculations(Player player, float skillValue);
|
protected abstract void dataCalculations(Player player, float skillValue);
|
||||||
|
|
||||||
protected abstract void permissionsCheck(Player player);
|
protected abstract void permissionsCheck(Player player);
|
||||||
|
@ -164,19 +164,28 @@ public class NotificationManager {
|
|||||||
/**
|
/**
|
||||||
* Sends a message to all admins with the admin notification formatting from the locale
|
* Sends a message to all admins with the admin notification formatting from the locale
|
||||||
* 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 fetched from locale
|
||||||
*/
|
*/
|
||||||
private 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))
|
||||||
{
|
{
|
||||||
player.sendMessage(LocaleLoader.getString("Notifications.Admin", msg));
|
player.sendMessage(LocaleLoader.getString("Notifications.Admin.Format.Others", msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//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.Format.Others", msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a confirmation message to the CommandSender who just executed an admin command
|
||||||
|
* @param commandSender target command sender
|
||||||
|
* @param msg message fetched from locale
|
||||||
|
*/
|
||||||
|
private static void sendAdminCommandConfirmation(CommandSender commandSender, String msg) {
|
||||||
|
commandSender.sendMessage(LocaleLoader.getString("Notifications.Admin.Format.Self", msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -203,11 +212,30 @@ public class NotificationManager {
|
|||||||
switch(sensitiveCommandType)
|
switch(sensitiveCommandType)
|
||||||
{
|
{
|
||||||
case XPRATE_MODIFY:
|
case XPRATE_MODIFY:
|
||||||
sendAdminNotification(LocaleLoader.getString("Notifications.Admin.XPRate.Start.Others", senderName, args));
|
sendAdminNotification(LocaleLoader.getString("Notifications.Admin.XPRate.Start.Others", addItemToFirstPositionOfArray(senderName, args)));
|
||||||
|
sendAdminCommandConfirmation(commandSender, LocaleLoader.getString("Notifications.Admin.XPRate.Start.Self", args));
|
||||||
break;
|
break;
|
||||||
case XPRATE_END:
|
case XPRATE_END:
|
||||||
sendAdminNotification(LocaleLoader.getString("Notifications.Admin.XPRate.End.Others", senderName, args));
|
sendAdminNotification(LocaleLoader.getString("Notifications.Admin.XPRate.End.Others", addItemToFirstPositionOfArray(senderName, args)));
|
||||||
|
sendAdminCommandConfirmation(commandSender, LocaleLoader.getString("Notifications.Admin.XPRate.End.Self", args));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes an array and an object, makes a new array with object in the first position of the new array,
|
||||||
|
* and the following elements in this new array being a copy of the existing array retaining their order
|
||||||
|
* @param itemToAdd the string to put at the beginning of the new array
|
||||||
|
* @param existingArray the existing array to be copied to the new array at position [0]+1 relative to their original index
|
||||||
|
* @return the new array combining itemToAdd at the start and existing array elements following while retaining their order
|
||||||
|
*/
|
||||||
|
public static String[] addItemToFirstPositionOfArray(String itemToAdd, String... existingArray) {
|
||||||
|
String[] newArray = new String[existingArray.length + 1];
|
||||||
|
newArray[0] = itemToAdd;
|
||||||
|
|
||||||
|
System.arraycopy(existingArray, 0, newArray, 1, existingArray.length);
|
||||||
|
|
||||||
|
return newArray;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -829,11 +829,12 @@ Commands.xprate.started.1=[[GOLD]]mcMMO XP RATE IS NOW {0}x!
|
|||||||
|
|
||||||
# Admin Notifications
|
# Admin Notifications
|
||||||
Server.ConsoleName=[Server Console]
|
Server.ConsoleName=[Server Console]
|
||||||
Notifications.Admin.XPRate.Start.Self=[[GREEN]]You have set the XP rate to [[GOLD]]{0}[[GREEN]]x!
|
Notifications.Admin.XPRate.Start.Self=[[GRAY]]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.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.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.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}
|
Notifications.Admin.Format.Others=[[GOLD]]([[GREEN]]mcMMO [[DARK_AQUA]]Admin Notification[[GOLD]]) [[GRAY]]{0}
|
||||||
|
Notifications.Admin.Format.Self=[[GOLD]]([[GREEN]]mcMMO [[DARK_RED]]Admin Command Executed[[GOLD]]) [[GRAY]]{0}
|
||||||
|
|
||||||
# Event
|
# Event
|
||||||
XPRate.Event=[[GOLD]]mcMMO is currently in an XP rate event! XP rate is {0}x!
|
XPRate.Event=[[GOLD]]mcMMO is currently in an XP rate event! XP rate is {0}x!
|
||||||
|
Loading…
Reference in New Issue
Block a user