Combine /tnt into /mode

This commit is contained in:
UnknownShadow200 2017-02-14 16:21:01 +11:00
parent 49e9830342
commit 030df99a03
4 changed files with 23 additions and 102 deletions

View File

@ -254,15 +254,15 @@ namespace MCGalaxy {
AABB bbCopy = bb;
// Attempt to drop the bot down up to 1 block
int fallY = -32;
int hitY = -32;
for (int dy = 0; dy >= -32; dy--) {
if (AABB.IntersectsSolidBlocks(bb, level)) { fallY = dy + 1; break; }
if (AABB.IntersectsSolidBlocks(bb, level)) { hitY = dy + 1; break; }
bb.Min.Y--; bb.Max.Y--;
}
// Does the bot fall down a block
if (fallY < 0) {
pos[0] += (ushort)dx; pos[1] += (ushort)fallY; pos[2] += (ushort)dz;
if (hitY < 0) {
pos[0] += (ushort)dx; pos[1] += (ushort)hitY; pos[2] += (ushort)dz;
return;
}

View File

@ -24,9 +24,24 @@ namespace MCGalaxy.Commands.Building {
public override string type { get { return CommandTypes.Building; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
public override CommandAlias[] Aliases {
get { return new[] { new CommandAlias("tnt", "tnt") }; }
}
public CmdMode() { }
public override void Use(Player p, string message) {
// Special handling for the old TNT command
if (message.CaselessStarts("tnt ")) {
string[] parts = message.SplitSpaces(2);
if (parts[1].CaselessEq("small")) {
message = Block.Name(Block.smalltnt);
} else if (parts[1].CaselessEq("big")) {
message = Block.Name(Block.bigtnt);
} else if (parts[1].CaselessEq("nuke")) {
message = Block.Name(Block.nuketnt);
}
}
if (message == "") {
if (p.modeType != 0) {
Player.Message(p, "&b{0} %Smode: &cOFF", Block.Name(p.modeType).Capitalize());
@ -61,9 +76,13 @@ namespace MCGalaxy.Commands.Building {
}
public override void Help(Player p) {
Player.Message(p, "%T/mode");
Player.Message(p, "%HReverts the last %T/mode [block].");
Player.Message(p, "%T/mode [block]");
Player.Message(p, "%HMakes every block placed into [block].");
Player.Message(p, "%H/[block] also works");
Player.Message(p, "%T/mode tnt small/big/nuke %H");
Player.Message(p, "%HMakes every block placed into exploding TNT (if physics on).");
}
}
}

View File

@ -1,97 +0,0 @@
/*
Copyright 2011 MCForge
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
{
public sealed class CmdTnt : Command
{
public override string name { get { return "tnt"; } }
public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Other; } }
public override bool museumUsable { get { return false; } }
public override LevelPermission defaultRank { get { return LevelPermission.Builder; } }
public override CommandPerm[] ExtraPerms {
get { return new[] {
new CommandPerm(LevelPermission.Operator, "+ can use big TNT"),
new CommandPerm(LevelPermission.Operator, "+ can allow/disallow tnt"),
new CommandPerm(LevelPermission.Operator, "+ can use nuke TNT"),
}; }
}
public override void Use(Player p, string message) {
if (message.Split(' ').Length > 1) { Help(p); return; }
if (p.modeType == Block.smalltnt || p.modeType == Block.bigtnt || p.modeType == Block.nuketnt) {
if (!p.allowTnt) {
Player.Message(p, "Tnt usage is not allowed at the moment!"); return;
}
p.modeType = 0; Player.Message(p, "TNT mode is now &cOFF%S.");
} else if (message.CaselessEq("small") || message == "") {
if (!p.allowTnt) {
Player.Message(p, "Tnt usage is not allowed at the moment!"); return;
}
p.modeType = Block.smalltnt;
Player.Message(p, "TNT mode is now &aON%S.");
} else if (message.CaselessEq("big")) {
if (!p.allowTnt) {
Player.Message(p, "Tnt usage is not allowed at the moment!"); return;
}
if (CheckExtraPerm(p, 1)) {
p.modeType = Block.bigtnt;
Player.Message(p, "TNT (Big) mode is now &aON%S.");
} else {
MessageNeedExtra(p, 1); return;
}
} else if (message.CaselessEq("nuke")) {
if (!p.allowTnt) {
Player.Message(p, "Tnt usage is not allowed at the moment!"); return;
}
if (CheckExtraPerm(p, 3)) {
p.modeType = Block.nuketnt;
Player.Message(p, "TNT (Nuke) mode is now &aON%S.");
} else {
MessageNeedExtra(p, 3); return;
}
} else if (message.CaselessEq("allow")) {
if (CheckExtraPerm(p, 2)) {
p.allowTnt = true; Player.Message(p, "&cTnt usage has now been enabled!");
} else {
MessageNeedExtra(p, 2); return;
}
return;
} else if (message.CaselessEq("disallow")) {
if (CheckExtraPerm(p, 2)) {
p.allowTnt = false; Player.Message(p, "&cTnt usage has now been disabled!");
} else {
MessageNeedExtra(p, 2); return;
}
return;
} else {
Help(p);
}
p.painting = false;
}
public override void Help(Player p) {
Player.Message(p, "%T/tnt small/big/nuke %H- Creates exploding TNT (if physics on).");
Player.Message(p, "%T/tnt allow/disallow %H- Allows/disallows TNT use server-wide.");
}
}
}

View File

@ -349,7 +349,6 @@
<Compile Include="Commands\other\CmdSendCmd.cs" />
<Compile Include="Commands\other\CmdSummon.cs" />
<Compile Include="Commands\other\CmdTimer.cs" />
<Compile Include="Commands\other\CmdTnt.cs" />
<Compile Include="Commands\other\CmdTp.cs" />
<Compile Include="Commands\other\CmdTpA.cs" />
<Compile Include="Commands\other\CmdWarp.cs" />