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


Java PlayerList类代码示例

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


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

示例1: isFakePlayer

import net.minecraft.server.management.PlayerList; //导入依赖的package包/类
private boolean isFakePlayer(Entity entity) {
    if (!(entity instanceof EntityPlayer)) {
        return false;
    }

    if (entity instanceof FakePlayer) {
        return true;
    }

    // If this returns false it is still possible we have a fake player. Try to find the player in the list of online players
    PlayerList playerList = DimensionManager.getWorld(0).getMinecraftServer().getPlayerList();
    EntityPlayerMP playerByUUID = playerList.getPlayerByUUID(((EntityPlayer) entity).getGameProfile().getId());
    if (playerByUUID == null) {
        // The player isn't online. Then it can't be real
        return true;
    }

    // The player is in the list. But is it this player?
    return entity != playerByUUID;
}
 
开发者ID:McJty,项目名称:InControl,代码行数:21,代码来源:GenericRuleEvaluator.java

示例2: InjectIntegrated

import net.minecraft.server.management.PlayerList; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
public static void InjectIntegrated(MinecraftServer server)
{
	PlayerList playerList = server.getPlayerList();

	try {
		if (!(playerList instanceof HookedIntegratedPlayerList) && playerList instanceof IntegratedPlayerList)
		{
			server.setPlayerList(new HookedIntegratedPlayerList((IntegratedPlayerList)playerList));
		}
		else
		{
			// uh ho...
			Util.logger.error("Unable to inject custom PlayerList into server due to unknown type! PlayerList was of type {}.", playerList.getClass().toString());
		}
	} catch (IllegalAccessException | NoSuchFieldException | SecurityException e) {
		Util.logger.logException("Exception trying to inject custom PlayerList into server!", e);
	}
}
 
开发者ID:orbwoi,项目名称:UniversalRemote,代码行数:20,代码来源:ServerInjector.java

示例3: InjectDedicated

import net.minecraft.server.management.PlayerList; //导入依赖的package包/类
@SideOnly(Side.SERVER)
public static void InjectDedicated(MinecraftServer server)
{
	PlayerList playerList = server.getPlayerList();

	try {
		if (playerList instanceof DedicatedPlayerList)
		{
			server.setPlayerList(new HookedDedicatedPlayerList((DedicatedPlayerList)playerList));
		}
		else
		{
			// uh ho...
			Util.logger.error("Unable to inject custom PlayerList into server due to unknown type! PlayerList was of type {}.", playerList.getClass().toString());
		}
	} catch (IllegalAccessException | NoSuchFieldException | SecurityException e) {
		Util.logger.logException("Exception trying to inject custom PlayerList into server!", e);
	}
}
 
开发者ID:orbwoi,项目名称:UniversalRemote,代码行数:20,代码来源:ServerInjector.java

示例4: unloadRecord

import net.minecraft.server.management.PlayerList; //导入依赖的package包/类
/**
 * Unload given record. It will send to all players a packet to unload a
 * record.
 */
public static void unloadRecord(Record record)
{
    PlayerList players = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList();
    String filename = record.filename;

    for (String username : players.getAllUsernames())
    {
        EntityPlayerMP player = players.getPlayerByUsername(username);

        if (player != null)
        {
            IRecording recording = Recording.get(player);

            if (recording.hasRecording(filename))
            {
                recording.removeRecording(filename);

                Dispatcher.sendTo(new PacketUnloadFrames(filename), player);
            }
        }
    }
}
 
开发者ID:mchorse,项目名称:blockbuster,代码行数:27,代码来源:Utils.java

示例5: onItemRightClick

import net.minecraft.server.management.PlayerList; //导入依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack is, World w, EntityPlayer p, EnumHand h) {
	if(!w.isRemote){
		EntityPlayerMP player = (EntityPlayerMP) p;
		if(!player.isCreative()){
			player.addChatMessage(new TextComponentString(ChatFormatting.RED + "You must be in creative to use this!"));
			return new ActionResult(EnumActionResult.PASS, is);
		}
		player.setPortal(player.getPosition());
		MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
		PlayerList list = server.getPlayerList();
		BlockPos pos = player.getPosition();
		if(player.isSneaking())
			list.transferPlayerToDimension(player, 0, new MonumentTeleporter(server.worldServerForDimension(0)));	
		else{
			DungeonDimension.getNextDimensionForWorld(w);
			list.transferPlayerToDimension(player, DungeonDimension.current_dimension, new MonumentTeleporter(server.worldServerForDimension(DungeonDimension.current_dimension)));	
		}
		return new ActionResult(EnumActionResult.SUCCESS, is);
	}
	return new ActionResult(EnumActionResult.PASS, is);
}
 
