本文整理汇总了Java中net.minecraft.command.WrongUsageException类的典型用法代码示例。如果您正苦于以下问题:Java WrongUsageException类的具体用法?Java WrongUsageException怎么用?Java WrongUsageException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WrongUsageException类属于net.minecraft.command包,在下文中一共展示了WrongUsageException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import net.minecraft.command.WrongUsageException; //导入依赖的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() > 0)
{
GameProfile gameprofile = server.getPlayerList().getOppedPlayers().getGameProfileFromName(args[0]);
if (gameprofile == null)
{
throw new CommandException("commands.deop.failed", new Object[] {args[0]});
}
else
{
server.getPlayerList().removeOp(gameprofile);
notifyCommandListener(sender, this, "commands.deop.success", new Object[] {args[0]});
}
}
else
{
throw new WrongUsageException("commands.deop.usage", new Object[0]);
}
}
示例2: processCommand
import net.minecraft.command.WrongUsageException; //导入依赖的package包/类
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length == 1 && args[0].length() > 0)
{
MinecraftServer minecraftserver = MinecraftServer.getServer();
GameProfile gameprofile = minecraftserver.getConfigurationManager().getOppedPlayers().getGameProfileFromName(args[0]);
if (gameprofile == null)
{
throw new CommandException("commands.deop.failed", new Object[] {args[0]});
}
else
{
minecraftserver.getConfigurationManager().removeOp(gameprofile);
notifyOperators(sender, this, "commands.deop.success", new Object[] {args[0]});
}
}
else
{
throw new WrongUsageException("commands.deop.usage", new Object[0]);
}
}
示例3: processCommand
import net.minecraft.command.WrongUsageException; //导入依赖的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()});
}
}
}
示例4: processCommand
import net.minecraft.command.WrongUsageException; //导入依赖的package包/类
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length == 1 && args[0].length() > 0)
{
MinecraftServer minecraftserver = MinecraftServer.getServer();
GameProfile gameprofile = minecraftserver.getPlayerProfileCache().getGameProfileForUsername(args[0]);
if (gameprofile == null)
{
throw new CommandException("commands.op.failed", new Object[] {args[0]});
}
else
{
minecraftserver.getConfigurationManager().addOp(gameprofile);
notifyOperators(sender, this, "commands.op.success", new Object[] {args[0]});
}
}
else
{
throw new WrongUsageException("commands.op.usage", new Object[0]);
}
}
示例5: handleTracking
import net.minecraft.command.WrongUsageException; //导入依赖的package包/类
private void handleTracking(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length != 3)
{
throw new WrongUsageException("commands.forge.usage.tracking");
}
String type = args[1];
int duration = parseInt(args[2], 1, 60);
if ("te".equals(type))
{
doTurnOnTileEntityTracking(server, sender, duration);
}
else
{
throw new WrongUsageException("commands.forge.usage.tracking");
}
}
示例6: processCommand
import net.minecraft.command.WrongUsageException; //导入依赖的package包/类
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
BlockPos blockpos;
if (args.length == 0)
{
blockpos = getCommandSenderAsPlayer(sender).getPosition();
}
else
{
if (args.length != 3 || sender.getEntityWorld() == null)
{
throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]);
}
blockpos = parseBlockPos(sender, args, 0, true);
}
sender.getEntityWorld().setSpawnPoint(blockpos);
MinecraftServer.getServer().getConfigurationManager().sendPacketToAllPlayers(new S05PacketSpawnPosition(blockpos));
notifyOperators(sender, this, "commands.setworldspawn.success", new Object[] {Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
}
示例7: processCommand
import net.minecraft.command.WrongUsageException; //导入依赖的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]);
}
}
示例8: processCommand
import net.minecraft.command.WrongUsageException; //导入依赖的package包/类
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length == 1 && args[0].length() > 0)
{
MinecraftServer minecraftserver = MinecraftServer.getServer();
GameProfile gameprofile = minecraftserver.getConfigurationManager().getBannedPlayers().isUsernameBanned(args[0]);
if (gameprofile == null)
{
throw new CommandException("commands.unban.failed", new Object[] {args[0]});
}
else
{
minecraftserver.getConfigurationManager().getBannedPlayers().removeEntry(gameprofile);
notifyOperators(sender, this, "commands.unban.success", new Object[] {args[0]});
}
}
else
{
throw new WrongUsageException("commands.unban.usage", new Object[0]);
}
}
示例9: execute
import net.minecraft.command.WrongUsageException; //导入依赖的package包/类
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
}
else
{
EntityPlayer entityplayer = getPlayer(server, sender, args[0]);
String s = buildString(args, 1);
try
{
ITextComponent itextcomponent = ITextComponent.Serializer.jsonToComponent(s);
entityplayer.addChatMessage(TextComponentUtils.processComponent(sender, itextcomponent, entityplayer));
}
catch (JsonParseException jsonparseexception)
{
/**
* Convert a JsonParseException into a user-friendly exception
*/
throw toSyntaxException(jsonparseexception);
}
}
}
示例10: execute
import net.minecraft.command.WrongUsageException; //导入依赖的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]);
}
}
示例11: setSteps
import net.minecraft.command.WrongUsageException; //导入依赖的package包/类
private void setSteps(IIfEntryStore store, ICommandSender sender, String act, String res) throws CommandException
{
int steps;
switch (act)
{
case "unlock":
steps = PurMag.INSTANCE.getIfRegistry().getEntry(res).getSteps().size();
break;
case "lock":
steps = 0;
break;
default:
throw new WrongUsageException(getUsage(sender));
}
store.setSteps(res, steps);
}
示例12: spawn
import net.minecraft.command.WrongUsageException; //导入依赖的package包/类
private void spawn(ICommandSender sender, String[] args) throws CommandException {
if (!(sender instanceof EntityPlayer)) {
return;
}
if (args.length != 2) {
throw new WrongUsageException("commands.nemesis_system.usage");
}
EntityPlayer player = getCommandSenderAsPlayer(sender);
World world = player.world;
INemesisRegistry registry = NemesisRegistryProvider.get(world);
NemesisEntry nemesis = registry.getByName(args[1]);
SpawnHandler.spawnNemesis(world, player.getPosition(), nemesis);
}
示例13: execute
import net.minecraft.command.WrongUsageException; //导入依赖的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() > 0)
{
GameProfile gameprofile = server.getPlayerProfileCache().getGameProfileForUsername(args[0]);
if (gameprofile == null)
{
throw new CommandException("commands.op.failed", new Object[] {args[0]});
}
else
{
server.getPlayerList().addOp(gameprofile);
notifyCommandListener(sender, this, "commands.op.success", new Object[] {args[0]});
}
}
else
{
throw new WrongUsageException("commands.op.usage", new Object[0]);
}
}
示例14: gui
import net.minecraft.command.WrongUsageException; //导入依赖的package包/类
private void gui(ICommandSender sender, String[] args) throws CommandException {
if (!(sender instanceof EntityPlayer)) {
return;
}
EntityPlayerMP player = getCommandSenderAsPlayer(sender);
if (args.length == 1) {
NemesisSystem.NETWORK.sendTo(new MessageOpenNemesisGui(player), player);
return;
}
if (args.length == 2) {
NemesisEntry nemesis = NemesisRegistryProvider.get(player.world).getByName(args[1]);
NemesisKnowledge knowledge = DiscoveryUtil.getGetPlayerKnowledgeOfNemesis(player, nemesis.getId());
if (knowledge == null) {
knowledge = new NemesisKnowledge();
}
NemesisSystem.NETWORK.sendTo(new MessageOpenNemesisDetailsGui(nemesis, knowledge), player);
return;
}
throw new WrongUsageException("commands.nemesis_system.usage");
}
示例15: execute
import net.minecraft.command.WrongUsageException; //导入依赖的package包/类
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
BlockPos blockpos;
if (args.length == 0)
{
blockpos = getCommandSenderAsPlayer(sender).getPosition();
}
else
{
if (args.length != 3 || sender.getEntityWorld() == null)
{
throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]);
}
blockpos = parseBlockPos(sender, args, 0, true);
}
sender.getEntityWorld().setSpawnPoint(blockpos);
server.getPlayerList().sendPacketToAllPlayers(new SPacketSpawnPosition(blockpos));
notifyCommandListener(sender, this, "commands.setworldspawn.success", new Object[] {Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
}