mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-28 16:07:07 -04:00
Fix being able to unmute yourself and a NullReferenceException being thrown when no online player matches the given name. Also /tree should not overwrite existing blocks. (Thanks goodlyay) Closes #122
This commit is contained in:
parent
15d9aab358
commit
dc9b1b4ca1
@ -18,11 +18,6 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
namespace MCGalaxy.Commands
|
namespace MCGalaxy.Commands
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Bug:
|
|
||||||
/// Doesn't save mute.txt
|
|
||||||
/// Players with the defaultRank can unmute themself
|
|
||||||
/// </summary>
|
|
||||||
public sealed class CmdMute : Command
|
public sealed class CmdMute : Command
|
||||||
{
|
{
|
||||||
public override string name { get { return "mute"; } }
|
public override string name { get { return "mute"; } }
|
||||||
@ -35,51 +30,29 @@ namespace MCGalaxy.Commands
|
|||||||
public override void Use(Player p, string message)
|
public override void Use(Player p, string message)
|
||||||
{
|
{
|
||||||
if (message == "" || message.Split(' ').Length > 2) { Help(p); return; }
|
if (message == "" || message.Split(' ').Length > 2) { Help(p); return; }
|
||||||
Player who = PlayerInfo.Find(message);
|
Player who = PlayerInfo.FindOrShowMatches(p, message);
|
||||||
|
if (who == null) {
|
||||||
if (who == null)
|
if (Server.muted.Contains(message)) {
|
||||||
{
|
|
||||||
if (Server.muted.Contains(message))
|
|
||||||
{
|
|
||||||
Server.muted.Remove(message);
|
Server.muted.Remove(message);
|
||||||
Player.GlobalMessage(message + Server.DefaultColor + " is not online but is now &bun-muted");
|
Player.GlobalMessage(message + Server.DefaultColor + " is not online but is now &bun-muted");
|
||||||
Extensions.DeleteLineWord("ranks/muted.txt", who.name.ToLower());
|
Extensions.DeleteLineWord("ranks/muted.txt", who.name.ToLower());
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (who == p)
|
|
||||||
{
|
|
||||||
if (p.muted)
|
|
||||||
{
|
|
||||||
p.muted = false;
|
|
||||||
Player.SendMessage(p, "You &bun-muted" + Server.DefaultColor + " yourself!");
|
|
||||||
Extensions.DeleteLineWord("ranks/muted.txt", p.name.ToLower());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Player.SendMessage(p, "You cannot mute yourself!");
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (who.muted)
|
if (who == p) { Player.SendMessage(p, "You cannot mute or unmute yourself."); return; }
|
||||||
{
|
|
||||||
|
if (who.muted) {
|
||||||
who.muted = false;
|
who.muted = false;
|
||||||
Player.SendChatFrom(who, who.color + who.DisplayName + Server.DefaultColor + " has been &bun-muted", false);
|
Player.SendChatFrom(who, who.color + who.DisplayName + " %Shas been &bun-muted", false);
|
||||||
Extensions.DeleteLineWord("ranks/muted.txt", who.name.ToLower());
|
Extensions.DeleteLineWord("ranks/muted.txt", who.name.ToLower());
|
||||||
}
|
} else {
|
||||||
else
|
if (p != null && who.group.Permission >= p.group.Permission) {
|
||||||
{
|
Player.SendMessage(p, "Cannot mute someone of a higher or equal rank."); return;
|
||||||
if (p != null)
|
|
||||||
{
|
|
||||||
if (who != p) if (who.group.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot mute someone of a higher or equal rank."); return; }
|
|
||||||
}
|
}
|
||||||
who.muted = true;
|
who.muted = true;
|
||||||
Player.SendChatFrom(who, who.color + who.DisplayName + Server.DefaultColor + " has been &8muted", false);
|
Player.SendChatFrom(who, who.color + who.DisplayName + " %Shas been &8muted", false);
|
||||||
using (StreamWriter writer = new StreamWriter("ranks/muted.txt", true))
|
using (StreamWriter writer = new StreamWriter("ranks/muted.txt", true)) {
|
||||||
{
|
|
||||||
writer.WriteLine(who.name.ToLower());
|
writer.WriteLine(who.name.ToLower());
|
||||||
}
|
}
|
||||||
Server.s.Log("SAVED: ranks/muted.txt");
|
Server.s.Log("SAVED: ranks/muted.txt");
|
||||||
|
@ -64,7 +64,6 @@ namespace MCGalaxy.Commands {
|
|||||||
TreeDrawOp op = new TreeDrawOp();
|
TreeDrawOp op = new TreeDrawOp();
|
||||||
op.Type = cpos.mode;
|
op.Type = cpos.mode;
|
||||||
op.random = p.random;
|
op.random = p.random;
|
||||||
op.overwrite = true;
|
|
||||||
Brush brush = null;
|
Brush brush = null;
|
||||||
|
|
||||||
if (cpos.brushMsg != "") {
|
if (cpos.brushMsg != "") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user