本文整理汇总了Java中com.sk89q.worldguard.protection.flags.InvalidFlagFormat类的典型用法代码示例。如果您正苦于以下问题:Java InvalidFlagFormat类的具体用法?Java InvalidFlagFormat怎么用?Java InvalidFlagFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvalidFlagFormat类属于com.sk89q.worldguard.protection.flags包,在下文中一共展示了InvalidFlagFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseInput
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; //导入依赖的package包/类
@Override
public PotionEffect parseInput(FlagContext context) throws InvalidFlagFormat
{
String[] splitd = context.getUserInput().trim().split(" ");
if (splitd.length == 2)
{
PotionEffectType potionEffect = PotionEffectType.getByName(splitd[0]);
if (potionEffect != null)
{
return new PotionEffect(potionEffect, 160, new Integer(splitd[1]));
}
else
{
throw new InvalidFlagFormat("Unable to find the potion effect!");
}
}
else
{
throw new InvalidFlagFormat("Please use format: <effect name> <effect amplifier>");
}
}
示例2: parseInput
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; //导入依赖的package包/类
@Override
public Set<T> parseInput(FlagContext context) throws InvalidFlagFormat
{
String input = context.getUserInput();
if (input.isEmpty())
{
return Sets.newHashSet();
}
else
{
Set<T> items = Sets.newHashSet();
for (String str : input.split(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)", -1))
{
if (str.startsWith("\"") && str.endsWith("\""))
{
str = str.substring(1, str.length() - 1);
}
FlagContext copy = context.copyWith(null, str, null);
items.add(this.getType().parseInput(copy));
}
return items;
}
}
示例3: setFlag
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; //导入依赖的package包/类
public static <T> void setFlag(ProtectedRegion region, Flag<T> flag, String value) throws CommandException, InvalidFlagFormat {
CommandContext ccontext = new CommandContext("rg "+value, valueFlags);
region.setFlag(flag, flag.parseInput(WGBukkit.getPlugin(), Bukkit.getConsoleSender(), ccontext.getRemainingString(0)));
if (ccontext.hasFlag('g')) {
String group = ccontext.getFlag('g');
RegionGroupFlag groupFlag = flag.getRegionGroupFlag();
if (groupFlag == null) {
return;
}
RegionGroup groupValue = groupFlag.parseInput(WGBukkit.getPlugin(), Bukkit.getConsoleSender(), group);
if (groupValue == groupFlag.getDefault()) {
region.setFlag(groupFlag, null);
} else {
region.setFlag(groupFlag, groupValue);
}
}
}
示例4: parseInput
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; //导入依赖的package包/类
@Override
public AudioDelay parseInput(String input) throws InvalidFlagFormat {
Range delayTime = null;
String trackId = null;
String[] properties = input.split(":");
if (!properties[0].startsWith("time=")) {
properties[0] = "time=" + properties[0];
}
for (String property : properties) {
String[] keyValuePair = property.split("=");
if (keyValuePair.length != 2) {
throw new InvalidFlagFormat("AudioDelay must be in the format ':<key>=<value>' following the delay range or constant");
}
String key = keyValuePair[0], value = keyValuePair[1];
if (delayTime == null && key.equals("time")) {
delayTime = Range.parse(value);
if (delayTime == null) {
throw new InvalidFlagFormat(plugin.getMessenger().getMessage("failed.invalid-delay-range", true, value));
}
} else if (trackId == null && key.equals("track")) {
trackId = value;
try {
ConnectUtils.validateIdentifier(trackId);
} catch (IdentifierSyntaxException e) {
throw new InvalidFlagFormat("track " + e.getMessage());
}
} else {
throw new InvalidFlagFormat("Duplicate or unknown AudioDelay property '" + key + "'");
}
}
if (delayTime == null) {
throw new InvalidFlagFormat("AudioDelay is missing required 'time' property");
}
return new AudioDelay(delayTime, trackId);
}
示例5: convertCommandArg
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; //导入依赖的package包/类
@Override
public Result<T> convertCommandArg(String argName, String arg) {
try {
return Result.success(flag.parseInput(arg));
} catch (InvalidFlagFormat e) {
return Result.fail(e.getMessage());
}
}
示例6: parseInput
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; //导入依赖的package包/类
@Override
public SoundData parseInput(FlagContext context) throws InvalidFlagFormat
{
String[] splitd = context.getUserInput().trim().split(" ");
if (splitd.length == 2)
{
return new SoundData(splitd[0], new Integer(splitd[1]));
}
else
{
throw new InvalidFlagFormat("Please use format: <sound name> <interval in ticks>");
}
}
示例7: parseInput
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; //导入依赖的package包/类
@Override
public Material parseInput(FlagContext context) throws InvalidFlagFormat
{
Material material = Material.getMaterial(context.getUserInput().trim().toUpperCase());
if (material != null)
{
return material;
}
else
{
throw new InvalidFlagFormat("Unable to find the material!");
}
}
示例8: parseInput
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; //导入依赖的package包/类
@Override
public PotionEffectType parseInput(FlagContext context) throws InvalidFlagFormat
{
PotionEffectType potionEffect = PotionEffectType.getByName(context.getUserInput().trim());
if (potionEffect != null)
{
return potionEffect;
}
else
{
throw new InvalidFlagFormat("Unable to find the potion effect!");
}
}
示例9: setFlag
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; //导入依赖的package包/类
/**
* Set a WorldGuard region flag.
* @param region The WorldGuard region to set
* @param flag The flag to set
* @param value The value to set the flag to
* @param <V> They type of flag to set
* @throws InvalidFlagFormat When the value of the flag is wrong
*/
private <V> void setFlag(ProtectedRegion region, Flag<V> flag, String value) throws InvalidFlagFormat {
V current = region.getFlag(flag);
V next = plugin.getWorldGuardHandler().parseFlagInput(flag, value);
if(!Objects.equals(current, next)) {
region.setFlag(flag, next);
}
}
示例10: setFlag
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; //导入依赖的package包/类
private <V> void setFlag(Target t, ProtectedRegion region,
Flag<V> flag, CommandSender sender, String value)
throws InvalidFlagFormat {
try {
region.setFlag(flag, flag.parseInput(FlagContext.create().setSender(sender).setInput(value).build()));
} catch (NoClassDefFoundError ex) {
// probably WorldGuard 3.1.2 or earlier
region.setFlag(flag, flag.unmarshal(ReflectionUtils.invokeMethod(flag, "parseInput", WorldGuardPlugin.inst(), sender, value)));
}
}
示例11: parseInput
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; //导入依赖的package包/类
@Override
public AudioTrack parseInput(FlagContext context) throws InvalidFlagFormat {
return parseInput(stringFlag.parseInput(context));
}
示例12: setRegionFlags
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; //导入依赖的package包/类
private static ProtectedCuboidRegion setRegionFlags(IslandInfo islandConfig) throws InvalidFlagFormat {
String regionName = islandConfig.getName() + "island";
return setRegionFlags(islandConfig, regionName);
}
示例13: parseFlagInput
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; //导入依赖的package包/类
@Override
public <V> V parseFlagInput(Flag<V> flag, String input) throws InvalidFlagFormat {
return flag.parseInput(FlagContext.create().setInput(input).build());
}
示例14: parseFlagGroupInput
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; //导入依赖的package包/类
@Override
public RegionGroup parseFlagGroupInput(RegionGroupFlag flag, String input) throws InvalidFlagFormat {
return flag.parseInput(FlagContext.create().setInput(input).build());
}
示例15: parseFlagInput
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; //导入依赖的package包/类
@Override
public <V> V parseFlagInput(Flag<V> flag, String input) throws InvalidFlagFormat {
return flag.parseInput(WorldGuardPlugin.inst(), null, input);
}