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


Java UserListBansEntry类代码示例

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


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

示例1: getBanEntry

import net.minecraft.server.management.UserListBansEntry; //导入依赖的package包/类
@Override
public org.bukkit.BanEntry getBanEntry(String target) {
    Validate.notNull(target, "Target cannot be null");

    GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(target);
    if (profile == null) {
        return null;
    }

    UserListBansEntry entry = (UserListBansEntry) list.func_152683_b(profile);
    if (entry == null) {
        return null;
    }

    return new CraftProfileBanEntry(profile, entry, list);
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:17,代码来源:CraftProfileBanList.java

示例2: addBan

import net.minecraft.server.management.UserListBansEntry; //导入依赖的package包/类
@Override
public org.bukkit.BanEntry addBan(String target, String reason, Date expires, String source) {
    Validate.notNull(target, "Ban target cannot be null");

    GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(target);
    if (profile == null) {
        return null;
    }

    UserListBansEntry entry = new UserListBansEntry(profile, new Date(),
            StringUtils.isBlank(source) ? null : source, expires,
            StringUtils.isBlank(reason) ? null : reason);

    list.func_152687_a(entry);

    try {
        list.func_152678_f();
    } catch (IOException ex) {
        MinecraftServer.getLogger().error("Failed to save banned-players.json, " + ex.getMessage());
    }

    return new CraftProfileBanEntry(profile, entry, list);
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:24,代码来源:CraftProfileBanList.java

示例3: run

import net.minecraft.server.management.UserListBansEntry; //导入依赖的package包/类
@Override
public void run() {
    if (this.ban) {
        MinecraftServer minecraftserver = SpongeImpl.getServer();
        GameProfile gameprofile = minecraftserver.getPlayerProfileCache().getGameProfileForUsername(player.getName());

        UserListBansEntry userlistbansentry = new UserListBansEntry(gameprofile, null, ((EntityPlayer) player).getName(),
                null, this.reason.toPlain());
        minecraftserver.getPlayerList().getBannedPlayers().addEntry(userlistbansentry);
        EntityPlayerMP entityplayermp = minecraftserver.getPlayerList().getPlayerByUsername(this.player.getName());

        if (entityplayermp != null) {
            entityplayermp.connection.disconnect(new TextComponentTranslation("You are banned from this server."));
        }
    }
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:17,代码来源:PlayerKickBanTask.java

示例4: CraftProfileBanEntry

import net.minecraft.server.management.UserListBansEntry; //导入依赖的package包/类
public CraftProfileBanEntry(GameProfile profile, UserListBansEntry entry, UserListBans list) {
    this.list = list;
    this.profile = profile;
    this.created = entry.getCreated() != null ? new Date(entry.getCreated().getTime()) : null;
    this.source = entry.getSource();
    this.expiration = entry.getBanEndDate() != null ? new Date(entry.getBanEndDate().getTime()) : null;
    this.reason = entry.getBanReason();
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:9,代码来源:CraftProfileBanEntry.java

示例5: save

import net.minecraft.server.management.UserListBansEntry; //导入依赖的package包/类
@Override
public void save() {
    UserListBansEntry entry = new UserListBansEntry(profile, this.created, this.source, this.expiration, this.reason);
    this.list.func_152687_a(entry);
    try {
        this.list.func_152678_f();
    } catch (IOException ex) {
        MinecraftServer.getLogger().error("Failed to save banned-players.json, " + ex.getMessage());
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:11,代码来源:CraftProfileBanEntry.java

示例6: getBanEntries

import net.minecraft.server.management.UserListBansEntry; //导入依赖的package包/类
@Override
public Set<org.bukkit.BanEntry> getBanEntries() {
    ImmutableSet.Builder<org.bukkit.BanEntry> builder = ImmutableSet.builder();
    for (UserListEntry entry : list.getValues()) {
        GameProfile profile = (GameProfile) entry.func_152640_f(); // Should be getKey
        builder.add(new CraftProfileBanEntry(profile, (UserListBansEntry) entry, list));
    }

    return builder.build();
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:11,代码来源:CraftProfileBanList.java

示例7: processCommand

import net.minecraft.server.management.UserListBansEntry; //导入依赖的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]);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:41,代码来源:CommandBanPlayer.java

示例8: execute

import net.minecraft.server.management.UserListBansEntry; //导入依赖的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]);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:40,代码来源:CommandBanPlayer.java


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