本文整理汇总了Java中com.dsh105.commodus.StringUtil.combineArray方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtil.combineArray方法的具体用法?Java StringUtil.combineArray怎么用?Java StringUtil.combineArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.dsh105.commodus.StringUtil
的用法示例。
在下文中一共展示了StringUtil.combineArray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Suggestion
import com.dsh105.commodus.StringUtil; //导入方法依赖的package包/类
public Suggestion(InfluxManager<?> manager, String input, int maximumAllowed) {
this.manager = manager;
this.input = input;
this.suggestions = new ArrayList<>();
for (Controller controller : this.manager.getMappedCommands()) {
if (this.suggestions.size() > maximumAllowed) {
break;
}
if (!this.suggestions.contains(controller.getCommand().getAcceptedStringSyntax())) {
Command command = controller.getCommand();
String[] parts = command.getStringSyntax().split("\\s+");
String[] parts2 = command.getAcceptedStringSyntax().split("\\s+");
int maxIndex = command.getIndexOf(command.getFirstVariable(), false);
if (maxIndex < 0) maxIndex = parts.length;
int maxIndex2 = command.getIndexOf(command.getFirstVariable(), false);
if (maxIndex2 < 0) maxIndex2 = parts2.length;
String suggestion = StringUtil.combineArray(0, maxIndex, " ", parts);
String suggestion2 = StringUtil.combineArray(0, maxIndex2, " ", parts);
if (this.input.startsWith(suggestion) || this.input.startsWith(suggestion2)) {
this.suggestions.add(command.getAcceptedStringSyntax());
}
}
}
}
示例2: convert
import com.dsh105.commodus.StringUtil; //导入方法依赖的package包/类
@Override
public SpongePosition convert(ContextualVariable variable) throws ConversionException {
try {
SpongePosition position = SpongeUtil.readLocation(0, variable.getConsumedArguments());
if (position == null) {
throw new ConversionException("Invalid location coordinates provided: " + StringUtil.combineArray(0, 4, ", ", variable.getConsumedArguments()));
}
return position;
} catch (IllegalStateException e) {
throw new ConversionException("World does not exist:" + variable.getConsumedArguments()[0]);
}
}
示例3: convert
import com.dsh105.commodus.StringUtil; //导入方法依赖的package包/类
@Override
public Location convert(ContextualVariable variable) throws ConversionException {
try {
Location location = BukkitUtil.readLocation(0, variable.getConsumedArguments());
if (location == null) {
throw new ConversionException("Invalid location coordinates provided: " + StringUtil.combineArray(0, 4, ", ", variable.getConsumedArguments()));
}
return location;
} catch (IllegalStateException e) {
throw new ConversionException("World does not exist:" + variable.getConsumedArguments()[0]);
}
}
示例4: convert
import com.dsh105.commodus.StringUtil; //导入方法依赖的package包/类
@Override
public Voxel convert(ContextualVariable variable) throws ConversionException {
int[] coordinates = new int[3];
for (int i = 0; i < 3; i++) {
try {
coordinates[i] = GeneralUtil.toInteger(variable.getConsumedArguments()[i]);
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
throw new ConversionException("Invalid voxel coordinates provided: " + StringUtil.combineArray(0, 4, ", ", variable.getConsumedArguments()));
}
}
return new Voxel(coordinates[0], coordinates[1], coordinates[2]);
}
示例5: prepare
import com.dsh105.commodus.StringUtil; //导入方法依赖的package包/类
public static PowerMessage prepare(InfluxManager<?> manager, BukkitHelpEntry helpEntry, String message, int maxDescLength) {
int aliases = helpEntry.getController().getCommand().getAliases().size();
PowerMessage result = new PowerMessage();
int next = 0;
Matcher matcher = Pattern.compile("<(.+?)>").matcher(message);
while (next < message.length()) {
if (matcher.find()) {
if (matcher.start() > next) {
result.then(manager.getResponder().format(message.substring(matcher.start(), next)));
}
next = matcher.end() + 1;
switch (matcher.group(1)) {
case "command":
result.then(manager.getResponder().format(manager.getCommandPrefix() + helpEntry.getController().getCommand().getAcceptedStringSyntax(), false))
.colour(ChatColor.UNDERLINE)
.tooltip(manager.getResponder().format("{c2}Click to auto-complete"))
.suggest(helpEntry.getController().getCommand().getAcceptedStringSyntax());
break;
case "alias_num":
result.then(aliases + " alias" + (aliases == 1 ? "" : "es") + "");
if (aliases > 1) {
result.tooltip(manager.getResponder().format(StringUtil.combine("{c1}, {c2}", helpEntry.getController().getCommand().getReadableStringAliases())));
}
break;
case "short_desc":
case "long_desc":
String desc = matcher.group(1).equals("short_desc") ? helpEntry.getShortDescription() : StringUtil.combineArray("\n", helpEntry.getLongDescription()[0]);
if (maxDescLength > 0) {
desc = desc.length() > maxDescLength ? desc.substring(0, maxDescLength - 3) + "..." : desc;
}
result.then(desc);
break;
default:
result.then(manager.getResponder().format(matcher.group(0), false));
break;
}
} else {
// We're done
result.then(message.substring(next));
break;
}
}
return result;
}
示例6: prepare
import com.dsh105.commodus.StringUtil; //导入方法依赖的package包/类
public static Message.Text prepare(final InfluxManager<?> manager, final SpongeHelpEntry helpEntry, String message, int maxDescLength) {
int aliases = helpEntry.getController().getCommand().getAliases().size();
MessageBuilder.Text result = Messages.builder("");
int next = 0;
Matcher matcher = Pattern.compile("<(.+?)>").matcher(message);
while (next < message.length()) {
if (matcher.find()) {
if (matcher.start() > next) {
result.append(Messages.of(manager.getResponder().format(message.substring(matcher.start(), next))));
}
next = matcher.end() + 1;
switch (matcher.group(1)) {
case "command":
result.append(Messages.of(manager.getResponder().format(manager.getCommandPrefix() + helpEntry.getController().getCommand().getAcceptedStringSyntax(), false)))
.style(TextStyles.UNDERLINE)
.onHover(new HoverAction.ShowText() {
@Override
public String getId() {
return "auto-complete";
}
@Override
public Message getResult() {
return Messages.of(manager.getResponder().format("{c2}Click to auto-complete"));
}
})
.onClick(new ClickAction.SuggestCommand() {
@Override
public String getId() {
return "entry-command";
}
@Override
public String getResult() {
return helpEntry.getController().getCommand().getAcceptedStringSyntax();
}
});
break;
case "alias_num":
result.append(Messages.of(aliases + " alias" + (aliases == 1 ? "" : "es") + ""));
if (aliases > 1) {
result.onHover(new HoverAction.ShowText() {
@Override
public String getId() {
return "aliases";
}
@Override
public Message getResult() {
return Messages.of(manager.getResponder().format(StringUtil.combine("{c1}, {c2}", helpEntry.getController().getCommand().getReadableStringAliases())));
}
});
}
break;
case "short_desc":
case "long_desc":
String desc = matcher.group(1).equals("short_desc") ? helpEntry.getShortDescription() : StringUtil.combineArray("\n", helpEntry.getLongDescription()[0]);
if (maxDescLength > 0) {
desc = desc.length() > maxDescLength ? desc.substring(0, maxDescLength - 3) + "..." : desc;
}
result.append(Messages.of(desc));
break;
default:
result.append(Messages.of(manager.getResponder().format(matcher.group(0), false)));
break;
}
} else {
// We're done
result.append(Messages.of(message.substring(next)));
break;
}
}
return result.build();
}
示例7: getConsumedValue
import com.dsh105.commodus.StringUtil; //导入方法依赖的package包/类
public String getConsumedValue() {
return StringUtil.combineArray(" ", value);
}