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