Package org.spout.vanilla.data

Examples of org.spout.vanilla.data.GameMode


  }

  public static GameMode popGameMode(String argName, CommandArguments args) throws ArgumentParseException {
    String raw = args.currentArgument(argName);
    if (raw.length() == 1) {
      GameMode mode = null;
      if (raw.equalsIgnoreCase("s")) {
        mode = GameMode.SURVIVAL;
      } else if (raw.equalsIgnoreCase("c")) {
        mode = GameMode.CREATIVE;
      } else if (raw.equalsIgnoreCase("a")) {
View Full Code Here


      PlayerGameModeChangedEvent event = holder.getEngine().getEventManager().callEvent(new PlayerGameModeChangedEvent((Player) getOwner(), mode));
      if (event.isCancelled()) {
        return;
      }
      changeToFromCreative ^= event.getMode() == GameMode.CREATIVE;
      GameMode old = getGameMode();
      mode = event.getMode();

      //In Survival we shoudn't be able to fly.
      setCanFly(mode == GameMode.CREATIVE, updateClient);
      if (changeToFromCreative) {
View Full Code Here

    stepY = node.STEP_Y.getInt() & (~Chunk.BLOCKS.MASK);
    lastY = Integer.MAX_VALUE;

    final ManagedMap data = world.getData();
    final Human human = getOwner().add(Human.class);
    GameMode gamemode = null;
    Difficulty difficulty = data.get(VanillaData.DIFFICULTY);
    Dimension dimension = data.get(VanillaData.DIMENSION);
    WorldType worldType = data.get(VanillaData.WORLD_TYPE);

    if (human != null) {
      gamemode = human.getGameMode();
    }
    getSession().send(new PlayerRespawnMessage(0, difficulty.getId(), gamemode.getId(), 256, worldType.toString()));
    getSession().send(new PlayerRespawnMessage(1, difficulty.getId(), gamemode.getId(), 256, worldType.toString()));
    getSession().send(new PlayerRespawnMessage(dimension.getId(), difficulty.getId(), gamemode.getId(), 256, worldType.toString()));

    if (human != null) {
      human.updateAbilities();
    }
View Full Code Here

  }

  @CommandDescription (aliases = {"gamemode", "gm"}, usage = "<0|1|2|survival|creative|adventure|s|c|a> [player] (0 = SURVIVAL, 1 = CREATIVE, 2 = ADVENTURE)", desc = "Change a player's game mode")
  @Permissible ("vanilla.command.gamemode")
  public void gamemode(CommandSource source, CommandArguments args) throws CommandException {
    GameMode mode = VanillaArgumentTypes.popGameMode("gamemode", args);
    Player player = args.popPlayerOrMe("player", source);
    args.assertCompletelyParsed();

    Human human = player.get(Human.class);
    if (human == null) {
      throw new CommandException("Invalid player!");
    }

    human.setGamemode(mode);

    if (!player.equals(source)) {
      source.sendMessage(plugin.getPrefix() + ChatStyle.WHITE + player.getName()
          + "'s " + ChatStyle.GREEN + "gamemode has been changed to "
          + ChatStyle.WHITE + mode.name() + ChatStyle.GREEN + ".");
    }
  }
View Full Code Here

      final Human human = session.getPlayer().add(Human.class);
      final Difficulty difficulty = data.get(VanillaData.DIFFICULTY);
      final Dimension dimension = data.get(VanillaData.DIMENSION);
      final WorldType worldType = data.get(VanillaData.WORLD_TYPE);

      GameMode gamemode;

      int entityId = session.getPlayer().getId();

      //  MC Packet Order: 0x01 Login, 0xFA Custom (ServerTypeName), 0x06 SpawnPos, 0xCA PlayerAbilities, 0x10 BlockSwitch
      gamemode = data.get(VanillaData.GAMEMODE);
      final PlayerLoginRequestMessage idMsg = new PlayerLoginRequestMessage(entityId, worldType.toString(), gamemode.getId(), (byte) dimension.getId(), difficulty.getId(), (byte) server.getMaxPlayers());
      session.send(Session.SendType.FORCE, idMsg);
      session.setState(Session.State.GAME);
      if (human.getAttachedCount() <= 1) {
        // If we haven't logged in before, we want to set all abilities to the default gamemode
        human.setGamemode(gamemode, false);
View Full Code Here

TOP

Related Classes of org.spout.vanilla.data.GameMode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.