コード例 #1
0
  /** also checks for multiple logins across servers */
  public EntityPlayerMP createPlayerForUser(GameProfile profile) {
    UUID var2 = EntityPlayer.getUUID(profile);
    ArrayList var3 = Lists.newArrayList();
    EntityPlayerMP var5;

    for (int var4 = 0; var4 < this.playerEntityList.size(); ++var4) {
      var5 = (EntityPlayerMP) this.playerEntityList.get(var4);

      if (var5.getUniqueID().equals(var2)) {
        var3.add(var5);
      }
    }

    Iterator var6 = var3.iterator();

    while (var6.hasNext()) {
      var5 = (EntityPlayerMP) var6.next();
      var5.playerNetServerHandler.kickPlayerFromServer("You logged in from another location");
    }

    Object var7;

    if (this.mcServer.isDemo()) {
      var7 = new DemoWorldManager(this.mcServer.worldServerForDimension(0));
    } else {
      var7 = new ItemInWorldManager(this.mcServer.worldServerForDimension(0));
    }

    return new EntityPlayerMP(
        this.mcServer,
        this.mcServer.worldServerForDimension(0),
        profile,
        (ItemInWorldManager) var7);
  }
コード例 #2
0
  @SubscribeEvent
  public void onPlayerOpenContainer(PlayerOpenContainerEvent event) {
    if (event.entityPlayer instanceof EntityPlayerMP) {
      if (event.entityPlayer.openContainer instanceof net.minecraft.inventory.ContainerWorkbench
          && event.entityPlayer.openContainer.inventoryItemStacks.get(0) != null) {
        EntityPlayerMP playerMP = (EntityPlayerMP) event.entityPlayer;
        PlayerData player = PlayerStore.getInstance().getPlayer(playerMP.getUniqueID().toString());
        Item item =
            (Item)
                ((ItemStack) event.entityPlayer.openContainer.inventoryItemStacks.get(0)).getItem();
        ArrayList<ItemPerk> entitylist = PerkStore.getPerksForItem(item.getUnlocalizedName());
        boolean requiresPerk = false;
        if (entitylist != null) {
          requiresPerk = true;
        }
        for (ItemSkill skill : SkillStore.getInstance().getItemSkill()) {
          ArrayList<ItemXP> temp = skill.getExp();
          for (int i = 0; i < temp.size(); i++) {
            Item compareItem = ((ItemXP) temp.get(i)).getItem();
            if (item.equals(compareItem)) {
              if (requiresPerk) {
                if (PlayerHandler.hasPerk(player, entitylist)) {

                } else {
                  PlayerHandler.taskFail((EntityPlayer) playerMP);
                  event.entityPlayer.closeScreen();
                  break;
                }
              }
            }
          }
        }
      }
    }
  }
コード例 #3
0
  /** also stores the NBTTags if this is an intergratedPlayerList */
  protected void writePlayerData(EntityPlayerMP playerIn) {
    this.playerNBTManagerObj.writePlayerData(playerIn);
    StatisticsFile var2 = (StatisticsFile) this.playerStatFiles.get(playerIn.getUniqueID());

    if (var2 != null) {
      var2.func_150883_b();
    }
  }
コード例 #4
0
  /**
   * Called when a player disconnects from the game. Writes player data to disk and removes them
   * from the world.
   */
  public void playerLoggedOut(EntityPlayerMP playerIn) {
    playerIn.triggerAchievement(StatList.leaveGameStat);
    this.writePlayerData(playerIn);
    WorldServer var2 = playerIn.getServerForPlayer();

    if (playerIn.ridingEntity != null) {
      var2.removePlayerEntityDangerously(playerIn.ridingEntity);
      logger.debug("removing player mount");
    }

    var2.removeEntity(playerIn);
    var2.getPlayerManager().removePlayer(playerIn);
    this.playerEntityList.remove(playerIn);
    this.field_177454_f.remove(playerIn.getUniqueID());
    this.playerStatFiles.remove(playerIn.getUniqueID());
    this.sendPacketToAllPlayers(
        new S38PacketPlayerListItem(
            S38PacketPlayerListItem.Action.REMOVE_PLAYER, new EntityPlayerMP[] {playerIn}));
  }
コード例 #5
0
  public static EntityPlayerMP getPlayerByUUID(UUID theUUID) {
    List players = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
    EntityPlayerMP entityplayermp;
    for (int i = players.size() - 1; i >= 0; --i) {
      entityplayermp = (EntityPlayerMP) players.get(i);

      if (entityplayermp.getUniqueID().equals(theUUID)) {
        return entityplayermp;
      }
    }
    return null;
  }
コード例 #6
0
  /**
   * Called when a player successfully logs in. Reads player data from disk and inserts the player
   * into the world.
   */
  public void playerLoggedIn(EntityPlayerMP playerIn) {
    this.playerEntityList.add(playerIn);
    this.field_177454_f.put(playerIn.getUniqueID(), playerIn);
    this.sendPacketToAllPlayers(
        new S38PacketPlayerListItem(
            S38PacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {playerIn}));
    WorldServer var2 = this.mcServer.worldServerForDimension(playerIn.dimension);
    var2.spawnEntityInWorld(playerIn);
    this.func_72375_a(playerIn, (WorldServer) null);

    for (int var3 = 0; var3 < this.playerEntityList.size(); ++var3) {
      EntityPlayerMP var4 = (EntityPlayerMP) this.playerEntityList.get(var3);
      playerIn.playerNetServerHandler.sendPacket(
          new S38PacketPlayerListItem(
              S38PacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {var4}));
    }
  }
コード例 #7
0
 @SubscribeEvent // Assumed that crafting wasn't blocked
 public void onItemCraftedEvent(ItemCraftedEvent event) {
   if (event.player instanceof EntityPlayerMP) {
     EntityPlayerMP playerMP = (EntityPlayerMP) event.player;
     PlayerData player = PlayerStore.getInstance().getPlayer(playerMP.getUniqueID().toString());
     Item item =
         (Item) ((ItemStack) event.player.openContainer.inventoryItemStacks.get(0)).getItem();
     ArrayList<ItemPerk> entitylist = PerkStore.getPerksForItem(item.getUnlocalizedName());
     boolean requiresPerk = false;
     if (entitylist != null) {
       requiresPerk = true;
     }
     for (ItemSkill skill : SkillStore.getInstance().getItemSkill()) {
       ArrayList<ItemXP> temp = skill.getExp();
       for (int i = 0; i < temp.size(); i++) {
         Item compareItem = ((ItemXP) temp.get(i)).getItem();
         if (item.equals(compareItem)) {
           if (requiresPerk) {
             if (PlayerHandler.hasPerk(player, entitylist)) {
               //    								if (event.entity.isDead){
               PlayerHandler.awardXP(player, skill.name, temp.get(i).getXp(), playerMP);
               //    								}
             }
             //    							else
             //    							{
             //    								PlayerHandler.taskFail((EntityPlayer) playerMP);
             //    								event.player.closeScreen();
             //    							}
           } else {
             //    							if (event.entity.isDead){
             PlayerHandler.awardXP(player, skill.name, temp.get(i).getXp(), playerMP);
             //    							}
           }
         }
       }
     }
   }
 }
コード例 #8
0
  @SubscribeEvent
  public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
    // System.out.println("onPlayerLoggedIn");

    if (event.player instanceof EntityPlayerMP) {
      EntityPlayerMP player = (EntityPlayerMP) event.player;

      if (MobDictionary.proxy.isDedicatedServer()) { // dedicated server
        try {
          MobDatas.loadOnDedicatedServer(player); // load
        } catch (IOException e) {
          e.printStackTrace();
        }

        UUID uuid = player.getUniqueID();
        String[] nameList = MobDatas.toArrayOnDedicatedServer(player);

        MessageSyncData msg = new MessageSyncData(nameList);

        // System.out.println("dispatchMessage");

        PacketHandler.DISPATCHER.sendTo(msg, player); // to MessageSyncDataHandler
      } else { // integrated server
        try {
          MobDatas.load(); // load
        } catch (IOException e) {
          e.printStackTrace();
        }

        String[] nameList = MobDatas.toArray();
        MessageSyncData msg = new MessageSyncData(nameList);
        // System.out.println("dispatchMessage");

        PacketHandler.DISPATCHER.sendTo(msg, player); // to MessageSyncDataHandler
      }
    }
  }
