public void transferPlayerToDimension(EntityPlayerMP par1EntityPlayerMP, int par2) {
    int var3 = par1EntityPlayerMP.dimension;
    WorldServer var4 = this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension);
    par1EntityPlayerMP.dimension = par2;
    WorldServer var5 = this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension);
    par1EntityPlayerMP.playerNetServerHandler.sendPacketToPlayer(
        new Packet9Respawn(
            par1EntityPlayerMP.dimension,
            (byte) par1EntityPlayerMP.worldObj.difficultySetting,
            var5.getWorldInfo().getTerrainType(),
            var5.getHeight(),
            par1EntityPlayerMP.theItemInWorldManager.getGameType()));
    var4.removeEntity(par1EntityPlayerMP);
    par1EntityPlayerMP.isDead = false;
    this.transferEntityToWorld(par1EntityPlayerMP, var3, var4, var5);
    this.func_72375_a(par1EntityPlayerMP, var4);
    par1EntityPlayerMP.playerNetServerHandler.setPlayerLocation(
        par1EntityPlayerMP.posX,
        par1EntityPlayerMP.posY,
        par1EntityPlayerMP.posZ,
        par1EntityPlayerMP.rotationYaw,
        par1EntityPlayerMP.rotationPitch);
    par1EntityPlayerMP.theItemInWorldManager.setWorld(var5);
    this.updateTimeAndWeatherForPlayer(par1EntityPlayerMP, var5);
    this.syncPlayerInventory(par1EntityPlayerMP);
    Iterator var6 = par1EntityPlayerMP.getActivePotionEffects().iterator();

    while (var6.hasNext()) {
      PotionEffect var7 = (PotionEffect) var6.next();
      par1EntityPlayerMP.playerNetServerHandler.sendPacketToPlayer(
          new Packet41EntityEffect(par1EntityPlayerMP.entityId, var7));
    }
  }
 /** 传送部分代码 */
 @Override
 public void onEntityCollidedWithBlock(
     World par1World, int par2, int par3, int par4, Entity par5Entity) {
   if (par5Entity.ridingEntity == null
       && par5Entity.riddenByEntity == null
       && par5Entity instanceof EntityPlayerMP) {
     EntityPlayerMP thePlayer = (EntityPlayerMP) par5Entity;
     if (thePlayer.timeUntilPortal > 0) {
       thePlayer.timeUntilPortal = 10;
     } else if (thePlayer.dimension != ModuleTerrain.xenContinentDimensionID) {
       thePlayer.timeUntilPortal = 10;
       thePlayer
           .mcServer
           .getConfigurationManager()
           .transferPlayerToDimension(
               thePlayer,
               ModuleTerrain.xenContinentDimensionID,
               new TeleporterXen(
                   thePlayer.mcServer.worldServerForDimension(
                       ModuleTerrain.xenContinentDimensionID)));
     } else {
       thePlayer.timeUntilPortal = 10;
       thePlayer
           .mcServer
           .getConfigurationManager()
           .transferPlayerToDimension(
               thePlayer, 0, new TeleporterXen(thePlayer.mcServer.worldServerForDimension(0)));
     }
   }
 }
