mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Now /ccols list uses pagintation too
This commit is contained in:
parent
cc773a82fe
commit
5de6a59c3d
@ -21,6 +21,8 @@ using MCGalaxy.Blocks;
|
|||||||
namespace MCGalaxy {
|
namespace MCGalaxy {
|
||||||
public sealed partial class Block {
|
public sealed partial class Block {
|
||||||
|
|
||||||
|
public static bool IsPhysicsId(byte block) { return block >= CpeCount && block != custom_block; }
|
||||||
|
|
||||||
public static bool Walkthrough(byte block) {
|
public static bool Walkthrough(byte block) {
|
||||||
return block == air || block == shrub || block == Block.snow
|
return block == air || block == shrub || block == Block.snow
|
||||||
|| block == fire || block == rope
|
|| block == fire || block == rope
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
namespace MCGalaxy.Commands.CPE {
|
namespace MCGalaxy.Commands.CPE {
|
||||||
@ -40,7 +41,8 @@ namespace MCGalaxy.Commands.CPE {
|
|||||||
case "delete":
|
case "delete":
|
||||||
RemoveHandler(p, args); break;
|
RemoveHandler(p, args); break;
|
||||||
case "list":
|
case "list":
|
||||||
ListHandler(p, args, false); break;
|
string modifer = args.Length > 1 ? args[1] : "";
|
||||||
|
ListHandler(p, "ccols list", modifer); break;
|
||||||
case "edit":
|
case "edit":
|
||||||
case "modify":
|
case "modify":
|
||||||
EditHandler(p, args); break;
|
EditHandler(p, args); break;
|
||||||
@ -96,28 +98,19 @@ namespace MCGalaxy.Commands.CPE {
|
|||||||
Player.Message(p, "Successfully removed a custom color.");
|
Player.Message(p, "Successfully removed a custom color.");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void ListHandler(Player p, string[] args, bool all) {
|
internal static void ListHandler(Player p, string cmd, string modifier) {
|
||||||
int offset = 0, index = 0, count = 0;
|
List<CustomColor> validCols = new List<CustomColor>(Colors.ExtColors.Length);
|
||||||
if (args != null && args.Length > 1) int.TryParse(args[1], out offset);
|
foreach (CustomColor col in Colors.ExtColors) {
|
||||||
CustomColor[] cols = Colors.ExtColors;
|
|
||||||
|
|
||||||
for (int i = 0; i < cols.Length; i++) {
|
|
||||||
CustomColor col = cols[i];
|
|
||||||
if (col.Undefined) continue;
|
if (col.Undefined) continue;
|
||||||
|
validCols.Add(col);
|
||||||
|
}
|
||||||
|
MultiPageOutput.Output(p, validCols, FormatColor, cmd, "colors", modifier, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (index >= offset) {
|
// Not very elegant, because we don't want the % to be escaped like everywhere else
|
||||||
count++;
|
static string FormatColor(CustomColor col) {
|
||||||
const string format = "{4}{0} &{1}({2}){4} - %{1}, falls back to &{3}%{3}.";
|
const string format = "{0} &{1}({2})%S - %&S{1}, falls back to &{3}%&{3}{3}";
|
||||||
Player.SendMessage(p, String.Format(format, col.Name, col.Code, col.Hex(), col.Fallback, Server.DefaultColor), false);
|
return String.Format(format, col.Name, col.Code, col.Hex(), col.Fallback);
|
||||||
|
|
||||||
if (count >= 8 && !all) {
|
|
||||||
const string helpFormat = "To see the next set of custom colors, type %T/ccols list {0}";
|
|
||||||
Player.Message(p, helpFormat, offset + 8);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditHandler(Player p, string[] args) {
|
void EditHandler(Player p, string[] args) {
|
||||||
|
@ -55,7 +55,7 @@ namespace MCGalaxy.Commands {
|
|||||||
Player.Message(p, "4 - &4Maroon %S| 5 - &5Purple %S| 6 - &6Gold %S| 7 - &7Silver");
|
Player.Message(p, "4 - &4Maroon %S| 5 - &5Purple %S| 6 - &6Gold %S| 7 - &7Silver");
|
||||||
Player.Message(p, "8 - &8Gray %S| 9 - &9Blue %S| a - &aLime %S| b - &bAqua");
|
Player.Message(p, "8 - &8Gray %S| 9 - &9Blue %S| a - &aLime %S| b - &bAqua");
|
||||||
Player.Message(p, "c - &cRed %S| d - &dPink %S| e - &eYellow %S| f - &fWhite");
|
Player.Message(p, "c - &cRed %S| d - &dPink %S| e - &eYellow %S| f - &fWhite");
|
||||||
CmdCustomColors.ListHandler(p, null, true);
|
CmdCustomColors.ListHandler(p, "help colors", "all");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (CmdCommands.DoCommand(p, message)) break;
|
if (CmdCommands.DoCommand(p, message)) break;
|
||||||
|
@ -20,9 +20,11 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace MCGalaxy {
|
namespace MCGalaxy {
|
||||||
|
|
||||||
/// <summary> Outputs a large range of values across a number of 'pages'. </summary>
|
/// <summary> Outputs a large range of values across a number of 'pages'. (Pagination) </summary>
|
||||||
public static class MultiPageOutput {
|
public static class MultiPageOutput {
|
||||||
|
|
||||||
|
/// <summary> Outputs a large range of values across a number of 'pages'. (Pagination) </summary>
|
||||||
|
/// <param name="lines">true if each item is printed on a separate line, false if combined. </param>
|
||||||
public static void Output<T>(Player p, IList<T> items, Func<T, string> formatter,
|
public static void Output<T>(Player p, IList<T> items, Func<T, string> formatter,
|
||||||
string cmd, string type, string modifier, bool lines) {
|
string cmd, string type, string modifier, bool lines) {
|
||||||
int page = 0, total = items.Count;
|
int page = 0, total = items.Count;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user