mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-17 19:29:49 -04:00
Add event for reporting a player (Thanks SpicyCombo)
This commit is contained in:
parent
799cb97b47
commit
71f21ef010
@ -21,6 +21,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using MCGalaxy.DB;
|
||||
using MCGalaxy.Events;
|
||||
|
||||
namespace MCGalaxy.Commands.Moderation {
|
||||
public sealed class CmdReport : Command2 {
|
||||
@ -152,6 +153,10 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
p.Message("&aReport sent! It should be viewed when a {0} &ais online",
|
||||
checkPerms.Describe());
|
||||
|
||||
ModAction action = new ModAction(target, p, ModActionType.Reported, reason);
|
||||
OnModActionEvent.Call(action);
|
||||
if (!action.Announce) return;
|
||||
|
||||
string opsMsg = "λNICK &Sreported " + nick + "&S. Reason: " + reason;
|
||||
Chat.MessageFrom(ChatScope.Perms, p, opsMsg, checkPerms, null, true);
|
||||
string allMsg = "Use &T/Report check " + target + " &Sto see all of their reports";
|
||||
|
@ -17,11 +17,11 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.Events {
|
||||
|
||||
namespace MCGalaxy.Events
|
||||
{
|
||||
/// <summary> Represents a moderation action. </summary>
|
||||
public sealed class ModAction {
|
||||
|
||||
public sealed class ModAction
|
||||
{
|
||||
/// <summary> Target player name or IP. </summary>
|
||||
public string Target;
|
||||
|
||||
@ -86,8 +86,8 @@ namespace MCGalaxy.Events {
|
||||
public delegate void OnModAction(ModAction action);
|
||||
|
||||
/// <summary> Types of moderation actions that can occur. </summary>
|
||||
public enum ModActionType {
|
||||
|
||||
public enum ModActionType
|
||||
{
|
||||
/// <summary> Player was banned. </summary>
|
||||
Ban,
|
||||
/// <summary> Player was unbanned. </summary>
|
||||
@ -117,10 +117,13 @@ namespace MCGalaxy.Events {
|
||||
Rank,
|
||||
/// <summary> Player was kicked from the server. </summary>
|
||||
Kicked,
|
||||
/// <summary> Player was reported </summary>
|
||||
Reported,
|
||||
}
|
||||
|
||||
/// <summary> Raised when a moderation action occurs. </summary>
|
||||
public sealed class OnModActionEvent : IEvent<OnModAction> {
|
||||
public sealed class OnModActionEvent : IEvent<OnModAction>
|
||||
{
|
||||
public static void Call(ModAction e) {
|
||||
if (handlers.Count == 0) return;
|
||||
CallCommon(pl => pl(e));
|
||||
|
@ -20,12 +20,12 @@ using System.Collections.Generic;
|
||||
using System.Net.Sockets;
|
||||
using MCGalaxy.Network;
|
||||
|
||||
namespace MCGalaxy.Events.ServerEvents {
|
||||
|
||||
namespace MCGalaxy.Events.ServerEvents
|
||||
{
|
||||
public delegate void OnSendingHeartbeat(Heartbeat service, ref string name);
|
||||
/// <summary> Called when a heartbeat is being sent out. </summary>
|
||||
public sealed class OnSendingHeartbeatEvent : IEvent<OnSendingHeartbeat> {
|
||||
|
||||
public sealed class OnSendingHeartbeatEvent : IEvent<OnSendingHeartbeat>
|
||||
{
|
||||
public static void Call(Heartbeat service, ref string name) {
|
||||
IEvent<OnSendingHeartbeat>[] items = handlers.Items;
|
||||
// Can't use CallCommon because we need to pass arguments by ref
|
||||
@ -38,8 +38,8 @@ namespace MCGalaxy.Events.ServerEvents {
|
||||
|
||||
public delegate void OnShuttingDown(bool restarting, string reason);
|
||||
/// <summary> Called when the server is shutting down or restarting. </summary>
|
||||
public sealed class OnShuttingDownEvent : IEvent<OnShuttingDown> {
|
||||
|
||||
public sealed class OnShuttingDownEvent : IEvent<OnShuttingDown>
|
||||
{
|
||||
public static void Call(bool restarting, string reason) {
|
||||
if (handlers.Count == 0) return;
|
||||
CallCommon(pl => pl(restarting, reason));
|
||||
@ -48,8 +48,8 @@ namespace MCGalaxy.Events.ServerEvents {
|
||||
|
||||
public delegate void OnConfigUpdated();
|
||||
/// <summary> Called when the server configuration has been updated. </summary>
|
||||
public sealed class OnConfigUpdatedEvent : IEvent<OnConfigUpdated> {
|
||||
|
||||
public sealed class OnConfigUpdatedEvent : IEvent<OnConfigUpdated>
|
||||
{
|
||||
public static void Call() {
|
||||
if (handlers.Count == 0) return;
|
||||
CallCommon(pl => pl());
|
||||
@ -58,8 +58,8 @@ namespace MCGalaxy.Events.ServerEvents {
|
||||
|
||||
public delegate void OnConnectionReceived(Socket s, ref bool cancel);
|
||||
/// <summary> Called when a new connection has been received. </summary>
|
||||
public sealed class OnConnectionReceivedEvent : IEvent<OnConnectionReceived> {
|
||||
|
||||
public sealed class OnConnectionReceivedEvent : IEvent<OnConnectionReceived>
|
||||
{
|
||||
public static void Call(Socket s, ref bool cancel) {
|
||||
IEvent<OnConnectionReceived>[] items = handlers.Items;
|
||||
// Can't use CallCommon because we need to pass arguments by ref
|
||||
@ -72,8 +72,8 @@ namespace MCGalaxy.Events.ServerEvents {
|
||||
|
||||
public delegate void OnChatSys(ChatScope scope, string msg, object arg,
|
||||
ref ChatMessageFilter filter, bool relay);
|
||||
public sealed class OnChatSysEvent : IEvent<OnChatSys> {
|
||||
|
||||
public sealed class OnChatSysEvent : IEvent<OnChatSys>
|
||||
{
|
||||
public static void Call(ChatScope scope, string msg, object arg,
|
||||
ref ChatMessageFilter filter, bool relay) {
|
||||
IEvent<OnChatSys>[] items = handlers.Items;
|
||||
@ -86,8 +86,8 @@ namespace MCGalaxy.Events.ServerEvents {
|
||||
|
||||
public delegate void OnChatFrom(ChatScope scope, Player source, string msg,
|
||||
object arg, ref ChatMessageFilter filter, bool relay);
|
||||
public sealed class OnChatFromEvent : IEvent<OnChatFrom> {
|
||||
|
||||
public sealed class OnChatFromEvent : IEvent<OnChatFrom>
|
||||
{
|
||||
public static void Call(ChatScope scope,Player source, string msg,
|
||||
object arg, ref ChatMessageFilter filter, bool relay) {
|
||||
IEvent<OnChatFrom>[] items = handlers.Items;
|
||||
@ -100,8 +100,8 @@ namespace MCGalaxy.Events.ServerEvents {
|
||||
|
||||
public delegate void OnChat(ChatScope scope, Player source, string msg,
|
||||
object arg, ref ChatMessageFilter filter, bool relay);
|
||||
public sealed class OnChatEvent : IEvent<OnChat> {
|
||||
|
||||
public sealed class OnChatEvent : IEvent<OnChat>
|
||||
{
|
||||
public static void Call(ChatScope scope, Player source, string msg,
|
||||
object arg, ref ChatMessageFilter filter, bool relay) {
|
||||
IEvent<OnChat>[] items = handlers.Items;
|
||||
@ -114,8 +114,8 @@ namespace MCGalaxy.Events.ServerEvents {
|
||||
|
||||
public delegate void OnPluginMessageReceived(Player p, byte channel, byte[] data);
|
||||
/// <summary> Called when a player sends a PluginMessage CPE packet to the server. </summary>
|
||||
public sealed class OnPluginMessageReceivedEvent : IEvent<OnPluginMessageReceived> {
|
||||
|
||||
public sealed class OnPluginMessageReceivedEvent : IEvent<OnPluginMessageReceived>
|
||||
{
|
||||
public static void Call(Player p, byte channel, byte[] data) {
|
||||
if (handlers.Count == 0) return;
|
||||
CallCommon(pl => pl(p, channel, data));
|
||||
|
@ -75,7 +75,7 @@ namespace MCGalaxy.Generator
|
||||
{
|
||||
if (grassY > 0)
|
||||
MapSet(lvl.Width, lvl.Length, ptr, 0, grassY - 1, Block.Dirt);
|
||||
if (grassY < lvl.Height)
|
||||
if (grassY >= 0 && grassY < lvl.Height)
|
||||
MapSet(lvl.Width, lvl.Length, ptr, grassY, grassY, Block.Grass);
|
||||
}
|
||||
return true;
|
||||
|
@ -108,7 +108,7 @@ namespace MCGalaxy.Modules.Relay.Discord
|
||||
}
|
||||
|
||||
public override void Close() {
|
||||
Server.Hearbeats.Cancel(heartbeat);
|
||||
Server.Heartbeats.Cancel(heartbeat);
|
||||
try {
|
||||
client.Close();
|
||||
} catch {
|
||||
@ -182,7 +182,7 @@ namespace MCGalaxy.Modules.Relay.Discord
|
||||
string interval = (string)data["heartbeat_interval"];
|
||||
int msInterval = int.Parse(interval);
|
||||
|
||||
heartbeat = Server.Hearbeats.QueueRepeat(SendHeartbeat, null,
|
||||
heartbeat = Server.Heartbeats.QueueRepeat(SendHeartbeat, null,
|
||||
TimeSpan.FromMilliseconds(msInterval));
|
||||
Identify();
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ namespace MCGalaxy.Network
|
||||
/// <summary> Starts pumping heartbeats </summary>
|
||||
public static void Start() {
|
||||
OnBeat(null); // immedately call so URL is shown as soon as possible in console
|
||||
Server.Hearbeats.QueueRepeat(OnBeat, null, TimeSpan.FromSeconds(30));
|
||||
Server.Heartbeats.QueueRepeat(OnBeat, null, TimeSpan.FromSeconds(30));
|
||||
}
|
||||
|
||||
static void OnBeat(SchedulerTask task) {
|
||||
|
@ -82,7 +82,7 @@ namespace MCGalaxy {
|
||||
public static Scheduler MainScheduler = new Scheduler("MCG_MainScheduler");
|
||||
public static Scheduler Background = new Scheduler("MCG_BackgroundScheduler");
|
||||
public static Scheduler Critical = new Scheduler("MCG_CriticalScheduler");
|
||||
public static Scheduler Hearbeats = new Scheduler("MCG_HeartbeatsScheduler");
|
||||
public static Scheduler Heartbeats = new Scheduler("MCG_HeartbeatsScheduler");
|
||||
public static Server s = new Server();
|
||||
|
||||
public const byte VERSION_0016 = 3; // classic 0.0.16
|
||||
|
Loading…
x
Reference in New Issue
Block a user