예제 #3
0
  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 list =
        MinecraftServer.getServer()
            .getConfigurationManager()
            .getPlayersMatchingAddress(p_147210_2_);
    String[] astring = new String[list.size()];
    int i = 0;
    EntityPlayerMP entityplayermp;

    for (Iterator iterator = list.iterator();
        iterator.hasNext();
        astring[i++] = entityplayermp.getName()) {
      entityplayermp = (EntityPlayerMP) iterator.next();
      entityplayermp.playerNetServerHandler.kickPlayerFromServer("You have been IP banned.");
    }

    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)});
    }
  }
 @SuppressWarnings("unchecked")
 private void pop() {
   List<EntityLivingBase> ents =
       worldObj.getEntitiesWithinAABB(
           EntityLivingBase.class,
           AxisAlignedBB.getBoundingBox(
               xCoord + 1.0,
               yCoord + 1.0,
               zCoord + 1.0,
               xCoord + xLength - 1,
               yCoord + 3.0,
               zCoord + zLength - 1));
   for (EntityLivingBase ent : ents) {
     if (ent instanceof EntityPlayer) {
       EntityPlayerMP player = (EntityPlayerMP) ent;
       if (!player.capabilities.isCreativeMode) {
         player.playerNetServerHandler.sendPacket(
             new S12PacketEntityVelocity(
                 player.getEntityId(), 0.0, MathHelper.randomDoubleInRange(0.5, 2), 0.0));
       }
     } else {
       if (!ent.isDead) {
         ent.addVelocity(0.0, MathHelper.randomDoubleInRange(0.5, 2), 0);
       }
     }
   }
 }
  /** moves provided player from overworld to nether or vice versa */
  public void transferPlayerToDimension(EntityPlayerMP playerIn, int dimension) {
    int var3 = playerIn.dimension;
    WorldServer var4 = this.mcServer.worldServerForDimension(playerIn.dimension);
    playerIn.dimension = dimension;
    WorldServer var5 = this.mcServer.worldServerForDimension(playerIn.dimension);
    playerIn.playerNetServerHandler.sendPacket(
        new S07PacketRespawn(
            playerIn.dimension,
            playerIn.worldObj.getDifficulty(),
            playerIn.worldObj.getWorldInfo().getTerrainType(),
            playerIn.theItemInWorldManager.getGameType()));
    var4.removePlayerEntityDangerously(playerIn);
    playerIn.isDead = false;
    this.transferEntityToWorld(playerIn, var3, var4, var5);
    this.func_72375_a(playerIn, var4);
    playerIn.playerNetServerHandler.setPlayerLocation(
        playerIn.posX, playerIn.posY, playerIn.posZ, playerIn.rotationYaw, playerIn.rotationPitch);
    playerIn.theItemInWorldManager.setWorld(var5);
    this.updateTimeAndWeatherForPlayer(playerIn, var5);
    this.syncPlayerInventory(playerIn);
    Iterator var6 = playerIn.getActivePotionEffects().iterator();

    while (var6.hasNext()) {
      PotionEffect var7 = (PotionEffect) var6.next();
      playerIn.playerNetServerHandler.sendPacket(
          new S1DPacketEntityEffect(playerIn.getEntityId(), var7));
    }
  }
예제 #6
0
 public static EntityPlayerMP getPlayerForName(String name) {
   EntityPlayerMP tempPlayer =
       FMLCommonHandler.instance()
           .getMinecraftServerInstance()
           .getConfigurationManager()
           .func_152612_a(name);
   if (tempPlayer != null) {
     return tempPlayer;
   }
   List<EntityPlayerMP> possibles = new LinkedList();
   ArrayList<EntityPlayerMP> temp =
       (ArrayList)
           FMLCommonHandler.instance()
               .getSidedDelegate()
               .getServer()
               .getConfigurationManager()
               .playerEntityList;
   for (EntityPlayerMP player : temp) {
     if (player.getDisplayName().equalsIgnoreCase(name)) {
       return player;
     }
     if (player.getDisplayName().toLowerCase().contains(name.toLowerCase())) {
       possibles.add(player);
     }
   }
   if (possibles.size() == 1) {
     return (EntityPlayerMP) possibles.get(0);
   }
   return null;
 }
 /**
  * Triggered whenever an entity collides with this block (enters into the block). Args: world, x,
  * y, z, entity
  */
 public void onEntityCollidedWithBlock(
     World par1World, int par2, int par3, int par4, Entity par5Entity) {
   if ((par5Entity.ridingEntity == null)
       && (par5Entity.riddenByEntity == null)
       && ((par5Entity instanceof EntityPlayerMP))) {
     EntityPlayerMP thePlayer = (EntityPlayerMP) par5Entity;
     if (thePlayer.timeUntilPortal > 0) {
       thePlayer.timeUntilPortal = 10;
     } else if (thePlayer.dimension != Config.vaerynID) {
       thePlayer.timeUntilPortal = 10;
       thePlayer
           .mcServer
           .getConfigurationManager()
           .transferPlayerToDimension(
               thePlayer,
               Config.vaerynID,
               new TeleporterVaeryn(thePlayer.mcServer.worldServerForDimension(Config.vaerynID)));
     } else {
       thePlayer.timeUntilPortal = 10;
       thePlayer
           .mcServer
           .getConfigurationManager()
           .transferPlayerToDimension(
               thePlayer, 0, new TeleporterVaeryn(thePlayer.mcServer.worldServerForDimension(0)));
     }
   }
 }
예제 #8
0
  @Override
  public void processCommand(ICommandSender sender, String[] par2ArrayOfStr) {
    EntityPlayer player = getCommandSenderAsPlayer(sender);
    EntityPlayerMP other = func_82359_c(sender, par2ArrayOfStr[0]);

    if (par2ArrayOfStr.length != 1) {
      player.addChatMessage(getCommandUsage(sender));
      return;
    }

    NBTTagCompound playerdata =
        NecessitiesMain.instance.necessities_data.getCompoundTag(other.username);
    NecessitiesMain.instance.necessities_data.setCompoundTag(other.username, playerdata);
    NBTTagCompound tpa = playerdata.getCompoundTag("[Tpa]");
    playerdata.setCompoundTag("[Tpa]", tpa);

    if (tpa.hasKey("DenyAll")) {
      player.addChatMessage("Player " + other.username + " has blocked all teleport requests.");
      return;
    }
    tpa.setString("Command", "TPA");
    tpa.setString("Who", player.username);
    player.addChatMessage("Sending teleport request to player " + other.username);
    other.addChatMessage(
        player.username
            + " has requested to teleport to you.  Use /tpaccept to accept or /tpreject to refuse.");
  }
  public void processCommand(ICommandSender sender, String[] args) {
    if (args.length > 0 && args[0].length() > 1) {
      EntityPlayerMP entityplayermp =
          MinecraftServer.getServer().getConfigurationManager().getPlayerByUsername(args[0]);
      String s = "Kicked by an operator.";
      boolean flag = false;

      if (entityplayermp == null) {
        throw new PlayerNotFoundException();
      } else {
        if (args.length >= 2) {
          s = getChatComponentFromNthArg(sender, args, 1).getUnformattedText();
          flag = true;
        }

        entityplayermp.playerNetServerHandler.kickPlayerFromServer(s);

        if (flag) {
          notifyOperators(
              sender,
              this,
              "commands.kick.success.reason",
              new Object[] {entityplayermp.getCommandSenderName(), s});
        } else {
          notifyOperators(
              sender,
              this,
              "commands.kick.success",
              new Object[] {entityplayermp.getCommandSenderName()});
        }
      }
    } else {
      throw new WrongUsageException("commands.kick.usage", new Object[0]);
    }
  }
예제 #10
0
  @Override
  public void processCommandConsole(ICommandSender sender, String[] args) {
    if (args.length >= 1) {
      EntityPlayerMP player = FunctionHelper.getPlayerForName(args[0]);
      if (player != null) {
        PlayerInfo.getPlayerInfo(player.username).back = new WarpPoint(player);

        WarpPoint spawn;
        ChunkCoordinates point =
            FMLCommonHandler.instance()
                .getMinecraftServerInstance()
                .worldServers[0]
                .provider
                .getSpawnPoint();
        spawn =
            new WarpPoint(
                0, point.posX, point.posY, point.posZ, player.rotationPitch, player.rotationYaw);
        TeleportCenter.addToTpQue(spawn, player);
        player.sendChatToPlayer(Localization.get("command.spawn.done"));
        return;
      } else {
        OutputHandler.chatError(sender, Localization.format(Localization.ERROR_NOPLAYER, args[0]));
        return;
      }
    }
  }
예제 #11
0
  protected void func_147210_a(ICommandSender p_147210_1_, String p_147210_2_, String p_147210_3_) {
    BanEntry var4 = new BanEntry(p_147210_2_);
    var4.func_73687_a(p_147210_1_.func_70005_c_());
    if (p_147210_3_ != null) {
      var4.func_73689_b(p_147210_3_);
    }

    MinecraftServer.func_71276_C().func_71203_ab().func_72363_f().func_73706_a(var4);
    List var5 = MinecraftServer.func_71276_C().func_71203_ab().func_72382_j(p_147210_2_);
    String[] var6 = new String[var5.size()];
    int var7 = 0;

    EntityPlayerMP var9;
    for (Iterator var8 = var5.iterator(); var8.hasNext(); var6[var7++] = var9.func_70005_c_()) {
      var9 = (EntityPlayerMP) var8.next();
      var9.field_71135_a.func_147360_c("You have been IP banned.");
    }

    if (var5.isEmpty()) {
      func_71522_a(p_147210_1_, "commands.banip.success", new Object[] {p_147210_2_});
    } else {
      func_71522_a(
          p_147210_1_,
          "commands.banip.success.players",
          new Object[] {p_147210_2_, func_71527_a(var6)});
    }
  }
