mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 20:36:42 +00:00
Improved re-use of command help formatting.
This commit is contained in:
@ -22,7 +22,7 @@ package com.sk89q.worldedit.util.command;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.sk89q.minecraft.util.commands.*;
|
||||
import com.sk89q.worldedit.util.formatting.ColorCodeBuilder;
|
||||
import com.sk89q.worldedit.util.formatting.CommandListBox;
|
||||
import com.sk89q.worldedit.util.formatting.components.CommandListBox;
|
||||
import com.sk89q.worldedit.util.formatting.StyledFragment;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -17,17 +17,20 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.util.formatting;
|
||||
package com.sk89q.worldedit.util.formatting.components;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.Style;
|
||||
import com.sk89q.worldedit.util.formatting.StyledFragment;
|
||||
|
||||
/**
|
||||
* Represents a fragment representing a command that is to be typed.
|
||||
*/
|
||||
public class Cmd extends StyledFragment {
|
||||
public class Code extends StyledFragment {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
public Cmd() {
|
||||
public Code() {
|
||||
super(Style.CYAN);
|
||||
}
|
||||
|
@ -17,7 +17,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.util.formatting;
|
||||
package com.sk89q.worldedit.util.formatting.components;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.Style;
|
||||
|
||||
public class CommandListBox extends MessageBox {
|
||||
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.util.formatting.components;
|
||||
|
||||
import com.sk89q.worldedit.util.command.Description;
|
||||
import com.sk89q.worldedit.util.formatting.Style;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* A box to describe usage of a command.
|
||||
*/
|
||||
public class CommandUsageBox extends MessageBox {
|
||||
|
||||
/**
|
||||
* Create a new box.
|
||||
*
|
||||
* @param description the command to describe
|
||||
* @param title the title
|
||||
*/
|
||||
public CommandUsageBox(Description description, String title) {
|
||||
super(title);
|
||||
checkNotNull(description);
|
||||
attachCommandUsage(description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new box.
|
||||
*
|
||||
* @param description the command to describe
|
||||
*/
|
||||
public CommandUsageBox(Description description) {
|
||||
super("Usage Help");
|
||||
checkNotNull(description);
|
||||
attachCommandUsage(description);
|
||||
}
|
||||
|
||||
private void attachCommandUsage(Description description) {
|
||||
if (description.getUsage() != null) {
|
||||
getContents().append(new Label().append("Usage: "));
|
||||
getContents().append(description.getUsage());
|
||||
} else {
|
||||
getContents().append(new Subtle().append("Usage information is not available."));
|
||||
}
|
||||
|
||||
getContents().newLine();
|
||||
|
||||
if (description.getHelp() != null) {
|
||||
getContents().createFragment(Style.YELLOW_DARK).append(description.getHelp());
|
||||
} else if (description.getShortDescription() != null) {
|
||||
getContents().createFragment(Style.YELLOW_DARK).append(description.getShortDescription());
|
||||
} else {
|
||||
getContents().append(new Subtle().append("No further help is available."));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.util.formatting.components;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.Style;
|
||||
import com.sk89q.worldedit.util.formatting.StyledFragment;
|
||||
|
||||
/**
|
||||
* Represents a fragment representing a label.
|
||||
*/
|
||||
public class Label extends StyledFragment {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
public Label() {
|
||||
super(Style.YELLOW);
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.util.formatting;
|
||||
package com.sk89q.worldedit.util.formatting.components;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.ColorCodeBuilder;
|
||||
import com.sk89q.worldedit.util.formatting.Style;
|
||||
import com.sk89q.worldedit.util.formatting.StyledFragment;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.util.formatting.components;
|
||||
|
||||
import com.sk89q.worldedit.util.formatting.Style;
|
||||
import com.sk89q.worldedit.util.formatting.StyledFragment;
|
||||
|
||||
/**
|
||||
* Represents a subtle part of the message.
|
||||
*/
|
||||
public class Subtle extends StyledFragment {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
public Subtle() {
|
||||
super(Style.GRAY);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user