当前位置: 首页>>代码示例>>Java>>正文


Java SyntaxErrorException类代码示例

本文整理汇总了Java中net.minecraft.command.SyntaxErrorException的典型用法代码示例。如果您正苦于以下问题:Java SyntaxErrorException类的具体用法?Java SyntaxErrorException怎么用?Java SyntaxErrorException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SyntaxErrorException类属于net.minecraft.command包,在下文中一共展示了SyntaxErrorException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processCommand

import net.minecraft.command.SyntaxErrorException; //导入依赖的package包/类
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 2)
    {
        throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
    }
    else
    {
        EntityPlayer entityplayer = getPlayer(sender, args[0]);
        String s = buildString(args, 1);

        try
        {
            IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);
            entityplayer.addChatMessage(ChatComponentProcessor.processComponent(sender, ichatcomponent, entityplayer));
        }
        catch (JsonParseException jsonparseexception)
        {
            Throwable throwable = ExceptionUtils.getRootCause(jsonparseexception);
            throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {throwable == null ? "" : throwable.getMessage()});
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:27,代码来源:CommandMessageRaw.java

示例2: func_175779_n

import net.minecraft.command.SyntaxErrorException; //导入依赖的package包/类
protected void func_175779_n(ICommandSender p_175779_1_, String[] p_175779_2_, int p_175779_3_) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard();
    String s = getPlayerName(p_175779_1_, p_175779_2_[p_175779_3_++]);

    if (s.length() > 40)
    {
        throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
    }
    else
    {
        ScoreObjective scoreobjective = this.getObjective(p_175779_2_[p_175779_3_], false);

        if (scoreobjective.getCriteria() != IScoreObjectiveCriteria.TRIGGER)
        {
            throw new CommandException("commands.scoreboard.players.enable.noTrigger", new Object[] {scoreobjective.getName()});
        }
        else
        {
            Score score = scoreboard.getValueFromObjective(s, scoreobjective);
            score.setLocked(false);
            notifyOperators(p_175779_1_, this, "commands.scoreboard.players.enable.success", new Object[] {scoreobjective.getName(), s});
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:26,代码来源:CommandScoreboard.java

示例3: processCommand

import net.minecraft.command.SyntaxErrorException; //导入依赖的package包/类
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length == 1 && args[0].length() > 1)
    {
        Matcher matcher = CommandBanIp.field_147211_a.matcher(args[0]);

        if (matcher.matches())
        {
            MinecraftServer.getServer().getConfigurationManager().getBannedIPs().removeEntry(args[0]);
            notifyOperators(sender, this, "commands.unbanip.success", new Object[] {args[0]});
        }
        else
        {
            throw new SyntaxErrorException("commands.unbanip.invalid", new Object[0]);
        }
    }
    else
    {
        throw new WrongUsageException("commands.unbanip.usage", new Object[0]);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:25,代码来源:CommandPardonIp.java

示例4: enablePlayerTrigger

import net.minecraft.command.SyntaxErrorException; //导入依赖的package包/类
protected void enablePlayerTrigger(ICommandSender sender, String[] p_184914_2_, int p_184914_3_, MinecraftServer server) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard(server);
    String s = getPlayerName(server, sender, p_184914_2_[p_184914_3_++]);

    if (s.length() > 40)
    {
        throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
    }
    else
    {
        ScoreObjective scoreobjective = this.convertToObjective(p_184914_2_[p_184914_3_], false, server);

        if (scoreobjective.getCriteria() != IScoreCriteria.TRIGGER)
        {
            throw new CommandException("commands.scoreboard.players.enable.noTrigger", new Object[] {scoreobjective.getName()});
        }
        else
        {
            Score score = scoreboard.getOrCreateScore(s, scoreobjective);
            score.setLocked(false);
            notifyCommandListener(sender, this, "commands.scoreboard.players.enable.success", new Object[] {scoreobjective.getName(), s});
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:26,代码来源:CommandScoreboard.java

示例5: execute

import net.minecraft.command.SyntaxErrorException; //导入依赖的package包/类
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length == 1 && args[0].length() > 1)
    {
        Matcher matcher = CommandBanIp.IP_PATTERN.matcher(args[0]);

        if (matcher.matches())
        {
            server.getPlayerList().getBannedIPs().removeEntry(args[0]);
            notifyCommandListener(sender, this, "commands.unbanip.success", new Object[] {args[0]});
        }
        else
        {
            throw new SyntaxErrorException("commands.unbanip.invalid", new Object[0]);
        }
    }
    else
    {
        throw new WrongUsageException("commands.unbanip.usage", new Object[0]);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:25,代码来源:CommandPardonIp.java

示例6: execute

import net.minecraft.command.SyntaxErrorException; //导入依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length >= 1) {
        Set<ResourceLocation> set;
        if (args[0].equals("models"))
            set = GameRegistry.findRegistry(CSReadedModel.class).getKeys();
        else if (args[0].equals("animations"))
            set = GameRegistry.findRegistry(CSReadedAnim.class).getKeys();
        else
            throw new SyntaxErrorException();
        String str = "";
        for (ResourceLocation res : set) {
            if (!str.equals(""))
                str = str + ", ";
            str = str + res.toString();
        }
        sender.sendMessage(new TextComponentString(str));
    }
    else
        throw new WrongUsageException(CommandCSList.usage);
}
 
开发者ID:Leviathan-Studio,项目名称:CraftStudioAPI,代码行数:22,代码来源:CommandCSList.java

示例7: consume_int

import net.minecraft.command.SyntaxErrorException; //导入依赖的package包/类
public int consume_int(String errorText, int min, int max) throws CommandException {
	String str = consume_string(errorText);

	try {
		int l = Integer.parseInt(str);

		if(l > max) {
			throw new NumberFormatException("Given value '"+l+"' is higher than maximum value '"+max+"'.");
		}

		if(l < min) {
			throw new NumberFormatException("Given value '"+l+"' is smaller than minimum value '"+min+"'.");
		}

		return l;
	} catch (NumberFormatException e) {
		throw new SyntaxErrorException(errorText, e);
	}
}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:20,代码来源:CommandArgumentParser.java

示例8: consume_long

import net.minecraft.command.SyntaxErrorException; //导入依赖的package包/类
public long consume_long(String errorText, long min, long max) throws CommandException {
	String str = consume_string(errorText);

	try {
		long l = Long.parseLong(str);

		if(l > max) {
			throw new NumberFormatException("Given value '"+l+"' is higher than maximum value '"+max+"'.");
		}

		if(l < min) {
			throw new NumberFormatException("Given value '"+l+"' is smaller than minimum value '"+min+"'.");
		}

		return l;
	} catch (NumberFormatException e) {
		throw new SyntaxErrorException(errorText, e);
	}
}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:20,代码来源:CommandArgumentParser.java

示例9: consume_float

import net.minecraft.command.SyntaxErrorException; //导入依赖的package包/类
public float consume_float(String errorText, float min, float max) throws CommandException {
	String str = consume_string(errorText);

	try {
		float l = Float.parseFloat(str);

		if(l > max) {
			throw new NumberFormatException("Given value '"+l+"' is higher than maximum value '"+max+"'.");
		}

		if(l < min) {
			throw new NumberFormatException("Given value '"+l+"' is smaller than minimum value '"+min+"'.");
		}

		return l;
	} catch (NumberFormatException e) {
		throw new SyntaxErrorException(errorText, e);
	}
}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:20,代码来源:CommandArgumentParser.java

示例10: consume_double

import net.minecraft.command.SyntaxErrorException; //导入依赖的package包/类
public double consume_double(String errorText, double min, double max) throws CommandException {
	String str = consume_string(errorText);

	try {
		double l = Double.parseDouble(str);

		if(l > max) {
			throw new NumberFormatException("Given value '"+l+"' is higher than maximum value '"+max+"'.");
		}

		if(l < min) {
			throw new NumberFormatException("Given value '"+l+"' is smaller than minimum value '"+min+"'.");
		}

		return l;
	} catch (NumberFormatException e) {
		throw new SyntaxErrorException(errorText, e);
	}
}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:20,代码来源:CommandArgumentParser.java

示例11: processCommand

import net.minecraft.command.SyntaxErrorException; //导入依赖的package包/类
public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
{
    if (par2ArrayOfStr.length < 2)
    {
        throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
    }
    else
    {
        EntityPlayerMP var3 = getPlayer(par1ICommandSender, par2ArrayOfStr[0]);
        String var4 = func_82360_a(par1ICommandSender, par2ArrayOfStr, 1);

        try
        {
            IChatComponent var5 = IChatComponent.Serializer.func_150699_a(var4);
            var3.addChatMessage(var5);
        }
        catch (JsonParseException var6)
        {
            throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {ExceptionUtils.getRootCause(var6).getMessage()});
        }
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:23,代码来源:CommandMessageRaw.java

示例12: processCommand

import net.minecraft.command.SyntaxErrorException; //导入依赖的package包/类
public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
{
    if (par2ArrayOfStr.length == 1 && par2ArrayOfStr[0].length() > 1)
    {
        Matcher var3 = CommandBanIp.field_147211_a.matcher(par2ArrayOfStr[0]);

        if (var3.matches())
        {
            MinecraftServer.getServer().getConfigurationManager().getBannedIPs().remove(par2ArrayOfStr[0]);
            notifyAdmins(par1ICommandSender, "commands.unbanip.success", new Object[] {par2ArrayOfStr[0]});
        }
        else
        {
            throw new SyntaxErrorException("commands.unbanip.invalid", new Object[0]);
        }
    }
    else
    {
        throw new WrongUsageException("commands.unbanip.usage", new Object[0]);
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:22,代码来源:CommandPardonIp.java

示例13: processCommand

import net.minecraft.command.SyntaxErrorException; //导入依赖的package包/类
public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_)
{
    if (p_71515_2_.length < 2)
    {
        throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
    }
    else
    {
        EntityPlayerMP entityplayermp = getPlayer(p_71515_1_, p_71515_2_[0]);
        String s = func_82360_a(p_71515_1_, p_71515_2_, 1);

        try
        {
            IChatComponent ichatcomponent = IChatComponent.Serializer.func_150699_a(s);
            entityplayermp.addChatMessage(ichatcomponent);
        }
        catch (JsonParseException jsonparseexception)
        {
            Throwable throwable = ExceptionUtils.getRootCause(jsonparseexception);
            throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {throwable == null ? "" : throwable.getMessage()});
        }
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:24,代码来源:CommandMessageRaw.java

示例14: processCommand

import net.minecraft.command.SyntaxErrorException; //导入依赖的package包/类
public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_)
{
    if (p_71515_2_.length == 1 && p_71515_2_[0].length() > 1)
    {
        Matcher matcher = CommandBanIp.field_147211_a.matcher(p_71515_2_[0]);

        if (matcher.matches())
        {
            MinecraftServer.getServer().getConfigurationManager().getBannedIPs().func_152684_c(p_71515_2_[0]);
            func_152373_a(p_71515_1_, this, "commands.unbanip.success", new Object[] {p_71515_2_[0]});
        }
        else
        {
            throw new SyntaxErrorException("commands.unbanip.invalid", new Object[0]);
        }
    }
    else
    {
        throw new WrongUsageException("commands.unbanip.usage", new Object[0]);
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:22,代码来源:CommandPardonIp.java

示例15: execute

import net.minecraft.command.SyntaxErrorException; //导入依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	if (args.length < 1) throw new SyntaxErrorException();

	final String subCommand = args[0];

	if (subCommand.equals(COMMAND_CLASS)) {
		if (args.length < 2) throw new SyntaxErrorException();
		final String clsName = args[1];
		final ClassMeta meta = getMeta(clsName);

		sender.sendMessage(new TextComponentTranslation("openmodslib.command.class_source", meta.cls.getName(), meta.source()));

		final ApiInfo api = meta.api;
		if (api != null) {
			sender.sendMessage(new TextComponentTranslation("openmodslib.command.api_class",
					api.api, api.owner, api.version));
		}

		for (Map.Entry<File, Set<String>> e : meta.providerMods.entrySet())
			sender.sendMessage(new TextComponentTranslation("openmodslib.command.class_provider",
					e.getKey().getAbsolutePath(),
					Joiner.on(',').join(e.getValue())));
	}
}
 
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:26,代码来源:CommandSource.java


注:本文中的net.minecraft.command.SyntaxErrorException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。