Combine /click and /mark into just /mark.

This commit is contained in:
UnknownShadow200 2016-06-10 22:53:09 +10:00
parent 84835429c6
commit 0d6ecc0144
8 changed files with 61 additions and 90 deletions

View File

@ -1,60 +0,0 @@
/*
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at
http://www.opensource.org/licenses/ecl2.php
http://www.gnu.org/licenses/gpl-3.0.html
Unless required by applicable law or agreed to in writing,
software distributed under the Licenses are distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
namespace MCGalaxy.Commands.Building {
public sealed class CmdClick : Command {
public override string name { get { return "click"; } }
public override string shortcut { get { return "x"; } }
public override string type { get { return CommandTypes.Building; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
public CmdClick() { }
public override void Use(Player p, string message) {
if (p == null) { MessageInGameOnly(p); return; }
Vec3U16 click = p.lastClick;
ushort value;
if (message.IndexOf(' ') != -1) {
string[] args = message.ToLower().Split(' ');
if (args.Length != 3) { Help(p); return; }
for (int i = 0; i < 3; i++) {
if (args[i] == "x" || args[i] == "y" || args[i] == "z") {
// use the last value
} else if (ushort.TryParse(args[i], out value)) {
if (i == 0) click.X = value;
else if (i == 1) click.Y = value;
else click.Z = value;
} else {
Player.Message(p, "\"" + args[i] + "\" was not valid"); return;
}
}
}
click = Vec3U16.ClampToBounds(click.X, click.Y, click.Z, p.level);
p.ManualChange(click.X, click.Y, click.Z, 0, Block.rock);
Player.Message(p, "Clicked &b(" + click.X + ", " + click.Y + ", " + click.Z + ")");
}
public override void Help(Player p) {
Player.Message(p, "/click [x y z] - Fakes a click");
Player.Message(p, "If no xyz is given, it uses the last place clicked");
Player.Message(p, "/click 200 y 200 will cause it to click at 200x, last y and 200z");
}
}
}

View File

@ -1,5 +1,5 @@
/*
Copyright 2015 MCGalaxy team
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may
@ -18,22 +18,53 @@
namespace MCGalaxy.Commands.Building {
public sealed class CmdMark : Command {
public override string name { get { return "mark"; } }
public override string shortcut { get { return "m"; } }
public override string shortcut { get { return "click"; } }
public override string type { get { return CommandTypes.Building; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
public CmdMark() { }
public override CommandAlias[] Aliases {
get { return new[] { new CommandAlias("m"), new CommandAlias("x") }; }
}
public override void Use(Player p, string message) {
if (p == null) { MessageInGameOnly(p); return; }
// convert player pos to block coords
Vec3U16 P = Vec3U16.ClampPos(p.pos[0], (ushort)(p.pos[1] - 32), p.pos[2], p.level);
P.X /= 32; P.Y /= 32; P.Z /= 32;
if (message != "" && !ParseCoords(message, p, ref P)) return;
Vec3U16 P = Vec3U16.ClampPosToBounds(p.pos[0], (ushort)(p.pos[1] - 32), p.pos[2], p.level);
Command.all.Find("click").Use(p, (P.X / 32) + " " + (P.Y / 32) + " " + (P.Z / 32));
P = Vec3U16.Clamp(P.X, P.Y, P.Z, p.level);
if (!p.HasBlockchange) {
Player.Message(p, "Cannot mark, no selection or cuboid in progress."); return;
}
p.ManualChange(P.X, P.Y, P.Z, 0, Block.rock);
Player.Message(p, "Mark placed at &b({0}, {1}, {2})", P.X, P.Y, P.Z);
}
bool ParseCoords(string message, Player p, ref Vec3U16 P) {
string[] args = message.ToLower().Split(' ');
if (args.Length != 3) { Help(p); return false; }
ushort value;
for (int i = 0; i < 3; i++) {
if (args[i] == "x") { P.X = p.lastClick.X;
} else if (args[i] == "y") { P.Y = p.lastClick.Y;
} else if (args[i] == "z") { P.Z = p.lastClick.Z;
} else if (ushort.TryParse(args[i], out value)) {
if (i == 0) P.X = value;
else if (i == 1) P.Y = value;
else P.Z = value;
} else {
Player.Message(p, "\"{0}\" was not valid", args[i]); return false;
}
}
return true;
}
public override void Help(Player p) {
Player.Message(p, "/mark - Clicks where you are standing.");
Player.Message(p, "Use this to place a marker at your position when making a selection or cuboid.");
Player.Message(p, "%T/mark [x y z] %H- Places a marker for selections or cuboids");
Player.Message(p, " %HIf no xyz is given, marks at where you are standing");
Player.Message(p, " %He.g. /mark 30 y 20 will mark at (30, last y, 20)");
}
}
}

View File

@ -55,7 +55,7 @@ namespace MCGalaxy.Commands.Building {
if (type == Block.Zero) return;
if (!Block.canPlace(p, type)) { Player.Message(p, "Cannot place that block type."); return; }
Vec3U16 P = Vec3U16.ClampPosToBounds(x, y, z, p.level);
Vec3U16 P = Vec3U16.ClampPos(x, y, z, p.level);
P.X /= 32; P.Y /= 32; P.Z /= 32;
p.level.UpdateBlock(p, P.X, P.Y, P.Z, type, extType);

View File

@ -25,7 +25,7 @@ namespace MCGalaxy.Commands.Building {
public override string shortcut { get { return "wrt"; } }
public override string type { get { return CommandTypes.Building; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Builder; } }
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
static char[] trimChars = { ' ' };
public override void Use(Player p, string message) {
@ -92,7 +92,7 @@ namespace MCGalaxy.Commands.Building {
public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Building; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
public override void Use(Player p, string message) {
Command.all.Find("writetext").Use(p, "1 1 " + message);

View File

@ -28,6 +28,7 @@ namespace MCGalaxy {
internal bool cancelBlock = false;
internal bool cancelmysql = false;
internal bool cancelmessage = false;
internal bool HasBlockchange { get { return Blockchange != null; } }
//Should people be able to cancel this event?
/// <summary> Called when the MOTD is sent to the player </summary>

View File

@ -125,7 +125,7 @@
<Compile Include="Commands\building\CmdBind.cs" />
<Compile Include="Commands\building\CmdBrush.cs" />
<Compile Include="Commands\building\CmdCenter.cs" />
<Compile Include="Commands\building\CmdClick.cs" />
<Compile Include="Commands\building\CmdMark.cs" />
<Compile Include="Commands\building\CmdCmdBind.cs" />
<Compile Include="Commands\building\CmdCopy.cs" />
<Compile Include="Commands\building\CmdCuboid.cs" />
@ -136,7 +136,6 @@
<Compile Include="Commands\building\CmdHollow.cs" />
<Compile Include="Commands\building\CmdImageprint.cs" />
<Compile Include="Commands\building\CmdLine.cs" />
<Compile Include="Commands\building\CmdMark.cs" />
<Compile Include="Commands\building\CmdMaze.cs" />
<Compile Include="Commands\building\CmdMessageBlock.cs" />
<Compile Include="Commands\building\CmdMode.cs" />

View File

@ -54,7 +54,7 @@ namespace MCGalaxy {
public float Length { get { return (float)Math.Sqrt( X * X + Y * Y + Z * Z ); } }
/// <summary> Clamps the given block coordinates to inside the map. </summary>
public static Vec3U16 ClampToBounds(ushort x, ushort y, ushort z, Level lvl) {
public static Vec3U16 Clamp(ushort x, ushort y, ushort z, Level lvl) {
Vec3U16 P = new Vec3U16(x, y, z);
if (P.X >= 32768) P.X = 0;
if (P.Y >= 32768) P.Y = 0;
@ -67,7 +67,7 @@ namespace MCGalaxy {
}
/// <summary> Clamps the given player position coordinates to inside the map. </summary>
public static Vec3U16 ClampPosToBounds(ushort x, ushort y, ushort z, Level lvl) {
public static Vec3U16 ClampPos(ushort x, ushort y, ushort z, Level lvl) {
Vec3U16 P = new Vec3U16(x, y, z);
if (P.X >= 32768) P.X = 0;
if (P.Y >= 32768) P.Y = 0;