예제 #12
0
  public void func_71515_b(ICommandSender p_71515_1_, String[] p_71515_2_) {
    if (p_71515_2_.length >= 1 && p_71515_2_[0].length() > 1) {
      Matcher var3 = field_147211_a.matcher(p_71515_2_[0]);
      IChatComponent var4 = null;
      if (p_71515_2_.length >= 2) {
        var4 = func_147178_a(p_71515_1_, p_71515_2_, 1);
      }

      if (var3.matches()) {
        this.func_147210_a(p_71515_1_, p_71515_2_[0], var4 == null ? null : var4.func_150260_c());
      } else {
        EntityPlayerMP var5 =
            MinecraftServer.func_71276_C().func_71203_ab().func_72361_f(p_71515_2_[0]);
        if (var5 == null) {
          throw new PlayerNotFoundException("commands.banip.invalid", new Object[0]);
        }

        this.func_147210_a(
            p_71515_1_, var5.func_71114_r(), var4 == null ? null : var4.func_150260_c());
      }

    } else {
      throw new WrongUsageException("commands.banip.usage", new Object[0]);
    }
  }
예제 #13
0
  public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) {
    if (par2ArrayOfStr.length > 0 && par2ArrayOfStr[0].length() > 1) {
      EntityPlayerMP entityplayermp =
          MinecraftServer.getServer()
              .getConfigurationManager()
              .getPlayerForUsername(par2ArrayOfStr[0]);
      String s = "Kicked by an operator.";
      boolean flag = false;

      if (entityplayermp == null) {
        throw new PlayerNotFoundException();
      } else {
        if (par2ArrayOfStr.length >= 2) {
          s = func_82360_a(par1ICommandSender, par2ArrayOfStr, 1);
          flag = true;
        }

        entityplayermp.playerNetServerHandler.kickPlayerFromServer(s);

        if (flag) {
          notifyAdmins(
              par1ICommandSender,
              "commands.kick.success.reason",
              new Object[] {entityplayermp.getEntityName(), s});
        } else {
          notifyAdmins(
              par1ICommandSender,
              "commands.kick.success",
              new Object[] {entityplayermp.getEntityName()});
        }
      }
    } else {
      throw new WrongUsageException("commands.kick.usage", new Object[0]);
    }
  }
예제 #14
0
  /** Actually does the banning work. */
  protected void banIP(ICommandSender par1ICommandSender, String par2Str, String par3Str) {
    BanEntry banentry = new BanEntry(par2Str);
    banentry.setBannedBy(par1ICommandSender.getCommandSenderName());

    if (par3Str != null) {
      banentry.setBanReason(par3Str);
    }

    MinecraftServer.getServer().getConfigurationManager().getBannedIPs().put(banentry);
    List list = MinecraftServer.getServer().getConfigurationManager().getPlayerList(par2Str);
    String[] astring = new String[list.size()];
    int i = 0;
    EntityPlayerMP entityplayermp;

    for (Iterator iterator = list.iterator();
        iterator.hasNext();
        astring[i++] = entityplayermp.getEntityName()) {
      entityplayermp = (EntityPlayerMP) iterator.next();
      entityplayermp.playerNetServerHandler.kickPlayerFromServer("You have been IP banned.");
    }

    if (list.isEmpty()) {
      notifyAdmins(par1ICommandSender, "commands.banip.success", new Object[] {par2Str});
    } else {
      notifyAdmins(
          par1ICommandSender,
          "commands.banip.success.players",
          new Object[] {par2Str, joinNiceString(astring)});
    }
  }
  public static boolean sendToBed(String playername) {

    EntityPlayerMP player =
        MinecraftServer.getServer().getConfigurationManager().func_152612_a(playername);
    ChunkCoordinates dest = player.getBedLocation(0);
    return movePlayer(playername, 0, dest);
  }
