mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 21:51:19 -04:00
Fix /spawn not being denied when MOTD denies client-side respawning (thanks tornato)
This commit is contained in:
parent
ea7fac097d
commit
be9145bd8d
@ -25,6 +25,11 @@ namespace MCGalaxy.Commands.World {
|
||||
public override bool SuperUseable { get { return false; } }
|
||||
|
||||
public override void Use(Player p, string message, CommandData data) {
|
||||
if (!Hacks.CanUseRespawn(p, p.level)) {
|
||||
p.Message("You cannot use %T/Spawn %Son this map.");
|
||||
p.isFlying = false; return;
|
||||
}
|
||||
|
||||
if (message.Length > 0) { Help(p); return; }
|
||||
PlayerActions.Respawn(p);
|
||||
}
|
||||
|
@ -19,25 +19,38 @@ using System;
|
||||
using MCGalaxy.Network;
|
||||
|
||||
namespace MCGalaxy {
|
||||
/// <summary> Assistant class for parsing MOTD flags. (-hax, +fly etc) </summary>
|
||||
/// <remarks> CanUse methods also check MOTD of zone player is in. </remarks>
|
||||
public static class Hacks {
|
||||
|
||||
/// <summary> Returns whether the player is currently able to use any hacks at all. </summary>
|
||||
public static bool CanUseHacks(Player p, Level lvl) {
|
||||
byte[] packet = MakeHackControl(p, lvl.GetMotd(p));
|
||||
return packet[1] != 0 && packet[2] != 0 && packet[3] != 0 && packet[4] != 0 && packet[5] != 0;
|
||||
}
|
||||
|
||||
/// <summary> Returns whether the player is currently able to fly. </summary>
|
||||
public static bool CanUseFly(Player p, Level lvl) {
|
||||
return MakeHackControl(p, lvl.GetMotd(p))[1] != 0;
|
||||
}
|
||||
|
||||
/// <summary> Returns whether the player is currently able to use noclip. </summary>
|
||||
public static bool CanUseNoclip(Player p, Level lvl) {
|
||||
return MakeHackControl(p, lvl.GetMotd(p))[2] != 0;
|
||||
}
|
||||
|
||||
/// <summary> Returns whether the player is currently able to move at faster speeds. </summary>
|
||||
public static bool CanUseSpeed(Player p, Level lvl) {
|
||||
return MakeHackControl(p, lvl.GetMotd(p))[3] != 0;
|
||||
}
|
||||
|
||||
/// <summary> Returns whether the player is currently able to respawn. </summary>
|
||||
public static bool CanUseRespawn(Player p, Level lvl) {
|
||||
return MakeHackControl(p, lvl.GetMotd(p))[4] != 0;
|
||||
}
|
||||
|
||||
/// <summary> Parses the MOTD flags and returns resulting HackControl packet. </summary>
|
||||
///<remarks> "+ophax" permission is determined by p.Rank >= LevelPermission.Operator </remarks>
|
||||
public static byte[] MakeHackControl(Player p, string motd) {
|
||||
motd = Colors.Strip(motd);
|
||||
bool isOp = p.Rank >= LevelPermission.Operator;
|
||||
|
Loading…
x
Reference in New Issue
Block a user