Skip to content

Commit

Permalink
Chanded the way commands display.
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityfox committed Jan 10, 2016
1 parent 5ec45e5 commit 4d03c6c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm
throw new CommandException(Text.of("No Region with name \"" + parse.args[1] + "\"!"));
Text.Builder builder = Text.builder();
builder.append(Text.of(TextColors.GOLD, "\n-----------------------------------------------------\n"));
builder.append(Text.of(TextColors.GREEN, "---General---\n"));
builder.append(Text.of(TextColors.GREEN, "------- General -------\n"));
builder.append(Text.of(TextColors.GOLD, "Name: "), Text.of(TextColors.RESET, region.getName() + "\n"));
builder.append(Text.of(TextColors.GOLD, "Type: "), Text.of(TextColors.RESET, region.getLongTypeName() + "\n"));
builder.append(Text.builder()
Expand All @@ -106,9 +106,9 @@ public CommandResult process(CommandSource source, String arguments) throws Comm
.onHover(TextActions.showText(Text.of("Click to " + (region.isEnabled() ? "Disable" : "Enable"))))
.build());
builder.append(Text.of(TextColors.GOLD, "World: "), Text.of(TextColors.RESET, region.getWorld().getName() + "\n"));
builder.append(Text.of(TextColors.GREEN, "---Details---\n"));
builder.append(Text.of(TextColors.GREEN, "------- Details -------\n"));
builder.append(region.getDetails(parse.args.length < 3 ? "" : parse.args[2]));
builder.append(Text.of(TextColors.GREEN, "\n---Linked Handlers---"));
builder.append(Text.of(TextColors.GREEN, "\n------- Linked Handlers -------"));
if (region.getHandlers().size() == 0)
builder.append(Text.of(TextStyles.ITALIC, "\nNo linked Handlers!"));
region.getHandlers().stream().forEach(handler -> builder.append(Text.of(FGHelper.getColorForHandler(handler),
Expand All @@ -126,7 +126,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm
throw new CommandException(Text.of("No Handler with name \"" + parse.args[1] + "\"!"));
Text.Builder builder = Text.builder();
builder.append(Text.of(TextColors.GOLD, "\n-----------------------------------------------------\n"));
builder.append(Text.of(TextColors.GREEN, "---General---\n"));
builder.append(Text.of(TextColors.GREEN, "------- General -------\n"));
builder.append(Text.of(TextColors.GOLD, "Name: "), Text.of(TextColors.RESET, handler.getName() + "\n"));
builder.append(Text.of(TextColors.GOLD, "Type: "), Text.of(TextColors.RESET, handler.getLongTypeName() + "\n"));
builder.append(Text.builder()
Expand All @@ -141,8 +141,19 @@ public CommandResult process(CommandSource source, String arguments) throws Comm
.onClick(TextActions.suggestCommand("/foxguard handlers priority " + handler.getName() + " "))
.onHover(TextActions.showText(Text.of("Click to Change Priority")))
.build());
builder.append(Text.of(TextColors.GREEN, "---Details---\n"));
builder.append(Text.of(TextColors.GREEN, "------- Details -------\n"));
builder.append(handler.getDetails(parse.args.length < 3 ? "" : parse.args[2]));
builder.append(Text.of(TextColors.GREEN, "\n------- Linked Regions -------"));
List<IRegion> regionList = FGManager.getInstance().getRegionsList().stream()
.filter(region -> region.getHandlers().contains(handler))
.collect(GuavaCollectors.toImmutableList());
if (regionList.size() == 0)
builder.append(Text.of(TextStyles.ITALIC, "\nNo linked Regions!"));
regionList.stream().forEach(region -> builder.append(Text.of(FGHelper.getColorForRegion(region),
TextActions.runCommand("/foxguard detail region " + region.getName()),
TextActions.showText(Text.of("View Details")),
"\n" + FGHelper.getRegionName(region, true)
)));
source.sendMessage(builder.build());
return CommandResult.empty();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ public CommandResult process(CommandSource source, String arguments) throws Comm
output.append(Text.of(TextColors.GOLD, "\n-----------------------------------------------------\n"));
output.append(Text.of(TextColors.AQUA, "----- Position: (" + String.format("%.1f, %.1f, %.1f", x, y, z) + ") -----\n"));
if (!parse.flagmap.containsKey("handler") || parse.flagmap.containsKey("region")) {
output.append(Text.of(TextColors.GREEN, "----- Regions Located Here -----\n"));
output.append(Text.of(TextColors.GREEN, "------- Regions Located Here -------\n"));
ListIterator<IRegion> regionListIterator = regionList.listIterator();
while (regionListIterator.hasNext()) {
IRegion region = regionListIterator.next();
output.append(Text.of(FGHelper.getColorForRegion(region),
TextActions.runCommand("/foxguard detail region --w:" + region.getWorld().getName() + " " + region.getName()),
TextActions.showText(Text.of("View Details")),
region.getShortTypeName() + " : " + region.getName()));
FGHelper.getRegionName(region, false)));
if (regionListIterator.hasNext()) output.append(Text.of("\n"));
}
flag = true;
Expand All @@ -144,7 +144,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm
regionList.forEach(region -> region.getHandlers().stream()
.filter(handler -> !handlerList.contains(handler))
.forEach(handlerList::add));
output.append(Text.of(TextColors.GREEN, "----- Handlers Located Here -----\n"));
output.append(Text.of(TextColors.GREEN, "------- Handlers Located Here -------\n"));
ListIterator<IHandler> handlerListIterator = handlerList.listIterator();
while (handlerListIterator.hasNext()) {
IHandler handler = handlerListIterator.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ public CommandResult process(CommandSource source, String arguments) throws Comm

Text.Builder output = Text.builder()
.append(Text.of(TextColors.GOLD, "\n-----------------------------------------------------\n"))
.append(Text.of(TextColors.GREEN, "---Regions" + (allFlag ? "" : (" for world: \"" + worldName + "\"")) + "---\n"));
.append(Text.of(TextColors.GREEN, "------- Regions" + (allFlag ? "" : (" for world: \"" + worldName + "\"")) + " -------\n"));
ListIterator<IRegion> regionListIterator = regionList.listIterator();
while (regionListIterator.hasNext()) {
IRegion region = regionListIterator.next();
output.append(Text.of(FGHelper.getColorForRegion(region),
TextActions.runCommand("/foxguard detail region --w:" + region.getWorld().getName() + " " + region.getName()),
TextActions.showText(Text.of("View Details")),
getRegionName(region, allFlag)));
FGHelper.getRegionName(region, allFlag)));
if (regionListIterator.hasNext()) output.append(Text.of("\n"));
}
source.sendMessage(output.build());
Expand All @@ -110,7 +110,7 @@ public CommandResult process(CommandSource source, String arguments) throws Comm

Text.Builder output = Text.builder()
.append(Text.of(TextColors.GOLD, "\n-----------------------------------------------------\n"))
.append(Text.of(TextColors.GREEN, "---Handlers---\n"));
.append(Text.of(TextColors.GREEN, "------- Handlers -------\n"));
ListIterator<IHandler> handlerListIterator = handlerList.listIterator();
while (handlerListIterator.hasNext()) {
IHandler handler = handlerListIterator.next();
Expand All @@ -128,10 +128,6 @@ public CommandResult process(CommandSource source, String arguments) throws Comm
}


private String getRegionName(IRegion region, boolean dispWorld) {
return region.getShortTypeName() + " : " + (dispWorld ? region.getWorld().getName() + " : " : "") + region.getName();
}

private boolean contains(String[] aliases, String input) {
for (String alias : aliases) {
if (alias.equalsIgnoreCase(input)) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ public static List<IHandler> getSelectedHandlers(CommandSource source) {
return ((HandlersStateField) FCStateManager.instance().getStateMap().get(source).getOrCreate(HandlersStateField.ID).get()).getList();
}

public static String getRegionName(IRegion region, boolean dispWorld) {
return region.getShortTypeName() + " : " + (dispWorld ? region.getWorld().getName() + " : " : "") + region.getName();
}
}

0 comments on commit 4d03c6c

Please sign in to comment.