예제 #16
0
  @Override
  public void processCommand(ICommandSender sender, String[] params) {
    MinecraftServer server = MinecraftServer.getServer();
    EntityPlayerMP player = getCommandSenderAsPlayer(sender);
    WorldServer world =
        server.worldServerForDimension(player.getEntityWorld().provider.dimensionId);

    if (!TFCOptions.enableDebugMode) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Debug Mode Required"));
      return;
    }

    if (params.length == 0) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk"));
      Chunk chunk = world.getChunkFromBlockCoords((int) player.posX, (int) player.posZ);
      for (int x = 0; x < 16; x++) {
        for (int z = 0; z < 16; z++) {
          for (int y = 0; y < 256; y++) {
            Block id = chunk.getBlock(x, y, z);
            if (id != TFCBlocks.Ore
                && id != TFCBlocks.Ore2
                && id != TFCBlocks.Ore3
                && id != Blocks.bedrock)
              world.setBlock(
                  x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    } else if (params.length == 1) {
      TFC_Core.sendInfoMessage(
          player,
          new ChatComponentText(
              "Stripping Chunks Within a Radius of " + Integer.parseInt(params[0])));
      int radius = Integer.parseInt(params[0]);
      for (int i = -radius; i <= radius; i++) {
        for (int k = -radius; k <= radius; k++) {
          Chunk chunk =
              world.getChunkFromBlockCoords(
                  (int) player.posX + (i * 16), (int) player.posZ + (k * 16));
          for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
              for (int y = 0; y < 256; y++) {
                Block id = chunk.getBlock(x, y, z);
                if (id != TFCBlocks.Ore
                    && id != TFCBlocks.Ore2
                    && id != TFCBlocks.Ore3
                    && id != Blocks.bedrock)
                  world.setBlock(
                      x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
              }
            }
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    }
  }
예제 #17
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    if (player instanceof EntityPlayerMP) {
      final TileEntityGuide guide = getTileEntity(world, x, y, z, TileEntityGuide.class);

      if (guide != null) {
        final EntityPlayerMP playerMP = (EntityPlayerMP) player;

        if (areButtonsActive(playerMP)) {
          final Vec3 relPos = Vec3.createVectorHelper(hitX, hitY, hitZ);
          final Entry<AxisAlignedBB, ShapeManipulator> clickBox = findClickBox(relPos);
          if (clickBox != null) return clickBox.getValue().activate(playerMP, guide);
        }

        final ItemStack heldStack = playerMP.getHeldItem();
        if (heldStack != null) {
          if (guide.onItemUse(playerMP, heldStack, side, hitX, hitY, hitZ)) return true;
        }
      }
    }

    return true;
  }
  /** 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);
  }
예제 #19
0
  public static EntityPlayerMP getPlayerBaseServerFromPlayerUsername(
      String username, boolean ignoreCase) {
    MinecraftServer server = MinecraftServer.getServer();

    if (server != null) {
      if (ignoreCase) {
        return getPlayerForUsernameVanilla(server, username);
      } else {
        Iterator iterator = server.getConfigurationManager().playerEntityList.iterator();
        EntityPlayerMP entityplayermp;

        do {
          if (!iterator.hasNext()) {
            return null;
          }

          entityplayermp = (EntityPlayerMP) iterator.next();
        } while (!entityplayermp.getName().equalsIgnoreCase(username));

        return entityplayermp;
      }
    }

    GCLog.severe("Warning: Could not find player base server instance for player " + username);

    return null;
  }
예제 #20
0
  public void func_71515_b(ICommandSender p_71515_1_, String[] p_71515_2_) {
    if (p_71515_2_.length > 0 && p_71515_2_[0].length() > 1) {
      EntityPlayerMP var3 =
          MinecraftServer.func_71276_C().func_71203_ab().func_72361_f(p_71515_2_[0]);
      String var4 = "Kicked by an operator.";
      boolean var5 = false;
      if (var3 == null) {
        throw new PlayerNotFoundException();
      } else {
        if (p_71515_2_.length >= 2) {
          var4 = func_82360_a(p_71515_1_, p_71515_2_, 1);
          var5 = true;
        }

        var3.field_71135_a.func_72565_c(var4);
        if (var5) {
          func_71522_a(
              p_71515_1_,
              "commands.kick.success.reason",
              new Object[] {var3.func_70023_ak(), var4});
        } else {
          func_71522_a(p_71515_1_, "commands.kick.success", new Object[] {var3.func_70023_ak()});
        }
      }
    } else {
      throw new WrongUsageException("commands.kick.usage", new Object[0]);
    }
  }
예제 #21
0
  public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) {
    if (par2ArrayOfStr.length >= 1 && par2ArrayOfStr[0].length() > 1) {
      Matcher var3 = field_147211_a.matcher(par2ArrayOfStr[0]);
      IChatComponent var4 = null;

      if (par2ArrayOfStr.length >= 2) {
        var4 = func_147178_a(par1ICommandSender, par2ArrayOfStr, 1);
      }

      if (var3.matches()) {
        this.func_147210_a(
            par1ICommandSender, par2ArrayOfStr[0], var4 == null ? null : var4.getUnformattedText());
      } else {
        EntityPlayerMP var5 =
            MinecraftServer.getServer()
                .getConfigurationManager()
                .getPlayerEntity(par2ArrayOfStr[0]);

        if (var5 == null) {
          throw new PlayerNotFoundException("commands.banip.invalid", new Object[0]);
        }

        this.func_147210_a(
            par1ICommandSender,
            var5.getPlayerIP(),
            var4 == null ? null : var4.getUnformattedText());
      }
    } else {
      throw new WrongUsageException("commands.banip.usage", new Object[0]);
    }
  }
예제 #22
0
  /** Called when a CommandSender executes this command */
  public void execute(ICommandSender sender, String[] args) throws CommandException {
    if (args.length >= 1 && args[0].length() > 1) {
      IChatComponent ichatcomponent =
          args.length >= 2 ? getChatComponentFromNthArg(sender, args, 1) : null;
      Matcher matcher = field_147211_a.matcher(args[0]);

      if (matcher.matches()) {
        this.func_147210_a(
            sender, args[0], ichatcomponent == null ? null : ichatcomponent.getUnformattedText());
      } else {
        EntityPlayerMP entityplayermp =
            MinecraftServer.getServer().getConfigurationManager().getPlayerByUsername(args[0]);

        if (entityplayermp == null) {
          throw new PlayerNotFoundException("commands.banip.invalid", new Object[0]);
        }

        this.func_147210_a(
            sender,
            entityplayermp.getPlayerIP(),
            ichatcomponent == null ? null : ichatcomponent.getUnformattedText());
      }
    } else {
      throw new WrongUsageException("commands.banip.usage", new Object[0]);
    }
  }
예제 #23
0
  protected void func_147210_a(ICommandSender p_147210_1_, String p_147210_2_, String p_147210_3_) {
    BanEntry var4 = new BanEntry(p_147210_2_);
    var4.setBannedBy(p_147210_1_.getCommandSenderName());

    if (p_147210_3_ != null) {
      var4.setBanReason(p_147210_3_);
    }

    MinecraftServer.getServer().getConfigurationManager().getBannedIPs().put(var4);
    List var5 = MinecraftServer.getServer().getConfigurationManager().getPlayerList(p_147210_2_);
    String[] var6 = new String[var5.size()];
    int var7 = 0;
    EntityPlayerMP var9;

    for (Iterator var8 = var5.iterator();
        var8.hasNext();
        var6[var7++] = var9.getCommandSenderName()) {
      var9 = (EntityPlayerMP) var8.next();
      var9.playerNetServerHandler.kickPlayerFromServer("You have been IP banned.");
    }

    if (var5.isEmpty()) {
      notifyAdmins(p_147210_1_, "commands.banip.success", new Object[] {p_147210_2_});
    } else {
      notifyAdmins(
          p_147210_1_,
          "commands.banip.success.players",
          new Object[] {p_147210_2_, joinNiceString(var6)});
    }
  }
  // An example showing how to get all players currently in game and check what achievements they
  // have
  public static void printPlayerAchievements() {
    if (FMLCommonHandler.instance().getMinecraftServerInstance() == null)
      return; // Return in the server is not running. Probably not necessary

    List allPlayers =
        FMLCommonHandler.instance()
            .getMinecraftServerInstance()
            .getConfigurationManager()
            .playerEntityList;
    List allAchievements = AchievementList.achievementList;

    for (Object playerObject : allPlayers) {
      if (!(playerObject instanceof EntityPlayerMP)) continue;

      EntityPlayerMP player = (EntityPlayerMP) playerObject;
      LogHelper.info(player.getCommandSenderName()); // Prints the in game name of the player

      for (Object achievementObject : allAchievements) {
        Achievement achievement = (Achievement) achievementObject;

        LogHelper.info(
            achievement.statId); // Prints the achievement id e.g. "achievement.ae2.Facade"
        LogHelper.info(
            StatCollector.translateToLocal(
                achievement.statId)); // This will get the localized name of the achievement
        LogHelper.info(
            player
                .func_147099_x()
                .hasAchievementUnlocked(
                    achievement)); // Prints true or false depending on weather or not the player
        // has this achievement unlocked
      }
    }
  }
예제 #25
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;
                }
              }
            }
          }
        }
      }
    }
  }
