All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.nukkit.command.tree.node.WildcardIntNode Maven / Gradle / Ivy

There is a newer version: 1.20.40-r1
Show newest version
package cn.nukkit.command.tree.node;

import cn.nukkit.api.PowerNukkitXOnly;
import cn.nukkit.api.Since;

/**
 * 代表一个可以输入通配符 * 的{@link IntNode},当输入通配符时,将会解析结果将变成默认值{@link #defaultV}
 * 

* 所有命令参数类型为{@link cn.nukkit.command.data.CommandParamType#WILDCARD_INT WILDCARD_INT}如果没有手动指定{@link IParamNode},则会默认使用这个解析 *

* {@code defaultV = Integer.MIN_VALUE} */ @PowerNukkitXOnly @Since("1.19.60-r1") public class WildcardIntNode extends ParamNode { private final int defaultV; public WildcardIntNode() { this(Integer.MIN_VALUE); } public WildcardIntNode(int defaultV) { this.defaultV = defaultV; } @Override public void fill(String arg) { if (arg.length() == 1 && arg.charAt(0) == '*') { this.value = defaultV; } else { try { this.value = Integer.parseInt(arg); } catch (NumberFormatException e) { this.error(); } } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy