From cd5f832adf68f7d8b6f585396399e9ac1850e531 Mon Sep 17 00:00:00 2001 From: wizjany Date: Sat, 3 Aug 2013 09:23:36 -0400 Subject: [PATCH] Added methods to CommandContext to get slices excluding flags et al. --- .../minecraft/util/commands/CommandContext.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java b/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java index 0a36b7e98..16ddedbe1 100644 --- a/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java +++ b/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java @@ -204,6 +204,18 @@ public class CommandContext { return slice; } + public String[] getParsedSlice(int index) { + String[] slice = new String[parsedArgs.size() - index]; + System.arraycopy(parsedArgs.toArray(new String[parsedArgs.size()]), index, slice, 0, parsedArgs.size() - index); + return slice; + } + + public String[] getParsedPaddedSlice(int index, int padding) { + String[] slice = new String[parsedArgs.size() - index + padding]; + System.arraycopy(parsedArgs.toArray(new String[parsedArgs.size()]), index, slice, padding, parsedArgs.size() - index); + return slice; + } + public boolean hasFlag(char ch) { return booleanFlags.contains(ch) || valueFlags.containsKey(ch); }