Skip to content

Commit

Permalink
Move NotesPlugin into Modules folder
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Jul 25, 2021
1 parent 92d6272 commit 6ccf8c6
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 29 deletions.
2 changes: 0 additions & 2 deletions MCGalaxy/Commands/EntityPropertyCmd.cs
Expand Up @@ -79,7 +79,5 @@ public abstract class EntityPropertyCmd : Command2 {
protected virtual void SetBotData(Player p, PlayerBot bot, string args) { }
protected virtual void SetOnlineData(Player p, Player who, string args) { }
protected virtual void SetPlayerData(Player p, string target, string args) { }


}
}
6 changes: 4 additions & 2 deletions MCGalaxy/MCGalaxy_.csproj
Expand Up @@ -294,7 +294,6 @@
<Compile Include="Commands\Moderation\CmdModerate.cs" />
<Compile Include="Commands\Moderation\CmdMoveAll.cs" />
<Compile Include="Commands\Moderation\CmdMute.cs" />
<Compile Include="Commands\Moderation\CmdNotes.cs" />
<Compile Include="Commands\Moderation\CmdOhide.cs" />
<Compile Include="Commands\Moderation\CmdP2P.cs" />
<Compile Include="Commands\Moderation\CmdPass.cs" />
Expand Down Expand Up @@ -388,7 +387,6 @@
<Compile Include="CorePlugin\IPThrottler.cs" />
<Compile Include="CorePlugin\MiscHandlers.cs" />
<Compile Include="CorePlugin\ModActionHandler.cs" />
<Compile Include="CorePlugin\NotesPlugin.cs" />
<Compile Include="Database\Backends\SQLite.cs" />
<Compile Include="Database\Backends\SQLiteBackend.cs" />
<Compile Include="Database\BlockDB\BlockDB.cs" />
Expand Down Expand Up @@ -586,6 +584,8 @@
<Compile Include="Blocks\Physics\TntPhysics.cs" />
<Compile Include="Blocks\Physics\ZombiePhysics.cs" />
<Compile Include="Levels\Zone.cs" />
<Compile Include="Modules\Moderation\Notes\CmdNotes.cs" />
<Compile Include="Modules\Moderation\Notes\NotesPlugin.cs" />
<Compile Include="Modules\Relay\BotControllersCmd.cs" />
<Compile Include="Modules\Relay\Discord\DiscordApiClient.cs" />
<Compile Include="Modules\Relay\Discord\DiscordBot.cs" />
Expand Down Expand Up @@ -731,6 +731,8 @@
<Folder Include="Generator\LibNoise" />
<Folder Include="Generator\Classic" />
<Folder Include="Generator\Realistic" />
<Folder Include="Modules\Moderation" />
<Folder Include="Modules\Moderation\Notes" />
<Folder Include="Modules\Relay\Discord" />
<Folder Include="Modules\Relay" />
<Folder Include="Network\Heartbeat" />
Expand Down
Expand Up @@ -17,9 +17,12 @@
*/
using System;
using System.Collections.Generic;
using MCGalaxy.Commands;

