mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
more work on chat rewrite
This commit is contained in:
parent
6c86854b44
commit
b5e327eded
@ -15,6 +15,7 @@ permissions and limitations under the Licenses.
|
||||
using System;
|
||||
using System.Text;
|
||||
using MCGalaxy.Commands;
|
||||
using MCGalaxy.Events.ServerEvents;
|
||||
|
||||
namespace MCGalaxy {
|
||||
public enum ChatScope {
|
||||
@ -28,6 +29,8 @@ namespace MCGalaxy {
|
||||
Level,
|
||||
/// <summary> Messages all players in (or spying on) a particular chatroom. </summary>
|
||||
Chatroom,
|
||||
/// <summary> Messages all players in all chatrooms. </summary>
|
||||
AllChatrooms,
|
||||
|
||||
/// <summary> Messages all players of a given rank </summary>
|
||||
Rank,
|
||||
@ -85,14 +88,15 @@ namespace MCGalaxy {
|
||||
string room = (string)arg;
|
||||
return pl.Chatroom == room || pl.spyChatRooms.CaselessContains(room);
|
||||
}
|
||||
public static bool FilterAllChatrooms(Player pl, object arg) { return pl.Chatroom != null; }
|
||||
|
||||
public static bool FilterRank(Player pl, object arg) { return pl.Rank == (LevelPermission)arg; }
|
||||
public static bool FilterAboveOrSameRank(Player pl, object arg) { return pl.Rank >= (LevelPermission)arg; }
|
||||
public static bool FilterBelowRank(Player pl, object arg) { return pl.Rank < (LevelPermission)arg; }
|
||||
|
||||
static ChatMessageFilter[] scopeFilters = new ChatMessageFilter[] {
|
||||
FilterAll, FilterGlobal, FilterLevel, FilterChatroom,
|
||||
FilterRank, FilterAboveOrSameRank, FilterBelowRank,
|
||||
public static ChatMessageFilter[] scopeFilters = new ChatMessageFilter[] {
|
||||
FilterAll, FilterGlobal, FilterLevel, FilterChatroom,
|
||||
FilterAllChatrooms, FilterRank, FilterAboveOrSameRank, FilterBelowRank,
|
||||
};
|
||||
|
||||
public static ChatMessageFilter FilterVisible(Player source) {
|
||||
@ -129,14 +133,13 @@ namespace MCGalaxy {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
ChatMessageFilter scopeFilter = scopeFilters[(int)scope];
|
||||
|
||||
OnChatSysEvent.Call(scope, ref msg, arg, ref filter, irc);
|
||||
foreach (Player pl in players) {
|
||||
if (!scopeFilter(pl, arg)) continue;
|
||||
if (filter != null && !filter(pl, arg)) continue;
|
||||
|
||||
Player.Message(pl, msg);
|
||||
}
|
||||
|
||||
if (irc) Server.IRC.Say(msg); // TODO: check scope filter here
|
||||
}
|
||||
|
||||
|
||||
@ -164,6 +167,7 @@ namespace MCGalaxy {
|
||||
ChatMessageFilter scopeFilter = scopeFilters[(int)scope];
|
||||
if (source == null) source = ConsolePlayer.Instance;
|
||||
|
||||
OnChatFromEvent.Call(scope, source, ref msg, arg, ref filter, irc);
|
||||
foreach (Player pl in players) {
|
||||
if (!scopeFilter(pl, arg)) continue;
|
||||
if (filter != null && !filter(pl, arg)) continue;
|
||||
@ -171,8 +175,6 @@ namespace MCGalaxy {
|
||||
if (!NotIgnoring(pl, source)) continue;
|
||||
Player.Message(pl, UnescapeMessage(pl, source, msg));
|
||||
}
|
||||
|
||||
if (irc) Server.IRC.Say(msg); // TODO: check scope filter here
|
||||
}
|
||||
|
||||
|
||||
@ -192,6 +194,7 @@ namespace MCGalaxy {
|
||||
ChatMessageFilter scopeFilter = scopeFilters[(int)scope];
|
||||
if (source == null) source = ConsolePlayer.Instance;
|
||||
|
||||
OnChatEvent.Call(scope, source, ref msg, arg, ref filter, irc);
|
||||
foreach (Player pl in players) {
|
||||
if (!NotIgnoring(pl, source)) continue;
|
||||
// Always show message to self too (unless ignoring self)
|
||||
@ -202,8 +205,6 @@ namespace MCGalaxy {
|
||||
|
||||
Player.Message(pl, UnescapeMessage(pl, source, msg));
|
||||
}
|
||||
|
||||
if (irc) Server.IRC.Say(msg); // TODO: check scope filter here
|
||||
source.CheckForMessageSpam();
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
Player.Message(p, "Use %T{0} abort %Sat anytime to abort the creation process.", cmd);
|
||||
Player.Message(p, " Use %T{0} revert %Sto go back a step", cmd);
|
||||
Player.Message(p, " Use %T{0} [input] %Sto provide input", cmd);
|
||||
Player.Message(p, "%f----------------------------------------------------------");
|
||||
Player.Message(p, "&f----------------------------------------------------------");
|
||||
|
||||
SetStep(p, global, 2);
|
||||
SendStepHelp(p, global);
|
||||
@ -680,7 +680,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
|
||||
for (int i = 0; i < help.Length; i++)
|
||||
Player.Message(p, help[i]);
|
||||
Player.Message(p, "%f--------------------------");
|
||||
Player.Message(p, "&f--------------------------");
|
||||
}
|
||||
|
||||
static void SendEditHelp(Player p, string section) {
|
||||
|
@ -242,8 +242,7 @@ namespace MCGalaxy.Commands.Chatting {
|
||||
Logger.Log(LogType.ChatroomChat, "<GlobalChatRoom>{0}: {1}", p.name, message);
|
||||
message = "<GlobalChatRoom> λNICK: &f" + message;
|
||||
|
||||
Chat.MessageFrom(ChatScope.All, p, message,
|
||||
null, (pl, arg) => pl.Chatroom != null);
|
||||
Chat.MessageChat(ChatScope.AllChatrooms, p, message, null, null);
|
||||
p.lastchatroomglobal = DateTime.UtcNow;
|
||||
} else {
|
||||
Player.Message(p, "Sorry, you must wait 30 seconds in between each global chatroom message!!");
|
||||
|
@ -33,7 +33,7 @@ namespace MCGalaxy.Commands.Chatting {
|
||||
public override void Use(Player p, string message) {
|
||||
if (!message.CaselessEq("global")) {
|
||||
ClearChat(p);
|
||||
Player.Message(p, "%4Chat cleared.");
|
||||
Player.Message(p, "&4Chat cleared.");
|
||||
} else {
|
||||
if (!CheckExtraPerm(p, 1)) return;
|
||||
|
||||
@ -41,7 +41,7 @@ namespace MCGalaxy.Commands.Chatting {
|
||||
foreach (Player pl in players) {
|
||||
ClearChat(pl);
|
||||
}
|
||||
Chat.MessageAll("%4Global Chat cleared.");
|
||||
Chat.MessageAll("&4Global Chat cleared.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ namespace MCGalaxy.Commands.Chatting {
|
||||
if (p != null && target.Rank > p.Rank) {
|
||||
MessageTooHighRank(p, "&cdeath-hug%S", true); return;
|
||||
}
|
||||
target.HandleDeath(Block.Stone, "@p %Sdied from a %cdeadly hug.");
|
||||
target.HandleDeath(Block.Stone, "@p %Sdied from a &cdeadly hug.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,13 +82,13 @@ namespace MCGalaxy.Commands.Eco {
|
||||
if (!DateTime.TryParseExact(date, dateFormat, null, 0, out time)) return false;
|
||||
|
||||
TimeSpan delta = DateTime.Now - time;
|
||||
value = prefix + " %f" + delta.Shorten() + " ago" + suffix;
|
||||
value = prefix + " &f" + delta.Shorten() + " ago" + suffix;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/Balance [player]");
|
||||
Player.Message(p, "%HShows how much %3" + ServerConfig.Currency + " %H[player] has, " +
|
||||
Player.Message(p, "%HShows how much &3" + ServerConfig.Currency + " %H[player] has, " +
|
||||
"plus their most recent transactions.");
|
||||
Player.Message(p, "%HIf [player] is not given, shows your own balance.");
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands.Eco {
|
||||
if (item == null) { Help(p); return; }
|
||||
|
||||
if (!item.Enabled) {
|
||||
Player.Message(p, "%cThe {0} item is not currently buyable.", item.Name); return;
|
||||
Player.Message(p, "&cThe {0} item is not currently buyable.", item.Name); return;
|
||||
}
|
||||
if (p.Rank < item.PurchaseRank) {
|
||||
Formatter.MessageNeedMinPerm(p, "+ can purchase a " + item.Name, item.PurchaseRank); return;
|
||||
|
@ -33,7 +33,7 @@ namespace MCGalaxy.Commands.Eco {
|
||||
int matches = 1;
|
||||
Player who = PlayerInfo.FindMatches(p, data.TargetName, out matches);
|
||||
if (matches > 1) return;
|
||||
if (p != null && p == who) { Player.Message(p, "You cannot give yourself %3" + ServerConfig.Currency); return; }
|
||||
if (p != null && p == who) { Player.Message(p, "You cannot give yourself &3" + ServerConfig.Currency); return; }
|
||||
int money = 0;
|
||||
|
||||
if (who == null) {
|
||||
@ -58,14 +58,14 @@ namespace MCGalaxy.Commands.Eco {
|
||||
|
||||
static bool ReachedMax(Player p, int current, int amount) {
|
||||
if (current + amount > 16777215) {
|
||||
Player.Message(p, "%cPlayers cannot have over %316,777,215 %3" + ServerConfig.Currency); return true;
|
||||
Player.Message(p, "&cPlayers cannot have over &316,777,215 &3" + ServerConfig.Currency); return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/Give [player] [amount] <reason>");
|
||||
Player.Message(p, "%HGives [player] [amount] %3" + ServerConfig.Currency);
|
||||
Player.Message(p, "%HGives [player] [amount] &3" + ServerConfig.Currency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands.Eco {
|
||||
int matches = 1;
|
||||
Player who = PlayerInfo.FindMatches(p, data.TargetName, out matches);
|
||||
if (matches > 1) return;
|
||||
if (p != null && p == who) { Player.Message(p, "You cannot pay yourself %3" + ServerConfig.Currency); return; }
|
||||
if (p != null && p == who) { Player.Message(p, "You cannot pay yourself &3" + ServerConfig.Currency); return; }
|
||||
int money, srcMoney = Player.IsSuper(p) ? int.MaxValue : p.money;
|
||||
|
||||
if (who == null) {
|
||||
@ -57,10 +57,10 @@ namespace MCGalaxy.Commands.Eco {
|
||||
|
||||
static bool IsLegalPayment(Player p, int payer, int receiver, int amount) {
|
||||
if (receiver + amount > 16777215) {
|
||||
Player.Message(p, "%cPlayers cannot have over %f16777215 %3" + ServerConfig.Currency); return false;
|
||||
Player.Message(p, "&cPlayers cannot have over &f16777215 &3" + ServerConfig.Currency); return false;
|
||||
}
|
||||
if (payer < amount) {
|
||||
Player.Message(p, "%cYou don't have enough %3" + ServerConfig.Currency); return false;
|
||||
Player.Message(p, "&cYou don't have enough &3" + ServerConfig.Currency); return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace MCGalaxy.Commands.Eco {
|
||||
if (item == null) { Help(p); return; }
|
||||
|
||||
if (!item.Enabled) {
|
||||
Player.Message(p, "%cThe " + item.ShopName + " item is not currently buyable."); return;
|
||||
Player.Message(p, "&cThe " + item.ShopName + " item is not currently buyable."); return;
|
||||
}
|
||||
item.OnStoreCommand(p);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands.Eco {
|
||||
int matches = 1;
|
||||
Player who = PlayerInfo.FindMatches(p, data.TargetName, out matches);
|
||||
if (matches > 1) return;
|
||||
if (p != null && p == who) { Player.Message(p, "%cYou can't take %3" + ServerConfig.Currency + "%c from yourself"); return; }
|
||||
if (p != null && p == who) { Player.Message(p, "&cYou can't take &3" + ServerConfig.Currency + "&c from yourself"); return; }
|
||||
|
||||
int money = 0;
|
||||
if (who == null) {
|
||||
|
@ -54,8 +54,8 @@ namespace MCGalaxy.Commands.Fun {
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/Human %H- pledges that you will not be infected.");
|
||||
Player.Message(p, "%HIf you survive, you receive an &aextra 5 %3" + ServerConfig.Currency);
|
||||
Player.Message(p, "%HHowever, if you are infected, you will &close 2 %3" + ServerConfig.Currency);
|
||||
Player.Message(p, "%HIf you survive, you receive an &aextra 5 &3" + ServerConfig.Currency);
|
||||
Player.Message(p, "%HHowever, if you are infected, you will &close 2 &3" + ServerConfig.Currency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,14 +156,14 @@ namespace MCGalaxy.Commands.Info {
|
||||
void ShowEnv(Player p, MapInfoData data, LevelConfig cfg) {
|
||||
string url = cfg.Terrain.Length > 0 ? cfg.Terrain : ServerConfig.DefaultTerrain;
|
||||
if (url.Length > 0) {
|
||||
Player.Message(p, "Terrain: %b" + url);
|
||||
Player.Message(p, "Terrain: &b" + url);
|
||||
} else {
|
||||
Player.Message(p, "No custom terrain set for this map.");
|
||||
}
|
||||
|
||||
url = cfg.TexturePack.Length > 0 ? cfg.TexturePack : ServerConfig.DefaultTexture;
|
||||
if (url.Length > 0) {
|
||||
Player.Message(p, "Texture pack: %b" + url);
|
||||
Player.Message(p, "Texture pack: &b" + url);
|
||||
} else {
|
||||
Player.Message(p, "No custom texture pack set for this map.");
|
||||
}
|
||||
@ -226,7 +226,7 @@ namespace MCGalaxy.Commands.Info {
|
||||
}
|
||||
|
||||
static string Color(string src) {
|
||||
return (src == null || src.Length == 0 || src == "-1") ? "%bnone%e" : "%b" + src + "%e";
|
||||
return (src == null || src.Length == 0 || src == "-1") ? "&bnone&e" : "&b" + src + "&e";
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -71,7 +71,7 @@ namespace MCGalaxy.Commands.Maintenance {
|
||||
Player.Message(p, "%T/BlockDB enable [map]");
|
||||
Player.Message(p, "%HEnables %Hrecording block changes to the BlockDB for [map]");
|
||||
Player.Message(p, "%HIf no map name is given, uses your current map.");
|
||||
Player.Message(p, "%CUse these commands with great caution!");
|
||||
Player.Message(p, "&cUse these commands with great caution!");
|
||||
}
|
||||
}
|
||||
}
|
@ -48,10 +48,10 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
List<Player> GetPatrolCandidates(Player p) {
|
||||
List<Player> candidates = new List<Player>();
|
||||
LevelPermission perm = CommandExtraPerms.MinPerm(name);
|
||||
Player[] online = PlayerInfo.Online.Items;
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
DateTime cutoff = DateTime.UtcNow.AddSeconds(-15);
|
||||
|
||||
foreach (Player target in online) {
|
||||
foreach (Player target in players) {
|
||||
if (target.Rank > perm || target == p || !Entities.CanSee(p, target)) continue;
|
||||
if (target.LastPatrol > cutoff) continue;
|
||||
candidates.Add(target);
|
||||
|
@ -153,7 +153,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
LevelPermission checkRank = CommandExtraPerms.Find(name, 1).MinRank;
|
||||
string checkRankName = Group.GetColoredName(checkRank);
|
||||
if (reports.Count >= 5) {
|
||||
Player.Message(p, "{0} &calready has 5 reports! Please wait until an {1}%c+ has reviewed these reports first!",
|
||||
Player.Message(p, "{0} &calready has 5 reports! Please wait until an {1}&c+ has reviewed these reports first!",
|
||||
PlayerInfo.GetColoredName(p, target), checkRankName);
|
||||
return;
|
||||
}
|
||||
|
@ -16,45 +16,68 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using MCGalaxy.Events;
|
||||
using MCGalaxy.Commands.Chatting;
|
||||
|
||||
namespace MCGalaxy.Core {
|
||||
|
||||
internal static class ChatHandler {
|
||||
|
||||
internal static void HandleOnChat(ChatScope scope, Player source, ref string msg,
|
||||
object arg, ref ChatMessageFilter filter, bool irc) {
|
||||
msg = msg.Replace("λFULL", source.name).Replace("λNICK", source.name);
|
||||
LogType logType = LogType.PlayerChat;
|
||||
|
||||
if (scope == ChatScope.AboveEqRank) {
|
||||
logType = LogType.StaffChat;
|
||||
} else if (scope == ChatScope.Chatroom || scope == ChatScope.AllChatrooms) {
|
||||
logType = LogType.ChatroomChat;
|
||||
} else if (scope == ChatScope.Rank) {
|
||||
logType = LogType.RankChat;
|
||||
}
|
||||
|
||||
Logger.Log(logType, msg);
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
ChatMessageFilter scopeFilter = Chat.scopeFilters[(int)scope];
|
||||
|
||||
foreach (Player pl in players) {
|
||||
if (pl == source || !Chat.NotIgnoring(pl, source)) continue;
|
||||
if (!scopeFilter(pl, arg)) continue;
|
||||
if (filter != null && !filter(pl, arg)) continue;
|
||||
|
||||
source.TotalMessagesSent++; break;
|
||||
}
|
||||
}
|
||||
|
||||
internal static void HandleCommand(Player p, string cmd, string args) {
|
||||
if (!ServerConfig.CoreSecretCommands) return;
|
||||
|
||||
//DO NOT REMOVE THE TWO COMMANDS BELOW, /PONY AND /RAINBOWDASHLIKESCOOLTHINGS. -EricKilla
|
||||
// DO NOT REMOVE THE TWO COMMANDS BELOW, /PONY AND /RAINBOWDASHLIKESCOOLTHINGS. -EricKilla
|
||||
if (cmd == "pony") {
|
||||
p.cancelcommand = true;
|
||||
if (!MessageCmd.CanSpeak(p, cmd)) return;
|
||||
int ponycount = p.Extras.GetInt("MCG_PONY", 0);
|
||||
int used = p.Extras.GetInt("MCG_PONY");
|
||||
|
||||
if (ponycount < 2) {
|
||||
if (used < 2) {
|
||||
Chat.MessageFrom(p, "λNICK %Sjust so happens to be a proud brony! Everyone give λNICK %Sa brohoof!");
|
||||
Logger.Log(LogType.CommandUsage, "{0} used /{1}", p.name, cmd);
|
||||
} else {
|
||||
Player.Message(p, "You have used this command 2 times. You cannot use it anymore! Sorry, Brony!");
|
||||
}
|
||||
|
||||
ponycount++;
|
||||
p.Extras.PutInt("MCGalaxy_Core_Pony", ponycount);
|
||||
p.Extras.PutInt("MCG_PONY", used + 1);
|
||||
} else if (cmd == "rainbowdashlikescoolthings") {
|
||||
p.cancelcommand = true;
|
||||
if (!MessageCmd.CanSpeak(p, cmd)) return;
|
||||
int rdcount = p.Extras.GetInt("MCG_RD", 0);
|
||||
int used = p.Extras.GetInt("MCG_RD");
|
||||
|
||||
if (rdcount < 2) {
|
||||
if (used < 2) {
|
||||
Chat.MessageGlobal("&4T&6H&eI&aS&3 S&9E&1R&4V&6E&eR &aJ&3U&9S&1T &4G&6O&eT &a2&30 &9P&1E&4R&6C&eE&aN&3T &9C&1O&4O&6L&eE&aR&3!");
|
||||
Logger.Log(LogType.CommandUsage, "{0} used /{1}", p.name, cmd);
|
||||
} else {
|
||||
Player.Message(p, "You have used this command 2 times. You cannot use it anymore! Sorry, Brony!");
|
||||
}
|
||||
|
||||
rdcount++;
|
||||
p.Extras.PutInt("MCGalaxy_Core_RD", rdcount);
|
||||
p.Extras.PutInt("MCG_RD", used + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ using MCGalaxy.Events;
|
||||
using MCGalaxy.Events.EconomyEvents;
|
||||
using MCGalaxy.Events.GroupEvents;
|
||||
using MCGalaxy.Events.PlayerEvents;
|
||||
using MCGalaxy.Events.ServerEvents;
|
||||
using MCGalaxy.Tasks;
|
||||
|
||||
namespace MCGalaxy.Core {
|
||||
@ -33,6 +34,7 @@ namespace MCGalaxy.Core {
|
||||
public override void Load(bool startup) {
|
||||
OnPlayerConnectEvent.Register(ConnectHandler.HandleConnect, Priority.Critical);
|
||||
OnPlayerCommandEvent.Register(ChatHandler.HandleCommand, Priority.Critical);
|
||||
OnChatEvent.Register(ChatHandler.HandleOnChat, Priority.Critical);
|
||||
OnPlayerStartConnectingEvent.Register(ConnectingHandler.HandleConnecting, Priority.Critical);
|
||||
|
||||
OnSentMapEvent.Register(MiscHandlers.HandleOnMapSent, Priority.Critical);
|
||||
@ -50,6 +52,7 @@ namespace MCGalaxy.Core {
|
||||
public override void Unload(bool shutdown) {
|
||||
OnPlayerConnectEvent.Unregister(ConnectHandler.HandleConnect);
|
||||
OnPlayerCommandEvent.Unregister(ChatHandler.HandleCommand);
|
||||
OnChatEvent.Unregister(ChatHandler.HandleOnChat);
|
||||
OnPlayerStartConnectingEvent.Unregister(ConnectingHandler.HandleConnecting);
|
||||
|
||||
OnSentMapEvent.Unregister(MiscHandlers.HandleOnMapSent);
|
||||
|
@ -51,10 +51,10 @@ namespace MCGalaxy.Eco {
|
||||
internal void Setup(Player p, string[] args) {
|
||||
switch (args[1].ToLower()) {
|
||||
case "enable":
|
||||
Player.Message(p, "%aThe {0} item is now enabled.", Name);
|
||||
Player.Message(p, "&aThe {0} item is now enabled.", Name);
|
||||
Enabled = true; break;
|
||||
case "disable":
|
||||
Player.Message(p, "%aThe {0} item is now disabled.", Name);
|
||||
Player.Message(p, "&aThe {0} item is now disabled.", Name);
|
||||
Enabled = false; break;
|
||||
case "purchaserank":
|
||||
if (args.Length == 2) { Player.Message(p, "You need to provide a rank name."); return; }
|
||||
@ -115,7 +115,7 @@ namespace MCGalaxy.Eco {
|
||||
// Must always provide an argument.
|
||||
if (args.Length < 2) { OnStoreCommand(p); return; }
|
||||
if (p.money < Price) {
|
||||
Player.Message(p, "%cYou don't have enough &3{1}&c to buy a {0}.", Name, ServerConfig.Currency); return;
|
||||
Player.Message(p, "&cYou don't have enough &3{1} &cto buy a {0}.", Name, ServerConfig.Currency); return;
|
||||
}
|
||||
DoPurchase(p, message, args);
|
||||
}
|
||||
|
@ -76,16 +76,16 @@ namespace MCGalaxy.Eco {
|
||||
protected internal override void OnBuyCommand(Player p, string message, string[] args) {
|
||||
if (args.Length < 3) { OnStoreCommand(p); return; }
|
||||
LevelPreset preset = FindPreset(args[1]);
|
||||
if (preset == null) { Player.Message(p, "%cThat isn't a level preset"); return; }
|
||||
if (preset == null) { Player.Message(p, "&cThat isn't a level preset"); return; }
|
||||
|
||||
if (p.money < preset.price) {
|
||||
Player.Message(p, "%cYou don't have enough %3" + ServerConfig.Currency + "%c to buy that map"); return;
|
||||
Player.Message(p, "&cYou don't have enough &3" + ServerConfig.Currency + "&c to buy that map"); return;
|
||||
}
|
||||
string name = p.name + "_" + args[2];
|
||||
|
||||
try {
|
||||
Command.Find("NewLvl").Use(null, name + " " + preset.x + " " + preset.y + " " + preset.z + " " + preset.type);
|
||||
Player.Message(p, "%aCreating level: '%f" + name + "%a' . . .");
|
||||
Player.Message(p, "&aCreating level: '&f" + name + "&a' . . .");
|
||||
|
||||
CmdLoad.LoadLevel(null, name);
|
||||
Level level = LevelInfo.FindExact(name);
|
||||
@ -93,9 +93,9 @@ namespace MCGalaxy.Eco {
|
||||
Level.SaveSettings(level);
|
||||
PlayerActions.ChangeMap(p, name);
|
||||
|
||||
Player.Message(p, "%aSuccessfully created your map: '%f" + name + "%a'");
|
||||
Player.Message(p, "&aSuccessfully created your map: '&f" + name + "&a'");
|
||||
} catch {
|
||||
Player.Message(p, "%cSomething went wrong, Money untouched"); return;
|
||||
Player.Message(p, "&cSomething went wrong, Money untouched"); return;
|
||||
}
|
||||
Economy.MakePurchase(p, preset.price, "%3Map: %f" + preset.name);
|
||||
}
|
||||
@ -116,14 +116,14 @@ namespace MCGalaxy.Eco {
|
||||
}
|
||||
|
||||
void AddPreset(Player p, string[] args, LevelPreset preset) {
|
||||
if (preset != null) { Player.Message(p, "%cThat preset level already exists"); return; }
|
||||
if (preset != null) { Player.Message(p, "&cThat preset level already exists"); return; }
|
||||
|
||||
preset = new LevelPreset();
|
||||
preset.name = args[2];
|
||||
if (OkayAxis(args[3]) && OkayAxis(args[4]) && OkayAxis(args[5])) {
|
||||
preset.x = args[3]; preset.y = args[4]; preset.z = args[5];
|
||||
} else {
|
||||
Player.Message(p, "%cDimension must be a power of 2"); return;
|
||||
Player.Message(p, "&cDimension must be a power of 2"); return;
|
||||
}
|
||||
|
||||
if (!MapGen.IsRecognisedTheme(args[6])) {
|
||||
@ -133,43 +133,43 @@ namespace MCGalaxy.Eco {
|
||||
if (!CommandParser.GetInt(p, args[7], "Price", ref preset.price, 0)) return;
|
||||
|
||||
Presets.Add(preset);
|
||||
Player.Message(p, "%aSuccessfully added the following map preset:");
|
||||
Player.Message(p, "Name: %f" + preset.name);
|
||||
Player.Message(p, "&aSuccessfully added the following map preset:");
|
||||
Player.Message(p, "Name: &f" + preset.name);
|
||||
Player.Message(p, "x:" + preset.x + ", y:" + preset.y + ", z:" + preset.z);
|
||||
Player.Message(p, "Map Type: %f" + preset.type);
|
||||
Player.Message(p, "Map Price: %f" + preset.price + " %3" + ServerConfig.Currency);
|
||||
Player.Message(p, "Map Type: &f" + preset.type);
|
||||
Player.Message(p, "Map Price: &f" + preset.price + " &3" + ServerConfig.Currency);
|
||||
}
|
||||
|
||||
void RemovePreset(Player p, string[] args, LevelPreset preset) {
|
||||
if (preset == null) { Player.Message(p, "%cThat preset level doesn't exist"); return; }
|
||||
if (preset == null) { Player.Message(p, "&cThat preset level doesn't exist"); return; }
|
||||
Presets.Remove(preset);
|
||||
Player.Message(p, "%aSuccessfully removed preset: %f" + preset.name);
|
||||
Player.Message(p, "&aSuccessfully removed preset: &f" + preset.name);
|
||||
}
|
||||
|
||||
void EditPreset(Player p, string[] args, LevelPreset preset) {
|
||||
if (preset == null) { Player.Message(p, "%cThat preset level doesn't exist"); return; }
|
||||
if (preset == null) { Player.Message(p, "&cThat preset level doesn't exist"); return; }
|
||||
|
||||
if (args[3] == "name" || args[3] == "title") {
|
||||
preset.name = args[4];
|
||||
Player.Message(p, "%aSuccessfully changed preset name to %f" + preset.name);
|
||||
Player.Message(p, "&aSuccessfully changed preset name to &f" + preset.name);
|
||||
} else if (args[3] == "x" || args[3] == "y" || args[3] == "z") {
|
||||
if (!OkayAxis(args[4])) { Player.Message(p, "%cDimension was wrong, it must be a power of 2"); return; }
|
||||
if (!OkayAxis(args[4])) { Player.Message(p, "&cDimension was wrong, it must be a power of 2"); return; }
|
||||
|
||||
if (args[3] == "x") preset.x = args[4];
|
||||
if (args[3] == "y") preset.y = args[4];
|
||||
if (args[3] == "z") preset.z = args[4];
|
||||
Player.Message(p, "%aSuccessfully changed preset {0} size to %f{1}", args[3], args[4]);
|
||||
Player.Message(p, "&aSuccessfully changed preset {0} size to &f{1}", args[3], args[4]);
|
||||
} else if (args[3] == "type" || args[3] == "theme") {
|
||||
if (!MapGen.IsRecognisedTheme(args[4])) { MapGen.PrintThemes(p); return; }
|
||||
|
||||
preset.type = args[4].ToLower();
|
||||
Player.Message(p, "%aSuccessfully changed preset type to %f" + preset.type);
|
||||
Player.Message(p, "&aSuccessfully changed preset type to &f" + preset.type);
|
||||
} else if (args[3] == "price") {
|
||||
int newPrice = 0;
|
||||
if (!CommandParser.GetInt(p, args[4], "Price", ref newPrice, 0)) return;
|
||||
|
||||
preset.price = newPrice;
|
||||
Player.Message(p, "%aSuccessfully changed preset price to %f" + preset.price + " %3" + ServerConfig.Currency);
|
||||
Player.Message(p, "&aSuccessfully changed preset price to &f" + preset.price + " &3" + ServerConfig.Currency);
|
||||
} else {
|
||||
Player.Message(p, "Supported properties to edit: name, title, x, y, z, type, price");
|
||||
}
|
||||
|
@ -32,16 +32,16 @@ namespace MCGalaxy.Eco {
|
||||
protected override void DoPurchase(Player p, string message, string[] args) {
|
||||
if (args.Length == 1) {
|
||||
Command.Find("LoginMessage").Use(p, "-own");
|
||||
Player.Message(p, "%aYour login message was removed for free.");
|
||||
Player.Message(p, "&aYour login message was removed for free.");
|
||||
return;
|
||||
}
|
||||
|
||||
string text = message.SplitSpaces(2)[1]; // keep spaces this way
|
||||
if (text == PlayerDB.GetLoginMessage(p)) {
|
||||
Player.Message(p, "%cYou already have that login message."); return;
|
||||
Player.Message(p, "&cYou already have that login message."); return;
|
||||
}
|
||||
if (text.Length > NetUtils.StringSize) {
|
||||
Player.Message(p, "%cLogin message must be 64 characters or less."); return;
|
||||
Player.Message(p, "&cLogin message must be 64 characters or less."); return;
|
||||
}
|
||||
Command.Find("LoginMessage").Use(p, "-own " + text);
|
||||
Economy.MakePurchase(p, Price, "%3LoginMessage: %f" + text);
|
||||
@ -60,16 +60,16 @@ namespace MCGalaxy.Eco {
|
||||
protected override void DoPurchase(Player p, string message, string[] args) {
|
||||
if (args.Length == 1) {
|
||||
Command.Find("LogoutMessage").Use(p, "-own");
|
||||
Player.Message(p, "%aYour logout message was removed for free.");
|
||||
Player.Message(p, "&aYour logout message was removed for free.");
|
||||
return;
|
||||
}
|
||||
|
||||
string text = message.SplitSpaces(2)[1]; // keep spaces this way
|
||||
if (text == PlayerDB.GetLogoutMessage(p)) {
|
||||
Player.Message(p, "%cYou already have that logout message."); return;
|
||||
Player.Message(p, "&cYou already have that logout message."); return;
|
||||
}
|
||||
if (text.Length > NetUtils.StringSize) {
|
||||
Player.Message(p, "%cLogin message must be 64 characters or less."); return;
|
||||
Player.Message(p, "&cLogin message must be 64 characters or less."); return;
|
||||
}
|
||||
Command.Find("LogoutMessage").Use(p, "-own " + text);
|
||||
Economy.MakePurchase(p, Price, "%3LogoutMessage: %f" + text);
|
||||
|
@ -31,15 +31,15 @@ namespace MCGalaxy.Eco {
|
||||
protected override void DoPurchase(Player p, string message, string[] args) {
|
||||
if (args.Length == 1) {
|
||||
Command.Find("Title").Use(p, "-own");
|
||||
Player.Message(p, "%aYour title was removed for free."); return;
|
||||
Player.Message(p, "&aYour title was removed for free."); return;
|
||||
}
|
||||
|
||||
string title = message.SplitSpaces(2)[1]; // keep spaces this way
|
||||
if (title == p.title) {
|
||||
Player.Message(p, "%cYou already have that title."); return;
|
||||
Player.Message(p, "&cYou already have that title."); return;
|
||||
}
|
||||
if (title.Length >= 20) {
|
||||
Player.Message(p, "%cTitles must be under 20 characters."); return;
|
||||
Player.Message(p, "&cTitles must be under 20 characters."); return;
|
||||
}
|
||||
|
||||
Command.Find("Title").Use(p, "-own " + title);
|
||||
@ -59,15 +59,15 @@ namespace MCGalaxy.Eco {
|
||||
protected override void DoPurchase(Player p, string message, string[] args) {
|
||||
if (args.Length == 1) {
|
||||
Command.Find("Nick").Use(p, "-own");
|
||||
Player.Message(p, "%aYour nickname was removed for free."); return;
|
||||
Player.Message(p, "&aYour nickname was removed for free."); return;
|
||||
}
|
||||
|
||||
string nick = message.SplitSpaces(2)[1]; // keep spaces this way
|
||||
if (nick == p.DisplayName) {
|
||||
Player.Message(p, "%cYou already have that nickname."); return;
|
||||
Player.Message(p, "&cYou already have that nickname."); return;
|
||||
}
|
||||
if (nick.Length >= 30) {
|
||||
Player.Message(p, "%cNicknames must be under 30 characters."); return;
|
||||
Player.Message(p, "&cNicknames must be under 30 characters."); return;
|
||||
}
|
||||
|
||||
Command.Find("Nick").Use(p, "-own " + nick);
|
||||
@ -89,7 +89,7 @@ namespace MCGalaxy.Eco {
|
||||
string colName = Colors.Name(color);
|
||||
|
||||
if (color == p.titlecolor) {
|
||||
Player.Message(p, "%cYou already have a " + color + colName + "%c titlecolor"); return;
|
||||
Player.Message(p, "&cYou already have a " + color + colName + "&c titlecolor"); return;
|
||||
}
|
||||
|
||||
Command.Find("TColor").Use(p, "-own " + colName);
|
||||
@ -111,7 +111,7 @@ namespace MCGalaxy.Eco {
|
||||
string colName = Colors.Name(color);
|
||||
|
||||
if (color == p.color) {
|
||||
Player.Message(p, "%cYou already have a " + color + colName + "%c color"); return;
|
||||
Player.Message(p, "&cYou already have a " + color + colName + "&c color"); return;
|
||||
}
|
||||
|
||||
Command.Find("Color").Use(p, "-own " + colName);
|
||||
|
@ -81,42 +81,42 @@ namespace MCGalaxy.Eco {
|
||||
|
||||
protected internal override void OnBuyCommand(Player p, string message, string[] args) {
|
||||
if (args.Length >= 2) {
|
||||
Player.Message(p, "%cYou cannot provide a rank name, use %a/buy rank %cto buy the NEXT rank."); return;
|
||||
Player.Message(p, "&cYou cannot provide a rank name, use &a/buy rank &cto buy the NEXT rank."); return;
|
||||
}
|
||||
|
||||
RankEntry nextRank = NextRank(p);
|
||||
if (nextRank == null) {
|
||||
Player.Message(p, "%cYou are already at or past the max buyable rank"); return;
|
||||
Player.Message(p, "&cYou are already at or past the max buyable rank"); return;
|
||||
}
|
||||
if (p.money < nextRank.Price) {
|
||||
Player.Message(p, "%cYou don't have enough %3" + ServerConfig.Currency + "%c to buy the next rank"); return;
|
||||
Player.Message(p, "&cYou don't have enough &3" + ServerConfig.Currency + "&c to buy the next rank"); return;
|
||||
}
|
||||
|
||||
string rankName = Group.Find(nextRank.Perm).Name; // TODO: What if null reference happens here
|
||||
Command.Find("SetRank").Use(null, p.name + " " + rankName);
|
||||
Player.Message(p, "You bought the rank " + p.group.ColoredName);
|
||||
Economy.MakePurchase(p, nextRank.Price, "%3Rank: " + p.group.ColoredName);
|
||||
Economy.MakePurchase(p, nextRank.Price, "&3Rank: " + p.group.ColoredName);
|
||||
}
|
||||
|
||||
protected internal override void OnSetupCommand(Player p, string[] args) {
|
||||
if (args[1].CaselessEq("price")) {
|
||||
Group grp = Matcher.FindRanks(p, args[2]);
|
||||
if (grp == null) return;
|
||||
if (p != null && p.Rank < grp.Permission) { Player.Message(p, "%cCannot set price of a rank higher than yours."); return; }
|
||||
if (p != null && p.Rank < grp.Permission) { Player.Message(p, "&cCannot set price of a rank higher than yours."); return; }
|
||||
|
||||
int cost = 0;
|
||||
if (!CommandParser.GetInt(p, args[3], "Price", ref cost, 0)) return;
|
||||
Player.Message(p, "%aSet price of rank {0} %ato &f{1} &3{2}", grp.ColoredName, cost, ServerConfig.Currency);
|
||||
Player.Message(p, "&aSet price of rank {0} &ato &f{1} &3{2}", grp.ColoredName, cost, ServerConfig.Currency);
|
||||
GetOrAdd(grp.Permission).Price = cost;
|
||||
} else if (Command.IsDeleteCommand(args[1])) {
|
||||
Group grp = Matcher.FindRanks(p, args[2]);
|
||||
if (grp == null) return;
|
||||
if (p != null && p.Rank < grp.Permission) { Player.Message(p, "%cCannot remove a rank higher than yours."); return; }
|
||||
if (p != null && p.Rank < grp.Permission) { Player.Message(p, "&cCannot remove a rank higher than yours."); return; }
|
||||
|
||||
if (Remove(grp.Permission)) {
|
||||
Player.Message(p, "%aMade rank {0} %ano longer buyable", grp.ColoredName);
|
||||
Player.Message(p, "&aMade rank {0} &ano longer buyable", grp.ColoredName);
|
||||
} else {
|
||||
Player.Message(p, "%cThat rank was not buyable to begin with.");
|
||||
Player.Message(p, "&cThat rank was not buyable to begin with.");
|
||||
}
|
||||
} else {
|
||||
OnSetupCommandHelp(p);
|
||||
@ -144,12 +144,12 @@ namespace MCGalaxy.Eco {
|
||||
protected internal override void OnStoreCommand(Player p) {
|
||||
Player.Message(p, "%T/Buy rankup");
|
||||
if (Ranks.Count == 0) {
|
||||
Player.Message(p, "%cNo ranks have been setup be buyable. See %T/eco help rank"); return;
|
||||
Player.Message(p, "&cNo ranks have been setup be buyable. See %T/eco help rank"); return;
|
||||
}
|
||||
|
||||
LevelPermission maxRank = Ranks[Ranks.Count - 1].Perm;
|
||||
Player.Message(p, "%fThe highest buyable rank is: {0}", Group.GetColoredName(maxRank));
|
||||
Player.Message(p, "%cYou can only buy ranks one at a time, in sequential order.");
|
||||
Player.Message(p, "&fThe highest buyable rank is: {0}", Group.GetColoredName(maxRank));
|
||||
Player.Message(p, "&cYou can only buy ranks one at a time, in sequential order.");
|
||||
|
||||
foreach (RankEntry rank in Ranks) {
|
||||
Player.Message(p, "&6{0} %S- &a{1} %S{2}",
|
||||
|
@ -110,7 +110,7 @@ namespace MCGalaxy.Eco {
|
||||
data.InfectMessages.Add(text);
|
||||
|
||||
PlayerDB.AppendInfectMessage(p.name, text);
|
||||
Player.Message(p, "%aAdded infect message: &f" + text);
|
||||
Player.Message(p, "&aAdded infect message: &f" + text);
|
||||
Economy.MakePurchase(p, Price, "%3InfectMessage: " + message);
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ namespace MCGalaxy.Eco {
|
||||
|
||||
protected internal override void OnBuyCommand(Player p, string message, string[] args) {
|
||||
if (p.money < Price) {
|
||||
Player.Message(p, "%cYou don't have enough &3{1} &c to buy a {0}.", Name, ServerConfig.Currency); return;
|
||||
Player.Message(p, "&cYou don't have enough &3{1} &cto buy a {0}.", Name, ServerConfig.Currency); return;
|
||||
}
|
||||
if (!Server.zombie.Running || !Server.zombie.RoundInProgress) {
|
||||
Player.Message(p, "You can only buy an invisiblity potion " +
|
||||
|
@ -43,8 +43,45 @@ namespace MCGalaxy.Events.ServerEvents {
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void OnChat();
|
||||
public delegate void OnChatSys(ChatScope scope, ref string msg, object arg,
|
||||
ref ChatMessageFilter filter, bool irc);
|
||||
public sealed class OnChatSysEvent : IEvent<OnChatSys> {
|
||||
|
||||
public static void Call(ChatScope scope, ref string msg, object arg,
|
||||
ref ChatMessageFilter filter, bool irc) {
|
||||
IEvent<OnChatSys>[] items = handlers.Items;
|
||||
for (int i = 0; i < items.Length; i++) {
|
||||
try { items[i].method(scope, ref msg, arg, ref filter, irc); }
|
||||
catch (Exception ex) { LogHandlerException(ex, items[i]); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void OnChatFrom(ChatScope scope, Player source, ref string msg,
|
||||
object arg, ref ChatMessageFilter filter, bool irc);
|
||||
public sealed class OnChatFromEvent : IEvent<OnChatFrom> {
|
||||
|
||||
public static void Call(ChatScope scope,Player source, ref string msg,
|
||||
object arg, ref ChatMessageFilter filter, bool irc) {
|
||||
IEvent<OnChatFrom>[] items = handlers.Items;
|
||||
for (int i = 0; i < items.Length; i++) {
|
||||
try { items[i].method(scope, source, ref msg, arg, ref filter, irc); }
|
||||
catch (Exception ex) { LogHandlerException(ex, items[i]); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void OnChat(ChatScope scope, Player source, ref string msg,
|
||||
object arg, ref ChatMessageFilter filter, bool irc);
|
||||
public sealed class OnChatEvent : IEvent<OnChat> {
|
||||
|
||||
|
||||
public static void Call(ChatScope scope, Player source, ref string msg,
|
||||
object arg, ref ChatMessageFilter filter, bool irc) {
|
||||
IEvent<OnChat>[] items = handlers.Items;
|
||||
for (int i = 0; i < items.Length; i++) {
|
||||
try { items[i].method(scope, source, ref msg, arg, ref filter, irc); }
|
||||
catch (Exception ex) { LogHandlerException(ex, items[i]); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ namespace MCGalaxy.Games {
|
||||
DateTime now = DateTime.UtcNow;
|
||||
if (now < last) return;
|
||||
|
||||
Player.Message(p, "%4Do not {0} &c- ops have been warned.", action);
|
||||
Player.Message(p, "&4Do not {0} &c- ops have been warned.", action);
|
||||
Chat.MessageFromOps(p, "λNICK &4appears to be " + action + "ing");
|
||||
Logger.Log(LogType.SuspiciousActivity, "{0} appears to be {1}ing", p.name, action);
|
||||
last = now.AddSeconds(5);
|
||||
|
@ -34,14 +34,13 @@ namespace MCGalaxy.Games {
|
||||
}
|
||||
|
||||
public void Message(Player source, string message) {
|
||||
MessageOnline(source, "&9- to team - λNICK: &f" + message);
|
||||
message = "&9- to team - λNICK: &f" + message;
|
||||
Chat.MessageChat(ChatScope.All, source, message, this,
|
||||
(pl, arg) => pl.Game.Team == arg);
|
||||
}
|
||||
|
||||
public void Action(Player source, string message) {
|
||||
MessageOnline(source, "Team - λNICK %S" + message);
|
||||
}
|
||||
|
||||
void MessageOnline(Player source, string message) {
|
||||
message = "Team - λNICK %S" + message;
|
||||
Chat.MessageFrom(ChatScope.All, source, message, this,
|
||||
(pl, arg) => pl.Game.Team == arg);
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ namespace MCGalaxy.Games {
|
||||
|
||||
void IncreaseAliveStats(Player p) {
|
||||
if (p.Game.PledgeSurvive) {
|
||||
Player.Message(p, "You received &a5 %3" + ServerConfig.Currency +
|
||||
Player.Message(p, "You received &a5 &3" + ServerConfig.Currency +
|
||||
" %Sfor successfully pledging that you would survive.");
|
||||
p.SetMoney(p.money + 5);
|
||||
}
|
||||
|
@ -132,6 +132,7 @@ namespace MCGalaxy {
|
||||
|
||||
message = EmotesHandler.Replace(message);
|
||||
message = ChatTokens.ApplyCustom(message);
|
||||
message = message.Replace("&f", "%S");
|
||||
message = Colors.ConvertMCToIRC(message.Replace("%S", ResetSignal));
|
||||
return message;
|
||||
}
|
||||
|
@ -550,11 +550,11 @@ namespace MCGalaxy {
|
||||
|
||||
if (IsPartialSpaced(text)) {
|
||||
partialMessage += text.Substring(0, text.Length - 2) + " ";
|
||||
SendMessage(Colors.teal + "Partial message: &f" + partialMessage);
|
||||
SendMessage("&3Partial message: &f" + partialMessage);
|
||||
return true;
|
||||
} else if (IsPartialJoined(text)) {
|
||||
partialMessage += text.Substring(0, text.Length - 2);
|
||||
SendMessage(Colors.teal + "Partial message: &f" + partialMessage);
|
||||
SendMessage("&3Partial message: &f" + partialMessage);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user