Ejemplo n.º 1
0
  @Override
  public void setGameMode(GameMode mode) {
    if (getHandle().playerNetServerHandler == null) return;
    if (mode == null) {
      throw new IllegalArgumentException("Mode cannot be null");
    }

    if (mode != getGameMode()) {
      PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(this, mode);
      server.getPluginManager().callEvent(event);
      if (event.isCancelled()) {
        return;
      }

      getHandle().theItemInWorldManager.setGameType(EnumGameType.getByID(mode.getValue()));
      getHandle()
          .playerNetServerHandler
          .sendPacketToPlayer(new Packet70GameEvent(3, mode.getValue()));
    }
  }
Ejemplo n.º 2
0
 @SuppressWarnings("deprecation")
 public void setGameMode(Player player, String param) {
   param = param.toLowerCase();
   for (GameMode gm : GameMode.values()) {
     if (gm.toString().toLowerCase().startsWith(param)
         || param.equalsIgnoreCase(gm.getValue() + "")) {
       setGameMode(player, gm);
       return;
     }
   }
   sendMessage("No such gamemode: &c" + param);
 }
Ejemplo n.º 3
0
  @Override
  public void setGameMode(GameMode mode) {
    if (getHandle().field_71135_a == null) return;

    if (mode == null) {
      throw new IllegalArgumentException("Mode cannot be null");
    }

    if (mode != getGameMode()) {
      PlayerGameModeChangeEvent event = new PlayerGameModeChangeEvent(this, mode);
      server.getPluginManager().callEvent(event);
      if (event.isCancelled()) {
        return;
      }

      getHandle()
          .field_71134_c
          .func_73076_a(net.minecraft.world.EnumGameType.func_77146_a(mode.getValue()));
      getHandle()
          .field_71135_a
          .func_72567_b(new net.minecraft.network.packet.Packet70GameEvent(3, mode.getValue()));
    }
  }
Ejemplo n.º 4
0
	@Override
	public void setDefaultGameMode(GameMode mode) {
		theServer.setGameType(EnumGameType.getByID(mode.getValue()));

	}