mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-28 07:56:20 -04:00
Remove pointless CommandHasBadColourCodes which never really worked properly.
This commit is contained in:
parent
8caf30d81b
commit
ea02a24cbd
@ -73,10 +73,11 @@ namespace MCGalaxy.Commands {
|
|||||||
"custom color with the name \"" + name + "\"."); return;
|
"custom color with the name \"" + name + "\"."); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char fallback = args[3][0];
|
char fallback = args[3][0];
|
||||||
if (!Colors.IsStandardColor(fallback)) {
|
if (!Colors.IsStandardColor(fallback)) {
|
||||||
Player.SendMessage(p, fallback + " must be a standard color code."); return;
|
Player.SendMessage(p, fallback + " must be a standard color code."); return;
|
||||||
}
|
}
|
||||||
|
if (fallback >= 'A' && fallback <= 'F') fallback += ' ';
|
||||||
|
|
||||||
string hex = args[4];
|
string hex = args[4];
|
||||||
if (hex.Length > 0 && hex[0] == '#')
|
if (hex.Length > 0 && hex[0] == '#')
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
namespace MCGalaxy.Commands
|
namespace MCGalaxy.Commands {
|
||||||
{
|
|
||||||
public sealed class CmdSay : Command
|
public sealed class CmdSay : Command {
|
||||||
{
|
|
||||||
public override string name { get { return "say"; } }
|
public override string name { get { return "say"; } }
|
||||||
public override string shortcut { get { return ""; } }
|
public override string shortcut { get { return ""; } }
|
||||||
public override string type { get { return CommandTypes.Other; } }
|
public override string type { get { return CommandTypes.Other; } }
|
||||||
@ -26,25 +26,15 @@ namespace MCGalaxy.Commands
|
|||||||
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||||
public CmdSay() { }
|
public CmdSay() { }
|
||||||
|
|
||||||
public override void Use(Player p, string message)
|
public override void Use(Player p, string message) {
|
||||||
{
|
|
||||||
if (message == "") { Help(p); return; }
|
if (message == "") { Help(p); return; }
|
||||||
|
|
||||||
//for (int i = 0; i < 10; i++)
|
|
||||||
// message = message.Replace("%" + i, "&" + i);
|
|
||||||
//for (char c = 'a'; c <= 'f'; c++)
|
|
||||||
// message = message.Replace("%" + c, "&" + c);
|
|
||||||
message = Colors.EscapeColors(message);
|
message = Colors.EscapeColors(message);
|
||||||
Player.GlobalMessage(message);
|
Player.GlobalMessage(message);
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
|
||||||
message = message.Replace("&" + i, "");
|
|
||||||
for (char c = 'a'; c <= 'f'; c++)
|
|
||||||
message = message.Replace("&" + c, "");
|
|
||||||
Server.IRC.Say(message);
|
Server.IRC.Say(message);
|
||||||
}
|
}
|
||||||
public override void Help(Player p)
|
|
||||||
{
|
public override void Help(Player p) {
|
||||||
Player.SendMessage(p, "/say - broadcasts a global message to everyone in the server.");
|
Player.SendMessage(p, "/say - broadcasts a global message to everyone in the server.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,9 +269,6 @@ namespace MCGalaxy {
|
|||||||
if (banCmd.Contains(cmdName)) {
|
if (banCmd.Contains(cmdName)) {
|
||||||
error = "You are not allowed to use this command from IRC."; return false;
|
error = "You are not allowed to use this command from IRC."; return false;
|
||||||
}
|
}
|
||||||
if (Player.CommandHasBadColourCodes(null, message)) {
|
|
||||||
error = "Your command had invalid color codes."; return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,9 +188,13 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
if (colorParse) {
|
if (colorParse) {
|
||||||
for (int i = 0; i < 128; i++) {
|
for (int i = 0; i < 128; i++) {
|
||||||
if (Colors.IsStandardColor((char)i)) continue;
|
if (Colors.IsStandardColor((char)i)) {
|
||||||
CustomColor col = Colors.ExtColors[i];
|
if (i >= 'A' && i <= 'F') // WoM does not work with uppercase color codes.
|
||||||
|
sb.Replace("&" + (char)i, "&" + (char)(i + ' '));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomColor col = Colors.ExtColors[i];
|
||||||
if (col.Undefined) {
|
if (col.Undefined) {
|
||||||
sb.Replace("&" + (char)i, ""); continue;
|
sb.Replace("&" + (char)i, ""); continue;
|
||||||
}
|
}
|
||||||
|
@ -477,36 +477,6 @@ namespace MCGalaxy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool CommandHasBadColourCodes(Player who, string message) {
|
|
||||||
string[] checkmessagesplit = message.Split(' ');
|
|
||||||
bool lastendwithcolour = false;
|
|
||||||
foreach ( string s in checkmessagesplit ) {
|
|
||||||
s.Trim();
|
|
||||||
if ( s.StartsWith("%") ) {
|
|
||||||
if ( lastendwithcolour ) {
|
|
||||||
if ( who != null ) {
|
|
||||||
who.SendMessage("Sorry, Your colour codes in this command were invalid (You cannot use 2 colour codes next to each other");
|
|
||||||
who.SendMessage("Command failed.");
|
|
||||||
Server.s.Log(who.name + " attempted to send a command with invalid colours codes (2 colour codes were next to each other)!");
|
|
||||||
Chat.GlobalMessageOps(who.color + who.DisplayName + " " + Server.DefaultColor + " attempted to send a command with invalid colours codes (2 colour codes were next to each other)!");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if ( s.Length == 2 ) {
|
|
||||||
lastendwithcolour = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( s.TrimEnd(Server.ColourCodesNoPercent).EndsWith("%") ) {
|
|
||||||
lastendwithcolour = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
lastendwithcolour = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<ChatMessage> Last50Chat = new List<ChatMessage>();
|
public static List<ChatMessage> Last50Chat = new List<ChatMessage>();
|
||||||
public static void GlobalMessage(string message) {
|
public static void GlobalMessage(string message) {
|
||||||
GlobalMessage(message, false);
|
GlobalMessage(message, false);
|
||||||
|
@ -142,8 +142,7 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static string EscapeColors(string value) {
|
public static string EscapeColors(string value) {
|
||||||
if (value.IndexOf('%') == -1)
|
if (value.IndexOf('%') == -1) return value;
|
||||||
return value;
|
|
||||||
char[] chars = new char[value.Length];
|
char[] chars = new char[value.Length];
|
||||||
|
|
||||||
for (int i = 0; i < value.Length; i++ ) {
|
for (int i = 0; i < value.Length; i++ ) {
|
||||||
@ -163,7 +162,11 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static bool MapColor(ref char color) {
|
public static bool MapColor(ref char color) {
|
||||||
if (IsStandardColor(color)) return true;
|
if (IsStandardColor(color)) {
|
||||||
|
if (color >= 'A' && color <= 'F') color += ' ';
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (color == 's' || color == 'S') { color = Server.DefaultColor[1]; return true; }
|
if (color == 's' || color == 'S') { color = Server.DefaultColor[1]; return true; }
|
||||||
if (color == 'h' || color == 'H') { color = 'e'; return true; }
|
if (color == 'h' || color == 'H') { color = 'e'; return true; }
|
||||||
if (color == 't' || color == 'T') { color = 'a'; return true; }
|
if (color == 't' || color == 'T') { color = 'a'; return true; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user