예제 #26
0
  public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) {
    if (par2ArrayOfStr.length >= 1 && par2ArrayOfStr[0].length() > 1) {
      Matcher matcher = IPv4Pattern.matcher(par2ArrayOfStr[0]);
      String s = null;

      if (par2ArrayOfStr.length >= 2) {
        s = func_82360_a(par1ICommandSender, par2ArrayOfStr, 1);
      }

      if (matcher.matches()) {
        this.banIP(par1ICommandSender, par2ArrayOfStr[0], s);
      } else {
        EntityPlayerMP entityplayermp =
            MinecraftServer.getServer()
                .getConfigurationManager()
                .getPlayerForUsername(par2ArrayOfStr[0]);

        if (entityplayermp == null) {
          throw new PlayerNotFoundException("commands.banip.invalid", new Object[0]);
        }

        this.banIP(par1ICommandSender, entityplayermp.getPlayerIP(), s);
      }
    } else {
      throw new WrongUsageException("commands.banip.usage", new Object[0]);
    }
  }
예제 #27
0
  public static void givePlayerItem(
      EntityPlayerMP player, ItemStack stack, boolean infinite, boolean doGive) {
    if (stack.getItem() == null) {
      player.addChatComponentMessage(
          setColour(
              new ChatComponentTranslation("nei.chat.give.noitem"), EnumChatFormatting.WHITE));
      return;
    }

    int given = stack.stackSize;
    if (doGive) {
      if (infinite) {
        player.inventory.addItemStackToInventory(stack);
      } else {
        given -= InventoryUtils.insertItem(player.inventory, stack, false);
      }
    }

    sendNotice(
        player,
        new ChatComponentTranslation(
            "commands.give.success",
            stack.getChatComponent(),
            infinite ? "\u221E" : Integer.toString(given),
            player.getName()),
        "notify-item");
    player.openContainer.detectAndSendChanges();
  }
