mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -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
@ -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); }
|
||||
|
@ -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); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user