开发者ID:tiffit,项目名称:DungeonDimension,代码行数:23,代码来源:ItemCreativeTP.java

示例6: apply

import net.minecraft.server.management.PlayerList; //导入依赖的package包/类
/**
 * Called to apply the set
 */
@Override
public final void apply() {
    // Make sure we're on the server...
    if(FMLCommonHandler.instance().getMinecraftServerInstance() == null) return;

    // Register the operation
    OperationSet.addPerPlayerOperation(this);

    // ... and run it on all connected players
    PlayerList playerList = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList();

    for(EntityPlayerMP player : playerList.getPlayerList()) {
        doApply(player);
    }
}
 
开发者ID:legendblade,项目名称:CraftingHarmonics,代码行数:19,代码来源:BasePerPlayerOperation.java

示例7: handle

import net.minecraft.server.management.PlayerList; //导入依赖的package包/类
/** Actually handle it on the server thread here */
public void handle(MessageSecurePlayer m) {
	// make sure the provided player is valid
	PlayerList list = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList();
	for (EntityPlayerMP p : list.getPlayerList()) {
		if (p.dimension == m.dimension && p.getUniqueID().toString().equals(m.player.id.toString())) {
			TileEntitySecurityBox tile = (TileEntitySecurityBox) p.worldObj.getTileEntity(m.pos);
			// add or remove from the list
			if (m.add) {
				tile.addAllowedPlayer(p);
			} else {
				tile.removeAllowedPlayer(p);
			}
			tile.markDirty();
			
			// resync with clients
			EZNetwork.sendSecureSyncMsg(p.worldObj, m.pos, tile.getAllowedPlayers());
		}
	}
}
 
开发者ID:zerofall,项目名称:EZStorage2,代码行数:21,代码来源:MessageSecurePlayer.java

示例8: getRedstoneValue