コード例 #9
0
  /** Called on respawn */
  public EntityPlayerMP recreatePlayerEntity(
      EntityPlayerMP playerIn, int dimension, boolean conqueredEnd) {
    playerIn.getServerForPlayer().getEntityTracker().removePlayerFromTrackers(playerIn);
    playerIn.getServerForPlayer().getEntityTracker().untrackEntity(playerIn);
    playerIn.getServerForPlayer().getPlayerManager().removePlayer(playerIn);
    this.playerEntityList.remove(playerIn);
    this.mcServer
        .worldServerForDimension(playerIn.dimension)
        .removePlayerEntityDangerously(playerIn);
    BlockPos var4 = playerIn.func_180470_cg();
    boolean var5 = playerIn.isSpawnForced();
    playerIn.dimension = dimension;
    Object var6;

    if (this.mcServer.isDemo()) {
      var6 = new DemoWorldManager(this.mcServer.worldServerForDimension(playerIn.dimension));
    } else {
      var6 = new ItemInWorldManager(this.mcServer.worldServerForDimension(playerIn.dimension));
    }

    EntityPlayerMP var7 =
        new EntityPlayerMP(
            this.mcServer,
            this.mcServer.worldServerForDimension(playerIn.dimension),
            playerIn.getGameProfile(),
            (ItemInWorldManager) var6);
    var7.playerNetServerHandler = playerIn.playerNetServerHandler;
    var7.clonePlayer(playerIn, conqueredEnd);
    var7.setEntityId(playerIn.getEntityId());
    var7.func_174817_o(playerIn);
    WorldServer var8 = this.mcServer.worldServerForDimension(playerIn.dimension);
    this.func_72381_a(var7, playerIn, var8);
    BlockPos var9;

    if (var4 != null) {
      var9 =
          EntityPlayer.func_180467_a(
              this.mcServer.worldServerForDimension(playerIn.dimension), var4, var5);

      if (var9 != null) {
        var7.setLocationAndAngles(
            (double) ((float) var9.getX() + 0.5F),
            (double) ((float) var9.getY() + 0.1F),
            (double) ((float) var9.getZ() + 0.5F),
            0.0F,
            0.0F);
        var7.func_180473_a(var4, var5);
      } else {
        var7.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(0, 0.0F));
      }
    }

    var8.theChunkProviderServer.loadChunk((int) var7.posX >> 4, (int) var7.posZ >> 4);

    while (!var8.getCollidingBoundingBoxes(var7, var7.getEntityBoundingBox()).isEmpty()
        && var7.posY < 256.0D) {
      var7.setPosition(var7.posX, var7.posY + 1.0D, var7.posZ);
    }

    var7.playerNetServerHandler.sendPacket(
        new S07PacketRespawn(
            var7.dimension,
            var7.worldObj.getDifficulty(),
            var7.worldObj.getWorldInfo().getTerrainType(),
            var7.theItemInWorldManager.getGameType()));
    var9 = var8.getSpawnPoint();
    var7.playerNetServerHandler.setPlayerLocation(
        var7.posX, var7.posY, var7.posZ, var7.rotationYaw, var7.rotationPitch);
    var7.playerNetServerHandler.sendPacket(new S05PacketSpawnPosition(var9));
    var7.playerNetServerHandler.sendPacket(
        new S1FPacketSetExperience(var7.experience, var7.experienceTotal, var7.experienceLevel));
    this.updateTimeAndWeatherForPlayer(var7, var8);
    var8.getPlayerManager().addPlayer(var7);
    var8.spawnEntityInWorld(var7);
    this.playerEntityList.add(var7);
    this.field_177454_f.put(var7.getUniqueID(), var7);
    var7.addSelfToInternalCraftingInventory();
    var7.setHealth(var7.getHealth());
    return var7;
  }