mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Don't let you use /infoswap on same or higher ranked players.
This commit is contained in:
parent
b583e80d27
commit
e402a9f15b
@ -32,12 +32,10 @@ namespace MCGalaxy.Commands {
|
||||
string[] parts = message.SplitSpaces(2);
|
||||
if (message == "" || parts.Length == 1) { Help(p); return; }
|
||||
|
||||
Player who = PlayerInfo.Find(parts[0]);
|
||||
string whoTo = who == null ? parts[0] : who.name;
|
||||
string fromname = p == null ? "(console)" : p.name;
|
||||
if (!Player.ValidName(whoTo)) {
|
||||
Player.Message(p, "%cIllegal name!"); return;
|
||||
}
|
||||
Player receiver = PlayerInfo.Find(parts[0]);
|
||||
string receiverName = receiver == null ? parts[0] : receiver.name;
|
||||
string senderName = p == null ? "(console)" : p.name;
|
||||
if (!ValidName(p, receiverName, "player")) return;
|
||||
|
||||
message = parts[1];
|
||||
//DB
|
||||
@ -47,13 +45,13 @@ namespace MCGalaxy.Commands {
|
||||
message = message.Substring(0, 255);
|
||||
}
|
||||
//safe against SQL injections because whoTo is checked for illegal characters
|
||||
Database.Execute("CREATE TABLE if not exists `Inbox" + whoTo +
|
||||
Database.Execute("CREATE TABLE if not exists `Inbox" + receiverName +
|
||||
"` (PlayerFrom CHAR(20), TimeSent DATETIME, Contents VARCHAR(255));");
|
||||
Database.Execute("INSERT INTO `Inbox" + whoTo + "` (PlayerFrom, TimeSent, Contents) VALUES (@0, @1, @2)",
|
||||
fromname, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), message);
|
||||
Database.Execute("INSERT INTO `Inbox" + receiverName + "` (PlayerFrom, TimeSent, Contents) VALUES (@0, @1, @2)",
|
||||
senderName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), message);
|
||||
|
||||
Player.Message(p, "Message sent to &5" + whoTo + ".");
|
||||
if (who != null) who.SendMessage("Message recieved from &5" + fromname + "%S.");
|
||||
Player.Message(p, "Message sent to &5" + receiverName + ".");
|
||||
if (receiver != null) receiver.SendMessage("Message recieved from &5" + senderName + "%S.");
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -49,9 +49,18 @@ namespace MCGalaxy.Commands {
|
||||
if (dst == null) {
|
||||
Player.Message(p, "\"{0}\" was not found in the database.", args[1]); return;
|
||||
}
|
||||
|
||||
Group srcGroup = Group.findPlayerGroup(src.Name);
|
||||
Group dstGroup = Group.findPlayerGroup(dst.Name);
|
||||
if (p != null && srcGroup.Permission > p.Rank) {
|
||||
Player.Message(p, "Cannot /infoswap for a player ranked equal or higher to yours."); return;
|
||||
}
|
||||
if (p != null && dstGroup.Permission > p.Rank) {
|
||||
Player.Message(p, "Cannot /infoswap for a player ranked equal or higher to yours."); return;
|
||||
}
|
||||
|
||||
Swap(src, dst); Swap(dst, src);
|
||||
SwapGroups(src, dst);
|
||||
SwapGroups(src, dst, srcGroup, dstGroup);
|
||||
}
|
||||
|
||||
const string format = "yyyy-MM-dd HH:mm:ss";
|
||||
@ -69,10 +78,7 @@ namespace MCGalaxy.Commands {
|
||||
src.Money, src.Title, src.TitleColor, src.TotalTime, dst.Name);
|
||||
}
|
||||
|
||||
void SwapGroups(PlayerData src, PlayerData dst) {
|
||||
Group srcGroup = Group.findPlayerGroup(src.Name);
|
||||
Group dstGroup = Group.findPlayerGroup(dst.Name);
|
||||
|
||||
void SwapGroups(PlayerData src, PlayerData dst, Group srcGroup, Group dstGroup) {
|
||||
srcGroup.playerList.Remove(src.Name);
|
||||
srcGroup.playerList.Add(dst.Name);
|
||||
srcGroup.playerList.Save();
|
||||
|
Loading…
x
Reference in New Issue
Block a user