mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
ZS/LS: Authors can't like/dislike own map anymore.
This commit is contained in:
parent
ff0932ad22
commit
80ea48ae7a
@ -16,12 +16,9 @@
|
|||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace MCGalaxy.Commands {
|
namespace MCGalaxy.Commands {
|
||||||
|
public class CmdMapLike : Command {
|
||||||
public sealed class CmdMapLike : Command {
|
|
||||||
public override string name { get { return "maplike"; } }
|
public override string name { get { return "maplike"; } }
|
||||||
public override string shortcut { get { return "like"; } }
|
public override string shortcut { get { return "like"; } }
|
||||||
public override string type { get { return CommandTypes.Games; } }
|
public override string type { get { return CommandTypes.Games; } }
|
||||||
@ -29,12 +26,34 @@ namespace MCGalaxy.Commands {
|
|||||||
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
|
||||||
public override CommandEnable Enabled { get { return CommandEnable.Zombie | CommandEnable.Lava; } }
|
public override CommandEnable Enabled { get { return CommandEnable.Zombie | CommandEnable.Lava; } }
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) { RateMap(p, true); }
|
||||||
if (p == null) { MessageInGameOnly(p); return; }
|
|
||||||
if (p.Game.RatedMap) { Player.Message(p, "You have already liked this map."); return; }
|
protected static bool RateMap(Player p, bool like) {
|
||||||
p.level.Likes++;
|
string action = like ? "like" : "dislike";
|
||||||
|
if (p == null) { MessageInGameOnly(p); return false; }
|
||||||
|
|
||||||
|
if (p.Game.RatedMap) {
|
||||||
|
Player.Message(p, "You have already {0}d this map.", action); return false;
|
||||||
|
}
|
||||||
|
if (CheckIsAuthor(p)) {
|
||||||
|
Player.Message(p, "Cannot {0} this map as you are an author of it.", action); return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (like) p.level.Likes++;
|
||||||
|
else p.level.Dislikes++;
|
||||||
p.Game.RatedMap = true;
|
p.Game.RatedMap = true;
|
||||||
Player.Message(p, "You have liked this map.");
|
|
||||||
|
action = like ? "&aliked" : "&cdisliked";
|
||||||
|
Player.Message(p, "You have {0} %Sthis map.", action);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected bool CheckIsAuthor(Player p) {
|
||||||
|
string[] authors = p.level.Authors.Split(',');
|
||||||
|
for (int i = 0; i < authors.Length; i++) {
|
||||||
|
if (authors[i].CaselessEq(p.name)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
@ -43,21 +62,10 @@ namespace MCGalaxy.Commands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class CmdMapDislike : Command {
|
public sealed class CmdMapDislike : CmdMapLike {
|
||||||
public override string name { get { return "mapdislike"; } }
|
public override string name { get { return "mapdislike"; } }
|
||||||
public override string shortcut { get { return "dislike"; } }
|
public override string shortcut { get { return "dislike"; } }
|
||||||
public override string type { get { return CommandTypes.Games; } }
|
public override void Use(Player p, string message) { RateMap(p, false); }
|
||||||
public override bool museumUsable { get { return true; } }
|
|
||||||
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
|
|
||||||
public override CommandEnable Enabled { get { return CommandEnable.Zombie | CommandEnable.Lava; } }
|
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
|
||||||
if (p == null) { MessageInGameOnly(p); return; }
|
|
||||||
if (p.Game.RatedMap) { Player.Message(p, "You have already disliked this map."); return; }
|
|
||||||
p.level.Dislikes++;
|
|
||||||
p.Game.RatedMap = true;
|
|
||||||
Player.Message(p, "You have disliked this map.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "%T/mapdislike");
|
Player.Message(p, "%T/mapdislike");
|
||||||
|
@ -103,9 +103,9 @@ namespace MCGalaxy.Commands {
|
|||||||
|
|
||||||
Player.Message(p, "&9Players in the review queue:");
|
Player.Message(p, "&9Players in the review queue:");
|
||||||
int pos = 1;
|
int pos = 1;
|
||||||
foreach (string who in Server.reviewlist) {
|
foreach (string name in Server.reviewlist) {
|
||||||
string rank = Group.findPlayer(who.ToLower());
|
Group grp = Group.findPlayerGroup(name);
|
||||||
Player.Message(p, "&a" + pos + ". &f" + who + "&a - Current Rank: " + Group.Find(rank).color + rank);
|
Player.Message(p, "&a" + pos + ". &f" + name + "&a - Current Rank: " + grp.ColoredName);
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user