import net.minecraft.server.management.PlayerList; //导入依赖的package包/类
@Override
public int getRedstoneValue(World world, BlockPos pos, int sensorRange, String textBoxText) {
    PlayerList playerList = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList();
    if (textBoxText.equals("")) {
        return Math.min(15, playerList.getCurrentPlayerCount());
    } else {
        for (String userName : playerList.getOnlinePlayerNames()) {
            if (userName.equalsIgnoreCase(textBoxText)) return 15;
        }
        return 0;
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:13,代码来源:WorldPlayersInServerSensor.java

示例9: getPlayer

import net.minecraft.server.management.PlayerList; //导入依赖的package包/类
private EntityPlayerMP getPlayer() {
    PlayerList pl = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList();
    if (playerUUID != null) {
        return pl.getPlayerByUUID(playerUUID);
    }
    return null;
}
 
开发者ID:CreeperShift,项目名称:WirelessCharger,代码行数:8,代码来源:TilePersonalCharger.java

示例10: HookedIntegratedPlayerList

import net.minecraft.server.management.PlayerList; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public HookedIntegratedPlayerList(IntegratedPlayerList oldList) throws IllegalAccessException, NoSuchFieldException, SecurityException {
	super(oldList.getServerInstance());

	InjectionHandler.copyAllFieldsFromEx(this, oldList, IntegratedPlayerList.class);

	mcServer = InjectionHandler.readFieldOfType(PlayerList.class, this, MinecraftServer.class);
	gameType = InjectionHandler.readFieldOfType(PlayerList.class, this, GameType.class);
	playerEntityList = InjectionHandler.readFieldOfType(PlayerList.class, this, List.class);
	uuidToPlayerMap = InjectionHandler.readFieldOfType(PlayerList.class, this, Map.class);
}
 
开发者ID:orbwoi,项目名称:UniversalRemote,代码行数:12,代码来源:HookedIntegratedPlayerList.java

示例11: HookedDedicatedPlayerList

import net.minecraft.server.management.PlayerList; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public HookedDedicatedPlayerList(DedicatedPlayerList oldList) throws IllegalAccessException, NoSuchFieldException, SecurityException {
	super(oldList.getServerInstance());

	InjectionHandler.copyAllFieldsFromEx(this, oldList, DedicatedPlayerList.class);

	mcServer = InjectionHandler.readFieldOfType(PlayerList.class, this, MinecraftServer.class);
	gameType = InjectionHandler.readFieldOfType(PlayerList.class, this, GameType.class);
	playerEntityList = InjectionHandler.readFieldOfType(PlayerList.class, this, List.class);
	uuidToPlayerMap = InjectionHandler.readFieldOfType(PlayerList.class, this, Map.class);
}
 
开发者ID:orbwoi,项目名称:UniversalRemote,代码行数:12,代码来源:HookedDedicatedPlayerList.java

示例12: NetworkDispatcher

import net.minecraft.server.management.PlayerList; //导入依赖的package包/类
public NetworkDispatcher(NetworkManager manager, PlayerList scm)
{
    super(false);
    this.manager = manager;
    this.scm = scm;
    this.side = Side.SERVER;
    this.handshakeChannel = new EmbeddedChannel(new HandshakeInjector(this), new ChannelRegistrationHandler(), new FMLHandshakeCodec(), new HandshakeMessageHandler<FMLHandshakeServerState>(FMLHandshakeServerState.class));
    this.handshakeChannel.attr(FML_DISPATCHER).set(this);
    this.handshakeChannel.attr(NetworkRegistry.CHANNEL_SOURCE).set(Side.CLIENT);
    this.handshakeChannel.attr(NetworkRegistry.FML_CHANNEL).set("FML|HS");
    this.handshakeChannel.attr(IS_LOCAL).set(manager.isLocalChannel());
    if (DEBUG_HANDSHAKE)
        PacketLoggingHandler.register(manager);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:NetworkDispatcher.java

示例13: teleportPlayerToDim

import net.minecraft.server.management.PlayerList; //导入依赖的package包/类
private Entity teleportPlayerToDim(World oldWorld, int newWorldID, double d, double e, double f, Entity entity)
{
    MinecraftServer server = entity.getServer();
    WorldServer oldWorldServer = server.worldServerForDimension(entity.dimension);
    WorldServer newWorldServer = server.worldServerForDimension(newWorldID);
    if (entity instanceof EntityPlayer) {
        EntityPlayerMP player = (EntityPlayerMP) entity;
        if (!player.worldObj.isRemote) {
            player.worldObj.theProfiler.startSection("portal");
            player.worldObj.theProfiler.startSection("changeDimension");
            PlayerList config = player.mcServer.getPlayerList();
            player.closeScreen();
            player.dimension = newWorldServer.provider.getDimension();
            player.playerNetServerHandler.sendPacket(new SPacketRespawn(player.dimension, player.worldObj.getDifficulty(), newWorldServer.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));
            oldWorldServer.removeEntity(player);
            player.isDead = false;
            player.setLocationAndAngles(d, e, f, player.rotationYaw, player.rotationPitch);
            newWorldServer.spawnEntityInWorld(player);
            player.setWorld(newWorldServer);
            config.preparePlayer(player, oldWorldServer);
            player.playerNetServerHandler.setPlayerLocation(d, e, f, entity.rotationYaw, entity.rotationPitch);
            player.interactionManager.setWorld(newWorldServer);
            config.updateTimeAndWeatherForPlayer(player, newWorldServer);
            config.syncPlayerInventory(player);
            player.worldObj.theProfiler.endSection();
            oldWorldServer.resetUpdateEntityTick();
            newWorldServer.resetUpdateEntityTick();
            player.worldObj.theProfiler.endSection();
            for (PotionEffect potionEffect : player.getActivePotionEffects()) {
                player.playerNetServerHandler.sendPacket(new SPacketEntityEffect(player.getEntityId(), potionEffect));
            }
            player.playerNetServerHandler.sendPacket(new SPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel));
            FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, oldWorldServer.provider.getDimension(), player.dimension);
        }
        player.worldObj.theProfiler.endSection();
        return player;
    }
    return null;
}
 
开发者ID:GamingsModding,项目名称:LittleThings-old,代码行数:40,代码来源:CommandDimTeleport.java

示例14: broadcastPacket

import net.minecraft.server.management.PlayerList; //导入依赖的package包/类
/**
 * Broadcast a packet to all players 
 */
private void broadcastPacket(IMessage packet)
{
    PlayerList players = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList();

    for (String username : players.getAllUsernames())
    {
        EntityPlayerMP player = players.getPlayerByUsername(username);

        if (player != null)
        {
            Dispatcher.sendTo(packet, player);
        }
    }
}
 
开发者ID:mchorse,项目名称:metamorph,代码行数:18,代码来源:CommandMetamorph.java

示例15: broadcastMessage

import net.minecraft.server.management.PlayerList; //导入依赖的package包/类
/**
 * Send given message to everyone on the server, to everyone.
 *
 * Invoke this method only on the server side.
 */
public static void broadcastMessage(ITextComponent message)
{
    PlayerList players = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList();

    for (String username : players.getAllUsernames())
    {
        EntityPlayerMP player = players.getPlayerByUsername(username);

        if (player != null)
        {
            player.addChatMessage(message);
        }
    }
}
 
开发者ID:mchorse,项目名称:blockbuster,代码行数:20,代码来源:Utils.java


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