예제 #28
0
  public static void setGamemode(EntityPlayerMP player, int mode) {
    if (mode < 0
        || mode >= NEIActions.gameModes.length
        || NEIActions.nameActionMap.containsKey(NEIActions.gameModes[mode])
            && !NEIServerConfig.canPlayerPerformAction(
                player.getName(), NEIActions.gameModes[mode])) {
      return;
    }

    // creative+
    NEIServerConfig.forPlayer(player.getName()).enableAction("creative+", mode == 2);
    if (mode == 2
        && !(player.openContainer
            instanceof ContainerCreativeInv)) // open the container immediately for the client
    {
      NEISPH.processCreativeInv(player, true);
    }

    // change it on the server
    player.theItemInWorldManager.setGameType(getGameType(mode));

    // tell the client to change it
    new PacketCustom(NEISPH.channel, 14).writeByte(mode).sendToPlayer(player);
    player.addChatMessage(new ChatComponentTranslation("nei.chat.gamemode." + mode));
  }
예제 #29
0
  @Override
  public boolean itemInteractionForEntity(
      ItemStack item, EntityPlayer player, EntityLivingBase entity) {

    if (entity.worldObj.isRemote) {
      return false;
    }
    boolean isCreative = player != null && player.capabilities.isCreativeMode;
    if (containsSoul(item) && !isCreative) {
      return false;
    }
    if (entity instanceof EntityPlayer) {
      return false;
    }

    String entityId = EntityList.getEntityString(entity);
    if (isBlackListed(entityId)) {
      return false;
    }

    if (!Config.soulVesselCapturesBosses && entity instanceof IBossDisplayData) {
      return false;
    }

    NBTTagCompound root = new NBTTagCompound();
    root.setString("id", entityId);
    entity.writeToNBT(root);

    ItemStack capturedMobVessel = new ItemStack(EnderIO.itemSoulVessel);
    capturedMobVessel.setTagCompound(root);
    setDisplayNameFromEntityNameTag(capturedMobVessel, entity);

    player.swingItem();
    if (!isCreative) {
      entity.setDead();
      if (entity.isDead) {
        item.stackSize--;
        if (!player.inventory.addItemStackToInventory(capturedMobVessel)) {
          entity.worldObj.spawnEntityInWorld(
              new EntityItem(
                  entity.worldObj, entity.posX, entity.posY, entity.posZ, capturedMobVessel));
        }
        player.setCurrentItemOrArmor(0, item);
        ((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer);
        return true;
      }
    } else {
      if (!player.inventory.addItemStackToInventory(
          capturedMobVessel)) // Inventory full, drop it in the world!
      {
        entity.worldObj.spawnEntityInWorld(
            new EntityItem(
                entity.worldObj, entity.posX, entity.posY, entity.posZ, capturedMobVessel));
      }
      ((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer);
      return true;
    }
    return false;
  }
예제 #30
0
  public static void teleportPlayerOutOfMachineDimension(EntityPlayerMP player) {
    NBTTagCompound playerNBT = player.getEntityData();

    // Grab the CompactMachines entry from the player NBT data
    NBTTagCompound cmNBT = null;
    if (playerNBT.hasKey(Reference.MOD_ID)) {
      cmNBT = playerNBT.getCompoundTag(Reference.MOD_ID);
    }

    int targetDimension = 0;
    double targetX;
    double targetY;
    double targetZ;

    if (cmNBT != null && cmNBT.hasKey("oldPosX")) {
      // First try to grab the original position by looking at the CompactMachines NBT Tag
      targetDimension = cmNBT.getInteger("oldDimension");
      targetX = cmNBT.getDouble("oldPosX");
      targetY = cmNBT.getDouble("oldPosY");
      targetZ = cmNBT.getDouble("oldPosZ");
    } else if (playerNBT.hasKey("oldDimension")
        && playerNBT.getInteger("oldDimension") != ConfigurationHandler.dimensionId) {
      // Backwards compatibility - but these values are also being set by RandomThings
      // A problem exists in two cases:
      // a) A player entered the SpiritDimension from the CM dimension, RandomThings would set the
      // oldDimension to the CM dimension
      // b) A player entered the CM dimension from the SpectreDimension, CM did previously set the
      // oldDimension to the SpectreDimension
      // In both cases the player gets trapped in a loop between the two dimensions and has no way
      // of getting back to the overworld
      // We want to allow backwards compatibility with our old settings so players in a CM during an
      // update to a version containing this commit
      // would still be trapped in the two dimensions. We can break this cycle by not allowing to
      // get back to another CM using the
      // old system.
      // That's because CM never writes its own dimension into the oldDimension tag, only
      // RandomThings would do that.
      targetDimension = playerNBT.getInteger("oldDimension");
      targetX = playerNBT.getDouble("oldPosX");
      targetY = playerNBT.getDouble("oldPosY");
      targetZ = playerNBT.getDouble("oldPosZ");
    } else {
      ChunkCoordinates cc =
          MinecraftServer.getServer().worldServerForDimension(0).provider.getRandomizedSpawnPoint();
      targetX = cc.posX;
      targetY = cc.posY;
      targetZ = cc.posZ;
    }

    MinecraftServer.getServer()
        .getConfigurationManager()
        .transferPlayerToDimension(
            player,
            targetDimension,
            new TeleporterCM(MinecraftServer.getServer().worldServerForDimension(targetDimension)));
    player.setPositionAndUpdate(targetX, targetY, targetZ);
  }