namespace MCGalaxy.Commands.Moderation {
public class CmdNotes : Command2 {
namespace MCGalaxy.Modules.Moderation.Notes
{
public class CmdNotes : Command2
{
public override string name { get { return "Notes"; } }
public override string type { get { return CommandTypes.Moderation; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
Expand Down Expand Up @@ -76,7 +79,8 @@ public class CmdNotes : Command2 {
}
}

public sealed class CmdMyNotes : CmdNotes {
public sealed class CmdMyNotes : CmdNotes
{
public override string name { get { return "MyNotes"; } }
public override string type { get { return CommandTypes.Other; } }
public override bool SuperUseable { get { return false; } }
Expand Down
Expand Up @@ -18,9 +18,10 @@
using System;
using MCGalaxy.Events;

namespace MCGalaxy.Core {

public sealed class NotesPlugin : Plugin {
namespace MCGalaxy.Modules.Moderation.Notes
{
public sealed class NotesPlugin : Plugin
{
public override string creator { get { return Server.SoftwareName + " team"; } }
public override string MCGalaxy_Version { get { return Server.Version; } }
public override string name { get { return "Core_NotesPlugin"; } }
Expand Down
16 changes: 9 additions & 7 deletions MCGalaxy/Modules/Relay/Discord/DiscordBot.cs
Expand Up @@ -26,9 +26,10 @@
using MCGalaxy.Events.ServerEvents;
using MCGalaxy.Util;

namespace MCGalaxy.Modules.Relay.Discord {

public sealed class DiscordBot : RelayBot {
namespace MCGalaxy.Modules.Relay.Discord
{
public sealed class DiscordBot : RelayBot
{
DiscordApiClient api;
DiscordWebsocket socket;
string botUserID;
Expand Down Expand Up @@ -232,7 +233,7 @@ public sealed class DiscordBot : RelayBot {
}

void UpdateDiscordStatus() {
try { socket.SendUpdateStatus(); } catch { }
try { socket.UpdateStatus(); } catch { }
}


Expand Down Expand Up @@ -284,11 +285,11 @@ public sealed class DiscordBot : RelayBot {
static readonly string[] markdown_special = { @"\", @"*", @"_", @"~", @"`", @"|" };
static readonly string[] markdown_escaped = { @"\\", @"\*", @"\_", @"\~", @"\`", @"\|" };
static string StripMarkdown(string message) {
// don't let user use bold/italic etc markdown
// don't let user use bold/italic etc markdown
for (int i = 0; i < markdown_special.Length; i++) {
message = message.Replace(markdown_special[i], markdown_escaped[i]);
}
return message;
return message;
}

protected override string PrepareMessage(string message) {
Expand Down Expand Up @@ -332,10 +333,11 @@ public sealed class DiscordBot : RelayBot {
ChannelSendEmbed embed = new ChannelSendEmbed(p.ChannelID);
int total;
List<OnlineListEntry> entries = PlayerInfo.GetOnlineList(p, p.Rank, out total);
embed.Color = Config.EmbedColor;

embed.Color = Config.EmbedColor;
embed.Title = string.Format("{0} player{1} currently online",
total, total.Plural());

foreach (OnlineListEntry e in entries) {
if (e.players.Count == 0) continue;

Expand Down
29 changes: 17 additions & 12 deletions MCGalaxy/Modules/Relay/Discord/DiscordWebsocket.cs
Expand Up @@ -25,13 +25,13 @@
using MCGalaxy.Network;
using MCGalaxy.Tasks;

namespace MCGalaxy.Modules.Relay.Discord {

namespace MCGalaxy.Modules.Relay.Discord
{
/// <summary> Implements a basic websocket for communicating with Discord's gateway </summary>
/// <remarks> https://discord.com/developers/docs/topics/gateway </remarks>
/// <remarks> https://i.imgur.com/Lwc5Wde.png </remarks>
public sealed class DiscordWebsocket : ClientWebSocket {

public sealed class DiscordWebsocket : ClientWebSocket
{
/// <summary> Authorisation token for the bot account </summary>
public string Token;
public bool CanReconnect = true;
Expand Down Expand Up @@ -154,7 +154,7 @@ public sealed class DiscordWebsocket : ClientWebSocket {

heartbeat = Server.Background.QueueRepeat(SendHeartbeat, null,
TimeSpan.FromMilliseconds(msInterval));
SendIdentify();
Identify();
}

void HandleDispatch(JsonObject obj) {
Expand Down Expand Up @@ -219,7 +219,17 @@ public sealed class DiscordWebsocket : ClientWebSocket {
const int INTENT_GUILD_MESSAGES = 1 << 9;
const int INTENT_DIRECT_MESSAGES = 1 << 12;

public void SendIdentify() {
public void Identify() {
JsonObject data = MakeIdentify();
SendMessage(OPCODE_IDENTIFY, data);
}

public void UpdateStatus() {
JsonObject data = MakePresence();
SendMessage(OPCODE_STATUS_UPDATE, data);
}

JsonObject MakeIdentify() {
JsonObject props = new JsonObject()
{
{ "$os", "linux" },
Expand All @@ -234,12 +244,7 @@ public sealed class DiscordWebsocket : ClientWebSocket {
{ "properties", props },
{ "presence", MakePresence() }
};
SendMessage(OPCODE_IDENTIFY, data);
}

public void SendUpdateStatus() {
JsonObject data = MakePresence();
SendMessage(OPCODE_STATUS_UPDATE, data);
return data;
}

JsonObject MakePresence() {
Expand Down
1 change: 1 addition & 0 deletions MCGalaxy/Scripting/Plugin.cs
Expand Up @@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
using MCGalaxy.Core;
using MCGalaxy.Modules.Moderation.Notes;
using MCGalaxy.Modules.Relay.Discord;
using MCGalaxy.Modules.Relay.IRC;
using MCGalaxy.Scripting;
Expand Down

0 comments on commit 6ccf8c6

Please sign in to comment.