public static void alertAdmins(Player offender, AlertType type, Object o) { if (!Config.getBoolean("Notify.Admins")) return; PermMan perm = NoItem.getPermsManager(); String msg = ChatColor.RED + "[NI]" + ChatColor.BLUE + parseAdminMessage(offender, type, o); for (Player p : Bukkit.getOnlinePlayers()) { if (perm.has(p, Perm.ADMIN)) p.sendMessage(msg); } }
/** * Parse admin message in specific. * * @param offender * @param type * @param o * @return */ private static String parseAdminMessage(Player offender, AlertType type, Object o) { String msg = Config.getString("Messages.Admin"); msg = msg.replace("%t", type.name().toLowerCase().replace("_", " ")); msg = parseMsg(offender, msg, o); return msg; }
public enum AlertType { CRAFT(Config.getBoolean("Notify.Craft"), Config.getString("Messages.Craft")), BREW(Config.getBoolean("Notify.Brew"), Config.getString("Messages.Brew")), WEAR(Config.getBoolean("Notify.Wear"), Config.getString("Messages.Wear")), PICK_UP(Config.getBoolean("Notify.Pickup"), Config.getString("Messages.Pickup")), DROP(Config.getBoolean("Notify.Drop"), Config.getString("Messages.Drop")), INTERACT(Config.getBoolean("Notify.Interact"), Config.getString("Messages.Interact")), HOLD(Config.getBoolean("Notify.Hold"), Config.getString("Messages.Hold")), COOK(Config.getBoolean("Notify.Cook"), Config.getString("Messages.Cook")), BREAK(Config.getBoolean("Notify.Break"), Config.getString("Messages.Break")), PLACE(Config.getBoolean("Notify.Place"), Config.getString("Messages.Place")), OPEN(Config.getBoolean("Notify.Open"), Config.getString("Messages.Open")), HAVE(Config.getBoolean("Notify.Have"), Config.getString("Messages.Have")), ENCHANT(Config.getBoolean("Notify.Enchant"), Config.getString("Messages.Enchant")), USE(Config.getBoolean("Notify.Use"), Config.getString("Messages.Use")); public final boolean notify; public final String message; private AlertType(Boolean notify, String msg) { this.notify = notify; this.message = msg; } }