Add gas block draw type to /gb and /lb (Thanks goodlyay), fix /rankinfo showing rank changes in wrong order, fix message block not reverting when no stored message is found, also reduce code duplication in /nick and /xnick.

This commit is contained in:
UnknownShadow200 2016-01-29 10:59:53 +11:00
parent 80d4c283e1
commit 1bac264497
6 changed files with 67 additions and 81 deletions

View File

@ -50,8 +50,8 @@ namespace MCGalaxy.Commands {
string reason = parts.Length <= 9 ? null :
CP437Reader.ConvertToRaw(parts[9].Replace("%20", " "));
Player.SendMessage(p, "&aRank changed from: " + newRank.color + newRank.name
+ " &ato " + oldRank.color + oldRank.name);
Player.SendMessage(p, "&aRank changed from: " + oldRank.color + oldRank.name
+ " &ato " + newRank.color + newRank.name);
Player.SendMessage(p, "&aRanked by: %S" + parts[1] + " &aon %S" + timeRanked);
if (reason != null)
Player.SendMessage(p, "&aRank reason: %S" + reason);

View File

@ -184,7 +184,7 @@ namespace MCGalaxy.Commands {
}
} else if (step == 11) {
bool result = byte.TryParse(value, out bd.BlockDraw);
if (result && bd.BlockDraw >= 0 && bd.BlockDraw <= 3)
if (result && bd.BlockDraw >= 0 && bd.BlockDraw <= 4)
step++;
} else if (step == 12) {
if (value == "0" || value == "1") {
@ -311,7 +311,7 @@ namespace MCGalaxy.Commands {
def.Shape = value == "0" ? (byte)0 : def.MaxY; break;
case "draw":
case "blockdraw":
if (!EditByte(p, value, "Block draw", ref def.BlockDraw, 11, 1, 0, 3)) return;
if (!EditByte(p, value, "Block draw", ref def.BlockDraw, 11, 1, 0, 4)) return;
break;
case "min":
case "mincoords":
@ -431,7 +431,7 @@ namespace MCGalaxy.Commands {
},
new[] { "Type '0' if the block should be darkened when in shadow, '1' if not(e.g lava)." },
new[] { "Define the block's draw method.", "0 = Opaque, 1 = Transparent (Like glass)",
"2 = Transparent (Like leaves), 3 = Translucent (Like ice)",
"2 = Transparent (Like leaves), 3 = Translucent (Like ice), 4 = Gas (Like air)",
},
new[] { "Type '0' if the block is treated as a sprite(e.g roses), '1' if not." },
new[] { "Enter the three minimum coordinates of the cube in pixels (separated by spaces). There are 16 pixels per block." },

View File

@ -1,54 +1,83 @@
/*
Copyright 2015 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.
*/
using System;
using MCGalaxy;
namespace MCGalaxy.Commands
{
public class CmdNick : Command
{
namespace MCGalaxy.Commands {
public class CmdNick : Command {
public override string name { get { return "nick"; } }
public override string shortcut { get { return "nickname"; } }
public override string type { get { return CommandTypes.Other; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public CmdNick() { }
static char[] trimChars = { ' ' };
public override void Use(Player p, string message)
{
public override void Use(Player p, string message) {
if (message == "") { Help(p); return; }
int pos = message.IndexOf(' ');
Player who = Player.Find(message.Split(' ')[0]);
string[] parts = message.Split(trimChars, 2);
Player who = Player.Find(parts[0]);
if (who == null) { Player.SendMessage(p, "Could not find player."); return; }
if (p != null && who.group.Permission > p.group.Permission)
{
Player.SendMessage(p, "Cannot change the nick of someone of greater rank");
return;
if (p != null && who.group.Permission > p.group.Permission) {
Player.SendMessage(p, "Cannot change the nick of someone of greater rank"); return;
}
string query;
string newName = "";
if (message.Split(' ').Length > 1) newName = message.Substring(pos + 1);
else
{
string newName = parts.Length > 1 ? parts[1] : "";
if (newName == "") {
who.DisplayName = who.name;
Player.GlobalChat(who, who.color + who.prefix + who.DisplayName + "&g has reverted their nick to their original name.", false);
Player.GlobalDespawn(p, false);
Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
return;
Player.GlobalChat(who, who.color + who.prefix + who.DisplayName + "%S has reverted their nick to their original name.", false);
} else {
if (newName.Length > 60) { Player.SendMessage(p, "Nick must be under 60 letters."); return; }
who.DisplayName = newName;
Player.GlobalChat(who, who.color + who.DisplayName + "%S has changed their nick to " + who.color + newName + "%S.", false);
}
if (newName.Length > 60) { Player.SendMessage(p, "Nick must be under 60 letters."); return; }
if (newName != "") Player.GlobalChat(who, who.color + who.DisplayName + "&g has changed their nick to " + newName + "&g.", false);
who.DisplayName = newName;
Player.GlobalDespawn(who, false);
Player.GlobalSpawn(who, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1], false);
PlayerDB.Save(who);
}
public override void Help(Player p)
{
public override void Help(Player p) {
Player.SendMessage(p, "/nick <player> [newName] - Gives <player> the nick of [newName].");
Player.SendMessage(p, "If no [newName] is given, the player's nick is reverted to their original name.");
}
}
public class CmdXNick : Command {
public override string name { get { return "xnick"; } }
public override string shortcut { get { return "xnickname"; } }
public override string type { get { return CommandTypes.Other; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public CmdXNick() { }
public override void Use(Player p, string message) {
Command.all.Find("nick").Use(p, p.name + " " + message);
}
public override void Help(Player p) {
Player.SendMessage(p, "/xnick [newName] - Gives you the nick of [newName].");
Player.SendMessage(p, "If no [newName] is given, your nick is reverted to your original name.");
}
}
}

View File

@ -1,44 +0,0 @@
using System;
using MCGalaxy;
namespace MCGalaxy.Commands
{
public class CmdXNick : Command
{
public override string name { get { return "xnick"; } }
public override string shortcut { get { return "xnickname"; } }
public override string type { get { return CommandTypes.Other; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public CmdXNick() { }
public override void Use(Player p, string message)
{
if (message == "")
{
p.DisplayName = p.name;
Player.GlobalChat(p, p.color + p.prefix + p.DisplayName + "&g has reverted their nick to their original name.", false);
Player.GlobalDespawn(p, false);
Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
return;
}
string newName = "";
newName = message;
if (newName.Length > 60) { Player.SendMessage(p, "Nick must be under 60 letters."); return; }
if (newName != "") Player.GlobalChat(p, p.color + p.DisplayName + "&g has changed their nick to " + newName + "&g.", false);
p.DisplayName = newName;
Player.GlobalDespawn(p, false);
Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false);
PlayerDB.Save(p);
}
public override void Help(Player p)
{
Player.SendMessage(p, "/xnick [newName] - Gives you the nick of [newName].");
Player.SendMessage(p, "If no [newName] is given, your nick is reverted to your original name.");
}
}
}

View File

@ -363,7 +363,6 @@
<Compile Include="Commands\Other\CmdWaypoint.cs" />
<Compile Include="Commands\Other\CmdXColor.cs" />
<Compile Include="Commands\Other\CmdXJail.cs" />
<Compile Include="Commands\Other\CmdXNick.cs" />
<Compile Include="Commands\Other\CmdXspawn.cs" />
<Compile Include="Commands\Other\CmdXTColor.cs" />
<Compile Include="Commands\Other\CmdXTitle.cs" />

View File

@ -1241,8 +1241,10 @@ namespace MCGalaxy {
Blockchange(this, x, y, z, Block.air, 0);
}
Messages.Dispose();
}
catch { Player.SendMessage(p, "No message was stored."); return; }
} catch {
Player.SendMessage(p, "No message was stored.");
RevertBlock(x, y, z); return;
}
}
private void DeleteBlock(byte b, ushort x, ushort y, ushort z, byte type, byte extType) {