forked from ClassiCube/MCGalaxy-Plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CmdTempBlock.cs
65 lines (56 loc) · 2.42 KB
/
CmdTempBlock.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using MCGalaxy;
using MCGalaxy.Commands;
using MCGalaxy.Blocks;
using MCGalaxy.Maths;
using BlockID = System.UInt16;
namespace CommandTempBlock
{
public sealed class CmdTempBlock : Command2
{
public override string name { get { return "TempBlock"; } }
public override string type { get { return CommandTypes.Building; } }
public override void Use(Player p, string message, CommandData data) {
if (!(p.group.Permission >= LevelPermission.Operator)) {
if (!Hacks.CanUseHacks(p)) {
if (data.Context != CommandContext.MessageBlock) {
p.Message("&cYou cannot use this command manually when hacks are disabled.");
return;
}
}
}
BlockID block = p.GetHeldBlock();
string[] parts = message.SplitSpaces();
Vec3S32 pos;
pos.X = p.Pos.BlockX;
pos.Y = (p.Pos.Y - 32) / 32;
pos.Z = p.Pos.BlockZ;
switch (parts.Length) {
case 1:
if (message == "") break;
if (!CommandParser.GetBlock(p, parts[0], out block)) return;
break;
case 3:
if (!CommandParser.GetCoords(p, parts, 0, ref pos)) return;
break;
case 4:
if (!CommandParser.GetBlock(p, parts[0], out block)) return;
if (!CommandParser.GetCoords(p, parts, 1, ref pos)) return;
break;
default:
p.Message("Invalid number of parameters"); return;
}
if (!CommandParser.IsBlockAllowed(p, "place ", block)) return;
pos = p.level.ClampPos(pos);
p.SendBlockchange((ushort)pos.X, (ushort)pos.Y, (ushort)pos.Z, block);
//string blockName = Block.GetName(p, block);
//p.Message("{3} block was placed at ({0}, {1}, {2}).", P.X, P.Y, P.Z, blockName);
}
public override void Help(Player p) {
p.Message("&T/TempBlock <block>");
p.Message("&HPlaces a client-side block at your feet");
p.Message("&T/TempBlock <block> [x] [y] [z]");
p.Message("&HPlaces a client-side block at [x] [y] [z]");
}
}
}