mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 03:55:18 -04:00
Fix doing portal/mb show on a map without portals/mbs causing an error
This commit is contained in:
parent
7c57f76280
commit
57a4777a87
@ -58,7 +58,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
bool allCmds = HasExtraPerm(p, 1);
|
||||
if (!MessageBlock.Validate(p, data.Message, allCmds)) return;
|
||||
|
||||
Player.Message(p, "Place where you wish the message block to go.");
|
||||
Player.Message(p, "Place where you wish the message block to go.");
|
||||
p.MakeSelection(1, data, PlacedMark);
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
|
||||
// Hardcoded aliases for backwards compatibility
|
||||
block.BlockID = Block.MB_White; block.ExtID = 0;
|
||||
if (name == "white") block.BlockID = Block.MB_White;
|
||||
if (name == "white") block.BlockID = Block.MB_White;
|
||||
if (name == "black") block.BlockID = Block.MB_Black;
|
||||
if (name == "air") block.BlockID = Block.MB_Air;
|
||||
if (name == "water") block.BlockID = Block.MB_Water;
|
||||
@ -114,9 +114,9 @@ namespace MCGalaxy.Commands.Building {
|
||||
p.level.UpdateBlock(p, x, y, z, args.Block);
|
||||
UpdateDatabase(p, args, x, y, z);
|
||||
Player.Message(p, "Message block created.");
|
||||
} else {
|
||||
} else {
|
||||
Player.Message(p, "Failed to create a message block.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
if (count == 0) {
|
||||
Database.Backend.AddRow("Messages" + lvlName, "X, Y, Z, Message", x, y, z, args.Message);
|
||||
} else {
|
||||
Database.Backend.UpdateRows("Messages" + lvlName, "Message=@3",
|
||||
Database.Backend.UpdateRows("Messages" + lvlName, "Message=@3",
|
||||
"WHERE X=@0 AND Y=@1 AND Z=@2", x, y, z, args.Message);
|
||||
}
|
||||
}
|
||||
@ -152,27 +152,28 @@ namespace MCGalaxy.Commands.Building {
|
||||
|
||||
void ShowMessageBlocks(Player p) {
|
||||
p.showMBs = !p.showMBs;
|
||||
using (DataTable table = Database.Backend.GetRows("Messages" + p.level.name, "*")) {
|
||||
if (p.showMBs) {
|
||||
ShowMessageBlocks(p, table);
|
||||
} else {
|
||||
HideMessageBlocks(p, table);
|
||||
int count = 0;
|
||||
|
||||
if (p.level.hasMessageBlocks) {
|
||||
using (DataTable table = Database.Backend.GetRows("Messages" + p.level.name, "*")) {
|
||||
count = table.Rows.Count;
|
||||
if (p.showMBs) { ShowMessageBlocks(p, table); }
|
||||
else { HideMessageBlocks(p, table); }
|
||||
}
|
||||
}
|
||||
Player.Message(p, "Now {0} %SMBs.", p.showMBs ? "showing &a" + count : "hiding");
|
||||
}
|
||||
|
||||
static void ShowMessageBlocks(Player p, DataTable table) {
|
||||
foreach (DataRow row in table.Rows) {
|
||||
p.SendBlockchange(U16(row["X"]), U16(row["Y"]), U16(row["Z"]), (ExtBlock)Block.Green);
|
||||
}
|
||||
Player.Message(p, "Now showing &a" + table.Rows.Count + " %SMBs.");
|
||||
}
|
||||
|
||||
static void HideMessageBlocks(Player p, DataTable table) {
|
||||
foreach (DataRow row in table.Rows) {
|
||||
p.RevertBlock(U16(row["X"]), U16(row["Y"]), U16(row["Z"]));
|
||||
}
|
||||
Player.Message(p, "Now hiding MBs.");
|
||||
}
|
||||
|
||||
static ushort U16(object x) { return Convert.ToUInt16(x); }
|
||||
@ -192,7 +193,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
|
||||
static void GetAllNames(Player p, List<string> names) {
|
||||
GetCoreNames(names, p.level);
|
||||
GetCoreNames(names, p.level);
|
||||
for (int i = Block.CpeCount; i < Block.Count; i++) {
|
||||
ExtBlock block = ExtBlock.FromRaw((byte)i);
|
||||
string name = Format(block, p.level, p.level.Props);
|
||||
|
@ -69,7 +69,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
if (name == "water") block.BlockID = Block.Portal_Water;
|
||||
if (name == "lava") block.BlockID = Block.Portal_Lava;
|
||||
|
||||
if (p.level.Props[block.Index].IsPortal) return block;
|
||||
if (p.level.Props[block.Index].IsPortal) return block;
|
||||
Help(p); return ExtBlock.Invalid;
|
||||
}
|
||||
|
||||
@ -81,8 +81,8 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
p.ClearBlockchange();
|
||||
|
||||
if (args.Multi && block.BlockID == Block.Red && args.Entries.Count > 0) {
|
||||
ExitChange(p, x, y, z, block); return;
|
||||
if (args.Multi && block.BlockID == Block.Red && args.Entries.Count > 0) {
|
||||
ExitChange(p, x, y, z, block); return;
|
||||
}
|
||||
|
||||
p.level.UpdateBlock(p, x, y, z, args.Block);
|
||||
@ -150,13 +150,16 @@ namespace MCGalaxy.Commands.Building {
|
||||
|
||||
void ShowPortals(Player p) {
|
||||
p.showPortals = !p.showPortals;
|
||||
using (DataTable table = Database.Backend.GetRows("Portals" + p.level.name, "*")) {
|
||||
if (p.showPortals) {
|
||||
ShowPortals(p, table);
|
||||
} else {
|
||||
HidePortals(p, table);
|
||||
int count = 0;
|
||||
|
||||
if (p.level.hasPortals) {
|
||||
using (DataTable table = Database.Backend.GetRows("Portals" + p.level.name, "*")) {
|
||||
count = table.Rows.Count;
|
||||
if (p.showPortals) { ShowPortals(p, table); }
|
||||
else { HidePortals(p, table); }
|
||||
}
|
||||
}
|
||||
}
|
||||
Player.Message(p, "Now {0} %Sportals.", p.showPortals ? "showing &a" + count : "hiding");
|
||||
}
|
||||
|
||||
static void ShowPortals(Player p, DataTable table) {
|
||||
@ -166,8 +169,6 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
p.SendBlockchange(U16(row["EntryX"]), U16(row["EntryY"]), U16(row["EntryZ"]), (ExtBlock)Block.Green);
|
||||
}
|
||||
|
||||
Player.Message(p, "Now showing &a" + table.Rows.Count + " %Sportals.");
|
||||
}
|
||||
|
||||
static void HidePortals(Player p, DataTable table) {
|
||||
@ -177,7 +178,6 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
p.RevertBlock(U16(row["EntryX"]), U16(row["EntryY"]), U16(row["EntryZ"]));
|
||||
}
|
||||
Player.Message(p, "Now hiding portals.");
|
||||
}
|
||||
|
||||
static ushort U16(object x) { return Convert.ToUInt16(x); }
|
||||
@ -197,7 +197,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
|
||||
static void GetAllNames(Player p, List<string> names) {
|
||||
GetCoreNames(names, p.level);
|
||||
GetCoreNames(names, p.level);
|
||||
for (int i = Block.CpeCount; i < Block.Count; i++) {
|
||||
ExtBlock block = ExtBlock.FromRaw((byte)i);
|
||||
string name = Format(block, p.level, p.level.Props);
|
||||
|
Loading…
x
Reference in New Issue
Block a user