mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 20:16:36 -04:00
Allow up/ua yourself, fix /ua with no args behaving incorrectly. (Thanks StarlightGlimmer)
This commit is contained in:
parent
3d66680b42
commit
2100dbd42d
@ -30,12 +30,14 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||
public override CommandAlias[] Aliases {
|
||||
get { return new[] { new CommandAlias("XUndo", null, "all"),
|
||||
new CommandAlias("UndoArea", "area"), new CommandAlias("ua", "area") }; }
|
||||
new CommandAlias("UndoArea", "-area"), new CommandAlias("ua", "-area") }; }
|
||||
}
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
bool area = message.CaselessStarts("area ");
|
||||
if (area) message = message.Substring("area ".Length);
|
||||
bool area = message.CaselessStarts("-area");
|
||||
if (area) {
|
||||
message = message.Substring("-area".Length).TrimStart();
|
||||
}
|
||||
|
||||
if (CheckSuper(p, message, "player name")) return;
|
||||
if (message.Length == 0) { Player.Message(p, "You need to provide a player name."); return; }
|
||||
@ -118,7 +120,8 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
if (names[i] == null) return null;
|
||||
|
||||
Group grp = Group.GroupIn(names[i]);
|
||||
if (p != null && grp.Permission >= p.Rank) {
|
||||
bool canUndo = p == null || grp.Permission < p.Rank || p.name.CaselessEq(names[i]);
|
||||
if (!canUndo) {
|
||||
MessageTooHighRank(p, "undo", false); return null;
|
||||
}
|
||||
|
||||
@ -130,7 +133,7 @@ namespace MCGalaxy.Commands.Moderation {
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/UndoPlayer [player1] <player2..> <timespan>");
|
||||
Player.Message(p, "%HUndoes the block changes of [players] in the past <timespan>");
|
||||
Player.Message(p, "%T/UndoPlayer area [player1] <player2..> <timespan>");
|
||||
Player.Message(p, "%T/UndoPlayer -area [player1] <player2..> <timespan>");
|
||||
Player.Message(p, "%HOnly undoes block changes in the specified region.");
|
||||
Player.Message(p, "%H If <timespan> is not given, undoes 30 minutes.");
|
||||
if (p == null || p.group.MaxUndo == -1 || p.group.MaxUndo == int.MaxValue)
|
||||
|
@ -20,8 +20,6 @@ using System.Threading;
|
||||
using MCGalaxy.Maths;
|
||||
|
||||
namespace MCGalaxy {
|
||||
|
||||
/// <summary> Represents a player or an NPC. </summary>
|
||||
public abstract class Entity {
|
||||
|
||||
// Raw orientation/position - access must be threadsafe
|
||||
@ -33,44 +31,28 @@ namespace MCGalaxy {
|
||||
protected internal Position lastPos;
|
||||
internal bool hasExtPositions;
|
||||
|
||||
|
||||
/// <summary> Model name of this entity. </summary>
|
||||
public string Model = "humanoid";
|
||||
|
||||
/// <summary> AABB of the model of this entity. </summary>
|
||||
public AABB ModelBB;
|
||||
|
||||
/// <summary> Skin name of this entity. </summary>
|
||||
public string SkinName;
|
||||
|
||||
|
||||
/// <summary> Gets or sets the orientation of this entity. </summary>
|
||||
public string SkinName;
|
||||
|
||||
public Orientation Rot {
|
||||
get { return Orientation.Unpack(_rot); }
|
||||
set { _rot = value.Pack(); OnSetRot(); }
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the position of this entity. </summary>
|
||||
public Position Pos {
|
||||
get { return Position.Unpack(Interlocked.Read(ref _pos)); }
|
||||
set { Interlocked.Exchange(ref _pos, value.Pack()); OnSetPos(); }
|
||||
}
|
||||
|
||||
/// <summary> Sets only the yaw and pitch of the orientation of this entity. </summary>
|
||||
public void SetYawPitch(byte yaw, byte pitch) {
|
||||
Orientation rot = Rot;
|
||||
rot.RotY = yaw; rot.HeadX = pitch;
|
||||
Rot = rot;
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Returns whether this entity can see the given entity in the world/level. </summary>
|
||||
|
||||
public abstract bool CanSeeEntity(Entity other);
|
||||
|
||||
/// <summary> Gets the entity/player ID of this entity. </summary>
|
||||
public abstract byte EntityID { get; }
|
||||
|
||||
/// <summary> Gets the world/level this entity is on. </summary>
|
||||
public abstract Level Level { get; }
|
||||
|
||||
protected virtual void OnSetPos() { }
|
||||
|
@ -55,7 +55,7 @@ namespace MCGalaxy.Games {
|
||||
switch (key.ToLower()) {
|
||||
case "start-on-startup": startOnStartup = bool.Parse(value); break;
|
||||
case "send-afk-to-main": sendAfkMain = bool.Parse(value); break;
|
||||
case "vote-count": voteCount = (byte)Utils.Clamp(decimal.Parse(value), 2, 10); break;
|
||||
case "vote-count": voteCount = (byte)Utils.Clamp(int.Parse(value), 2, 10); break;
|
||||
case "vote-time": voteTime = double.Parse(value); break;
|
||||
case "lives": lifeNum = int.Parse(value); break;
|
||||
|
||||
|
@ -73,14 +73,6 @@ namespace MCGalaxy {
|
||||
return Math.Max(Math.Min(value, hi), lo);
|
||||
}
|
||||
|
||||
public static decimal Clamp(decimal value, decimal lo, decimal hi) {
|
||||
return Math.Max(Math.Min(value, hi), lo);
|
||||
}
|
||||
|
||||
public static double Clamp(double value, double lo, double hi) {
|
||||
return Math.Max(Math.Min(value, hi), lo);
|
||||
}
|
||||
|
||||
/// <summary> Divides by 16, rounding up if there is a remainder. </summary>
|
||||
public static int CeilDiv16(int x) { return (x + 15) / 16; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user