Cleanup /freeze and /trust.

This commit is contained in:
UnknownShadow200 2016-03-15 13:58:15 +11:00
parent da36623a53
commit 290189d3c4
11 changed files with 80 additions and 45 deletions

View File

@ -40,7 +40,7 @@ namespace MCGalaxy.Commands
Player.SendMessage(p, who.color + who.name + " %S(" + who.DisplayName + ") %Sis on &b" + who.level.name);
Player.SendMessage(p, who.FullName + Server.DefaultColor + " %Shas :");
Player.SendMessage(p, "> > the rank of " + who.group.color + who.group.name);
if (Economy.Settings.Enabled))
if (Economy.Settings.Enabled)
Player.SendMessage(p, "> > &a" + who.money + Server.DefaultColor + " " + Server.moneys);
Player.SendMessage(p, "> > &cdied &a" + who.overallDeath + Server.DefaultColor + " times");

View File

@ -67,10 +67,10 @@ namespace MCGalaxy.Commands {
Player.GlobalMessage(banMsg);
} else {
if (stealth) {
banMsg = who.FullName + " %Swas STEALTH &8banned %Sby " + banner + "%S." + banReason;
banMsg = who.ColoredName + " %Swas STEALTH &8banned %Sby " + banner + "%S." + banReason;
Chat.GlobalMessageOps(banMsg);
} else {
banMsg = who.FullName + " %Swas &8banned %Sby " + banner + "%S." + banReason;
banMsg = who.ColoredName + " %Swas &8banned %Sby " + banner + "%S." + banReason;
Player.GlobalMessage(banMsg);
}

View File

@ -26,30 +26,27 @@ namespace MCGalaxy.Commands
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public CmdFreeze() { }
public override void Use(Player p, string message)
{
public override void Use(Player p, string message) {
if (message == "") { Help(p); return; }
Player who = PlayerInfo.Find(message);
if (who == null) { Player.SendMessage(p, "Could not find player."); return; }
else if (who == p) { Player.SendMessage(p, "Cannot freeze yourself."); return; }
else if (p != null) { if (who.group.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot freeze someone of equal or greater rank."); return; } }
string frozenby = (p == null) ? "<CONSOLE>" : p.color + p.DisplayName;
if (!who.frozen)
{
who.frozen = true;
Player.SendChatFrom(who, who.color + who.DisplayName + Server.DefaultColor + " has been &bfrozen" + Server.DefaultColor + " by " + frozenby + Server.DefaultColor + ".", false);
Server.s.Log(who.name + " has been frozen by " + frozenby);
Player who = PlayerInfo.FindOrShowMatches(message);
if (who == null) return;
if (p == who) { Player.SendMessage(p, "Cannot freeze yourself."); return; }
if (p != nul && who.group.Permission >= p.group.Permission) {
Player.SendMessage(p, "Cannot freeze someone of equal or greater rank."); return;
}
else
{
who.frozen = false;
Player.SendChatFrom(who, who.color + who.DisplayName + Server.DefaultColor + " has been &adefrosted" + Server.DefaultColor + " by " + frozenby + Server.DefaultColor + ".", false);
string frozenby = (p == null) ? "(console)" : p.ColoredName;
if (!who.frozen) {
Player.SendChatFrom(who, who.ColoredName + " %Shas been &bfrozen %Sby " + frozenby + "%S.", false);
Server.s.Log(who.name + " has been frozen by " + frozenby);
} else {
Player.SendChatFrom(who, who.ColoredName + " %Shas been &adefrosted %Sby " + frozenby + "%S.", false);
Server.s.Log(who.name + " has been defrosted by " + frozenby);
}
who.frozen = !who.frozen;
}
public override void Help(Player p)
{
public override void Help(Player p) {
Player.SendMessage(p, "/freeze <name> - Stops <name> from moving until unfrozen.");
}
}

View File

@ -26,25 +26,17 @@ namespace MCGalaxy.Commands
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public CmdTrust() { }
public override void Use(Player p, string message)
{
public override void Use(Player p, string message) {
if (message == "" || message.IndexOf(' ') != -1) { Help(p); return; }
Player who = PlayerInfo.Find(message);
if (who == null)
{
Player.SendMessage(p, "Could not find player specified");
return;
}
else
{
who.ignoreGrief = !who.ignoreGrief;
Player.SendMessage(p, who.color + who.DisplayName + Server.DefaultColor + "'s trust status: " + who.ignoreGrief);
who.SendMessage("Your trust status was changed to: " + who.ignoreGrief);
}
Player who = PlayerInfo.FindOrShowMatches(p, message);
if (who == null) return;
who.ignoreGrief = !who.ignoreGrief;
Player.SendMessage(p, who.ColoredName + "%S's trust status: " + who.ignoreGrief);
who.SendMessage("Your trust status was changed to: " + who.ignoreGrief);
}
public override void Help(Player p)
{
public override void Help(Player p) {
Player.SendMessage(p, "/trust <name> - Turns off the anti-grief for <name>");
}
}

View File

@ -37,10 +37,10 @@ namespace MCGalaxy.Commands
}
if (grp.Permission == LevelPermission.Banned) {
string banner = p == null ? "console" : p.color + p.DisplayName;
Player.GlobalMessage(who.FullName + " %Swas &8banned" + " %Sby " + banner + "%S.");
string banner = p == null ? "console" : p.FullName;
Player.GlobalMessage(who.ColoredName + " %Swas &8banned %Sby " + banner + "%S.");
} else {
Player.GlobalMessage(who.color + who.DisplayName + "%S's rank was set to " +
Player.GlobalMessage(who.ColoredName + "%S's rank was set to " +
grp.color + grp.name + "%S. (Congratulations!)");
who.SendMessage("You are now ranked " + grp.color + grp.name + "%S, type /help for your new set of commands.");
}

43
Economy/Item.cs Normal file
View File

@ -0,0 +1,43 @@
/*
Copyright 2015 MCGalaxy
Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at
http://www.opensource.org/licenses/ecl2.php
http://www.gnu.org/licenses/gpl-3.0.html
Unless required by applicable law or agreed to in writing,
software distributed under the Licenses are distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
using System;
using System.IO;
namespace MCGalaxy {
/// <summary> An abstract object that can be bought in the economy. (e.g. a rank, title, levels, etc) </summary>
public abstract class Item {
/// <summary> Simple name for this item. </summary>
public abstract string Name { get; }
/// <summary> Other common names for this item. </summary>
public abstract string[] Aliases { get; }
/// <summary> Whether this item can currently be bought in the economy. </summary>
public bool Enabled { get; set; }
/// <summary> Reads the properties of this item from the economy.properties file. </summary>
public abstract void Parse(StreamReader reader);
/// <summary> Writes the properties of this item to the economy.properties file. </summary>
public virtual void Serialise(StreamWriter writer) {
writer.WriteLine(Name + ":enabled:" + Enabled);
}
}
}

View File

@ -35,8 +35,7 @@ namespace MCGalaxy {
p.SendMessage("You are pillaring! Stop before you get kicked!");
}
if (p.blocksStacked == 4 ) {
p.Kick(" No pillaring allowed!");
return true;
p.Kick("No pillaring allowed!"); return true;
}
}
p.lastXblock = x; p.lastYblock = y; p.lastZblock = z;

View File

@ -411,6 +411,9 @@
<Compile Include="Drawing\DrawOps\TorusDrawOp.cs" />
<Compile Include="Drawing\DrawOps\WriteDrawOp.cs" />
<Compile Include="Drawing\Vector3U16.cs" />
<Compile Include="Economy\Awards.cs" />
<Compile Include="Economy\Economy.cs" />
<Compile Include="Economy\Item.cs" />
<Compile Include="Games\Countdown\CountdownGame.cs" />
<Compile Include="Games\Countdown\CountdownGame.Game.cs" />
<Compile Include="Games\Countdown\CountdownMapGen.cs" />
@ -522,10 +525,8 @@
<Compile Include="GUI\Win32\RECT.cs" />
<Compile Include="Database\DatabaseTransactionHelper.cs" />
<Compile Include="Database\Database.cs" />
<Compile Include="Server\Extra\Awards.cs" />
<Compile Include="Games\CTF\Auto_CTF.cs" />
<Compile Include="IRC\GlobalChatBot.cs" />
<Compile Include="Server\Extra\Economy.cs" />
<Compile Include="IRC\ForgeBot.cs" />
<Compile Include="GUI\EditText.cs">
<SubType>Form</SubType>
@ -729,6 +730,7 @@
<Folder Include="Levels\IO" />
<Folder Include="Levels\Generator" />
<Folder Include="Levels\Physics" />
<Folder Include="Economy" />
<Folder Include="Player\Group" />
<Folder Include="Player\Undo" />
<Folder Include="Plugins" />

View File

@ -106,6 +106,8 @@ namespace MCGalaxy {
public bool hackrank;
public string FullName { get { return color + prefix + DisplayName; } }
public string ColoredName { get { return color + DisplayName; } }
//Gc checks
public string lastmsg = "";