Merge pull request #201 from Goodlyay/master

Change perms, 8ball and bot nick.
This commit is contained in:
UnknownShadow200 2016-07-23 20:54:14 +10:00 committed by GitHub
commit 621922cece
5 changed files with 37 additions and 20 deletions

View File

@ -62,6 +62,7 @@ namespace MCGalaxy.Commands {
pBot.DisplayName = pBot.name;
Player.GlobalMessage("Bot " + pBot.ColoredName + "'s %Sreverted to their original name.");
} else {
if (newName.ToLower() == "empty") { newName = ""; }
if (newName.Length >= 30) { Player.Message(p, "Name must be under 30 letters."); return; }
Player.GlobalMessage("Bot " + pBot.ColoredName + "'s %Sname was set to " + newName + "%S.");
pBot.DisplayName = newName;
@ -94,6 +95,7 @@ namespace MCGalaxy.Commands {
Player.Message(p, "%HIf no [nick] is given, reverts player's nick to their original name.");
Player.Message(p, "%T/nick bot [bot] [name]");
Player.Message(p, "%HSets the name shown above that bot in game.");
Player.Message(p, "%HIf bot's [name] is \"empty\", then bots name becomes blank.");
}
}
}

View File

@ -16,38 +16,51 @@
permissions and limitations under the Licenses.
*/
using System;
using System.Threading;
using System.Text;
namespace MCGalaxy.Commands {
public sealed class Cmd8Ball : Command {
private static bool canUse = true;
public override string name { get { return "8ball"; } }
public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Chat; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
public Cmd8Ball() { }
static string[] answers = { "Not likely." , "Very likely." , "Impossible!" , "Probably." , "Ask again later." , "No." , "Maybe." };
DateTime nextUse;
string[] messages = { "Not likely." , "Very likely." , "Impossible!" , "No." , "Yes." , "Definitely!" , "Do some more thinking." };
public override void Use(Player p, string message) {
if (String.IsNullOrEmpty(message)) { Help(p); return; }
if (p.joker || p.muted) { Player.Message(p, "Cannot use 8ball while muted or jokered."); return; }
TimeSpan delta = nextUse - DateTime.UtcNow;
if (delta.TotalSeconds > 0) {
Player.Message(p, "The 8-ball is still recharging, wait another {0} seconds.",
(int)Math.Ceiling(delta.TotalSeconds));
if (Player.IsSuper(p)) { MessageInGameOnly(p); return; }
if (Server.chatmod || p.muted) {
Player.SendMessage(p, "Cannot use 8-ball while muted.");
return;
}
if (canUse == false) {Player.SendMessage(p, "Must wait 10 seconds from the last time the command was used to use it again!"); return;}
if (message == "") { Help(p); return; }
canUse = false;
StringBuilder builder = new StringBuilder(message.Length);
foreach (char c in message) {
if (ValidChar(c)) builder.Append(c);
}
nextUse = DateTime.UtcNow.AddSeconds(10);
Random random = new Random();
Chat.GlobalChatLevel(p, p.color + "*" + Colors.StripColors(p.DisplayName) + " asked the question " + message, false);
Chat.GlobalChatLevel(p, p.color + "*" + "The answer was " + answers[random.Next(answers.Length)], false);
string final = builder.ToString();
Random random = new Random(final.ToLower().GetHashCode());
Player.GlobalMessage(p.color + p.DisplayName + "%s asked the %b8-Ball: %f" + message);
Thread.Sleep(2000);
Player.GlobalMessage("The %b8-Ball %ssays:%f " + messages[random.Next(messages.Length)]);
Thread.Sleep(10000);
canUse = true;
}
bool ValidChar(char c) {
return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}
public override void Help(Player p) {
Player.Message(p, "%T/8ball (message)");
Player.Message(p, "%HGives you a meaningless response to a question.");
Player.Message(p, "%T/8ball [yes or no question]");
Player.Message(p, "%HGet an answer from the all-knowing 8-Ball!");
}
}
}

View File

@ -21,7 +21,7 @@ namespace MCGalaxy.Commands.Building {
public override string shortcut { get { return "a"; } }
public override string type { get { return CommandTypes.Building; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Builder; } }
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
public CmdAbort() { }
public override void Use(Player p, string message) {

View File

@ -21,10 +21,11 @@ namespace MCGalaxy.Commands.Building {
public override string shortcut { get { return "p"; } }
public override string type { get { return CommandTypes.Building; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Builder; } }
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
public CmdPaint() { }
public override void Use(Player p, string message) {
if (Player.IsSuper(p)) { MessageInGameOnly(p); return; }
if (message != "") { Help(p); return; }
p.painting = !p.painting;

View File

@ -23,9 +23,10 @@ namespace MCGalaxy.Commands {
public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Other; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Builder; } }
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
public override void Use(Player p, string message) {
if (Player.IsSuper(p)) { MessageInGameOnly(p); return; }
string[] args = message.Split(' ');
if (args.Length > 2) { Help(p); return; }