本文整理汇总了Java中net.minecraft.command.ICommandSender.getName方法的典型用法代码示例。如果您正苦于以下问题:Java ICommandSender.getName方法的具体用法?Java ICommandSender.getName怎么用?Java ICommandSender.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.command.ICommandSender
的用法示例。
在下文中一共展示了ICommandSender.getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: func_147210_a
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
protected void func_147210_a(ICommandSender p_147210_1_, String p_147210_2_, String p_147210_3_)
{
IPBanEntry ipbanentry = new IPBanEntry(p_147210_2_, (Date)null, p_147210_1_.getName(), (Date)null, p_147210_3_);
MinecraftServer.getServer().getConfigurationManager().getBannedIPs().addEntry(ipbanentry);
List<EntityPlayerMP> list = MinecraftServer.getServer().getConfigurationManager().getPlayersMatchingAddress(p_147210_2_);
String[] astring = new String[list.size()];
int i = 0;
for (EntityPlayerMP entityplayermp : list)
{
entityplayermp.playerNetServerHandler.kickPlayerFromServer("You have been IP banned.");
astring[i++] = entityplayermp.getName();
}
if (list.isEmpty())
{
notifyOperators(p_147210_1_, this, "commands.banip.success", new Object[] {p_147210_2_});
}
else
{
notifyOperators(p_147210_1_, this, "commands.banip.success.players", new Object[] {p_147210_2_, joinNiceString(astring)});
}
}
示例2: banIp
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
protected void banIp(MinecraftServer server, ICommandSender sender, String ipAddress, @Nullable String banReason)
{
UserListIPBansEntry userlistipbansentry = new UserListIPBansEntry(ipAddress, (Date)null, sender.getName(), (Date)null, banReason);
server.getPlayerList().getBannedIPs().addEntry(userlistipbansentry);
List<EntityPlayerMP> list = server.getPlayerList().getPlayersMatchingAddress(ipAddress);
String[] astring = new String[list.size()];
int i = 0;
for (EntityPlayerMP entityplayermp : list)
{
entityplayermp.connection.kickPlayerFromServer("You have been IP banned.");
astring[i++] = entityplayermp.getName();
}
if (list.isEmpty())
{
notifyCommandListener(sender, this, "commands.banip.success", new Object[] {ipAddress});
}
else
{
notifyCommandListener(sender, this, "commands.banip.success.players", new Object[] {ipAddress, joinNiceString(astring)});
}
}
示例3: execute
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (args.length < 1) throw new WrongUsageException("commands.incantation.usage");
if (sender.getCommandSenderEntity() == null) return;
final String command = args[0];
if (ModCommands.commands.containsKey(command)) {
ModCommands.commands.get(command).cast(server, sender, args);
} else {
throw new CommandException("commands.incantation.notFound", sender.getName());
}
}
示例4: processCommand
import net.minecraft.command.ICommandSender; //导入方法依赖的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.ban.failed", new Object[] {args[0]});
}
else
{
String s = null;
if (args.length >= 2)
{
s = getChatComponentFromNthArg(sender, args, 1).getUnformattedText();
}
UserListBansEntry userlistbansentry = new UserListBansEntry(gameprofile, (Date)null, sender.getName(), (Date)null, s);
minecraftserver.getConfigurationManager().getBannedPlayers().addEntry(userlistbansentry);
EntityPlayerMP entityplayermp = minecraftserver.getConfigurationManager().getPlayerByUsername(args[0]);
if (entityplayermp != null)
{
entityplayermp.playerNetServerHandler.kickPlayerFromServer("You are banned from this server.");
}
notifyOperators(sender, this, "commands.ban.success", new Object[] {args[0]});
}
}
else
{
throw new WrongUsageException("commands.ban.usage", new Object[0]);
}
}
示例5: execute
import net.minecraft.command.ICommandSender; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length != 3 && args.length != 2)
{
throw new WrongUsageException(getUsage(sender));
}
String act = args[0];
String res = args[1];
String player = args.length > 2 ? args[2] : sender.getName();
if (!Arrays.asList(server.getPlayerList().getOnlinePlayerNames()).contains(player))
{
throw new CommandException("command.pm_if.playerNotFound");
}
if (!(PurMag.INSTANCE.getIfRegistry().containsEntry(res) || res.equals("all")))
{
throw new CommandException("command.pm_if.entryNotFound");
}
EntityPlayerMP p = server.getPlayerList().getPlayerByUsername(player);
IIfEntryStore store = p.getCapability(CapabilityRegistry.ENTRY_STORE_CAP, null);
if(res.equals("all"))
{
for(IfEntry entr : PurMag.INSTANCE.getIfRegistry().entries)
{
setSteps(store, sender, act, entr.getId());
}
}
else
{
setSteps(store, sender, act, res);
}
store.sync(p);
sender.sendMessage(new TextComponentTranslation("command.pm_if.success." + act, "§5" + res, "§5" + player));
}
示例6: execute
import net.minecraft.command.ICommandSender; //导入方法依赖的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.ban.failed", new Object[] {args[0]});
}
else
{
String s = null;
if (args.length >= 2)
{
s = getChatComponentFromNthArg(sender, args, 1).getUnformattedText();
}
UserListBansEntry userlistbansentry = new UserListBansEntry(gameprofile, (Date)null, sender.getName(), (Date)null, s);
server.getPlayerList().getBannedPlayers().addEntry(userlistbansentry);
EntityPlayerMP entityplayermp = server.getPlayerList().getPlayerByUsername(args[0]);
if (entityplayermp != null)
{
entityplayermp.connection.kickPlayerFromServer("You are banned from this server.");
}
notifyCommandListener(sender, this, "commands.ban.success", new Object[] {args[0]});
}
}
else
{
throw new WrongUsageException("commands.ban.usage", new Object[0]);
}
}