mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Fix /copyslot clear (thanks Unk)
This commit is contained in:
parent
e2661264c1
commit
afb65c158c
@ -35,11 +35,15 @@ namespace MCGalaxy.Commands.Building
|
|||||||
} else if (message.CaselessEq("random")) {
|
} else if (message.CaselessEq("random")) {
|
||||||
SetRandomCopySlot(p);
|
SetRandomCopySlot(p);
|
||||||
} else if (message.CaselessStarts("clear")) {
|
} else if (message.CaselessStarts("clear")) {
|
||||||
string numStr = message.Substring(5).Trim();
|
string[] words = message.SplitSpaces();
|
||||||
int i = 0;
|
if (words.Length < 2) {
|
||||||
if (!CommandParser.GetInt(p, numStr, "Slot number", ref i, 1, p.group.CopySlots)) return;
|
p.Message("You must provide a slot number to clear.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int num = 0;
|
||||||
|
if (!CommandParser.GetInt(p, words[1], "Slot number", ref num, 1, p.group.CopySlots)) return;
|
||||||
|
|
||||||
ClearCopySlot(p, i);
|
ClearCopySlot(p, num);
|
||||||
} else {
|
} else {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if (!CommandParser.GetInt(p, message, "Slot number", ref i, 1, p.group.CopySlots)) return;
|
if (!CommandParser.GetInt(p, message, "Slot number", ref i, 1, p.group.CopySlots)) return;
|
||||||
@ -91,15 +95,15 @@ namespace MCGalaxy.Commands.Building
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ClearCopySlot(Player p, int i) {
|
static void ClearCopySlot(Player p, int num) {
|
||||||
int idx = i - 1;
|
int i = num - 1; //We know that i is 0 at min bc num passed to this is 1 at min
|
||||||
List<CopyState> copySlots = p.CopySlots;
|
List<CopyState> copySlots = p.CopySlots;
|
||||||
if (copySlots[idx] == null) {
|
if (i >= copySlots.Count || copySlots[i] == null) {
|
||||||
p.Message("Copy slot {0} is already empty.", i);
|
p.Message("Copy slot {0} is already empty.", num);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
copySlots[idx] = null;
|
copySlots[i] = null;
|
||||||
p.Message("Cleared copy slot {0}.", i);
|
p.Message("Cleared copy slot {0}.", num);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user