Don't allow /ascend or /descend when you can't use hacks. (Thanks goodlyay)

This commit is contained in:
UnknownShadow200 2016-07-28 17:17:22 +10:00
parent 4a3a1b82c5
commit b5b8197c04
8 changed files with 33 additions and 31 deletions

View File

@ -30,15 +30,10 @@ namespace MCGalaxy.Commands {
public override void Use(Player p, string message) {
Player[] alive = Server.zombie.Alive.Items;
if (alive.Length == 0) {
Player.Message(p, "No one is alive."); return;
}
if (alive.Length == 0) { Player.Message(p, "No one is alive."); return; }
Player.Message(p, "Players who are " + Colors.green + "alive %Sare:");
string list = "";
foreach (Player pl in alive)
list = list + pl.group.color + pl.DisplayName + "%S, ";
Player.Message(p, list);
Player.Message(p, "Players who are &2alive %Sare:");
Player.Message(p, alive.Join(pl => pl.ColoredName + "%S"));
}
public override void Help(Player p) {

View File

@ -30,15 +30,10 @@ namespace MCGalaxy.Commands {
public override void Use(Player p, string message) {
Player[] infected = Server.zombie.Infected.Items;
if (infected.Length == 0) {
Player.Message(p, "No one is infected"); return;
}
if (infected.Length == 0) { Player.Message(p, "No one is infected"); return; }
Player.Message(p, "Players who are " + Colors.red + "infected %Sare:");
string list = "";
foreach (Player pl in infected)
list = list + Colors.red + pl.DisplayName + "%S, ";
Player.Message(p, list);
Player.Message(p, "Players who are &cinfected %Sare:");
Player.Message(p, infected.Join(pl => "&c" + pl.DisplayName + "%S"));
}
public override void Help(Player p) {

View File

@ -16,9 +16,7 @@
permissions and limitations under the Licenses.
*/
namespace MCGalaxy.Commands {
public sealed class CmdJoker : Command {
public sealed class CmdJoker : Command {
public override string name { get { return "joker"; } }
public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Moderation; } }

View File

@ -27,6 +27,10 @@ namespace MCGalaxy.Commands {
public CmdAscend() { }
public override void Use(Player p, string message) {
if (Player.IsSuper(p)) { MessageInGameOnly(p); return; }
if (!p.level.CanUseHacks(p)) {
Player.Message(p, "You cannot use /ascend on this map."); return;
}
ushort x = (ushort)(p.pos[0] / 32), y = (ushort)(p.pos[1] / 32), z = (ushort)(p.pos[2] / 32);
while (y < p.level.Height) {
@ -52,8 +56,11 @@ namespace MCGalaxy.Commands {
}
public override void Help(Player p) {
string name = Group.findPerm(LevelPermission.Operator).ColoredName;
Player.Message(p, "%T/ascend");
Player.Message(p, "%HTeleports you to the first free space above you.");
Player.Message(p, "%H Does not work on maps which have -hax in their motd. " +
"(unless you are {0}%H+ and the motd also has +ophax)", name);
}
}
}

View File

@ -25,6 +25,10 @@ namespace MCGalaxy.Commands {
public CmdDescend() { }
public override void Use(Player p, string message) {
if (Player.IsSuper(p)) { MessageInGameOnly(p); return; }
if (!p.level.CanUseHacks(p)) {
Player.Message(p, "You cannot use /descend on this map."); return;
}
if (p.pos[1] < 51 + 4) { Player.Message(p, "No free spaces found below you."); return; }
// Move starting position down half a block since players are a little bit above the ground.
ushort x = (ushort)(p.pos[0] / 32), y = (ushort)((p.pos[1] - 51 - 4) / 32), z = (ushort)(p.pos[2] / 32);
@ -54,6 +58,8 @@ namespace MCGalaxy.Commands {
public override void Help(Player p) {
Player.Message(p, "%T/descend");
Player.Message(p, "%HTeleports you to the first free space below you.");
Player.Message(p, "%H Does not work on maps which have -hax in their motd. " +
"(unless you are {0}%H+ and the motd also has +ophax)", name);
}
}
}

View File

@ -28,13 +28,8 @@ namespace MCGalaxy.Commands {
public CmdFly() { }
public override void Use(Player p, string message) {
bool serverMotd = p.level == Server.mainLevel || p.level.motd == "ignore";
string motd = serverMotd ? Server.motd : p.level.motd;
bool noFly = motd.Contains("-hax") || p.level.ctfmode || p.level.CurrentGame() != null;
if (noFly && p.Rank >= LevelPermission.Operator && motd.Contains("+ophax"))
noFly = false;
if (noFly) {
if (Player.IsSuper(p)) { MessageInGameOnly(p); return; }
if (!p.level.CanUseHacks(p)) {
Player.Message(p, "You cannot use /fly on this map.");
p.isFlying = false; return;
}

View File

@ -109,6 +109,15 @@ namespace MCGalaxy {
CustomBlocks = null;
}
}
public bool CanUseHacks(Player p) {
bool serverMotd = p.level == Server.mainLevel || motd == "ignore";
string realMotd = serverMotd ? Server.motd : motd;
bool noHacks = realMotd.Contains("-hax") || ctfmode || CurrentGame() != null;
if (noHacks && p.Rank >= LevelPermission.Operator && realMotd.Contains("+ophax"))
return true;
return noHacks;
}
/// <summary> Whether block changes made on this level should be
/// saved to the BlockDB and .lvl files. </summary>

View File

@ -373,11 +373,8 @@ namespace MCGalaxy {
if (OnSettingsUpdate != null) OnSettingsUpdate();
}
public static string FindColor(string Username) {
foreach (Group grp in Group.GroupList.Where(grp => grp.playerList.Contains(Username))) {
return grp.color;
}
return Group.standard.color;
public static string FindColor(string name) {
return Group.findPlayerGroup(name).color;
}
}
}