mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -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) {
|
void ShowMessageBlocks(Player p) {
|
||||||
p.showMBs = !p.showMBs;
|
p.showMBs = !p.showMBs;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
if (p.level.hasMessageBlocks) {
|
||||||
using (DataTable table = Database.Backend.GetRows("Messages" + p.level.name, "*")) {
|
using (DataTable table = Database.Backend.GetRows("Messages" + p.level.name, "*")) {
|
||||||
if (p.showMBs) {
|
count = table.Rows.Count;
|
||||||
ShowMessageBlocks(p, table);
|
if (p.showMBs) { ShowMessageBlocks(p, table); }
|
||||||
} else {
|
else { HideMessageBlocks(p, table); }
|
||||||
HideMessageBlocks(p, table);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Player.Message(p, "Now {0} %SMBs.", p.showMBs ? "showing &a" + count : "hiding");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowMessageBlocks(Player p, DataTable table) {
|
static void ShowMessageBlocks(Player p, DataTable table) {
|
||||||
foreach (DataRow row in table.Rows) {
|
foreach (DataRow row in table.Rows) {
|
||||||
p.SendBlockchange(U16(row["X"]), U16(row["Y"]), U16(row["Z"]), (ExtBlock)Block.Green);
|
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) {
|
static void HideMessageBlocks(Player p, DataTable table) {
|
||||||
foreach (DataRow row in table.Rows) {
|
foreach (DataRow row in table.Rows) {
|
||||||
p.RevertBlock(U16(row["X"]), U16(row["Y"]), U16(row["Z"]));
|
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); }
|
static ushort U16(object x) { return Convert.ToUInt16(x); }
|
||||||
|
@ -150,13 +150,16 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
|
|
||||||
void ShowPortals(Player p) {
|
void ShowPortals(Player p) {
|
||||||
p.showPortals = !p.showPortals;
|
p.showPortals = !p.showPortals;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
if (p.level.hasPortals) {
|
||||||
using (DataTable table = Database.Backend.GetRows("Portals" + p.level.name, "*")) {
|
using (DataTable table = Database.Backend.GetRows("Portals" + p.level.name, "*")) {
|
||||||
if (p.showPortals) {
|
count = table.Rows.Count;
|
||||||
ShowPortals(p, table);
|
if (p.showPortals) { ShowPortals(p, table); }
|
||||||
} else {
|
else { HidePortals(p, table); }
|
||||||
HidePortals(p, table);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Player.Message(p, "Now {0} %Sportals.", p.showPortals ? "showing &a" + count : "hiding");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShowPortals(Player p, DataTable table) {
|
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);
|
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) {
|
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"]));
|
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); }
|
static ushort U16(object x) { return Convert.ToUInt16(x); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user